android.support.v4.app.FragmentActivity.recreate()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中android.support.v4.app.FragmentActivity.recreate()方法的一些代码示例,展示了FragmentActivity.recreate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentActivity.recreate()方法的具体详情如下:
包路径:android.support.v4.app.FragmentActivity
类名称:FragmentActivity
方法名:recreate

FragmentActivity.recreate介绍

暂无

代码示例

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    defaultPreferences.edit().putBoolean(Constants.KEY_THEME_CHANGE, true).apply();
    defaultPreferences.edit().putString(getString(R.string.theme_key), newValue.toString()).apply();
    if (!newValue.equals(startThemeKey) && getActivity() != null) {
      // If it's not the current theme
      getActivity().recreate();
    }
    return false;
  }
};

代码示例来源:origin: avjinder/Minimal-Todo

@Override
public void onResume() {
  super.onResume();
  app.send(this);
  SharedPreferences sharedPreferences = getActivity().getSharedPreferences(SHARED_PREF_DATA_SET_CHANGED, MODE_PRIVATE);
  if (sharedPreferences.getBoolean(ReminderFragment.EXIT, false)) {
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putBoolean(ReminderFragment.EXIT, false);
    editor.apply();
    getActivity().finish();
  }
  /*
  We need to do this, as this activity's onCreate won't be called when coming back from SettingsActivity,
  thus our changes to dark/light mode won't take place, as the setContentView() is not called again.
  So, inside our SettingsFragment, whenever the checkbox's value is changed, in our shared preferences,
  we mark our recreate_activity key as true.
  Note: the recreate_key's value is changed to false before calling recreate(), or we woudl have ended up in an infinite loop,
  as onResume() will be called on recreation, which will again call recreate() and so on....
  and get an ANR
   */
  if (getActivity().getSharedPreferences(THEME_PREFERENCES, MODE_PRIVATE).getBoolean(RECREATE_ACTIVITY, false)) {
    SharedPreferences.Editor editor = getActivity().getSharedPreferences(THEME_PREFERENCES, MODE_PRIVATE).edit();
    editor.putBoolean(RECREATE_ACTIVITY, false);
    editor.apply();
    getActivity().recreate();
  }
}

代码示例来源:origin: DreaminginCodeZH/PatternLock

@Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    switch (key) {
      case PreferenceContract.KEY_THEME:
        getActivity().recreate();
    }
  }
}

代码示例来源:origin: goodtime-productivity/Goodtime

@Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (getActivity() != null) {
      getActivity().recreate();
    }
    return true;
  }
});

代码示例来源:origin: 348476129/gank.io-with-MVVM

@Override
public void initListeners() {
  binding.switchbutton.setOnCheckedChangeListener((compoundButton, b) -> {
    if (b) {
      if (!isDarkTheme()) {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        mSettingFragmentPresenter.updateSetting(true);
        getActivity().recreate();
      }
    } else {
      if (isDarkTheme()) {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        mSettingFragmentPresenter.updateSetting(false);
        getActivity().recreate();
      }
    }
  });
  binding.collectionLayout.setOnClickListener(view -> {
    startActivity(new Intent(getActivity(), CollectionActivity.class));
  });
}

代码示例来源:origin: kollerlukas/Camera-Roll-Android-App

getActivity().recreate();
} else if (preference.getKey().equals(getString(R.string.pref_key_style))) {
  settings.setStyle((int) o);

代码示例来源:origin: grzegorznittner/chanu

pref = !pref;
  prefs.edit().putBoolean(SettingsActivity.PREF_USE_VOLUME_SCROLL, pref).apply();
  getActivity().recreate();
  return true;
case R.id.use_fast_scroll_menu:

相关文章

微信公众号

最新文章

更多

FragmentActivity类方法