Search in sources :

Example 81 with Fragment

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) {
        }
    }
}
Also used : Transformation(android.view.animation.Transformation) StatusInstallerFragment(de.robv.android.xposed.installer.installation.StatusInstallerFragment) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) StatusInstallerFragment(de.robv.android.xposed.installer.installation.StatusInstallerFragment) Fragment(android.app.Fragment) FragmentTransaction(android.app.FragmentTransaction) Animation(android.view.animation.Animation) LinearLayout(android.widget.LinearLayout)

Example 82 with Fragment

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();
    }
}
Also used : NavigationView(android.support.design.widget.NavigationView) View(android.view.View) StatusInstallerFragment(de.robv.android.xposed.installer.installation.StatusInstallerFragment) Fragment(android.app.Fragment)

Example 83 with Fragment

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);
}
Also used : RosterContact(com.xabber.android.data.roster.RosterContact) StatusBarPainter(com.xabber.android.ui.color.StatusBarPainter) Uri(android.net.Uri) ConferenceInfoFragment(com.xabber.android.ui.fragment.ConferenceInfoFragment) ContactVcardViewerFragment(com.xabber.android.ui.fragment.ContactVcardViewerFragment) Fragment(android.app.Fragment) View(android.view.View) TextView(android.widget.TextView) TextView(android.widget.TextView)

Example 84 with Fragment

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();
}
Also used : FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment)

Example 85 with Fragment

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();
    }
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment) AbSampleDialogFragment(com.ningcui.mylibrary.viewLib.dialog.AbSampleDialogFragment) AbProgressDialogFragment(com.ningcui.mylibrary.viewLib.dialog.AbProgressDialogFragment) AbAlertDialogFragment(com.ningcui.mylibrary.viewLib.dialog.AbAlertDialogFragment) DialogFragment(android.app.DialogFragment) AbProgressHorizontalDialogFragment(com.ningcui.mylibrary.viewLib.dialog.AbProgressHorizontalDialogFragment)

Aggregations

Fragment (android.app.Fragment)209 FragmentTransaction (android.app.FragmentTransaction)82 FragmentManager (android.app.FragmentManager)51 DialogFragment (android.app.DialogFragment)44 Bundle (android.os.Bundle)22 Intent (android.content.Intent)13 View (android.view.View)13 PreferenceFragment (android.support.v14.preference.PreferenceFragment)12 TextView (android.widget.TextView)8 BizFragment (org.aisen.weibo.sina.ui.fragment.base.BizFragment)8 Uri (android.net.Uri)6 ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)6 Activity (android.app.Activity)5 PreferenceFragment (android.preference.PreferenceFragment)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ViewGroup (android.view.ViewGroup)3 FrameLayout (android.widget.FrameLayout)3 ContactVcardViewerFragment (com.xabber.android.ui.fragment.ContactVcardViewerFragment)3 Method (java.lang.reflect.Method)3