Java Code Examples for android.support.v4.app.Fragment#getActivity()
The following examples show how to use
android.support.v4.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: ViperHelper.java From android-viper with Apache License 2.0 | 6 votes |
/** * Use in case this Presenter is associated with an {@link Fragment} * Call from {@link Fragment#onDestroyView()}. * Use in case Presenter is associated with Fragment. * * @param fragment {@link Fragment} instance */ public void onDestroyView(@NonNull Fragment fragment) { if(this.mPresenter == null) return; if(fragment.getActivity() != null && fragment.getActivity().isFinishing()) { this.mPresenter.onPresenterDetached(true); removePresenter(); } else { this.mPresenter.onPresenterDetached(false); this.mAlreadyCreated = false; } }
Example 2
Source File: ImmersionBar.java From ImmersionBar with Apache License 2.0 | 5 votes |
@TargetApi(14) public static int getNavigationBarWidth(@NonNull Fragment fragment) { if (fragment.getActivity() == null) { return 0; } return getNavigationBarWidth(fragment.getActivity()); }
Example 3
Source File: Session.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
AuthorizationRequest(final Fragment fragment) { startActivityDelegate = new StartActivityDelegate() { @Override public void startActivityForResult(Intent intent, int requestCode) { fragment.startActivityForResult(intent, requestCode); } @Override public Activity getActivityContext() { return fragment.getActivity(); } }; }
Example 4
Source File: SaveHarTask.java From CapturePacket with MIT License | 5 votes |
@Override protected void onPreExecute() { Fragment fragment = mFragmentRef.get(); if (fragment != null && fragment.isAdded()) { mPD = new ProgressDialog(fragment.getActivity()); mPD.setCancelable(false); mPD.setMessage("请稍后..."); mPD.show(); } }
Example 5
Source File: WriteDataActivity.java From PlayTogether with Apache License 2.0 | 5 votes |
public static void startActivityForResult(Fragment fragment, String hint, String limitHint, int inputType, int maxLength, int reqCode) { Intent intent = new Intent(fragment.getActivity(), WriteDataActivity.class); intent.putExtra(EXTRA_HINT, hint); intent.putExtra(EXTRA_LIMIT_HINT, limitHint); intent.putExtra(EXTRA_INPUT_TYPE, inputType); intent.putExtra(EXTRA_MAX_LENGTH, maxLength); fragment.startActivityForResult(intent, reqCode); }
Example 6
Source File: ActivityUtils.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
private static Bundle getOptionsBundle(final Fragment fragment, final int enterAnim, final int exitAnim) { Activity activity = fragment.getActivity(); if (activity == null) return null; return ActivityOptionsCompat.makeCustomAnimation(activity, enterAnim, exitAnim).toBundle(); }
Example 7
Source File: MediaShowActivity.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
/*** * 进入图片选择界面 * * @param activity * @param PickMode */ public static void gotoPicForResult(Fragment fragment, int PickMode, int maxPicks, ArrayList<MediaInfo> selectedMediaInfos) { Intent intent = new Intent(fragment.getActivity(), MediaShowActivity.class); intent.putExtra(MediaConstants.MEDIA_PICK_MODE, PickMode); intent.putExtra(MediaConstants.MEDIA_REQUEST_DATAS, selectedMediaInfos); intent.putExtra(MediaConstants.MEDIA_RESULT_TYPE, MediaConstants.TYPE_PIC); intent.putExtra(MediaConstants.MEDIA_MAX_MULTIPLE_PICK, maxPicks); fragment.startActivityForResult(intent, MediaConstants.MEDIA_REQUEST_PIC_CODE); }
Example 8
Source File: Session.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
AuthorizationRequest(final Fragment fragment) { startActivityDelegate = new StartActivityDelegate() { @Override public void startActivityForResult(Intent intent, int requestCode) { fragment.startActivityForResult(intent, requestCode); } @Override public Activity getActivityContext() { return fragment.getActivity(); } }; }
Example 9
Source File: Session.java From FacebookImageShareIntent with MIT License | 5 votes |
AuthorizationRequest(final Fragment fragment) { startActivityDelegate = new StartActivityDelegate() { @Override public void startActivityForResult(Intent intent, int requestCode) { fragment.startActivityForResult(intent, requestCode); } @Override public Activity getActivityContext() { return fragment.getActivity(); } }; }
Example 10
Source File: IntentIntegrator.java From zom-android-matrix with Apache License 2.0 | 4 votes |
/** * @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: HistoryCursorAdapter.java From android-opensource-library-56 with Apache License 2.0 | 4 votes |
public HistoryCursorAdapter(Fragment fragment) { super(fragment.getActivity(), null, false); mInflator = (LayoutInflater) fragment.getActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE); mFragment = fragment; }
Example 12
Source File: ImmersionBar.java From MNImageBrowser with GNU General Public License v3.0 | 4 votes |
public static boolean hasNotchScreen(@NonNull Fragment fragment) { if (fragment.getActivity() == null) { return false; } return hasNotchScreen(fragment.getActivity()); }
Example 13
Source File: ImmersionBar.java From MNImageBrowser with GNU General Public License v3.0 | 4 votes |
public static int getNotchHeight(@NonNull Fragment fragment) { if (fragment.getActivity() == null) { return 0; } return getNotchHeight(fragment.getActivity()); }
Example 14
Source File: ISCameraActivity.java From ImageSelector with Apache License 2.0 | 4 votes |
public static void startForResult(Fragment fragment, ISCameraConfig config, int requestCode) { Intent intent = new Intent(fragment.getActivity(), ISCameraActivity.class); intent.putExtra("config", config); fragment.startActivityForResult(intent, requestCode); }
Example 15
Source File: GroupDialogActivity.java From q-municate-android with Apache License 2.0 | 4 votes |
public static void startForResult(Fragment fragment, QBChatDialog chatDialog, int requestCode) { Intent intent = new Intent(fragment.getActivity(), GroupDialogActivity.class); intent.putExtra(QBServiceConsts.EXTRA_DIALOG, chatDialog); fragment.startActivityForResult(intent, requestCode); }
Example 16
Source File: IntentIntegrator.java From fdroidclient with GNU General Public License v3.0 | 4 votes |
/** * @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 17
Source File: ISListActivity.java From ImageSelector with Apache License 2.0 | 4 votes |
public static void startForResult(Fragment fragment, ISListConfig config, int RequestCode) { Intent intent = new Intent(fragment.getActivity(), ISListActivity.class); intent.putExtra("config", config); fragment.startActivityForResult(intent, RequestCode); }
Example 18
Source File: FragmentUtil.java From settlers-remake with MIT License | 4 votes |
private static AppCompatActivity getActivity(Fragment fragment) { return (AppCompatActivity) fragment.getActivity(); }
Example 19
Source File: GPreviewBuilder.java From ZoomPreviewPicture with Apache License 2.0 | 2 votes |
/*** * 设置开始启动预览 * @param fragment 启动 *@return GPreviewBuilder * **/ public static GPreviewBuilder from(@NonNull Fragment fragment) { return new GPreviewBuilder(fragment.getActivity()); }
Example 20
Source File: ImmersionBar.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 2 votes |
/** * 在Fragment里初始化 * Instantiates a new Immersion bar. * * @param fragment the fragment */ private ImmersionBar(Fragment fragment) { this(fragment.getActivity(), fragment); }