Search in sources :

Example 91 with FragmentActivity

use of android.support.v4.app.FragmentActivity in project WordPress-Android by wordpress-mobile.

the class SmartLockHelper method initSmartLockForPasswords.

public void initSmartLockForPasswords() {
    FragmentActivity activity = getActivityAndCheckAvailability();
    if (activity == null) {
        return;
    }
    mCredentialsClient = new GoogleApiClient.Builder(activity).addConnectionCallbacks((ConnectionCallbacks) activity).enableAutoManage(activity, (OnConnectionFailedListener) activity).addApi(Auth.CREDENTIALS_API).build();
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) OnConnectionFailedListener(com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener)

Example 92 with FragmentActivity

use of android.support.v4.app.FragmentActivity in project WordPress-Android by wordpress-mobile.

the class SmartLockHelper method getActivityAndCheckAvailability.

private FragmentActivity getActivityAndCheckAvailability() {
    FragmentActivity activity = mActivity.get();
    if (activity == null) {
        return null;
    }
    int status = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity);
    if (status == ConnectionResult.SUCCESS) {
        return activity;
    }
    return null;
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity)

Example 93 with FragmentActivity

use of android.support.v4.app.FragmentActivity in project AndroidUtilCode by Blankj.

the class Demo3Fragment method onClick.

@Override
public void onClick(View view) {
    tvAboutFragment.setText("");
    switch(view.getId()) {
        case R.id.btn_show_about_fragment:
            tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName() + "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null") + "\ntopShow: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName() + "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null") + "\n---all of fragments---\n" + FragmentUtils.getAllFragments(getFragmentManager()).toString() + "\n----------------------\n\n" + "---stack top---\n" + FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString() + "\n---stack bottom---\n\n");
            break;
        case R.id.btn_add_hide:
            FragmentUtils.addFragment(getFragmentManager(), Demo1Fragment.newInstance(), R.id.fragment_container, true, true);
            break;
        case R.id.btn_add_show:
            FragmentUtils.addFragment(getFragmentManager(), Demo1Fragment.newInstance(), R.id.fragment_container, false, true);
            break;
        case R.id.btn_add_child:
            FragmentUtils.addFragment(getChildFragmentManager(), Demo2Fragment.newInstance(), R.id.child_fragment_container, false, true);
            break;
        case R.id.btn_pop_to_root:
            FragmentUtils.popToFragment(getFragmentManager(), Demo1Fragment.class, true);
            break;
        case R.id.btn_pop_add:
            FragmentUtils.popAddFragment(getFragmentManager(), Demo2Fragment.newInstance(), R.id.fragment_container, true, new FragmentUtils.SharedElement(this.btnShowAboutFragment, "btnShowAboutFragment"));
            break;
        case R.id.btn_hide_show:
            Fragment fragment1 = FragmentUtils.findFragment(getFragmentManager(), Demo1Fragment.class);
            if (fragment1 != null) {
                FragmentUtils.hideShowFragment(this, fragment1);
            } else {
                ToastUtils.showLongToast("please add demo1 first!");
            }
            break;
        case R.id.btn_replace:
            Demo0Fragment demo0Fragment = Demo0Fragment.newInstance();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                demo0Fragment.setSharedElementEnterTransition(new DetailTransition());
                setExitTransition(new Fade());
                demo0Fragment.setEnterTransition(new Fade());
                demo0Fragment.setSharedElementReturnTransition(new DetailTransition());
            }
            ((FragmentActivity) getActivity()).rootFragment = FragmentUtils.replaceFragment(this, demo0Fragment, false, new FragmentUtils.SharedElement(ivSharedElement, getString(R.string.fragment_transition)));
            break;
    }
}
Also used : FragmentUtils(com.blankj.utilcode.util.FragmentUtils) DetailTransition(com.blankj.androidutilcode.transition.DetailTransition) Fragment(android.support.v4.app.Fragment) Fade(android.transition.Fade)

Example 94 with FragmentActivity

use of android.support.v4.app.FragmentActivity in project cornerstone by Onskreen.

the class CSSettingsViewer method update.

public void update(int index) {
    final FragmentActivity fa = this.getActivity();
    final Context ctx = fa.getApplicationContext();
    //Toast.makeText(ctx, "Selected setting is: " + index, Toast.LENGTH_LONG).show();
    if (!isInitialized) {
        final SharedPreferences settingsPref = fa.getSharedPreferences(CS_PREFS, 4);
        final SharedPreferences.Editor editor = settingsPref.edit();
        String panel0 = settingsPref.getString("panel0", null);
        String panel1 = settingsPref.getString("panel1", null);
        boolean startup = settingsPref.getBoolean("startup", fa.getResources().getBoolean(R.bool.startup));
        csTopApp = (ViewStub) fa.findViewById(R.id.cs_top_app);
        csTopApp.inflate();
        csBottomApp = (ViewStub) fa.findViewById(R.id.cs_bottom_app);
        csBottomApp.inflate();
        csLaunch = (ViewStub) fa.findViewById(R.id.cs_launch);
        csLaunch.inflate();
        ArrayAdapter topAd = new ArrayAdapter(ctx, android.R.layout.simple_list_item_single_choice, apps);
        final ListView topList = (ListView) fa.findViewById(R.id.cs_top_app_list);
        topList.setAdapter(topAd);
        topList.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {
                //showToast((String)apps.get(arg2));
                editor.putString("panel0", (String) packages.get(arg2));
                // Commit the edits!
                editor.commit();
            }
        });
        topList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        ArrayAdapter bottomAd = new ArrayAdapter(ctx, android.R.layout.simple_list_item_single_choice, apps);
        final ListView bottomList = (ListView) fa.findViewById(R.id.cs_bottom_app_list);
        bottomList.setAdapter(bottomAd);
        bottomList.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {
                //showToast((String)apps.get(arg2));
                editor.putString("panel1", (String) packages.get(arg2));
                // Commit the edits!
                editor.commit();
            }
        });
        bottomList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        isInitialized = true;
        int pos = packages.indexOf(panel0);
        if (pos != -1) {
            topList.setItemChecked(pos, true);
        }
        pos = packages.indexOf(panel1);
        if (pos != -1) {
            bottomList.setItemChecked(pos, true);
        }
        final RadioButton yesRB = (RadioButton) fa.findViewById(R.id.radio0);
        yesRB.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    editor.putBoolean("startup", true);
                    editor.commit();
                }
            }
        });
        final RadioButton noRB = (RadioButton) fa.findViewById(R.id.radio1);
        noRB.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    editor.putBoolean("startup", false);
                    editor.commit();
                }
            }
        });
        if (startup) {
            yesRB.setChecked(true);
        } else {
            noRB.setChecked(true);
        }
    }
    if (index == 0) {
        csTopApp.setVisibility(View.VISIBLE);
        csBottomApp.setVisibility(View.INVISIBLE);
        csLaunch.setVisibility(View.INVISIBLE);
    } else if (index == 1) {
        csBottomApp.setVisibility(View.VISIBLE);
        csTopApp.setVisibility(View.INVISIBLE);
        csLaunch.setVisibility(View.INVISIBLE);
    } else if (index == 2) {
        csLaunch.setVisibility(View.VISIBLE);
        csTopApp.setVisibility(View.INVISIBLE);
        csBottomApp.setVisibility(View.INVISIBLE);
    }
}
Also used : Context(android.content.Context) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) SharedPreferences(android.content.SharedPreferences) RadioButton(android.widget.RadioButton) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) FragmentActivity(android.support.v4.app.FragmentActivity) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) CompoundButton(android.widget.CompoundButton)

Example 95 with FragmentActivity

use of android.support.v4.app.FragmentActivity in project ExpandingPager by qs-lll.

the class FragmentTop method startInfoActivity.

@SuppressWarnings("unchecked")
private void startInfoActivity(View view, Travel travel) {
    FragmentActivity activity = getActivity();
    ActivityCompat.startActivity(activity, InfoActivity.newInstance(activity, travel), ActivityOptionsCompat.makeSceneTransitionAnimation(activity, new Pair<>(view, getString(R.string.transition_image))).toBundle());
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity)

Aggregations

FragmentActivity (android.support.v4.app.FragmentActivity)84 FragmentTransaction (android.app.FragmentTransaction)16 FragmentManager (android.support.v4.app.FragmentManager)16 FragmentTransaction (android.support.v4.app.FragmentTransaction)16 Fragment (android.support.v4.app.Fragment)11 Intent (android.content.Intent)6 Bundle (android.os.Bundle)5 View (android.view.View)4 DialogFragment (android.support.v4.app.DialogFragment)3 MediaControllerCompat (android.support.v4.media.session.MediaControllerCompat)3 SearchView (android.widget.SearchView)3 TextView (android.widget.TextView)3 Fragment (android.app.Fragment)2 ActionBar (android.support.v7.app.ActionBar)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)2 MediaRouteDialogFactory (android.support.v7.app.MediaRouteDialogFactory)2 RecyclerView (android.support.v7.widget.RecyclerView)2 InjectView (butterknife.InjectView)2 RequestManager (com.bumptech.glide.RequestManager)2 FacebookException (com.facebook.FacebookException)2