use of android.app.Fragment in project android_frameworks_base by crdroidandroid.
the class TunerActivity method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getFragmentManager().findFragmentByTag(TAG_TUNER) == null) {
final String action = getIntent().getAction();
final Fragment fragment;
if ("com.android.settings.action.DEMO_MODE".equals(action)) {
fragment = new DemoModeFragment();
} else if ("com.android.settings.action.NAV_BAR_TUNER".equals(action)) {
fragment = new NavBarTuner();
} else if ("com.android.settings.action.POWER_NOTIF_CONTROLS".equals(action)) {
fragment = new PowerNotificationControlsFragment();
} else {
fragment = new TunerFragment();
}
getFragmentManager().beginTransaction().replace(R.id.content_frame, fragment, TAG_TUNER).commit();
}
}
use of android.app.Fragment in project double-espresso by JakeWharton.
the class FragmentStack method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_stack);
// Watch for button clicks.
Button button = (Button) findViewById(R.id.new_fragment);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
addFragmentToStack();
}
});
if (savedInstanceState == null) {
// Do first time initialization -- add initial fragment.
Fragment newFragment = CountingFragment.newInstance(stackLevel);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(R.id.simple_fragment, newFragment).commit();
} else {
stackLevel = savedInstanceState.getInt("level");
}
}
use of android.app.Fragment in project double-espresso by JakeWharton.
the class FragmentStack method addFragmentToStack.
void addFragmentToStack() {
stackLevel++;
// Instantiate a new fragment.
Fragment newFragment = CountingFragment.newInstance(stackLevel);
// Add the fragment to the activity, pushing this transaction
// on to the back stack.
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.simple_fragment, newFragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.addToBackStack(null);
ft.commit();
}
use of android.app.Fragment in project android_frameworks_base by AOSPA.
the class TunerActivity method onPreferenceStartFragment.
@Override
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
try {
Class<?> cls = Class.forName(pref.getFragment());
Fragment fragment = (Fragment) cls.newInstance();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
setTitle(pref.getTitle());
transaction.replace(R.id.content_frame, fragment);
transaction.addToBackStack("PreferenceFragment");
transaction.commit();
return true;
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
Log.d("TunerActivity", "Problem launching fragment", e);
return false;
}
}
use of android.app.Fragment in project android_frameworks_base by AOSPA.
the class PrintActivity method ensureErrorUiShown.
private void ensureErrorUiShown(CharSequence message, int action) {
if (isFinishing() || isDestroyed()) {
return;
}
if (mUiState != UI_STATE_ERROR) {
mUiState = UI_STATE_ERROR;
mPrintPreviewController.setUiShown(false);
Fragment fragment = PrintErrorFragment.newInstance(message, action);
showFragment(fragment);
}
}
Aggregations