示例#1
0
 @Override
 public void onBackStackChanged() {
   if (mIgnoreBackStack || mCurrentPage < 0 || mCurrentPage >= mItems.size()) {
     return;
   }
   SliderItem item = mItems.get(mCurrentPage);
   WeakReference<Fragment> ref = item.mLastFragment;
   Fragment fragment = ref == null ? null : ref.get();
   if (fragment == null || !item.mSaveState) {
     return;
   }
   if (fragment.isAdded() && fragment.isDetached() && !fragment.isVisible()) {
     item.mSavedState = mFragmentManager.saveFragmentInstanceState(fragment);
   }
 }
 @Override
 public void onDestroyView() {
   mList = null;
   mHandler.removeCallbacks(mRequestFocus);
   mHandler.removeMessages(PreferenceFragment.MSG_BIND_PREFERENCES);
   super.onDestroyView();
 }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   mPreferenceManager =
       new PreferenceManager(getSupportActivity(), PreferenceFragment.FIRST_REQUEST_CODE);
   mPreferenceManager.setFragment(this);
 }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   final PreferenceScreen preferenceScreen = getPreferenceScreen();
   if (preferenceScreen != null) {
     Bundle container = new Bundle();
     preferenceScreen.saveHierarchyState(container);
     outState.putBundle(PreferenceFragment.PREFERENCES_TAG, container);
   }
 }
示例#5
0
 private void changePage(int position, SliderItem item) {
   mIgnoreBackStack = true;
   if (mCurrentPage >= 0) {
     final SliderItem lastItem = mAdapter.getItem(mCurrentPage);
     final WeakReference<Fragment> ref = lastItem.mLastFragment;
     final Fragment fragment = ref == null ? null : ref.get();
     if (fragment != null && fragment.isAdded() && lastItem.mSaveState) {
       if (!fragment.isDetached()) {
         mFragmentManager.beginTransaction().detach(fragment).commit();
         mFragmentManager.executePendingTransactions();
       }
       lastItem.mSavedState = mFragmentManager.saveFragmentInstanceState(fragment);
     }
   }
   mCurrentPage = position;
   mAdapter.notifyDataSetInvalidated();
   while (mFragmentManager.popBackStackImmediate()) {}
   final Fragment fragment = Fragment.instantiate(item.mFragmentClass);
   if (item.mSavedState != null) {
     fragment.setInitialSavedState(item.mSavedState);
   }
   item.mLastFragment = new WeakReference<Fragment>(fragment);
   replaceFragment(mFragmentManager, fragment);
   mIgnoreBackStack = false;
 }
示例#6
0
 public void onClick(View view) {
   FragmentManager fm = getSupportFragmentManager();
   while (fm.popBackStackImmediate()) {
     fm.executePendingTransactions();
   }
   replaceFragment(Fragment.instantiate(clazz));
   fm.executePendingTransactions();
   postDelayed(
       new Runnable() {
         @Override
         public void run() {
           requireSlidingMenu().showContent();
         }
       },
       100);
 }
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   if (mHavePrefs) {
     bindPreferences();
   }
   mInitDone = true;
   if (savedInstanceState != null) {
     Bundle container = savedInstanceState.getBundle(PreferenceFragment.PREFERENCES_TAG);
     if (container != null) {
       final PreferenceScreen preferenceScreen = getPreferenceScreen();
       if (preferenceScreen != null) {
         preferenceScreen.restoreHierarchyState(container);
       }
     }
   }
 }
示例#8
0
 /**
  * This method deletes all reference to a {@link Context} so {@link Activity} could be properly
  * recreated
  */
 @Override
 public void onDestroyView() {
   selectorBegin = textSelector.getBeginObject();
   selectorEnd = textSelector.getEndObject();
   selectorNoBegin = textSelector.isNoBegin();
   selectorNoEnd = textSelector.isNoEnd();
   if (mode != null) {
     mode.finish();
     mode = null;
   }
   super.onDestroyView();
   menu.destroyViews();
   editorScrollX = board.getEditorScrollX();
   editorScrollY = board.getEditorScrollY();
   lines = board.getLines();
   board.destroyViews();
   board = null;
   textSelector.destroy();
   textSelector = null;
 }
示例#9
0
 @Override
 public void onAttach(Activity activity) {
   super.onAttach(activity);
 }
 @Override
 public void onStop() {
   super.onStop();
   mPreferenceManager.dispatchActivityStop();
   mPreferenceManager.setOnPreferenceTreeClickListener(null);
 }
 @Override
 public void onStart() {
   super.onStart();
   mPreferenceManager.setOnPreferenceTreeClickListener(this);
 }
 @Override
 public void onDestroy() {
   super.onDestroy();
   mPreferenceManager.dispatchActivityDestroy();
 }
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   mPreferenceManager.dispatchActivityResult(requestCode, resultCode, data);
 }