handle deprecation of resource ids as constants

This commit is contained in:
Daniel Micay 2021-11-21 16:02:22 -05:00
parent fb44da509c
commit 2cdd5f967e
1 changed files with 39 additions and 50 deletions

View File

@ -499,56 +499,45 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { final int itemId = item.getItemId();
case R.id.action_previous: if (itemId == R.id.action_previous) {
onJumpToPageInDocument(mPage - 1); onJumpToPageInDocument(mPage - 1);
return true; return true;
} else if (itemId == R.id.action_next) {
case R.id.action_next:
onJumpToPageInDocument(mPage + 1); onJumpToPageInDocument(mPage + 1);
return true; return true;
} else if (itemId == R.id.action_first) {
case R.id.action_first:
onJumpToPageInDocument(1); onJumpToPageInDocument(1);
return true; return true;
} else if (itemId == R.id.action_last) {
case R.id.action_last:
onJumpToPageInDocument(mNumPages); onJumpToPageInDocument(mNumPages);
return true; return true;
} else if (itemId == R.id.action_open) {
case R.id.action_open:
openDocument(); openDocument();
return true; return true;
} else if (itemId == R.id.action_zoom_out) {
case R.id.action_zoom_out:
zoomOut(0.25f, true); zoomOut(0.25f, true);
return true; return true;
} else if (itemId == R.id.action_zoom_in) {
case R.id.action_zoom_in:
zoomIn(0.25f, true); zoomIn(0.25f, true);
return true; return true;
} else if (itemId == R.id.action_rotate_clockwise) {
case R.id.action_rotate_clockwise:
documentOrientationChanged(90); documentOrientationChanged(90);
return true; return true;
} else if (itemId == R.id.action_rotate_counterclockwise) {
case R.id.action_rotate_counterclockwise:
documentOrientationChanged(-90); documentOrientationChanged(-90);
return true; return true;
} else if (itemId == R.id.action_view_document_properties) {
case R.id.action_view_document_properties:
DocumentPropertiesFragment DocumentPropertiesFragment
.newInstance(mDocumentProperties) .newInstance(mDocumentProperties)
.show(getSupportFragmentManager(), DocumentPropertiesFragment.TAG); .show(getSupportFragmentManager(), DocumentPropertiesFragment.TAG);
return true; return true;
} else if (itemId == R.id.action_jump_to_page) {
case R.id.action_jump_to_page:
new JumpToPageFragment() new JumpToPageFragment()
.show(getSupportFragmentManager(), JumpToPageFragment.TAG); .show(getSupportFragmentManager(), JumpToPageFragment.TAG);
return true; return true;
}
default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
}
} }