Example usage for android.app FragmentTransaction TRANSIT_FRAGMENT_OPEN

List of usage examples for android.app FragmentTransaction TRANSIT_FRAGMENT_OPEN

Introduction

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

Prototype

int TRANSIT_FRAGMENT_OPEN

To view the source code for android.app FragmentTransaction TRANSIT_FRAGMENT_OPEN.

Click Source Link

Document

Fragment is being added onto the stack

Usage

From source file:ab.util.AbDialogUtil.java

/**
 * ?String?./*from ww  w  .  ja v  a2 s .  c om*/
 * 
 * @param context
 * @param title
 *            ?
 * @param message
 *            ???
 * @param onClickListener
 *            ?
 */
public static AbAlertDialogFragment showAlertDialog(Context context, String title, String message,
        AbDialogOnClickListener onClickListener) {
    FragmentActivity activity = (FragmentActivity) context;
    AbAlertDialogFragment newFragment = AbAlertDialogFragment.newInstance(0, title, message, null,
            onClickListener);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    // 
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.show(ft, mDialogTag);
    return newFragment;
}

From source file:com.ab.util.AbDialogUtil.java

/**
 * ???dialog View./* w  w w .java  2  s.c om*/
 * @param icon
 * @param title ?
 * @param view  ???
 */
public static AbAlertDialogFragment showAlertDialog(int icon, String title, View view) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    AbAlertDialogFragment newFragment = AbAlertDialogFragment.newInstance(icon, title, null, view, null);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    //    
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.show(ft, mDialogTag);
    return newFragment;
}

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)) {
        ////from  w  ww . j  av  a  2  s .  c  om
        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:com.bangqu.eshow.util.ESDialogUtil.java

/**
 * ???dialog View./*from  w ww  . j  a va  2 s . co  m*/
 * @param title ?
 * @param view  ???
 */
public static ESAlertDialogFragment showAlertDialog(String title, View view) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    ESAlertDialogFragment newFragment = ESAlertDialogFragment.newInstance(0, title, null, view, null);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    //    
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.show(ft, dialogTag);
    return newFragment;
}

From source file:com.tony.selene.dialog.AbDialogUtil.java

/**
 * ?View?.//from  w  w w  .  j  av  a 2  s  .c  om
 * 
 * @param icon
 * @param title
 *            ?
 * @param view
 *            ???
 * @param onClickListener
 *            ?
 */
public static TCAlertDialogFragment showAlertDialog(int icon, String title, View view,
        TCAlertDialogFragmentOnClickListener onClickListener) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    TCAlertDialogFragment newFragment = TCAlertDialogFragment.newInstance(icon, title, null, view,
            onClickListener);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    // 
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.show(ft, dialogTag);
    return newFragment;
}

From source file:cn.org.eshow.framwork.util.AbDialogUtil.java

/**
 * ???dialog View.// ww w.jav a 2s . c  o  m
 * @param title ?
 * @param view  ???
 */
public static AbAlertDialogFragment showAlertDialog(String title, View view) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    AbAlertDialogFragment newFragment = AbAlertDialogFragment.newInstance(0, title, null, view, null);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    //    
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.show(ft, dialogTag);
    return newFragment;
}

From source file:com.tct.mail.ui.OnePaneController.java

@Override
protected void showConversation(Conversation conversation) {
    super.showConversation(conversation);
    // TS: tao.gan 2015-09-21 EMAIL FEATURE-559893 ADD_S
    //we change from ConversationListFragment to ConversationViewFragment, should let the toolbar show
    animateShow(null);/*from w  w  w  .j  av a 2  s. co  m*/
    // TS: tao.gan 2015-09-21 EMAIL FEATURE-559893 ADD_E
    mConversationListVisible = false;
    if (conversation == null) {
        transitionBackToConversationListMode();
        return;
    }
    disableCabMode();
    if (ConversationListContext.isSearchResult(mConvListContext)) {
        mViewMode.enterSearchResultsConversationMode();
    } else {
        mViewMode.enterConversationMode();
    }
    final FragmentManager fm = mActivity.getFragmentManager();
    final FragmentTransaction ft = fm.beginTransaction();
    // Switching to conversation view is an incongruous transition:
    // we are not replacing a fragment with another fragment as
    // usual. Instead, reveal the heretofore inert conversation
    // ViewPager and just remove the previously visible fragment
    // e.g. conversation list, or possibly label list?).
    final Fragment f = fm.findFragmentById(R.id.content_pane);
    // FragmentManager#findFragmentById can return fragments that are not added to the activity.
    // We want to make sure that we don't attempt to remove fragments that are not added to the
    // activity, as when the transaction is popped off, the FragmentManager will attempt to
    // readd the same fragment twice
    if (f != null && f.isAdded()) {
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.remove(f);
        ft.commitAllowingStateLoss();
        //TS: jin.dong 2015-8-28 EMAIL BUGFIX-1075110 MOD_S
        try {
            fm.executePendingTransactions();
        } catch (IllegalArgumentException e) {
            LogUtils.d(LOG_TAG, e, "IllegalArgumentException occurred");
        }
        //TS: jin.dong 2015-8-28 EMAIL BUGFIX-1075110 MOD_E
    }
    mPagerController.show(mAccount, mFolder, conversation, true /* changeVisibility */);
    onConversationVisibilityChanged(true);
    onConversationListVisibilityChanged(false);
}

From source file:finalproject.ece558.edu.pdx.ece.brailleblackjack.PlayBlackJackGameFragment.java

/**
 * Set-up button listeners. Restore the state of the fragment if the state was saved. If no
 *  state to restore then go set-up the game. Finally inflate the layout of the fragment
 * @param inflater LayoutInflater object
 * @param container ViewGroup object/*from  w  w  w . j  a va  2  s  .c o  m*/
 * @param savedInstanceState Bundle object of saved instances
 * @return View to inflate the layout on the screen
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.fragment_play_black_jack_game, container, false);
    // Bind views
    group = (ViewGroup) v.findViewById(R.id.playFragment);

    // Set up the card slots
    dealer_left_slot = (ImageView) v.findViewById(R.id.img_view_dealer_left_card);
    dealer_right_slot = (ImageView) v.findViewById(R.id.img_view_dealer_right_card);
    player_left_slot = (ImageView) v.findViewById(R.id.img_view_player_left_card);
    player_right_slot = (ImageView) v.findViewById(R.id.img_view_player_right_card);

    // Set up the total slots
    dealer_top_total_slot = (ImageView) v.findViewById(R.id.img_view_dealer_top_total);
    dealer_bot_total_slot = (ImageView) v.findViewById(R.id.img_view_dealer_bot_total);
    player_top_total_slot = (ImageView) v.findViewById(R.id.img_view_player_top_total);
    player_bot_total_slot = (ImageView) v.findViewById(R.id.img_view_player_bot_total);

    /* Hit button Listener */
    button_hit = (Button) v.findViewById(R.id.button_hit);
    button_hit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            playerHits();
        }
    });

    /* Stand button Listener */
    button_stand = (Button) v.findViewById(R.id.button_stand);
    button_stand.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            playerStands();
        }
    });

    /* Start Over buttonListener */
    button_start_over = (Button) v.findViewById(R.id.button_start_over);
    button_start_over.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FragmentTransaction fm = getFragmentManager().beginTransaction();
            fm.replace(R.id.fragment_container, new PlayBlackJackGameFragment());
            fm.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            fm.commit();
        }
    });

    /* Hint button Listener */
    button_hint = (Button) v.findViewById(R.id.button_hint);
    button_hint.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            hintDialog();
        }
    });

    // If activity recreated (such as from screen rotate), restore
    // the previous article selection set by onSaveInstanceState().
    // This is primarily necessary when in the two-pane layout.
    if (savedInstanceState != null) {
        /* Restore Variables and Flags */
        dealer_had_ace = savedInstanceState.getBoolean("DEALER_HAD_ACE");
        player_had_ace = savedInstanceState.getBoolean("PLAYER_HAD_ACE");
        dealer_turn = savedInstanceState.getBoolean("DEALER_TURN");
        player_turn = savedInstanceState.getBoolean("PLAYER_TURN");

        first_draw_spoken = savedInstanceState.getBoolean("IS_FIRST_DRAW_SPOKEN");

        dealer_top_total_value = savedInstanceState.getInt("DEALER_TOP_TOTAL_VALUE");
        dealer_bot_total_value = savedInstanceState.getInt("DEALER_BOT_TOTAL_VALUE");
        player_top_total_value = savedInstanceState.getInt("PLAYER_TOP_TOTAL_VALUE");
        dealer_bot_total_value = savedInstanceState.getInt("PLAYER_BOT_TOTAL_VALUE");

        button_hit_state = savedInstanceState.getBoolean("BUTTON_HIT_STATE");
        button_stand_state = savedInstanceState.getBoolean("BUTTON_STAND_STATE");
        button_hint_state = savedInstanceState.getBoolean("BUTTON_HINT_STATE");

        /* Set button Visibility */
        changeAllButtonStates(button_hit_state, button_stand_state, button_hint_state, true);

        /* Restore Cards */
        curDeck = new Deck(context);
        String d_left, d_right, p_left, p_right;
        boolean dealer_left_exists = savedInstanceState.getBoolean("DEALER_LEFT_EXISTS");

        d_right = savedInstanceState.getString("DEALER_RIGHT_CARD");
        p_left = savedInstanceState.getString("PLAYER_LEFT_CARD");
        p_right = savedInstanceState.getString("PLAYER_RIGHT_CARD");

        dealer_right_card = curDeck.getCard(d_right);
        player_left_card = curDeck.getCard(p_left);
        player_right_card = curDeck.getCard(p_right);

        /* Restore Views and Totals and Description for TalkBack */
        dealer_left_slot.setContentDescription("Dealer left card is hidden until you stand");
        dealer_right_slot
                .setContentDescription("Dealer right card is " + dealer_right_card.getCardDescription());
        player_left_slot.setContentDescription("Your left card is " + player_left_card.getCardDescription());
        player_right_slot.setContentDescription("Your right card is " + player_right_card.getCardDescription());

        dealer_right_slot.setImageResource(dealer_right_card.getCardDrawable());
        player_left_slot.setImageResource(player_left_card.getCardDrawable());
        player_right_slot.setImageResource(player_right_card.getCardDrawable());

        if (dealer_left_exists) {
            d_left = savedInstanceState.getString("DEALER_LEFT_CARD");
            dealer_left_card = curDeck.getCard(d_left);
            dealer_left_slot.setImageResource(dealer_left_card.getCardDrawable());
            dealer_left_slot
                    .setContentDescription("Dealer left card is " + dealer_left_card.getCardDescription());
        }

        dealer_top_total_slot.setImageResource(giveTotalDrawable(dealer_top_total_value));
        dealer_top_total_slot
                .setContentDescription("Dealer has a total of" + String.valueOf(dealer_top_total_value));

        player_top_total_slot.setImageResource(giveTotalDrawable(player_top_total_value));
        player_top_total_slot
                .setContentDescription("You have a total of " + String.valueOf(player_top_total_value));

        if (player_bot_total_value > 0) {
            player_bot_total_slot.setImageResource(giveTotalDrawable(player_bot_total_value));
            player_bot_total_slot.setVisibility(v.VISIBLE);
            player_bot_total_slot.setContentDescription("Because of an ace you have an alternative total of"
                    + String.valueOf(player_bot_total_value));
        } else {
            player_bot_total_slot.setVisibility(v.INVISIBLE);
            player_bot_total_slot.setContentDescription("");
        }

        if (dealer_bot_total_value > 0) {
            dealer_bot_total_slot.setImageResource(giveTotalDrawable(dealer_bot_total_value));
            dealer_bot_total_slot.setVisibility(v.VISIBLE);
            dealer_top_total_slot.setContentDescription("Because of an ace dealer has an alternative total of"
                    + String.valueOf(dealer_bot_total_value));
        } else {
            dealer_bot_total_slot.setVisibility(v.INVISIBLE);
            dealer_top_total_slot.setContentDescription("");
        }
    } else {
        // Start Android Wear App if its connected
        sendMessage(START_WEAR);
        gameSetup();
    }

    // Inflate the layout for this fragment
    return v;
}

From source file:ab.util.AbDialogUtil.java

/**
 * ?View.//from  ww w.  jav  a 2  s. c  o  m
 * 
 * @param view
 *            ?
 */
public static AbAlertDialogFragment showAlertDialog(View view) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    AbAlertDialogFragment newFragment = AbAlertDialogFragment.newInstance(0, null, null, view, null);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    // 
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.show(ft, mDialogTag);
    return newFragment;
}

From source file:com.ab.util.AbDialogUtil.java

/**
 * ?View?.//  www .j  a va 2 s .  c  o m
 * @param icon
 * @param title ?
 * @param view ???
 * @param onClickListener ?
 */
public static AbAlertDialogFragment showAlertDialog(int icon, String title, View view,
        AbDialogOnClickListener onClickListener) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    AbAlertDialogFragment newFragment = AbAlertDialogFragment.newInstance(icon, title, null, view,
            onClickListener);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    //    
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.show(ft, mDialogTag);
    return newFragment;
}