Search in sources :

Example 91 with FragmentManager

use of android.app.FragmentManager in project facebook-android-sdk by facebook.

the class PickerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pickers);
    Bundle args = getIntent().getExtras();
    FragmentManager manager = getFragmentManager();
    Fragment fragmentToShow = null;
    Uri intentUri = getIntent().getData();
    if (FRIEND_PICKER.equals(intentUri)) {
        if (savedInstanceState == null) {
            friendPickerFragment = new FriendPickerFragment();
            friendPickerFragment.setSettingsFromBundle(args);
            friendPickerFragment.setFriendPickerType(FriendPickerFragment.FriendPickerType.TAGGABLE_FRIENDS);
        } else {
            friendPickerFragment = (FriendPickerFragment) manager.findFragmentById(R.id.picker_fragment);
            ;
        }
        friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {

            @Override
            public void onError(PickerFragment fragment, FacebookException error) {
                PickerActivity.this.onError(error);
            }
        });
        friendPickerFragment.setOnDoneButtonClickedListener(new PickerFragment.OnDoneButtonClickedListener() {

            @Override
            public void onDoneButtonClicked(PickerFragment fragment) {
                finishActivity();
            }
        });
        fragmentToShow = friendPickerFragment;
    } else if (PLACE_PICKER.equals(intentUri)) {
        if (savedInstanceState == null) {
            placePickerFragment = new PlacePickerFragment();
            placePickerFragment.setSettingsFromBundle(args);
        } else {
            placePickerFragment = (PlacePickerFragment) manager.findFragmentById(R.id.picker_fragment);
        }
        placePickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() {

            @Override
            public void onSelectionChanged(PickerFragment fragment) {
                // call finish since you can only pick one place
                finishActivity();
            }
        });
        placePickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() {

            @Override
            public void onError(PickerFragment fragment, FacebookException error) {
                PickerActivity.this.onError(error);
            }
        });
        placePickerFragment.setOnDoneButtonClickedListener(new PickerFragment.OnDoneButtonClickedListener() {

            @Override
            public void onDoneButtonClicked(PickerFragment fragment) {
                finishActivity();
            }
        });
        fragmentToShow = placePickerFragment;
    } else {
        // Nothing to do, finish
        setResult(RESULT_CANCELED);
        finish();
        return;
    }
    manager.beginTransaction().replace(R.id.picker_fragment, fragmentToShow).commit();
}
Also used : PlacePickerFragment(com.example.scrumptious.picker.PlacePickerFragment) Bundle(android.os.Bundle) Fragment(android.app.Fragment) PlacePickerFragment(com.example.scrumptious.picker.PlacePickerFragment) PickerFragment(com.example.scrumptious.picker.PickerFragment) FriendPickerFragment(com.example.scrumptious.picker.FriendPickerFragment) Uri(android.net.Uri) FragmentManager(android.app.FragmentManager) FacebookException(com.facebook.FacebookException) PlacePickerFragment(com.example.scrumptious.picker.PlacePickerFragment) PickerFragment(com.example.scrumptious.picker.PickerFragment) FriendPickerFragment(com.example.scrumptious.picker.FriendPickerFragment) FriendPickerFragment(com.example.scrumptious.picker.FriendPickerFragment)

Example 92 with FragmentManager

use of android.app.FragmentManager in project cardslib by gabrielemariotti.

the class MainActivity method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.demo_extras_activity_main);
    // The attacher should always be created in the Activity's onCreate
    //mPullToRefreshAttacher = PullToRefreshAttacher.get(this);
    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout_extras);
    mDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    _initMenu();
    mDrawerToggle = new CustomActionBarDrawerToggle(this, mDrawer);
    mDrawer.setDrawerListener(mDrawerToggle);
    // ---------------------------------------------------------------
    // ...
    String base64EncodedPublicKey = IabUtil.key;
    // compute your public key and store it in base64EncodedPublicKey
    mHelper = new IabHelper(this, base64EncodedPublicKey);
    mHelper.enableDebugLogging(true);
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {

        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                // Oh noes, there was a problem.
                Log.d(TAG, "Problem setting up In-app Billing: " + result);
                return;
            }
            // Have we been disposed of in the meantime? If so, quit.
            if (mHelper == null)
                return;
            // Hooray, IAB is fully set up!
            IabUtil.getInstance().retrieveData(mHelper);
        }
    });
    //BaseFragment baseFragment = null;
    if (savedInstanceState != null) {
        mSelectedFragment = savedInstanceState.getInt(BUNDLE_SELECTEDFRAGMENT);
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        if (fragmentManager.findFragmentById(R.id.fragment_main_extras) == null)
            mBaseFragment = selectFragment(mSelectedFragment);
    //if (mBaseFragment==null)
    //    mBaseFragment = selectFragment(mSelectedFragment);
    } else {
        mBaseFragment = new PicassoFragment();
        openFragment(mBaseFragment);
    }
//-----------------------------------------------------------------
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) IabResult(it.gmariotti.cardslib.demo.extras.iabutils.IabResult) IabHelper(it.gmariotti.cardslib.demo.extras.iabutils.IabHelper) PicassoFragment(it.gmariotti.cardslib.demo.extras.fragment.PicassoFragment) ExpandPicassoFragment(it.gmariotti.cardslib.demo.extras.fragment.ExpandPicassoFragment)

Example 93 with FragmentManager

use of android.app.FragmentManager in project cardslib by gabrielemariotti.

the class MainActivity method openDialogFragment.

private void openDialogFragment(DialogFragment dialogStandardFragment) {
    if (dialogStandardFragment != null) {
        FragmentManager fm = getFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        Fragment prev = fm.findFragmentByTag("carddemo_dialog_extras");
        if (prev != null) {
            ft.remove(prev);
        }
        //ft.addToBackStack(null);
        dialogStandardFragment.show(ft, "carddemo_dialog_extras");
    }
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) CroutonFragment(it.gmariotti.cardslib.demo.extras.fragment.CroutonFragment) UniversalImageLoaderFragment(it.gmariotti.cardslib.demo.extras.fragment.UniversalImageLoaderFragment) ListViewAnimationsFragment(it.gmariotti.cardslib.demo.extras.fragment.ListViewAnimationsFragment) DragDropListFragment(it.gmariotti.cardslib.demo.extras.fragment.DragDropListFragment) StickyListHeadersFragment(it.gmariotti.cardslib.demo.extras.fragment.StickyListHeadersFragment) ListViewGridAnimationsFragment(it.gmariotti.cardslib.demo.extras.fragment.ListViewGridAnimationsFragment) DialogFragment(android.app.DialogFragment) Fragment(android.app.Fragment) PicassoFragment(it.gmariotti.cardslib.demo.extras.fragment.PicassoFragment) BaseStaggeredGridFragment(it.gmariotti.cardslib.demo.extras.fragment.BaseStaggeredGridFragment) ExpandPicassoFragment(it.gmariotti.cardslib.demo.extras.fragment.ExpandPicassoFragment) GoogleProgressFragment(it.gmariotti.cardslib.demo.extras.fragment.nativeview.GoogleProgressFragment) CardWithListFragment(it.gmariotti.cardslib.demo.extras.fragment.CardWithListFragment) AnimateStaggeredGridFragment(it.gmariotti.cardslib.demo.extras.fragment.AnimateStaggeredGridFragment) IonFragment(it.gmariotti.cardslib.demo.extras.fragment.IonFragment) TwoWayViewFragment(it.gmariotti.cardslib.demo.extras.fragment.TwoWayViewFragment) ActionbarpullFragment(it.gmariotti.cardslib.demo.extras.fragment.ActionbarpullFragment) BaseFragment(it.gmariotti.cardslib.demo.extras.fragment.BaseFragment) StaggeredGridFragment(it.gmariotti.cardslib.demo.extras.fragment.StaggeredGridFragment)

Example 94 with FragmentManager

use of android.app.FragmentManager in project cardslib by gabrielemariotti.

the class MainActivity method openFragment.

private void openFragment(BaseFragment baseFragment) {
    if (baseFragment != null) {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        //fragmentTransaction.setCustomAnimations(R.animator.carddemo_fag_fade_in,R.animator.carddemo_frag_fade_out);
        fragmentTransaction.replace(R.id.fragment_main_extras, baseFragment);
        //fragmentTransaction.addToBackStack(null);
        fragmentTransaction.commit();
        if (baseFragment.getTitleResourceId() > 0)
            mCurrentTitle = baseFragment.getTitleResourceId();
    }
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction)

Example 95 with FragmentManager

use of android.app.FragmentManager in project cardslib by gabrielemariotti.

the class TwoWayViewFragment method fragmentHelper.

private void fragmentHelper(BaseFragment fragment) {
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.fragment_main_extras, fragment);
    fragmentTransaction.commit();
    if (fragment.getTitleResourceId() > 0)
        ((MainActivity) getActivity()).mCurrentTitle = fragment.getTitleResourceId();
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) MainActivity(it.gmariotti.cardslib.demo.extras.MainActivity)

Aggregations

FragmentManager (android.app.FragmentManager)177 FragmentTransaction (android.app.FragmentTransaction)84 Fragment (android.app.Fragment)51 Bundle (android.os.Bundle)22 DocumentInfo (com.android.documentsui.model.DocumentInfo)20 DialogFragment (android.app.DialogFragment)15 RootInfo (com.android.documentsui.model.RootInfo)15 ActionBar (android.support.v7.app.ActionBar)12 Intent (android.content.Intent)11 File (java.io.File)6 MediaRouter (android.media.MediaRouter)5 Uri (android.net.Uri)5 StorageManager (android.os.storage.StorageManager)5 VolumeInfo (android.os.storage.VolumeInfo)5 MenuItem (android.view.MenuItem)5 IOException (java.io.IOException)5 Toolbar (android.support.v7.widget.Toolbar)4 View (android.view.View)4 DialogInterface (android.content.DialogInterface)3 ViewGroup (android.view.ViewGroup)3