本文整理匯總了Java中android.support.v4.app.Fragment.getClass方法的典型用法代碼示例。如果您正苦於以下問題:Java Fragment.getClass方法的具體用法?Java Fragment.getClass怎麽用?Java Fragment.getClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.Fragment
的用法示例。
在下文中一共展示了Fragment.getClass方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setTabHide
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static void setTabHide(Fragment caller, FloatingActionButton chatHead) {
if (myAdapter.getItem(mViewPager.getCurrentItem()).getClass() == caller.getClass()) {
if (tabsLayout.getVisibility() == View.VISIBLE) {
tabsLayout.setVisibility(View.GONE, true, R.anim.fade_out);
}
if (chatHead.isVisible()) {
chatHead.hide();
}
}
}
示例2: setTabShow
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static void setTabShow(Fragment caller, FloatingActionButton chatHead) {
if (myAdapter.getItem(mViewPager.getCurrentItem()).getClass() == caller.getClass()) {
if (tabsLayout.getVisibility() == View.GONE) {
tabsLayout.setVisibility(View.VISIBLE, true, R.anim.fade_in);
}
if (!chatHead.isVisible()) {
chatHead.show();
}
}
}
示例3: FragmentPagerItem
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
protected FragmentPagerItem(String title, @NonNull Fragment fragment) {
this(title, fragment.getClass(), fragment.getArguments());
this.fragment = fragment;
}
示例4: init
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void init() {
addPreferencesFromResource(R.xml.settings);
if (Utils.DONATED) {
getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
}
SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
getPreferenceScreen().removePreference(forceEnglish);
} else {
forceEnglish.setOnPreferenceChangeListener(this);
}
/*
if (Utils.hideStartActivity()) {
((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
.removePreference(findPreference(KEY_MATERIAL_ICON));
} else {
findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
}
*/
findPreference(KEY_RESET_DATA).setOnPreferenceClickListener(this);
findPreference(KEY_UPDATE_NOTIFICATION).setOnPreferenceChangeListener(this);
findPreference(KEY_CHECK_UPDATE).setOnPreferenceClickListener(this);
findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);
if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
} else {
((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
findPreference(KEY_LAST_KMSG));
}
findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
findPreference(KEY_FINGERPRINT));
} else {
mFingerprint = findPreference(KEY_FINGERPRINT);
mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
}
PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
for (NavigationActivity.NavigationFragment navigationFragment : NavigationActivity.sFragments) {
Fragment fragment = navigationFragment.mFragment;
int id = navigationFragment.mId;
if (fragment != null && fragment.getClass() != SettingsFragment.class) {
SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
switchPreference.setSummary(getString(id));
switchPreference.setKey(fragment.getClass().getSimpleName() + "_enabled");
switchPreference.setChecked(Prefs.getBoolean(fragment.getClass().getSimpleName()
+ "_enabled", true, getActivity()));
switchPreference.setOnPreferenceChangeListener(this);
switchPreference.setPersistent(false);
sectionsCategory.addPreference(switchPreference);
}
}
}
示例5: init
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void init() {
addPreferencesFromResource(R.xml.settings);
if (Utils.DONATED) {
getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
}
SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
getPreferenceScreen().removePreference(forceEnglish);
} else {
forceEnglish.setOnPreferenceChangeListener(this);
}
if (Utils.hideStartActivity()) {
((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
.removePreference(findPreference(KEY_MATERIAL_ICON));
} else {
findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
}
findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);
if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
} else {
((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
findPreference(KEY_LAST_KMSG));
}
findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
findPreference(KEY_FINGERPRINT));
} else {
mFingerprint = findPreference(KEY_FINGERPRINT);
mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
}
PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
for (NavigationActivity.NavigationFragment navigationFragment : NavigationActivity.sFragments) {
Fragment fragment = navigationFragment.mFragment;
int id = navigationFragment.mId;
if (fragment != null && fragment.getClass() != SettingsFragment.class) {
SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
switchPreference.setSummary(getString(id));
switchPreference.setKey(fragment.getClass().getSimpleName() + "_enabled");
switchPreference.setChecked(Prefs.getBoolean(fragment.getClass().getSimpleName()
+ "_enabled", true, getActivity()));
switchPreference.setOnPreferenceChangeListener(this);
switchPreference.setPersistent(false);
sectionsCategory.addPreference(switchPreference);
}
}
}
示例6: innerLinkToFragment
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private static void innerLinkToFragment(FragmentManager fragmentManager, @NonNull Uri uri, @NonNull INLFragmentRoutingCallback callback, boolean linkFromActivity)
{
if(fragmentManager == null) return;
smartInit();
List<Fragment> addedFragmentList = fragmentManager.getFragments();
String url = uri.toString();
ArrayList<Mapping> targetFragmentMappings = linkFromActivity ? mMasterFragmentMappings : mChildFragmentMappings;
for(Mapping mapping : targetFragmentMappings)
{
if(mapping.isMatched(url))
{
boolean isTargetHasBeenAdded = false;
Fragment existingTargetFragment = null;
Class<? extends Fragment> target = mapping.getTargetFragment();
if(target == null) break;
if(addedFragmentList != null && !addedFragmentList.isEmpty())
{
for(Fragment f : addedFragmentList)
{
if(f == null) continue;
Class<? extends Fragment> fClass = f.getClass();
if(target.equals(fClass))
{
isTargetHasBeenAdded = true;
existingTargetFragment = f;
break;
}
}
}
Bundle extras = mapping.parseExtras(url);
if(isTargetHasBeenAdded)
{
callback.onFragmentRouting(existingTargetFragment, extras, true);
return;
}
try
{
callback.onFragmentRouting(target.newInstance(), extras, false);
return;
}
catch (Exception e)
{
e.printStackTrace();
}
break;
}
}
callback.onFragmentRouting(null, null, false);
}