use of android.app.Fragment in project XposedInstaller by rovo89.
the class WelcomeActivity method navigate.
private void navigate(final int itemId) {
final View elevation = findViewById(R.id.elevation);
Fragment navFragment = null;
switch(itemId) {
case R.id.nav_item_framework:
mPrevSelectedId = itemId;
setTitle(R.string.app_name);
navFragment = new StatusInstallerFragment();
break;
case R.id.nav_item_modules:
mPrevSelectedId = itemId;
setTitle(R.string.nav_item_modules);
navFragment = new ModulesFragment();
break;
case R.id.nav_item_downloads:
mPrevSelectedId = itemId;
setTitle(R.string.nav_item_download);
navFragment = new DownloadFragment();
break;
case R.id.nav_item_logs:
mPrevSelectedId = itemId;
setTitle(R.string.nav_item_logs);
navFragment = new LogsFragment();
break;
case R.id.nav_item_settings:
startActivity(new Intent(this, SettingsActivity.class));
mNavigationView.getMenu().findItem(mPrevSelectedId).setChecked(true);
return;
case R.id.nav_item_support:
startActivity(new Intent(this, SupportActivity.class));
mNavigationView.getMenu().findItem(mPrevSelectedId).setChecked(true);
return;
case R.id.nav_item_about:
startActivity(new Intent(this, AboutActivity.class));
mNavigationView.getMenu().findItem(mPrevSelectedId).setChecked(true);
return;
}
final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(4));
if (navFragment != null) {
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.animator.fade_in, R.animator.fade_out);
try {
transaction.replace(R.id.content_frame, navFragment).commit();
if (elevation != null) {
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
elevation.setLayoutParams(params);
}
};
a.setDuration(150);
elevation.startAnimation(a);
}
} catch (IllegalStateException ignored) {
}
}
}
use of android.app.Fragment in project XposedInstaller by rovo89.
the class WelcomeActivity method notifyDataSetChanged.
private void notifyDataSetChanged() {
View parentLayout = findViewById(R.id.content_frame);
String frameworkUpdateVersion = mRepoLoader.getFrameworkUpdateVersion();
boolean moduleUpdateAvailable = mRepoLoader.hasModuleUpdates();
Fragment currentFragment = getFragmentManager().findFragmentById(R.id.content_frame);
if (currentFragment instanceof DownloadDetailsFragment) {
if (frameworkUpdateVersion != null) {
Snackbar.make(parentLayout, R.string.welcome_framework_update_available + " " + String.valueOf(frameworkUpdateVersion), Snackbar.LENGTH_LONG).show();
}
}
boolean snackBar = XposedApp.getPreferences().getBoolean("snack_bar", true);
if (moduleUpdateAvailable && snackBar) {
Snackbar.make(parentLayout, R.string.modules_updates_available, Snackbar.LENGTH_LONG).setAction(getString(R.string.view), new View.OnClickListener() {
@Override
public void onClick(View view) {
switchFragment(2);
}
}).show();
}
}
use of android.app.Fragment in project xabber-android by redsolution.
the class ContactViewer method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
// View information about contact from system contact list
Uri data = getIntent().getData();
if (data != null && "content".equals(data.getScheme())) {
List<String> segments = data.getPathSegments();
if (segments.size() == 2 && "data".equals(segments.get(0))) {
Long id;
try {
id = Long.valueOf(segments.get(1));
} catch (NumberFormatException e) {
id = null;
}
if (id != null)
// FIXME: Will be empty while application is loading
for (RosterContact rosterContact : RosterManager.getInstance().getContacts()) if (id.equals(rosterContact.getViewId())) {
account = rosterContact.getAccount();
bareAddress = rosterContact.getUser();
break;
}
}
}
} else {
account = getAccount(getIntent());
bareAddress = getUser(getIntent());
}
if (bareAddress != null && bareAddress.equalsIgnoreCase(GroupManager.IS_ACCOUNT)) {
bareAddress = Jid.getBareAddress(AccountManager.getInstance().getAccount(account).getRealJid());
}
if (account == null || bareAddress == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish();
return;
}
setContentView(R.layout.contact_viewer);
if (savedInstanceState == null) {
Fragment fragment;
if (MUCManager.getInstance().hasRoom(account, bareAddress)) {
fragment = ConferenceInfoFragment.newInstance(account, bareAddress);
} else {
fragment = ContactVcardViewerFragment.newInstance(account, bareAddress);
}
getFragmentManager().beginTransaction().add(R.id.scrollable_container, fragment).commit();
}
bestContact = RosterManager.getInstance().getBestContact(account, bareAddress);
toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NavUtils.navigateUpFromSameTask(ContactViewer.this);
}
});
StatusBarPainter statusBarPainter = new StatusBarPainter(this);
statusBarPainter.updateWithAccountName(account);
final int accountMainColor = ColorManager.getInstance().getAccountPainter().getAccountMainColor(account);
contactTitleView = findViewById(R.id.contact_title_expanded);
findViewById(R.id.status_icon).setVisibility(View.GONE);
contactTitleView.setBackgroundColor(accountMainColor);
TextView contactNameView = (TextView) findViewById(R.id.name);
contactNameView.setVisibility(View.INVISIBLE);
collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle(bestContact.getName());
collapsingToolbar.setBackgroundColor(accountMainColor);
collapsingToolbar.setContentScrimColor(accountMainColor);
}
use of android.app.Fragment in project android_frameworks_base by crdroidandroid.
the class PreferenceActivity method switchToHeaderInner.
private void switchToHeaderInner(String fragmentName, Bundle args) {
getFragmentManager().popBackStack(BACK_STACK_PREFS, FragmentManager.POP_BACK_STACK_INCLUSIVE);
if (!isValidFragment(fragmentName)) {
throw new IllegalArgumentException("Invalid fragment for this activity: " + fragmentName);
}
Fragment f = Fragment.instantiate(this, fragmentName, args);
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
transaction.replace(com.android.internal.R.id.prefs, f);
transaction.commitAllowingStateLoss();
}
use of android.app.Fragment in project JustAndroid by chinaltz.
the class AbDialogUtil method removeDialog.
/**
* 移除Fragment.
*
* @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);
}
//不能加入到back栈
//ft.addToBackStack(null);
ft.commit();
} catch (Exception e) {
//可能有Activity已经被销毁的异常
e.printStackTrace();
}
}
Aggregations