Change ArrayList to SparseArray for ViewPager adapter's collection of Fragments

This commit is contained in:
Phillip Hsu
2016-08-14 01:23:15 -07:00
parent 04158bb6a8
commit b1f3c9c8c7
2 changed files with 15 additions and 13 deletions
@@ -63,8 +63,6 @@ public class StopwatchFragment extends RecyclerViewFragment<
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
mStartTime = mPrefs.getLong(KEY_START_TIME, 0);
mPauseTime = mPrefs.getLong(KEY_PAUSE_TIME, 0);
// TODO: Any better solutions?
mActivityFab = new WeakReference<>((FloatingActionButton) getActivity().findViewById(R.id.fab));
Log.d(TAG, "mStartTime = " + mStartTime
+ ", mPauseTime = " + mPauseTime);
}
@@ -74,6 +72,11 @@ public class StopwatchFragment extends RecyclerViewFragment<
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// TODO: Apply size span on chronom
View view = super.onCreateView(inflater, container, savedInstanceState);
// TODO: Any better alternatives?
// TOneverDO: Move to onCreate(). It is not called again on device rotation, so we will
// have a null reference.
mActivityFab = new WeakReference<>((FloatingActionButton) getActivity().findViewById(R.id.fab));
if (mStartTime > 0) {
long base = mStartTime;
if (mPauseTime > 0) {