Example usage for android.support.v4.app Fragment getActivity

List of usage examples for android.support.v4.app Fragment getActivity

Introduction

In this page you can find the example usage for android.support.v4.app Fragment getActivity.

Prototype

public Activity getActivity() 

Source Link

Usage

From source file:de.dreier.mytargets.utils.ToolbarUtils.java

public static void setTitle(Fragment fragment, String title) {
    setTitle((AppCompatActivity) fragment.getActivity(), title);
}

From source file:com.google.android.apps.santatracker.games.gumball.Utils.java

public static PlayGamesActivity getPlayGamesActivity(Fragment fragment) {
    Activity act = fragment.getActivity();
    if (act == null || !(act instanceof PlayGamesActivity)) {
        Log.w(TAG, "Fragment is not in a PlayGamesActivity!");
        return null;
    }//from  w w  w  . j av a2 s  .  com
    return (PlayGamesActivity) act;
}

From source file:net.ypresto.scabbard.Scabbard.java

/**
 * Creates fragment-scoped component using {@link ScabbardActivityComponent} and {@link ComponentFactory}.
 *//*www . j  a  v  a  2 s .  c o m*/
public static ScabbardFragmentComponent createFragmentComponent(Fragment fragment) {
    FragmentActivity activity = fragment.getActivity();
    ApplicationScopeInfo scopeInfo = APPLICATION_SCOPE_MANAGER.getScopeInfo(activity);
    ComponentFactory componentFactory = scopeInfo.getComponentFactory();
    ScabbardActivityComponent activityComponent = scopeInfo.getActivityComponentManager()
            .getComponent(activity);
    return componentFactory.createFragmentComponent(activityComponent, fragment);
}

From source file:de.dreier.mytargets.utils.ToolbarUtils.java

public static void setTitle(Fragment fragment, @StringRes int title) {
    setTitle((AppCompatActivity) fragment.getActivity(), title);
}

From source file:me.panpf.tool4a.util.InputMethodUtils.java

/**
 * ??//from  ww w . j  a v  a  2s .  c  om
 */
@SuppressWarnings("unused")
public static void hideSoftInput(Fragment fragment) {
    hideSoftInput(fragment != null ? fragment.getActivity() : null);
}

From source file:com.github.mkjensen.dml.util.LoadingHelper.java

/**
 * Hides the progress indicator, if present, for the specified fragment.
 *//*w w  w . j a  v a 2s  .  co m*/
public static void hideLoading(@NonNull Fragment fragment) {
    FragmentManager fragmentManager = fragment.getActivity().getSupportFragmentManager();
    Fragment loadingFragment = getLoadingFragment(fragmentManager);
    if (loadingFragment == null) {
        Log.w(TAG, "Was asked to remove nonexistent progress indicator, ignoring");
        return;
    }
    fragmentManager.beginTransaction().remove(loadingFragment).commitAllowingStateLoss(); // TODO: Is commitAllowingStateLoss okay, can it be avoided?
}

From source file:com.github.mkjensen.dml.util.LoadingHelper.java

/**
 * Shows the progress indicator, if not already present, for the specified fragment.
 *///  ww w  .  j ava2s. c  o m
public static void showLoading(@NonNull Fragment fragment) {
    FragmentManager fragmentManager = fragment.getActivity().getSupportFragmentManager();
    Fragment loadingFragment = getLoadingFragment(fragmentManager);
    if (loadingFragment != null) {
        Log.w(TAG, "Was asked to add progress indicator but it is already present, ignoring");
        return;
    }
    fragmentManager.beginTransaction().add(fragment.getId(), new LoadingFragment(), LOADING_FRAGMENT_TAG)
            .commit();
}

From source file:org.videolan.vlc.gui.PlaybackServiceFragment.java

public static void registerPlaybackService(Fragment fragment, PlaybackService.Client.Callback cb) {
    registerPlaybackService(fragment.getActivity(), cb);
}

From source file:com.stfalcon.socialauthhelper.twitter.TwitterAuthActivity.java

public static void authorize(Fragment fragment, int requestCode) {
    fragment.startActivityForResult(getIntent(fragment.getActivity()), requestCode);
    fragment.getActivity().overridePendingTransition(0, 0);
}

From source file:org.videolan.vlc.gui.PlaybackServiceFragment.java

public static void unregisterPlaybackService(Fragment fragment, PlaybackService.Client.Callback cb) {
    unregisterPlaybackService(fragment.getActivity(), cb);
}