Add skip to first/last page option
This commit is contained in:
parent
463c9a1e0a
commit
5b327d4d97
@ -310,8 +310,8 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
|
||||
}
|
||||
}
|
||||
|
||||
public void onJumpToPageInDocument(int selected_page) {
|
||||
if (selected_page >= 1 && selected_page <= mNumPages) {
|
||||
public void onJumpToPageInDocument(final int selected_page) {
|
||||
if (selected_page >= 1 && selected_page <= mNumPages && mPage != selected_page) {
|
||||
mPage = selected_page;
|
||||
renderPage(false);
|
||||
showPageNumber();
|
||||
@ -363,8 +363,9 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
final int ids[] = { R.id.action_zoom_in, R.id.action_zoom_out, R.id.action_jump_to_page,
|
||||
R.id.action_next, R.id.action_previous, R.id.action_rotate_clockwise,
|
||||
R.id.action_rotate_counterclockwise, R.id.action_view_document_properties };
|
||||
R.id.action_next, R.id.action_previous, R.id.action_first, R.id.action_last,
|
||||
R.id.action_rotate_clockwise, R.id.action_rotate_counterclockwise,
|
||||
R.id.action_view_document_properties };
|
||||
if (mDocumentState < STATE_LOADED) {
|
||||
for (final int id : ids) {
|
||||
final MenuItem item = menu.findItem(id);
|
||||
@ -400,19 +401,19 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_previous:
|
||||
if (mPage > 1) {
|
||||
mPage--;
|
||||
renderPage(false);
|
||||
showPageNumber();
|
||||
}
|
||||
onJumpToPageInDocument(mPage - 1);
|
||||
return true;
|
||||
|
||||
case R.id.action_next:
|
||||
if (mPage < mNumPages) {
|
||||
mPage++;
|
||||
renderPage(false);
|
||||
showPageNumber();
|
||||
}
|
||||
onJumpToPageInDocument(mPage + 1);
|
||||
return true;
|
||||
|
||||
case R.id.action_first:
|
||||
onJumpToPageInDocument(1);
|
||||
return true;
|
||||
|
||||
case R.id.action_last:
|
||||
onJumpToPageInDocument(mNumPages);
|
||||
return true;
|
||||
|
||||
case R.id.action_open:
|
||||
|
10
app/src/main/res/drawable/baseline_first_page_24.xml
Executable file
10
app/src/main/res/drawable/baseline_first_page_24.xml
Executable file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M18.41,16.59L13.82,12l4.59,-4.59L17,6l-6,6 6,6zM6,6h2v12H6z"/>
|
||||
</vector>
|
10
app/src/main/res/drawable/baseline_last_page_24.xml
Executable file
10
app/src/main/res/drawable/baseline_last_page_24.xml
Executable file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M5.59,7.41L10.18,12l-4.59,4.59L7,18l6,-6 -6,-6zM16,6h2v12h-2z"/>
|
||||
</vector>
|
@ -37,6 +37,18 @@
|
||||
android:title="@string/action_zoom_in"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_first"
|
||||
android:icon="@drawable/baseline_first_page_24"
|
||||
android:title="@string/action_first"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_last"
|
||||
android:icon="@drawable/baseline_last_page_24"
|
||||
android:title="@string/action_last"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_jump_to_page"
|
||||
android:icon="@drawable/ic_pageview_white_24dp"
|
||||
|
@ -5,6 +5,8 @@
|
||||
<string name="action_previous">Previous page</string>
|
||||
<string name="action_next">Next page</string>
|
||||
<string name="action_open">Open document</string>
|
||||
<string name="action_first">First page</string>
|
||||
<string name="action_last">Last page</string>
|
||||
<string name="action_zoom_out">Zoom out</string>
|
||||
<string name="action_zoom_in">Zoom in</string>
|
||||
<string name="action_rotate_clockwise">Rotate clockwise</string>
|
||||
|
Loading…
Reference in New Issue
Block a user