Example usage for android.app FragmentTransaction setTransition

List of usage examples for android.app FragmentTransaction setTransition

Introduction

In this page you can find the example usage for android.app FragmentTransaction setTransition.

Prototype

public abstract FragmentTransaction setTransition(@Transit int transit);

Source Link

Document

Select a standard transition animation for this transaction.

Usage

From source file:com.android.mail.ui.TwoPaneController.java

/**
 * Render the conversation list in the correct pane.
 *//*w ww  .ja v a2s.c  o m*/
private void renderConversationList() {
    if (mActivity == null) {
        return;
    }
    FragmentTransaction fragmentTransaction = mActivity.getFragmentManager().beginTransaction();
    // Use cross fading animation.
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    final Fragment conversationListFragment = ConversationListFragment.newInstance(mConvListContext);
    fragmentTransaction.replace(R.id.conversation_list_pane, conversationListFragment, TAG_CONVERSATION_LIST);
    fragmentTransaction.commitAllowingStateLoss();
}

From source file:com.prasanna.android.stacknetwork.QuestionActivity.java

private void displayPostCommentFragment(String title, long id, int viewPagerPosition, String fragmentTag,
        String defaultText) {/*from  w  ww  .ja  va 2s  .  c  o m*/
    postCommentFragment = new PostCommentFragment();
    postCommentFragment.setPostId(id);
    postCommentFragment.setViewPagerPosition(viewPagerPosition);
    postCommentFragment.setTitle(title);
    postCommentFragment.setResultReceiver(resultReceiver);

    if (commentsDraft.get(fragmentTag) != null)
        postCommentFragment.setDraftText(commentsDraft.get(fragmentTag));

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.fragmentContainer, postCommentFragment, fragmentTag);
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    transaction.addToBackStack(fragmentTag);
    transaction.commit();
}

From source file:com.prasanna.android.stacknetwork.QuestionActivity.java

private void showCommentFragment(long postId, ArrayList<Comment> comments) {
    String fragmentTag = postId + "-" + StringConstants.COMMENTS;
    commentFragment = findFragmentByTag(fragmentTag, CommentFragment.class);

    if (commentFragment == null) {
        commentFragment = new CommentFragment();
        commentFragment.setComments(comments);
        commentFragment.setResultReceiver(resultReceiver);

        String currentViewPagerFragmentTag = "android:switcher:" + R.id.viewPager + ":"
                + viewPager.getCurrentItem();

        OnCommentChangeListener onCommentChangeListener = (OnCommentChangeListener) getFragmentManager()
                .findFragmentByTag(currentViewPagerFragmentTag);

        if (onCommentChangeListener != null)
            commentFragment.setOnCommentChangeListener(onCommentChangeListener);
    }//w  ww  . j a  va2 s .  c om

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.fragmentContainer, commentFragment, fragmentTag);
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    transaction.addToBackStack(fragmentTag);
    transaction.commit();
}

From source file:de.lespace.apprtc.CallActivity.java

public void toggleCallControlFragmentVisibility() {
    if (!iceConnected || !callFragment.isAdded()) {
        return;/*from  w w w.  j  a  va 2 s . c o  m*/
    }
    // Show/hide call control fragment
    callControlFragmentVisible = !callControlFragmentVisible;
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    if (callControlFragmentVisible) {
        ft.show(callFragment);
        ft.show(hudFragment);
    } else {
        ft.hide(callFragment);
        ft.hide(hudFragment);
    }
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commit();
}

From source file:ml.puredark.hviewer.ui.fragments.SettingFragment.java

@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
    if (preference.getKey().equals(KEY_PREF_ABOUT_UPGRADE)) {
        ////  w w w .  java2 s.  c  o m
        if (!checking)
            UpdateManager.checkUpdate(activity);
    } else if (preference.getKey().equals(KEY_PREF_BKRS_BACKUP)) {
        //
        new AlertDialog.Builder(activity).setTitle("?").setMessage("?")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    String backup = new DataBackup().DoBackup();
                    activity.showSnackBar(backup);
                }).setNegativeButton(getString(R.string.cancel), null).show();

    } else if (preference.getKey().equals(KEY_PREF_BKRS_RESTORE)) {
        //
        new AlertDialog.Builder(activity).setTitle("???")
                .setMessage("????")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    String restore = new DataRestore().DoRestore();
                    Intent intent = new Intent();
                    activity.setResult(RESULT_OK, intent);
                    Toast.makeText(activity, restore, Toast.LENGTH_LONG).show();
                    activity.finish();
                }).setNegativeButton(getString(R.string.cancel), null).show();

    } else if (preference.getKey().equals(KEY_PREF_ABOUT_LICENSE)) {
        //???
        Intent intent = new Intent(activity, LicenseActivity.class);
        startActivity(intent);
    } else if (preference.getKey().equals(KEY_PREF_ABOUT_PRIVACY)) {
        //???
        Intent intent = new Intent(activity, PrivacyActivity.class);
        startActivity(intent);
    } else if (preference.getKey().equals(KEY_PREF_ABOUT_H_VIEWER)) {
        //
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.setting_content, new AboutFragment(activity));
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(null);
        transaction.commit();
    } else if (preference.getKey().equals(KEY_PREF_DOWNLOAD_PATH)) {
        //
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
            intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
            try {
                startActivityForResult(intent, RESULT_CHOOSE_DIRECTORY);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
                mDialog.show(getFragmentManager(), null);
            }
            new Handler().postDelayed(() -> {
                if (!opened)
                    activity.showSnackBar("?");
            }, 1000);
        } else {
            mDialog.show(getFragmentManager(), null);
        }
    } else if (preference.getKey().equals(KEY_PREF_DOWNLOAD_IMPORT)) {
        //
        new AlertDialog.Builder(activity).setTitle("?")
                .setMessage("??")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    DownloadedImport();
                }).setNegativeButton(getString(R.string.cancel), null).show();
    } else if (preference.getKey().equals(KEY_PREF_FAVOURITE_EXPORT)) {
        //?
        new AlertDialog.Builder(activity).setTitle("??")
                .setMessage("?")
                .setPositiveButton("", (dialog, which) -> {
                    DocumentFile file = FileHelper.createFileIfNotExist(Names.favouritesname,
                            DownloadManager.getDownloadPath(), Names.backupdirname);
                    if (file != null) {
                        FavouriteHolder holder = new FavouriteHolder(activity);
                        String json = new Gson().toJson(holder.getFavourites());
                        FileHelper.writeString(json, file);
                        holder.onDestroy();
                        activity.showSnackBar("??");
                    } else
                        activity.showSnackBar("");
                }).setNegativeButton(getString(R.string.cancel), null).show();
    } else if (preference.getKey().equals(KEY_PREF_FAVOURITE_IMPORT)) {
        //?
        new AlertDialog.Builder(activity).setTitle("??")
                .setMessage("???")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    String json = FileHelper.readString(Names.favouritesname, DownloadManager.getDownloadPath(),
                            Names.backupdirname);
                    if (json == null) {
                        activity.showSnackBar("?");
                    } else {
                        try {
                            List<Pair<CollectionGroup, List<LocalCollection>>> favGroups = new Gson().fromJson(
                                    json,
                                    new TypeToken<ArrayList<Pair<CollectionGroup, ArrayList<LocalCollection>>>>() {
                                    }.getType());
                            FavouriteHolder holder = new FavouriteHolder(activity);
                            for (Pair<CollectionGroup, List<LocalCollection>> pair : favGroups) {
                                Logger.d("DataStore", "" + pair.first);
                                CollectionGroup group = holder.getGroupByTitle(pair.first.title);
                                if (group == null) {
                                    group = pair.first;
                                    group.gid = holder.addFavGroup(group);
                                }
                                for (LocalCollection collection : pair.second) {
                                    collection.gid = group.gid;
                                    holder.addFavourite(collection);
                                }
                            }
                            holder.onDestroy();
                            activity.showSnackBar("??");
                        } catch (Exception e) {
                            e.printStackTrace();
                            activity.showSnackBar("?");
                        }
                    }
                }).setNegativeButton(getString(R.string.cancel), null).show();
    } else if (preference.getKey().equals(KEY_PREF_CACHE_CLEAN)) {
        //
        new AlertDialog.Builder(activity).setTitle("?")
                .setMessage("??")
                .setPositiveButton(getString(R.string.ok), (dialog, which) -> {
                    ImagePipeline imagePipeline = Fresco.getImagePipeline();
                    imagePipeline.clearDiskCaches();
                    activity.showSnackBar("??");
                    preference.setSummary(" 0.00 MB");
                }).setNegativeButton(getString(R.string.cancel), null).show();
    } else if (preference.getKey().equals(KEY_PREF_PROXY_DETAIL)) {
        //PROXY?
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.setting_content, new ProxyFragment(activity));
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(null);
        transaction.commit();
    } else if (preference.getKey().equals(KEY_PREF_LOCK_METHODS_DETAIL)) {
        //??
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(R.id.setting_content, new LockMethodFragment(activity));
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(null);
        transaction.commit();
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
}

From source file:us.cboyd.android.dicom.DcmBrowser.java

public void onFileSelected(int position, ArrayList<String> fileList, File currDir) {
    // The user selected a DICOM file from the DcmListFragment
    position -= 1;//from   w  w w .  ja va2  s.  c  o m
    if ((position < 0) || (position > fileList.size())) {
        // TODO: Error
        return;
    }

    if (mFragmented && mListFragment.isVisible()) {
        // If we're in the one-pane layout and need to swap fragments

        // Enable the Home/Up button to allow the user to go back to 
        ActionBar actionBar = getActionBar();
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Create fragment and give it an argument for the selected article
        Bundle args = new Bundle();
        args.putInt(DcmVar.POSITION, position);
        args.putStringArrayList(DcmVar.FILELIST, fileList);
        args.putString(DcmVar.CURRDIR, currDir.getPath());
        mInfoFragment.setArguments(args);
        FragmentTransaction transaction = getFragmentManager().beginTransaction();

        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack so the user can navigate back
        transaction.replace(R.id.fragment_container, mInfoFragment);
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.addToBackStack(null).commit();

        // set up the drawer's list view with items and click listener
        mDrawerList.setAdapter(mListFragment.getListAdapter());
    } else {
        // If we're in the two-pane layout or already displaying the DcmInfoFragment

        // Call a method in the DcmInfoFragment to update its content
        mInfoFragment.updateDicomInfo(position, fileList, currDir.getPath());
    }
    setTitle(fileList.get(position));
}

From source file:fr.cph.chicago.activity.MainActivity.java

@Override
public final void onNavigationDrawerItemSelected(final int position) {
    int oldPosition = mCurrentPosition;
    mCurrentPosition = position;//  w  ww .j  a v a 2s  .c om
    // update the main content by replacing fragments
    final FragmentManager fragmentManager = getFragmentManager();
    final FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    switch (position) {
    case POSITION_FAVORITES:
        if (mFavoritesFragment == null) {
            mFavoritesFragment = FavoritesFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mFavoritesFragment).commit();
        }
        break;
    case POSITION_TRAIN:
        if (mTrainFragment == null) {
            mTrainFragment = TrainFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mTrainFragment).commit();
        }
        break;
    case POSITION_BUS:
        if (mBusFragment == null) {
            mBusFragment = BusFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mBusFragment).commit();
        }
        break;
    case POSITION_DIVVY:
        if (mBikeFragment == null) {
            mBikeFragment = BikeFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mBikeFragment).commit();
        }
        break;
    case POSITION_NEARBY:
        if (mNearbyFragment == null) {
            mNearbyFragment = NearbyFragment.newInstance(position + 1);
            if (!this.isFinishing()) {
                ft.replace(R.id.container, mNearbyFragment).commit();
            }
        } else {
            if (oldPosition == 4) {
                fragmentManager.beginTransaction().commit();
            } else {
                if (!this.isFinishing()) {
                    ft.replace(R.id.container, mNearbyFragment).commit();
                }
            }
        }
        break;
    case POSITION_ALERTS:
        if (mAlertFragment == null) {
            mAlertFragment = AlertFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mAlertFragment).commit();
        }
        break;
    case POSITION_MAP:
        if (mMapFragment == null) {
            mMapFragment = MapFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mMapFragment).commit();
        }
        break;
    case POSITION_SETTINGS:
        if (mSettingsFragment == null) {
            mSettingsFragment = SettingsFragment.newInstance(position + 1);
        }
        if (!this.isFinishing()) {
            ft.replace(R.id.container, mSettingsFragment).commit();
        }
        break;
    }
}

From source file:com.android.tv.settings.accessories.AddAccessoryActivity.java

protected void switchToMultipleDevicesFragment() {
    FragmentTransaction ft = mFragmentManager.beginTransaction();
    mContentFragment = AddAccessoryContentFragment.newInstance(true);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.replace(R.id.content_fragment, mContentFragment);
    ft.disallowAddToBackStack();/*ww  w  .  j a  va2 s.c  o m*/

    ft.commit();
    mMsgHandler.sendEmptyMessageDelayed(MSG_MULTIPAIR_BLINK, BLINK_START);
    mShowingMultiFragment = true;
}

From source file:org.eyeseetea.malariacare.DashboardActivity.java

/**
 * Init the fragments/* w  ww  .j  av a 2s.  com*/
 */
private void setFragmentTransaction(int layout, ListFragment fragment) {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.add(layout, fragment);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.commit();
}

From source file:com.hijacker.MainActivity.java

static void isolate(String mac) {
    is_ap = getAPByMac(mac);/* ww  w .j a  v  a2 s.  co  m*/
    if (is_ap != null) {
        IsolatedFragment.exit_on = mFragmentManager.getBackStackEntryCount();
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.replace(R.id.fragment1, new IsolatedFragment());
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.addToBackStack(null);
        ft.commitAllowingStateLoss();
    }
    Tile.filter();
    if (debug) {
        if (is_ap == null)
            Log.d("HIJACKER/Main", "No AP isolated");
        else
            Log.d("HIJACKER/Main", "AP with MAC " + mac + " isolated");
    }
}