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();
}
}
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();
}
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;
}
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");
}
}
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;
}
Aggregations