Example usage for android.app FragmentTransaction TRANSIT_FRAGMENT_CLOSE

List of usage examples for android.app FragmentTransaction TRANSIT_FRAGMENT_CLOSE

Introduction

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

Prototype

int TRANSIT_FRAGMENT_CLOSE

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

Click Source Link

Document

Fragment is being removed from the stack

Usage

From source file:com.example.android.popularmovies.app.MovieListingFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    movies = new ArrayList<MovieDetails>();

    movieAdapter = new MovieArrayAdapter(getActivity(), // The current context (this activity)
            R.layout.list_item_listing, // The name of the layout ID.
            R.id.list_item_listing_textview, // The ID of the textview to populate.
            movies);/* w  ww .ja va2  s  .  co  m*/

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    Spinner spinner = (Spinner) rootView.findViewById(R.id.sort_spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.sort_options,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);

    FetchMovieListingTask movieListingTask = new FetchMovieListingTask();
    movieListingTask.execute(String.valueOf(spinner.getSelectedItemPosition()));

    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            FetchMovieListingTask movieListingTask = new FetchMovieListingTask();
            movieListingTask.execute(String.valueOf(i));
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    // Get a reference to the ListView, and attach this adapter to it.
    GridView gridView = (GridView) rootView.findViewById(R.id.grid_view_listing);
    gridView.setAdapter(movieAdapter);
    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            // Log.i("MovieListingFragment", "Item clicked: " + view.toString() + " " + i + " " + l);
            getActivity().getSupportFragmentManager().beginTransaction().addToBackStack(null)
                    .replace(R.id.container, MovieDetailsFragment.newInstance(movies.get(i).id))
                    .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commit();
        }
    });

    return rootView;
}

From source file:com.aoppp.gatewaymaster.dialogs.DialogUtil.java

/**
 * ??Fragment.//from   w w w  . j  ava2 s.  c om
 * 
 * @param context
 *            the context
 */
public static void removeDialog(Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        // 
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        ft.commit();
    } catch (Exception e) {
        // ?Activity??
        e.printStackTrace();
    }
}

From source file:com.notriddle.budget.EnvelopesActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (mNavToggle.onOptionsItemSelected(item)) {
        return true;
    }//from  www .ja  v a  2  s. c  o m
    switch (item.getItemId()) {
    case android.R.id.home:
        topFragment(EnvelopesFragment.class, FragmentTransaction.TRANSIT_FRAGMENT_CLOSE, null);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.farmerbb.taskbar.MainActivity.java

@Override
public void onBackPressed() {
    if (getFragmentManager().findFragmentById(R.id.fragmentContainer) instanceof AboutFragment)
        super.onBackPressed();
    else/*from ww  w .  j  av  a 2 s. c o m*/
        getFragmentManager().beginTransaction()
                .replace(R.id.fragmentContainer, new AboutFragment(), "AboutFragment")
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commit();
}

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

/**
 * ??Fragment.//from  w w w  .j ava 2s  .  c o m
 * @param context the context
 */
public static void removeDialog(final Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        //    
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(dialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        ft.commit();
    } catch (Exception e) {
        //?Activity??
        e.printStackTrace();
    }
}

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

/**
 * ??Fragment.// ww w.  java2s. c om
 * 
 * @param context
 *            the context
 */
public static void removeDialog(final Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        // 
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(dialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        ft.commit();
    } catch (Exception e) {
        // ?Activity??
        e.printStackTrace();
    }
}

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

/**
 * ??Fragment.//from   w  w w . j  a va 2 s.  c o  m
 * @param context the context
 */
public static void removeDialog(Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        //    
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        ft.commit();
    } catch (Exception e) {
        //?Activity??
        e.printStackTrace();
    }
}

From source file:com.pszh.ablibrary.util.AbDialogUtil.java

/**
 * ??Fragment.//from   w ww  .  j av a2s.c  o  m
 * @param context the context
 */
public static void removeDialog(Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        //    
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        if (context != null) {
            ft.commit();
        }
    } catch (Exception e) {
        //?Activity??
        e.printStackTrace();
    }
}

From source file:ab.util.AbDialogUtil.java

/**
 * ??Fragment.//w  w  w.  j  av a2s.  co  m
 * 
 * @param context
 *            the context
 */
public static void removeDialog(Context context) {
    try {
        FragmentActivity activity = (FragmentActivity) context;
        FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
        // 
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
        Fragment prev = activity.getFragmentManager().findFragmentByTag(mDialogTag);
        if (prev != null) {
            ft.remove(prev);
        }
        ft.addToBackStack(null);
        if (context != null) {
            ft.commit();
        }
    } catch (Exception e) {
        // ?Activity??
        e.printStackTrace();
    }
}

From source file:org.proninyaroslav.libretorrent.fragments.MainFragment.java

private void showBlankFragment() {
    if (Utils.isTablet(activity.getApplicationContext())) {
        FragmentManager fm = getFragmentManager();

        BlankFragment blank = BlankFragment.newInstance();

        fm.beginTransaction().replace(R.id.detail_torrent_fragmentContainer, blank)
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE).commitAllowingStateLoss();
    }//from   w  w w .ja v a  2 s.c o m
}