Search in sources :

Example 96 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project StylishMusicPlayer by ryanhoo.

the class LocalFilesFragment method onSegmentedChecked.

@OnCheckedChanged({ R.id.radio_button_all, R.id.radio_button_folder })
public void onSegmentedChecked(RadioButton radioButton, boolean isChecked) {
    int index = segmentedControls.indexOf(radioButton);
    Fragment fragment = mFragments.get(index);
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    if (isChecked) {
        fragmentTransaction.show(fragment);
    } else {
        fragmentTransaction.hide(fragment);
    }
    fragmentTransaction.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Fragment(android.support.v4.app.Fragment) BaseFragment(io.github.ryanhoo.music.ui.base.BaseFragment) AllLocalMusicFragment(io.github.ryanhoo.music.ui.local.all.AllLocalMusicFragment) FolderFragment(io.github.ryanhoo.music.ui.local.folder.FolderFragment) OnCheckedChanged(butterknife.OnCheckedChanged)

Example 97 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project ButterRemote-Android by se-bastiaan.

the class DonationFragment method show.

public static void show(FragmentManager fm) {
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag("");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);
    DonationFragment donationFragment = new DonationFragment();
    donationFragment.show(ft, TAG_FRAGMENT_DONATION);
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) DialogFragment(android.support.v4.app.DialogFragment) Fragment(android.support.v4.app.Fragment)

Example 98 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project ButterRemote-Android by se-bastiaan.

the class ControllerActivity method setFragment.

public void setFragment(Fragment fragment) {
    try {
        mHandler.post(new Runnable() {

            @Override
            public void run() {
                progressBar.setVisibility(View.GONE);
            }
        });
        DialogFragment dialogFragment = (DialogFragment) getSupportFragmentManager().findFragmentByTag("overlay_fragment");
        if (dialogFragment != null)
            dialogFragment.dismiss();
        fragment.setArguments(mExtras);
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        if (mCurrentFragment.equals(PLAYER)) {
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
                }
            });
            fragmentTransaction.setCustomAnimations(R.anim.still, R.anim.slide_down);
        } else if (mTopView.equals(PLAYER)) {
            mHandler.post(new Runnable() {

                @Override
                public void run() {
                    toolbar.setNavigationIcon(R.drawable.abc_ic_clear_mtrl_alpha);
                }
            });
            fragmentTransaction.setCustomAnimations(R.anim.slide_up, R.anim.still);
        } else {
            fragmentTransaction.setCustomAnimations(R.anim.fade_open, R.anim.fade_close);
        }
        fragmentTransaction.replace(R.id.frameLayout, fragment);
        fragmentTransaction.commit();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) DialogFragment(android.support.v4.app.DialogFragment)

Example 99 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project Conversations by siacs.

the class ConversationActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mOpenConversation = savedInstanceState.getString(STATE_OPEN_CONVERSATION, null);
        mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true);
        int pos = savedInstanceState.getInt(STATE_FIRST_VISIBLE, -1);
        int offset = savedInstanceState.getInt(STATE_OFFSET_FROM_TOP, 1);
        if (pos >= 0 && offset <= 0) {
            Log.d(Config.LOGTAG, "retrieved scroll position from instanceState " + pos + ":" + offset);
            mScrollPosition = new Pair<>(pos, offset);
        } else {
            mScrollPosition = null;
        }
        String pending = savedInstanceState.getString(STATE_PENDING_URI, null);
        if (pending != null) {
            Log.d(Config.LOGTAG, "ConversationsActivity.onCreate() - restoring pending image uri");
            mPendingImageUris.clear();
            mPendingImageUris.add(Uri.parse(pending));
        }
    }
    setContentView(R.layout.fragment_conversations_overview);
    this.mConversationFragment = new ConversationFragment();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.selected_conversation, this.mConversationFragment, "conversation");
    transaction.commit();
    listView = (EnhancedListView) findViewById(R.id.list);
    this.listAdapter = new ConversationAdapter(this, conversationList);
    listView.setAdapter(this.listAdapter);
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);
    }
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View clickedView, int position, long arg3) {
            if (getSelectedConversation() != conversationList.get(position)) {
                setSelectedConversation(conversationList.get(position));
                ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation());
                conversationWasSelectedByKeyboard = false;
            }
            hideConversationsOverview();
            openConversation();
        }
    });
    listView.setDismissCallback(new EnhancedListView.OnDismissCallback() {

        @Override
        public EnhancedListView.Undoable onDismiss(final EnhancedListView enhancedListView, final int position) {
            final int index = listView.getFirstVisiblePosition();
            View v = listView.getChildAt(0);
            final int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
            try {
                swipedConversation = listAdapter.getItem(position);
            } catch (IndexOutOfBoundsException e) {
                return null;
            }
            listAdapter.remove(swipedConversation);
            xmppConnectionService.markRead(swipedConversation);
            final boolean formerlySelected = (getSelectedConversation() == swipedConversation);
            if (position == 0 && listAdapter.getCount() == 0) {
                endConversation(swipedConversation, false, true);
                return null;
            } else if (formerlySelected) {
                setSelectedConversation(listAdapter.getItem(0));
                ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation());
            }
            return new EnhancedListView.Undoable() {

                @Override
                public void undo() {
                    listAdapter.insert(swipedConversation, position);
                    if (formerlySelected) {
                        setSelectedConversation(swipedConversation);
                        ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation());
                    }
                    swipedConversation = null;
                    listView.setSelectionFromTop(index + (listView.getChildCount() < position ? 1 : 0), top);
                }

                @Override
                public void discard() {
                    if (!swipedConversation.isRead() && swipedConversation.getMode() == Conversation.MODE_SINGLE) {
                        swipedConversation = null;
                        return;
                    }
                    endConversation(swipedConversation, false, false);
                    swipedConversation = null;
                }

                @Override
                public String getTitle() {
                    if (swipedConversation.getMode() == Conversation.MODE_MULTI) {
                        return getResources().getString(R.string.title_undo_swipe_out_muc);
                    } else {
                        return getResources().getString(R.string.title_undo_swipe_out_conversation);
                    }
                }
            };
        }
    });
    listView.enableSwipeToDismiss();
    listView.setSwipingLayout(R.id.swipeable_item);
    listView.setUndoStyle(EnhancedListView.UndoStyle.SINGLE_POPUP);
    listView.setUndoHideDelay(5000);
    listView.setRequireTouchBeforeDismiss(false);
    mContentView = findViewById(R.id.content_view_spl);
    if (mContentView == null) {
        mContentView = findViewById(R.id.content_view_ll);
    }
    if (mContentView instanceof SlidingPaneLayout) {
        SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
        mSlidingPaneLayout.setShadowResource(R.drawable.es_slidingpane_shadow);
        mSlidingPaneLayout.setSliderFadeColor(0);
        mSlidingPaneLayout.setPanelSlideListener(new PanelSlideListener() {

            @Override
            public void onPanelOpened(View arg0) {
                mShouldPanelBeOpen.set(true);
                updateActionBarTitle();
                invalidateOptionsMenu();
                hideKeyboard();
                if (xmppConnectionServiceBound) {
                    xmppConnectionService.getNotificationService().setOpenConversation(null);
                }
                closeContextMenu();
            }

            @Override
            public void onPanelClosed(View arg0) {
                mShouldPanelBeOpen.set(false);
                listView.discardUndo();
                openConversation();
            }

            @Override
            public void onPanelSlide(View arg0, float arg1) {
            // TODO Auto-generated method stub
            }
        });
    }
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) PanelSlideListener(android.support.v4.widget.SlidingPaneLayout.PanelSlideListener) ConversationAdapter(eu.siacs.conversations.ui.adapter.ConversationAdapter) SlidingPaneLayout(android.support.v4.widget.SlidingPaneLayout) View(android.view.View) AdapterView(android.widget.AdapterView) EnhancedListView(de.timroes.android.listview.EnhancedListView) SuppressLint(android.annotation.SuppressLint) FragmentTransaction(android.app.FragmentTransaction) EnhancedListView(de.timroes.android.listview.EnhancedListView) ActionBar(android.app.ActionBar)

Example 100 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project CircleBar by songnick.

the class MainActivity method switchFragment.

private void switchFragment(Fragment fragment) {
    mCurrentFragment = fragment;
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.container_fragment, fragment);
    ft.commitAllowingStateLoss();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction)

Aggregations

FragmentTransaction (android.support.v4.app.FragmentTransaction)367 Fragment (android.support.v4.app.Fragment)132 FragmentManager (android.support.v4.app.FragmentManager)73 DialogFragment (android.support.v4.app.DialogFragment)26 FragmentActivity (android.support.v4.app.FragmentActivity)25 View (android.view.View)23 FragmentTransaction (android.app.FragmentTransaction)18 Intent (android.content.Intent)18 TextView (android.widget.TextView)18 Button (android.widget.Button)17 Bundle (android.os.Bundle)16 OnClickListener (android.view.View.OnClickListener)16 SherlockFragment (com.actionbarsherlock.app.SherlockFragment)12 TargetApi (android.annotation.TargetApi)6 ActionBar (android.support.v7.app.ActionBar)6 AppCompatActivity (android.support.v7.app.AppCompatActivity)6 Toolbar (android.support.v7.widget.Toolbar)6 FriendsTimeLineFragment (org.qii.weiciyuan.ui.maintimeline.FriendsTimeLineFragment)6 UserInfoFragment (org.qii.weiciyuan.ui.userinfo.UserInfoFragment)6 Transition (android.transition.Transition)5