From 9fe07c763fd5dfa1f55515d594a74b3e46061f5d Mon Sep 17 00:00:00 2001 From: Phillip Hsu Date: Mon, 26 Sep 2016 17:52:34 -0700 Subject: [PATCH] Removed unused drawable reference and save last tab on page selected --- .../java/com/philliphsu/clock2/MainActivity.java | 16 ++++++---------- .../clock2/stopwatch/ui/StopwatchFragment.java | 2 -- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/philliphsu/clock2/MainActivity.java b/app/src/main/java/com/philliphsu/clock2/MainActivity.java index f2b49b8..a3e410c 100644 --- a/app/src/main/java/com/philliphsu/clock2/MainActivity.java +++ b/app/src/main/java/com/philliphsu/clock2/MainActivity.java @@ -1,8 +1,6 @@ package com.philliphsu.clock2; -import android.annotation.SuppressLint; import android.content.Intent; -import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.os.PersistableBundle; @@ -48,7 +46,6 @@ public class MainActivity extends BaseActivity { * {@link android.support.v4.app.FragmentStatePagerAdapter}. */ private SectionsPagerAdapter mSectionsPagerAdapter; - private Drawable mAddItemDrawable; @Bind(R.id.container) ViewPager mViewPager; @@ -194,15 +191,8 @@ public class MainActivity extends BaseActivity { mViewPager.removeOnPageChangeListener(mModifyFabPositionListener); } - @SuppressLint("CommitPrefEdits") @Override protected void onDestroy() { - final int currentTab = mViewPager.getCurrentItem(); - PreferenceManager.getDefaultSharedPreferences(this) - .edit() - .putInt(getString(R.string.key_last_tab), currentTab) - .commit(); - super.onDestroy(); this.mModifyFabPositionListener = null; } @@ -382,6 +372,12 @@ public class MainActivity extends BaseActivity { if (f != null) { f.onPageSelected(); } + + final int currentTab = mViewPager.getCurrentItem(); + PreferenceManager.getDefaultSharedPreferences(mViewPager.getContext()) + .edit() + .putInt(LAST_TAB, currentTab) + .commit(); } } } diff --git a/app/src/main/java/com/philliphsu/clock2/stopwatch/ui/StopwatchFragment.java b/app/src/main/java/com/philliphsu/clock2/stopwatch/ui/StopwatchFragment.java index 899b51c..5188e71 100644 --- a/app/src/main/java/com/philliphsu/clock2/stopwatch/ui/StopwatchFragment.java +++ b/app/src/main/java/com/philliphsu/clock2/stopwatch/ui/StopwatchFragment.java @@ -71,8 +71,6 @@ public class StopwatchFragment extends RecyclerViewFragment< // onCreateView() or any other callback that is guaranteed to be called. mStartDrawable = ContextCompat.getDrawable(getActivity(), R.drawable.ic_start_24dp); mPauseDrawable = ContextCompat.getDrawable(getActivity(), R.drawable.ic_pause_24dp); - - // TODO: Load the current lap here } @Nullable