List of usage examples for android.app Fragment getActivity
final public Activity getActivity()
From source file:Main.java
public static boolean isFragmentAttached(Fragment fragment) { return fragment.getActivity() != null; }
From source file:Main.java
/** * Shows a {@link Toast} on the UI thread. * * @param text The message to show/*from w w w . j av a 2 s . co m*/ */ public static void showToast(final Fragment fragment, final String text) { if (fragment.getActivity() != null) { fragment.getActivity().runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(fragment.getActivity(), text, Toast.LENGTH_SHORT).show(); } }); } }
From source file:io.pivotal.arca.fragments.ArcaDispatcherFactory.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static ArcaDispatcher generateDispatcher(android.app.Fragment fragment) { final ContentResolver resolver = fragment.getActivity().getContentResolver(); final ArcaExecutor executor = new ArcaExecutor.DefaultArcaExecutor(resolver, fragment.getActivity()); return new ArcaModernDispatcher(executor, fragment.getActivity(), fragment.getLoaderManager()); }
From source file:Main.java
@SuppressLint("NewApi") public static void sendSchemeAddMediaStack(Fragment context, String url) { sendSchemeAddMediaStack(context, url, getHomeScheme(context.getActivity())); }
From source file:Main.java
@SuppressLint("NewApi") public static void sendSchemeAddMediaStack(Fragment context, String url, Bundle bundle) { sendSchemeAddMediaStack(context, getHomeScheme(context.getActivity()), url, bundle); }
From source file:Main.java
@SuppressLint("NewApi") public static void sendSchemeForResultAddMediaStack(Fragment activity, String url, int requestCode) { sendSchemeForResultAddMediaStack(activity, url, getHomeScheme(activity.getActivity()), requestCode); }
From source file:com.shopgun.android.utils.KeyboardUtils.java
/** * Request to show the soft input window from the context of the window that is currently accepting input. * @param fragment The current fragment//from ww w. j ava2 s . co m */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void show(android.app.Fragment fragment) { if (fragment != null) { show(fragment.getActivity()); } }
From source file:com.shopgun.android.utils.KeyboardUtils.java
/** * Request to hide the soft input window from the context of the window that is currently accepting input. * @param fragment The current fragment//from w ww.j av a 2s . c o m */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void hide(android.app.Fragment fragment) { if (fragment != null) { hide(fragment.getActivity()); } }
From source file:dev.dworks.apps.anexplorer.BaseActivity.java
public static BaseActivity get(Fragment fragment) { return (BaseActivity) fragment.getActivity(); }
From source file:com.android.contacts.util.AccountFilterUtil.java
/** * Launches account filter setting Activity using * {@link Fragment#startActivityForResult(Intent, int)}. * * @param requestCode requestCode for {@link Activity#startActivityForResult(Intent, int)} * @param currentFilter currently-selected filter, so that it can be displayed as activated. *//* w w w . j av a 2 s .co m*/ public static void startAccountFilterActivityForResult(Fragment fragment, int requestCode, ContactListFilter currentFilter) { final Activity activity = fragment.getActivity(); if (activity != null) { final Intent intent = new Intent(activity, AccountFilterActivity.class); fragment.startActivityForResult(intent, requestCode); } else { Log.w(TAG, "getActivity() returned null. Ignored"); } }