From 90a87615d97463e9ded685b834c033f769f4f7a4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 13 Feb 2017 21:06:47 +0100 Subject: [PATCH] show the rotate actionbar button only if the current item is an image --- .../gallery/activities/ViewPagerActivity.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 562bca2a8..27d87a06f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -95,18 +95,19 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_viewpager, menu) + if (getCurrentMedium() == null) + return true menu.apply { - if (getCurrentMedium()?.isImage() == true) { - findItem(R.id.menu_set_as_wallpaper).isVisible = getCurrentMedium()?.isImage() == true - findItem(R.id.menu_edit).isVisible = getCurrentMedium()?.isImage() == true + findItem(R.id.menu_set_as_wallpaper).isVisible = getCurrentMedium()!!.isImage() == true + findItem(R.id.menu_edit).isVisible = getCurrentMedium()!!.isImage() == true + findItem(R.id.menu_rotate).isVisible = getCurrentMedium()!!.isImage() == true - findItem(R.id.menu_rotate).subMenu.apply { - clearHeader() - findItem(R.id.rotate_right).icon = resources.getColoredDrawable(R.drawable.ic_rotate_right, R.color.actionbar_menu_icon) - findItem(R.id.rotate_left).icon = resources.getColoredDrawable(R.drawable.ic_rotate_left, R.color.actionbar_menu_icon) - findItem(R.id.rotate_one_eighty).icon = resources.getColoredDrawable(R.drawable.ic_rotate_one_eighty, R.color.actionbar_menu_icon) - } + findItem(R.id.menu_rotate).subMenu.apply { + clearHeader() + findItem(R.id.rotate_right).icon = resources.getColoredDrawable(R.drawable.ic_rotate_right, R.color.actionbar_menu_icon) + findItem(R.id.rotate_left).icon = resources.getColoredDrawable(R.drawable.ic_rotate_left, R.color.actionbar_menu_icon) + findItem(R.id.rotate_one_eighty).icon = resources.getColoredDrawable(R.drawable.ic_rotate_one_eighty, R.color.actionbar_menu_icon) } }