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();
   }
 }
 @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;
 }
 public void removeFragment(Fragment fragment) {
   if (fragment != null) {
     // Get fragment manager form our activity
     FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
     fragmentManager.popBackStack();
   }
 }
  // ****************************************************************
  // * 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();
    }
  }
 @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);
   }
 }
 @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");
 }
  @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);
    }
  }
 @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();
 }
  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");
    }
  }
  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
 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());
 }
 public void show(AppCompatActivity context) {
   show(context.getSupportFragmentManager(), "TEXT_DISPLAY");
 }
  public ViewPagerAdapter(AppCompatActivity activity) {
    super(activity.getSupportFragmentManager());

    mContext = activity;
  }