Search in sources :

Example 6 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTabFragmentActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewpagertabfragment);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentByTag(ViewPagerTabFragmentParentFragment.FRAGMENT_TAG) == null) {
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.fragment, new ViewPagerTabFragmentParentFragment(), ViewPagerTabFragmentParentFragment.FRAGMENT_TAG);
        ft.commit();
        fm.executePendingTransactions();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 7 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project Shuttle by timusus.

the class MainActivity method swapFragments.

/**
     * Perform a fragment transaction for the passed in fragment
     *
     * @param fragment the fragment to transition to
     */
public void swapFragments(Fragment fragment, boolean addToBackStack) {
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out);
    fragmentTransaction.replace(R.id.main_container, fragment);
    if (addToBackStack) {
        fragmentTransaction.addToBackStack(null);
    }
    fragmentTransaction.commitAllowingStateLoss();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 8 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project Shuttle by timusus.

the class PlayerActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();
        return true;
    }
    if (item.getItemId() == R.id.menu_favorite) {
        PlaylistUtils.toggleFavorite(this);
        supportInvalidateOptionsMenu();
        return true;
    }
    if (item.getItemId() == R.id.menu_list) {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.setCustomAnimations(R.anim.abc_fade_in, R.anim.abc_fade_out, R.anim.abc_fade_in, R.anim.abc_fade_out);
        //Remove the lyrics fragment
        Fragment lyricsFragment = getSupportFragmentManager().findFragmentByTag(LYRICS_FRAGMENT);
        if (lyricsFragment != null) {
            ft.remove(lyricsFragment);
        }
        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.queue_container);
        if (fragment instanceof QueueFragment) {
            ft.remove(getSupportFragmentManager().findFragmentByTag(QUEUE_FRAGMENT));
        } else {
            ft.add(R.id.queue_container, QueueFragment.newInstance(), QUEUE_FRAGMENT);
        }
        ft.commit();
        return true;
    }
    switch(item.getItemId()) {
        case EQUALIZER:
            {
                final Intent equalizerIntent = new Intent(this, EqualizerActivity.class);
                startActivity(equalizerIntent);
                return true;
            }
        case OPTIONS:
            {
                startActivity(new Intent(this, SettingsActivity.class));
                return true;
            }
        case TIMER:
            {
                SleepTimer.createTimer(this, MusicUtils.getTimerActive(), MusicUtils.getTimeRemaining());
                return true;
            }
        case DELETE_ITEM:
            {
                new DialogUtils.DeleteDialogBuilder().context(this).singleMessageId(R.string.delete_song_desc).multipleMessage(R.string.delete_song_desc_multiple).itemNames(Collections.singletonList(MusicUtils.getSongName())).songsToDelete(Observable.just(Collections.singletonList(MusicUtils.getSong()))).build().show();
                return true;
            }
        case NEW_PLAYLIST:
            {
                PlaylistUtils.createPlaylistDialog(this, MusicUtils.getQueue());
                return true;
            }
        case PLAYLIST_SELECTED:
            {
                List<Song> songs = MusicUtils.getQueue();
                Playlist playlist = (Playlist) item.getIntent().getSerializableExtra(ShuttleUtils.ARG_PLAYLIST);
                PlaylistUtils.addToPlaylist(this, playlist, songs);
                return true;
            }
        case CLEAR_QUEUE:
            {
                MusicUtils.clearQueue();
                Intent intent = new Intent(this, MainActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                finish();
                return true;
            }
        case TAGGER:
            {
                TaggerDialog.newInstance(MusicUtils.getSong()).show(getSupportFragmentManager());
                return true;
            }
        case VIEW_INFO:
            {
                DialogUtils.showSongInfoDialog(this, MusicUtils.getSong());
                return true;
            }
    }
    if (item.getItemId() == R.id.menu_share) {
        String path = MusicUtils.getFilePath();
        if (!TextUtils.isEmpty(path)) {
            DialogUtils.showShareDialog(PlayerActivity.this, MusicUtils.getSong());
        }
        return true;
    }
    return false;
}
Also used : Playlist(com.simplecity.amp_library.model.Playlist) FragmentTransaction(android.support.v4.app.FragmentTransaction) Intent(android.content.Intent) List(java.util.List) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment) LyricsFragment(com.simplecity.amp_library.ui.fragments.LyricsFragment) Fragment(android.support.v4.app.Fragment) QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment)

Example 9 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project glimmr by brk3.

the class PhotosetsFragment method onLongClickDialogSelection.

@Override
public void onLongClickDialogSelection(Photoset photoset, int which) {
    Log.d(TAG, "onLongClickDialogSelection()");
    FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
    ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
    if (photoset != null) {
        Fragment prev = mActivity.getSupportFragmentManager().findFragmentByTag(AddToPhotosetDialogFragment.TAG);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        DialogFragment newFragment = AddToPhotosetDialogFragment.newInstance(photoset);
        newFragment.show(ft, AddToPhotosetDialogFragment.TAG);
    } else {
        Log.e(TAG, "onLongClickDialogSelection: photoset is null");
    }
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) AddToPhotosetDialogFragment(com.bourke.glimmr.fragments.photoset.AddToPhotosetDialogFragment) DialogFragment(android.support.v4.app.DialogFragment) AddToPhotosetDialogFragment(com.bourke.glimmr.fragments.photoset.AddToPhotosetDialogFragment) DialogFragment(android.support.v4.app.DialogFragment) Fragment(android.support.v4.app.Fragment) BaseFragment(com.bourke.glimmr.fragments.base.BaseFragment)

Example 10 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project glimmr by brk3.

the class AddToPhotosetDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mLayout = (LinearLayout) inflater.inflate(R.layout.add_to_photoset_fragment, container, false);
    TextView titleTextView = (TextView) mLayout.findViewById(R.id.titleText);
    titleTextView.setText(R.string.add_photos);
    mTextUtils.setFont(titleTextView, TextUtils.FONT_ROBOTOBOLD);
    //ProgressBar progressBar = (ProgressBar)
    //        mLayout.findViewById(R.id.progressIndicator);
    /* Nested fragments have to be added this way, not from xml */
    FragmentTransaction ft = getChildFragmentManager().beginTransaction();
    final boolean retainInstance = false;
    final PhotoStreamGridFragment frag = PhotoStreamGridFragment.newInstance(mOAuth.getUser(), retainInstance, ListView.CHOICE_MODE_MULTIPLE);
    ft.replace(R.id.photoStreamFragment, frag);
    ft.commit();
    /* When add button is clicked, get selected ids and add to queue */
    mLayout.findViewById(R.id.buttonAddToPhotoset).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            List<Photo> selectedPhotos = frag.getSelectedPhotos();
            for (Photo photo : selectedPhotos) {
                mQueue.add(new AddItemToPhotosetTask(mPhotoset.getId(), photo.getId(), mOAuth));
            }
            mActivity.startService(new Intent(mActivity, AddToPhotosetTaskQueueService.class));
            dismiss();
            Crouton.makeText(mActivity, R.string.photos_will_be_added, Style.CONFIRM).show();
        }
    });
    return mLayout;
}
Also used : AddItemToPhotosetTask(com.bourke.glimmr.tasks.AddItemToPhotosetTask) FragmentTransaction(android.support.v4.app.FragmentTransaction) PhotoStreamGridFragment(com.bourke.glimmr.fragments.home.PhotoStreamGridFragment) TextView(android.widget.TextView) List(java.util.List) Photo(com.googlecode.flickrjandroid.photos.Photo) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

FragmentTransaction (android.support.v4.app.FragmentTransaction)392 Fragment (android.support.v4.app.Fragment)135 FragmentManager (android.support.v4.app.FragmentManager)79 View (android.view.View)29 DialogFragment (android.support.v4.app.DialogFragment)27 FragmentActivity (android.support.v4.app.FragmentActivity)25 Bundle (android.os.Bundle)21 TextView (android.widget.TextView)19 FragmentTransaction (android.app.FragmentTransaction)18 Intent (android.content.Intent)18 Button (android.widget.Button)17 OnClickListener (android.view.View.OnClickListener)16 SherlockFragment (com.actionbarsherlock.app.SherlockFragment)12 ActionBar (android.support.v7.app.ActionBar)8 TargetApi (android.annotation.TargetApi)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