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:at.alladin.rmbt.android.map.RMBTMapFragment.java

@Override
public void onClick(View v) {
    final FragmentManager fm = getActivity().getFragmentManager();
    final FragmentTransaction ft;

    final GoogleMap map = getMap();

    switch (v.getId()) {

    case R.id.mapChooseButton:

        ft = fm.beginTransaction();//from ww w.jav a 2s  . c  o  m
        ft.replace(R.id.fragment_content, new RMBTMapChooseFragment(), "map_choose");
        ft.addToBackStack("map_choose");
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.commit();

        break;

    case R.id.mapFilterButton:

        ft = fm.beginTransaction();
        ft.replace(R.id.fragment_content, new RMBTMapFilterFragment(), "map_filter");
        ft.addToBackStack("map_filter");
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.commit();

        break;

    case R.id.mapLocateButton:

        if (map != null) {
            final Location location = geoLocation.getLastKnownLocation();
            if (location != null) {
                final LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude());
                gMap.animateCamera(CameraUpdateFactory.newLatLng(latlng));
            }
        }
        break;

    case R.id.mapHelpButton:
        ((RMBTMainActivity) getActivity()).showHelp("", false, AppConstants.PAGE_TITLE_HELP); // TODO: put correct
        // help url
        break;

    case R.id.mapInfoButton:
        showInfoToast();
        break;

    case R.id.mapZoomInButton:

        if (map != null)
            map.animateCamera(CameraUpdateFactory.zoomIn());

        break;

    case R.id.mapZoomOutButton:

        if (map != null)
            map.animateCamera(CameraUpdateFactory.zoomOut());

        break;

    default:
        break;
    }

}

From source file:org.akvo.caddisfly.ui.activity.MainActivity.java

void displayView(int position, boolean addToBackStack) {
    int index = getCurrentFragmentIndex();

    if (index == position) {
        // requested fragment is already showing
        return;/*from  w  w w  .ja v  a2s  . c  o m*/
    }

    MainApp mainApp = (MainApp) getApplicationContext();

    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();

    if (Config.FLOW_ACTION_EXTERNAL_SOURCE.equals(action) && type != null) {
        if ("text/plain".equals(type)) { //NON-NLS
            external = true;
            //mQuestionId = getIntent().getStringExtra("questionId");
            mQuestionTitle = getIntent().getStringExtra("questionTitle");

            String code = mQuestionTitle.substring(Math.max(0, mQuestionTitle.length() - 5));

            mainApp.setSwatches(code);
        }
    }

    if (mainApp.currentTestInfo == null) {
        mainApp.currentTestInfo = new TestInfo("", "", "");
    }

    Fragment fragment;

    switch (position) {
    case Config.HOME_SCREEN_INDEX:
        mStartFragment = StartFragment.newInstance(external, mainApp.currentTestInfo.getCode());
        fragment = mStartFragment;
        break;
    case Config.CALIBRATE_SCREEN_INDEX:
        mCalibrateFragment = new CalibrateFragment();
        fragment = mCalibrateFragment;
        setupActionBarSpinner();

        break;
    case Config.SETTINGS_SCREEN_INDEX:
        if (mSettingsFragment == null) {
            mSettingsFragment = new SettingsFragment();
        }
        fragment = mSettingsFragment;
        break;
    default:
        return;
    }
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.replace(R.id.container, fragment, String.valueOf(position));
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    if (addToBackStack) {
        ft.addToBackStack(null);
    }
    ft.commit();

    invalidateOptionsMenu();
    updateActionBarNavigation(position);
}

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

@NonNull
private FragmentTransaction getFragmentTransaction() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    if (isMoveToLeft) {
        isMoveToLeft = false;//  w  w w . j  av  a2s.c o  m
        ft.setCustomAnimations(R.animator.anim_slide_in_right, R.animator.anim_slide_out_right);
    } else {
        ft.setCustomAnimations(R.animator.anim_slide_in_left, R.animator.anim_slide_out_left);
    }
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    return ft;
}

From source file:com.nuvolect.securesuite.main.ContactListActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private ContactListFragment startContactListFragment() {

    boolean isDestroyed = false;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && m_act.isDestroyed())
        isDestroyed = true;//from   ww w .ja  v a  2s  .c o  m

    if (m_act == null || isDestroyed || m_act.isFinishing())
        return null;

    ContactListFragment clf = new ContactListFragment();
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.replace(R.id.contact_list_container, clf, CConst.CONTACT_LIST_FRAGMENT_TAG);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    ft.addToBackStack(null);
    ft.commit();
    return clf;
}

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

@Override
protected void showConversation(Conversation conversation, boolean inLoaderCallbacks) {
    super.showConversation(conversation, inLoaderCallbacks);
    mConversationListVisible = false;// w  w  w  . j  a  va 2 s.c  o  m
    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();
        fm.executePendingTransactions();
    }
    mPagerController.show(mAccount, mFolder, conversation, true /* changeVisibility */);
    onConversationVisibilityChanged(true);
    onConversationListVisibilityChanged(false);
}

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);/*w  ww .  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:com.hijacker.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.reset:
        stop(PROCESS_AIRODUMP);//  w w  w  .  j  ava  2 s.  c o  m
        Tile.clear();
        Tile.onCountsChanged();
        Airodump.startClean();
        return true;

    case R.id.stop_run:
        if (Airodump.isRunning())
            stop(PROCESS_AIRODUMP);
        else
            Airodump.start();
        return true;

    case R.id.stop_aireplay:
        stop(PROCESS_AIREPLAY);
        return true;

    case R.id.filter:
        new FiltersDialog().show(mFragmentManager, "FiltersDialog");
        return true;

    case R.id.settings:
        if (currentFragment != FRAGMENT_SETTINGS) {
            FragmentTransaction ft = mFragmentManager.beginTransaction();
            ft.replace(R.id.fragment1, new SettingsFragment());
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            ft.addToBackStack(null);
            ft.commitAllowingStateLoss();
        }
        return true;

    case R.id.export:
        new ExportDialog().show(mFragmentManager, "ExportDialog");
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

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/* ww  w.  jav a  2  s  . c om*/
 * @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:at.alladin.rmbt.android.main.RMBTMainActivity.java

public void initApp(boolean duringCreate) {
    //check log directory and send log files to control server if available
    checkLogs(getApplicationContext(), new OnCompleteListener() {

        @Override/*  www.  j  av  a2s  . c o  m*/
        public void onComplete(int flag, Object object) {
            //after log check: redirect system output to file if option is set
            redirectSystemOutput(ConfigHelper.isSystemOutputRedirectedToFile(RMBTMainActivity.this));
        }
    });

    popBackStackFull();

    FragmentTransaction ft;
    ft = fm.beginTransaction();
    ft.replace(R.id.fragment_content, new RMBTMainMenuFragment(), AppConstants.PAGE_TITLE_MAIN);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.commit();

    checkNews(getApplicationContext());
    checkSettings(false, null);
    //checkIp();
    waitForSettings(true, false, false);
    fetchMapOptions();
    historyResultLimit = Config.HISTORY_RESULTLIMIT_DEFAULT;

    if (!duringCreate && geoLocation != null)
        geoLocation.start();
}

From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java

public void showAbout() {
    popBackStackFull();/*w ww.  ja v  a2s .c o  m*/

    FragmentTransaction ft;
    ft = fm.beginTransaction();

    ft.replace(R.id.fragment_content, new RMBTAboutFragment(), AppConstants.PAGE_TITLE_ABOUT);
    ft.addToBackStack(AppConstants.PAGE_TITLE_ABOUT);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

    ft.commit();
    refreshActionBar(AppConstants.PAGE_TITLE_ABOUT);
}