コード例 #1
0
 private void dismissIfNecessary(AppCompatActivity context, String tag) {
   Fragment frag = context.getSupportFragmentManager().findFragmentByTag(tag);
   if (frag != null) {
     ((DialogFragment) frag).dismiss();
     context.getSupportFragmentManager().beginTransaction().remove(frag).commit();
   }
 }
コード例 #2
0
 @Nullable
 public static ColorChooserDialog findVisible(
     @NonNull AppCompatActivity context, @ColorChooserTag String tag) {
   Fragment frag = context.getSupportFragmentManager().findFragmentByTag(tag);
   if (frag != null && frag instanceof ColorChooserDialog) return (ColorChooserDialog) frag;
   return null;
 }
コード例 #3
0
 public void removeFragment(Fragment fragment) {
   if (fragment != null) {
     // Get fragment manager form our activity
     FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
     fragmentManager.popBackStack();
   }
 }
コード例 #4
0
  // ****************************************************************
  // * Constructors
  // ****************************************************************
  public GroupCreateActivityViewHolder(
      Context context, IFragmentController fragmentController, View view) {
    super(context, fragmentController, view);
    try {
      AppCompatActivity activity = (AppCompatActivity) context;

      Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
      activity.setSupportActionBar(toolbar);
      final ActionBar actionBar = activity.getSupportActionBar();
      actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
      fragmentManager = activity.getSupportFragmentManager();
      groupCreateFragment =
          (GroupCreateFragment) fragmentManager.findFragmentById(R.id.groupCreateFragment);
      groupCreateChoosePrivacyFragment =
          (GroupCreateChoosePrivacyFragment)
              fragmentManager.findFragmentById(R.id.groupCreateChoosePrivacyFragment);
      groupCreateChooseIconFragment =
          (GroupCreateChooseIconFragment)
              fragmentManager.findFragmentById(R.id.groupCreateChooseIconFragment);
      progressBar = (RelativeLayout) view.findViewById(R.id.progressBar);

      title = (TextView) view.findViewById(R.id.toolbarTitle);
      initialize(context);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #5
0
 @Override
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   if ((Boolean) newValue) {
     VerifyPasswordDialog verifyPasswordDialog = new VerifyPasswordDialog();
     verifyPasswordDialog.show(settingsActivity.getSupportFragmentManager(), null);
   } else {
     defaultPrefs.masterPasswordHash(null);
   }
   return true;
 }
コード例 #6
0
 /**
  * Requests the fine location permission. If a rationale with an additional explanation should be
  * shown to the user, displays a dialog that triggers the request.
  */
 public static void requestPermission(
     AppCompatActivity activity, int requestId, String permission, boolean finishActivity) {
   if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
     // Display a dialog with rationale.
     RationaleDialog.newInstance(requestId, finishActivity)
         .show(activity.getSupportFragmentManager(), "dialog");
   } else {
     // Location permission has not been granted yet, request it.
     ActivityCompat.requestPermissions(activity, new String[] {permission}, requestId);
   }
 }
コード例 #7
0
 @NonNull
 public ColorChooserDialog show(AppCompatActivity context) {
   String tag;
   Builder builder = getBuilder();
   if (builder.mColorsTop != null) tag = TAG_CUSTOM;
   else if (builder.mAccentMode) tag = TAG_ACCENT;
   else tag = TAG_PRIMARY;
   dismissIfNecessary(context, tag);
   show(context.getSupportFragmentManager(), tag);
   return this;
 }
コード例 #8
0
 protected void onPostExecute(Node n) {
   if (n == null) {
     AccessibleToast.makeText(
             activity,
             activity.getResources().getString(R.string.poi_error_poi_not_found),
             Toast.LENGTH_LONG)
         .show();
     return;
   }
   DeletePoiDialogFragment.createInstance(n)
       .show(activity.getSupportFragmentManager(), "DeletePoiDialogFragment");
 }
コード例 #9
0
  @Override
  protected void onAttachedToActivity() {
    super.onAttachedToActivity();

    AppCompatActivity activity = (AppCompatActivity) getContext();
    ColorDialogFragment fragment =
        (ColorDialogFragment)
            activity.getSupportFragmentManager().findFragmentByTag(getFragmentTag());
    if (fragment != null) {
      // re-bind preference to fragment
      fragment.setPreference(this);
    }
  }
コード例 #10
0
 @Override
 protected void onClick() {
   super.onClick();
   ColorDialogFragment fragment = ColorDialogFragment.newInstance();
   fragment.setSelector(colorSelector);
   fragment.setPreference(this);
   AppCompatActivity activity = (AppCompatActivity) getContext();
   activity
       .getSupportFragmentManager()
       .beginTransaction()
       .add(fragment, getFragmentTag())
       .commit();
 }
コード例 #11
0
  public static void show(
      AppCompatActivity activity, Integer containerViewId, ObaStop stop, Callback callback) {
    FragmentManager fm = activity.getSupportFragmentManager();

    SimpleArrivalListFragment fragment = new SimpleArrivalListFragment();
    fragment.setObaStop(stop);

    Intent intent = new Intent(activity, SimpleArrivalListFragment.class);
    intent.setData(Uri.withAppendedPath(ObaContract.Stops.CONTENT_URI, stop.getId()));
    fragment.setArguments(FragmentUtils.getIntentArgs(intent));
    fragment.setCallback(callback);

    try {
      FragmentTransaction ft = fm.beginTransaction();
      ft.replace(containerViewId, fragment, TAG);
      ft.addToBackStack(null);
      ft.commit();
    } catch (IllegalStateException e) {
      Log.e(TAG, "Cannot show SimpleArrivalListFragment after onSaveInstanceState has been called");
    }
  }
コード例 #12
0
  public void replaceContentFragment(
      Fragment fragment,
      int containerId,
      int enterAnim,
      int exitAnim,
      int popEnterAnim,
      int popExitAnim,
      boolean addToBackStack) {

    // Check for null
    if (fragment != null) {

      mFragmentName = fragment.getClass().getSimpleName();
      // Get fragment manager form our activity
      FragmentManager fragmentManager = mActivity.getSupportFragmentManager();

      // replace with new content
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

      // Animate only if above ICS
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        fragmentTransaction.setCustomAnimations(enterAnim, exitAnim, popEnterAnim, popExitAnim);
      }
      fragmentTransaction.replace(containerId, fragment, mFragmentName);
      if (addToBackStack) {
        fragmentTransaction.addToBackStack(null);
      }
      try {
        fragmentTransaction.commit();
      } catch (IllegalStateException ex) {
        Log.w(
            NavigationManager.class.getSimpleName(),
            "Cannot perform a FragmentTransaction after the Activity was stopped. Fragment name : "
                + mFragmentName);
        ex.printStackTrace();
        return;
      }
    }
  }
コード例 #13
0
ファイル: TabsAdapter.java プロジェクト: Tiboh/WorkoutProgram
 public TabsAdapter(AppCompatActivity activity, ViewPager pager) {
   super(activity.getSupportFragmentManager());
   mContext = activity;
   mViewPager = pager;
   mViewPager.setAdapter(this);
 }
コード例 #14
0
 public AddGifDialogHandler(AppCompatActivity activity) {
   this.mActivity = activity;
   this.fragmentHandler = new FragmentHandler(activity.getSupportFragmentManager());
 }
コード例 #15
0
 public void show(AppCompatActivity context) {
   show(context.getSupportFragmentManager(), "TEXT_DISPLAY");
 }
コード例 #16
0
  public ViewPagerAdapter(AppCompatActivity activity) {
    super(activity.getSupportFragmentManager());

    mContext = activity;
  }