Search in sources :

Example 16 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project HoloEverywhere by Prototik.

the class DatePreference method getDatePickerDialog.

private DatePickerDialog getDatePickerDialog(boolean create) {
    if (mDatePickerDialog == null && create) {
        mDatePickerDialog = DatePickerDialog.newInstance(mCallback, mYear, mMonth, mDay);
        mDatePickerDialog.setForceNotShow(true);
        final FragmentManager fm = Activity.extract(getContext(), true).getSupportFragmentManager();
        final FragmentTransaction ft = fm.beginTransaction();
        ft.add(mDatePickerDialog, getClass().getName() + "@" + getKey());
        ft.commitAllowingStateLoss();
        fm.executePendingTransactions();
    }
    return mDatePickerDialog;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 17 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project HoloEverywhere by Prototik.

the class DialogFragment method dismissInternal.

void dismissInternal(boolean allowStateLoss) {
    if (mDismissed) {
        return;
    }
    mDismissed = true;
    mShownByMe = false;
    if (mDialog != null) {
        mDialog.dismiss();
        mDialog = null;
    }
    mViewDestroyed = true;
    if (mBackStackId >= 0) {
        getFragmentManager().popBackStack(mBackStackId, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        mBackStackId = -1;
    } else {
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.remove(this);
        if (allowStateLoss) {
            ft.commitAllowingStateLoss();
        } else {
            ft.commit();
        }
    }
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 18 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project paper-onboarding-android by Ramotion.

the class FragmentsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragments_activity_layout);
    fragmentManager = getSupportFragmentManager();
    final PaperOnboardingFragment onBoardingFragment = PaperOnboardingFragment.newInstance(getDataForOnboarding());
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.add(R.id.fragment_container, onBoardingFragment);
    fragmentTransaction.commit();
    onBoardingFragment.setOnRightOutListener(new PaperOnboardingOnRightOutListener() {

        @Override
        public void onRightOut() {
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            Fragment bf = new BlankFragment();
            fragmentTransaction.replace(R.id.fragment_container, bf);
            fragmentTransaction.commit();
        }
    });
}
Also used : PaperOnboardingFragment(com.ramotion.paperonboarding.PaperOnboardingFragment) FragmentTransaction(android.support.v4.app.FragmentTransaction) Fragment(android.support.v4.app.Fragment) PaperOnboardingFragment(com.ramotion.paperonboarding.PaperOnboardingFragment) PaperOnboardingOnRightOutListener(com.ramotion.paperonboarding.listeners.PaperOnboardingOnRightOutListener)

Example 19 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project mounts2sd by SpazeDog.

the class ActivityTabController method tabSwitchFragment.

private void tabSwitchFragment(Integer tabId) {
    FragmentManager fragmentManager = getSupportFragmentManager();
    Boolean isAdded = fragmentManager.findFragmentByTag("" + tabId) != null;
    if (!isAdded || mTabFragments.get(tabId).isDetached()) {
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        for (int id : mTabFragments.keySet()) {
            if (id != tabId && fragmentManager.findFragmentByTag("" + id) != null && !mTabFragments.get(id).isDetached()) {
                fragmentTransaction.detach(mTabFragments.get(id));
            }
        }
        if (isAdded && mTabFragments.get(tabId).isDetached()) {
            fragmentTransaction.attach(mTabFragments.get(tabId));
        } else if (!isAdded) {
            fragmentTransaction.add(R.id.fragment_frame, mTabFragments.get(tabId), "" + tabId);
        }
        fragmentTransaction.commit();
    } else {
        tabUpdateButtons();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 20 with FragmentTransaction

use of android.support.v4.app.FragmentTransaction in project storymaker by StoryMaker.

the class AccountsActivity method addChooseAccountFragment.

public void addChooseAccountFragment(Bundle bundle) {
    FragmentManager fragManager = getSupportFragmentManager();
    FragmentTransaction fragTrans = fragManager.beginTransaction();
    List<Account> accounts = new ArrayList<>();
    final AuthTable authTable = new AuthTable();
    String[] siteAvailableNames = Account.CONTROLLER_SITE_NAMES;
    String[] siteAvailableKeys = Account.CONTROLLER_SITE_KEYS;
    Auth auth;
    for (int i = 0; i < siteAvailableKeys.length; i++) {
        auth = authTable.getAuthDefault(this, siteAvailableKeys[i]);
        if (auth == null) {
            accounts.add(new Account(-1, siteAvailableNames[i], siteAvailableKeys[i], "", "", null, false, false));
        } else {
            accounts.add(auth.convertToAccountObject());
        }
    }
    caFragment = new ChooseAccountFragment();
    caFragment.setArguments(bundle);
    caFragment.setLoginIntent(new Intent(this, ConnectAccountActivity.class));
    // FIXME we should probably make Account object parcelable and pass this through the bundle
    caFragment.setAccountsList(accounts);
    caFragment.setOnEventListener(new SiteController.OnEventListener() {

        @Override
        public void onSuccess(Account account) {
            Auth auth = authTable.getAuthDefault(getApplicationContext(), account.getSite());
            //if auth doesn't exist in db
            if (auth == null) {
                auth = new Auth(getApplicationContext(), -1, account.getName(), account.getSite(), null, null, null, null, null);
                auth.insert();
            }
            //set id of account based on returned id of auth insert
            account.setId(auth.getId());
            auth.setCredentials(account.getCredentials());
            auth.setData(account.getData());
            auth.setUserName(account.getUserName());
            auth.setExpires(null);
            authTable.updateLastLogin(getApplicationContext(), account.getSite(), auth.getUserName());
            auth.update();
        }

        @Override
        public void onFailure(Account account, String failureMessage) {
            Auth auth = authTable.getAuthDefault(getApplicationContext(), account.getSite());
            if (auth != null) {
                //TODO set variables here
                auth.setCredentials(account.getCredentials());
                auth.setUserName(account.getName());
                auth.setData(account.getData());
                // FIXME this is a hack to get isValid to fail, probably should be a setFailed() in auth that marks that we are busted
                auth.setExpires(new Date());
                auth.update();
            }
        }

        @Override
        public void onRemove(Account account) {
            authTable.delete(getApplicationContext(), account.getId());
        }
    });
    fragTrans.add(R.id.fragmentLayout, caFragment);
    fragTrans.commit();
}
Also used : Account(io.scal.secureshare.model.Account) ChooseAccountFragment(io.scal.secureshare.lib.ChooseAccountFragment) AuthTable(org.storymaker.app.model.AuthTable) ArrayList(java.util.ArrayList) Intent(android.content.Intent) SiteController(io.scal.secureshare.controller.SiteController) Date(java.util.Date) FragmentManager(android.support.v4.app.FragmentManager) FragmentTransaction(android.support.v4.app.FragmentTransaction) Auth(org.storymaker.app.model.Auth)

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