Skip to content

Commit

Permalink
Adding switching of pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Pozhidaev committed Oct 14, 2018
1 parent 667c9cf commit feaa942
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions src/main/java/org/luwrain/app/viewer/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,46 @@ private void load(String file)
if (event.isSpecial() && !event.isModified())
switch(event.getSpecial())
{
case PAGE_DOWN:
if (pdf == null)
return;
{
final int nextPage = pdf.getCurrentPageNum() + 1;
if (nextPage >= pdf.getPageCount())
{
luwrain.playSound(Sounds.EVENT_NOT_PROCESSED);
return;
}
pdf.showPage(nextPage);
luwrain.message("Страница " + (nextPage + 1) + " из " + pdf.getPageCount());//FIXME:
}
return;
case PAGE_UP:
if (pdf == null)
return;
{
final int prevPage = pdf.getCurrentPageNum() - 1;
if (prevPage < 0)
{
luwrain.playSound(Sounds.EVENT_NOT_PROCESSED);
return;
}
pdf.showPage(prevPage);
luwrain.message("Страница " + (prevPage + 1) + " из " + pdf.getPageCount());//FIXME:
}
return;
case ESCAPE:
if (pdf != null)
{
pdf.close();
pdf = null;
closeApp();
}
return;
}
luwrain.playSound(Sounds.EVENT_NOT_PROCESSED);
}
return;
}
luwrain.message(event.toString());
// luwrain.playSound(Sounds.EVENT_NOT_PROCESSED);
}

@Override public void closeApp()
{
Expand All @@ -157,6 +187,9 @@ private void load(String file)

@Override public String getAppName()
{
return strings.appName();
if (url == null)
return strings.appName();
final File file = Urls.toFile(url);
return file.getName();
}
}

0 comments on commit feaa942

Please sign in to comment.