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