Java Code Examples for android.app.Fragment#getActivity()

The following examples show how to use android.app.Fragment#getActivity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ask.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
public static Ask on(Fragment lFragment) {
    if (lFragment == null) {
        throw new IllegalArgumentException("Null Fragment Reference");
    }
    fragment = lFragment;
    activity = lFragment.getActivity();
    return new Ask();
}
 
Example 2
Source File: PropertiesView.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static PropertyEditor.Host getHost(Fragment f)
  {
      final PropertyEditor.Host host;
if(f.getArguments().containsKey(PropertyEditor.ARG_HOST_FRAGMENT_TAG))
	host = (PropertyEditor.Host) f.getFragmentManager().findFragmentByTag(f.getArguments().getString(PropertyEditor.ARG_HOST_FRAGMENT_TAG));
else
	host = (PropertyEditor.Host) f.getActivity();
      return host;
  }
 
Example 3
Source File: SoftKeyboardHelper.java    From Snake with Apache License 2.0 5 votes vote down vote up
public static boolean hideKeyboard(@NonNull Fragment fragment) {
    if(fragment.isDetached() || fragment.isRemoving() || null == fragment.getActivity()) return true;

    InputMethodManager inputMethodManager = (InputMethodManager) fragment.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    View rootView = fragment.getView();
    if(rootView instanceof ViewGroup) {
        View focusedChild = ((ViewGroup)rootView).getFocusedChild();
        if(null != focusedChild) {
            return inputMethodManager.hideSoftInputFromWindow(focusedChild.getWindowToken(), 0);
        }
    }

    return true;
}
 
Example 4
Source File: LockActivity.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void setPassword(Fragment fragment, int requestCode) {
    Intent intent = new Intent(fragment.getActivity(), LockActivity.class);
    intent.setAction(ACTION_SET_PASSWORD);
    fragment.startActivityForResult(intent, requestCode);
}
 
Example 5
Source File: BaseActivity.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
public static BaseActivity get(Fragment fragment) {
    return (BaseActivity) fragment.getActivity();
}
 
Example 6
Source File: BarcodeIntentIntegrator.java    From ratebeer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param fragment {@link Fragment} invoking the integration. {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment}
 * instead of an {@link Activity}
 */
public BarcodeIntentIntegrator(Fragment fragment) {
	this.activity = fragment.getActivity();
	this.fragment = fragment;
	initializeConfiguration();
}
 
Example 7
Source File: DocumentsActivity.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
public static DocumentsActivity get(Fragment fragment) {
    return (DocumentsActivity) fragment.getActivity();
}
 
Example 8
Source File: InstagramGalleryActivity.java    From InstagramPhotoPicker-Android with MIT License 4 votes vote down vote up
static void startForResult(Fragment fragment, int requestCode) {
    Intent i = new Intent(fragment.getActivity(), InstagramGalleryActivity.class);
    fragment.startActivityForResult(i, requestCode);
}
 
Example 9
Source File: InstagramLoginActivity.java    From InstagramPhotoPicker-Android with MIT License 4 votes vote down vote up
public static void startLoginForResult(Fragment fragment, String clientId, String redirectUri, int requestCode) {
    Intent i = new Intent(fragment.getActivity(), InstagramLoginActivity.class);
    i.putExtra(EXTRA_CLIENT_ID, clientId);
    i.putExtra(EXTRA_REDIRECT_URI, redirectUri);
    fragment.startActivityForResult(i, requestCode);
}
 
Example 10
Source File: IntentIntegrator.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param fragment {@link Fragment} invoking the integration.
 *  {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead
 *  of an {@link Activity}
 */
public IntentIntegrator(Fragment fragment) {
  this.activity = fragment.getActivity();
  this.fragment = fragment;
  initializeConfiguration();
}
 
Example 11
Source File: BaseActivity.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
public static BaseActivity get(Fragment fragment) {
    return (BaseActivity) fragment.getActivity();
}
 
Example 12
Source File: FragmentTransactionUriRequest.java    From WMRouter with Apache License 2.0 4 votes vote down vote up
/**
 * @param fragment 父fragment
 * @param uri      地址
 */
@RequiresApi(17)
public FragmentTransactionUriRequest(@NonNull Fragment fragment, String uri) {
    super(fragment.getActivity(), uri);
    mFragmentManager = fragment.getChildFragmentManager();
}
 
Example 13
Source File: PurchaseActivity.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
public static void showForResult(Fragment f, int requestCode) {
    final Intent intent = new Intent(f.getActivity(), PurchaseActivity.class);
    f.startActivityForResult(intent,
            requestCode);
}
 
Example 14
Source File: StandaloneActivity.java    From FireFiles with Apache License 2.0 4 votes vote down vote up
public static BaseActivity get(Fragment fragment) {
    return (BaseActivity) fragment.getActivity();
}
 
Example 15
Source File: Album.java    From Album with Apache License 2.0 4 votes vote down vote up
/**
 * Open the camera from the activity.
 */
public static Camera<ImageCameraWrapper, VideoCameraWrapper> camera(Fragment fragment) {
    return new AlbumCamera(fragment.getActivity());
}
 
Example 16
Source File: ChooserDialog.java    From android-file-chooser with Apache License 2.0 4 votes vote down vote up
public ChooserDialog(Fragment fragment) {
    this._context = fragment.getActivity();
    init();
}
 
Example 17
Source File: IntentIntegrator.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
/**
 * @param fragment {@link Fragment} invoking the integration.
 *  {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead
 *  of an {@link Activity}
 */
public IntentIntegrator(Fragment fragment) {
  this.activity = fragment.getActivity();
  this.fragment = fragment;
  initializeConfiguration();
}
 
Example 18
Source File: Album.java    From Album with Apache License 2.0 4 votes vote down vote up
/**
 * Preview Album.
 */
public static BasicGalleryWrapper<GalleryAlbumWrapper, AlbumFile, String, AlbumFile> galleryAlbum(Fragment fragment) {
    return new GalleryAlbumWrapper(fragment.getActivity());
}
 
Example 19
Source File: MaterialTapTargetPrompt.java    From styT with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a builder for a material tap target prompt that uses an explicit theme resource.
 * <p>
 * The {@code themeResId} may be specified as {@code 0} to use the parent {@code context}'s
 * resolved value for {@link R.attr#MaterialTapTargetPromptTheme}.
 *
 * @param fragment   the fragment to show the prompt within.
 * @param themeResId the resource ID of the theme against which to inflate this dialog, or
 *                   {@code 0} to use the parent {@code context}'s default material tap
 *                   target prompt theme
 */
public Builder(@NonNull final Fragment fragment, int themeResId) {
    this(fragment.getActivity(), themeResId);
}
 
Example 20
Source File: FileChooseActivity.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * 进入文件选择界面
 *
 * @param fragment
 * @param requestCode
 */
public static void goFileChooseActivity(Fragment fragment, int requestCode) {
    Intent intent = new Intent(fragment.getActivity(), FileChooseActivity.class);
    fragment.startActivityForResult(intent, requestCode);
}