Search in sources :

Example 36 with FragmentManager

use of android.support.v4.app.FragmentManager in project RxJava-Android-Samples by kaushikgopal.

the class RotationPersist1Fragment method startOperationFromWorkerFrag.

// -----------------------------------------------------------------------------------
@OnClick(R.id.btn_rotate_persist)
public void startOperationFromWorkerFrag() {
    _logs = new ArrayList<>();
    _adapter.clear();
    FragmentManager fm = getActivity().getSupportFragmentManager();
    RotationPersist1WorkerFragment frag = (RotationPersist1WorkerFragment) fm.findFragmentByTag(RotationPersist1WorkerFragment.TAG);
    if (frag == null) {
        frag = new RotationPersist1WorkerFragment();
        fm.beginTransaction().add(frag, RotationPersist1WorkerFragment.TAG).commit();
    } else {
        Timber.d("Worker frag already spawned");
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) OnClick(butterknife.OnClick)

Example 37 with FragmentManager

use of android.support.v4.app.FragmentManager in project nmid-headline by miao1007.

the class HomeActivity method onNavigationDrawerItemSelected.

@Override
public void onNavigationDrawerItemSelected(int position) {
    FragmentManager fragmentManager = getSupportFragmentManager();
    Fragment fragment = null;
    switch(position) {
        case 0:
            fragment = new SlidingTabFragment();
            break;
        case 1:
            fragment = new ImagesFeedFragment();
            break;
        case 2:
            fragment = new FavFeedFragment();
            break;
    }
    if (fragment != null) {
        fragmentManager.beginTransaction().replace(R.id.base_fragment_container, fragment).commit();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) ImagesFeedFragment(cn.edu.cqupt.nmid.headline.ui.fragment.ImagesFeedFragment) FavFeedFragment(cn.edu.cqupt.nmid.headline.ui.fragment.base.FavFeedFragment) SlidingTabFragment(cn.edu.cqupt.nmid.headline.ui.fragment.SlidingTabFragment) NavigationDrawerFragment(cn.edu.cqupt.nmid.headline.ui.fragment.NavigationDrawerFragment) ImagesFeedFragment(cn.edu.cqupt.nmid.headline.ui.fragment.ImagesFeedFragment) Fragment(android.support.v4.app.Fragment) FavFeedFragment(cn.edu.cqupt.nmid.headline.ui.fragment.base.FavFeedFragment) SlidingTabFragment(cn.edu.cqupt.nmid.headline.ui.fragment.SlidingTabFragment)

Example 38 with FragmentManager

use of android.support.v4.app.FragmentManager in project AndroidChangeSkin by hongyangAndroid.

the class MainActivity method initView.

private void initView() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.id_drawerLayout);
    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.id_left_menu_container);
    if (fragment == null) {
        fm.beginTransaction().add(R.id.id_left_menu_container, new MenuLeftFragment()).commit();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Fragment(android.support.v4.app.Fragment)

Example 39 with FragmentManager

use of android.support.v4.app.FragmentManager in project zxingfragmentlib by mitoyarzun.

the class SampleStretchedActivity method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stretched_sample);
    FragmentManager fm = getSupportFragmentManager();
    mScannerFragment = (BarCodeScannerFragment) fm.findFragmentById(R.id.scanner_fragment);
    layoutContent = (LinearLayout) findViewById(R.id.layout_content);
    final ViewTreeObserver observer = layoutContent.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            // We're assuming that the other layout is under the scanner
            int activityWidth = layoutContent.getWidth();
            int activityHeight = findViewById(R.id.scanner_fragment).getHeight();
            int usableWidth = layoutContent.getWidth();
            int usableHeight = activityHeight - layoutContent.getHeight();
            int desiredHeight = (int) (usableHeight * 0.8);
            int desiredWidth = (int) (usableWidth * 0.75);
            Rect framingRect = new Rect(// left
            (usableWidth - desiredWidth) / 2, // top
            (usableHeight - desiredHeight) / 2, // right
            (usableWidth - desiredWidth) / 2 + desiredWidth, // bottom
            (usableHeight - desiredHeight) / 2 + desiredHeight);
            Log.v("RECT", "left: " + framingRect.left + " top: " + framingRect.top + " right: " + framingRect.right + " bottom: " + framingRect.bottom + " activityHeight: " + activityHeight + " activitiWidth: " + activityWidth);
        //        mScannerFragment.setFramingRect(framingRect);
        }
    });
//    mToggleButton = (Button) findViewById(R.id.button_flash);
//    mToggleButton.setOnClickListener(createToggleFlashListener());
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Rect(android.graphics.Rect) ViewTreeObserver(android.view.ViewTreeObserver)

Example 40 with FragmentManager

use of android.support.v4.app.FragmentManager in project AboutLibraries by mikepenz.

the class FragmentActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment);
    //Remove line to test RTL support
    //getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    new DrawerBuilder(this).withToolbar(toolbar).addDrawerItems(new PrimaryDrawerItem().withName("Home"), new PrimaryDrawerItem().withName(R.string.action_manifestactivity).withIdentifier(R.id.action_manifestactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_extendactivity).withIdentifier(R.id.action_extendactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_customsortactivity).withIdentifier(R.id.action_customsortactivity).withSelectable(false), new PrimaryDrawerItem().withName(R.string.action_opensource).withIdentifier(R.id.action_opensource).withSelectable(false)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

        @Override
        public boolean onItemClick(View view, int i, IDrawerItem drawerItem) {
            // Handle action bar item clicks here. The action bar will
            // automatically handle clicks on the Home/Up button, so long
            // as you specify a parent activity in AndroidManifest.xml.
            long id = drawerItem.getIdentifier();
            if (id == R.id.action_opensource) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/mikepenz/AboutLibraries"));
                startActivity(browserIntent);
            } else if (id == R.id.action_extendactivity) {
                Intent intent = new Intent(getApplicationContext(), ExtendActivity.class);
                startActivity(intent);
            } else if (id == R.id.action_customsortactivity) {
                Intent intent = new Intent(getApplicationContext(), CustomSortActivity.class);
                startActivity(intent);
            } else if (id == R.id.action_manifestactivity) {
                new LibsBuilder().withLibraries("crouton, actionbarsherlock", "showcaseview").withAutoDetect(true).withLicenseShown(true).withVersionShown(true).withActivityTitle("Open Source").withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR).withListener(libsListener).withLibTaskCallback(libTaskCallback).withUiListener(libsUIListener).start(FragmentActivity.this);
            }
            return false;
        }
    }).build();
    /*
        //NOTE: This is how you can modify a specific library definition during runtime
        HashMap<String, HashMap<String, String>> libsModification = new HashMap<String, HashMap<String, String>>();
        HashMap<String, String> modifyAboutLibraries = new HashMap<String, String>();
        modifyAboutLibraries.put("name", "_AboutLibraries");
        libsModification.put("aboutlibraries", modifyAboutLibraries);
        .withLibraryModification(libsModification);
        */
    LibsSupportFragment fragment = new LibsBuilder().withLibraries("crouton", "activeandroid", "actionbarsherlock", "showcaseview").withVersionShown(false).withLicenseShown(false).withLibraryModification("aboutlibraries", Libs.LibraryFields.LIBRARY_NAME, "_AboutLibraries").supportFragment();
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
}
Also used : LibsSupportFragment(com.mikepenz.aboutlibraries.ui.LibsSupportFragment) FragmentManager(android.support.v4.app.FragmentManager) PrimaryDrawerItem(com.mikepenz.materialdrawer.model.PrimaryDrawerItem) IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) LibsBuilder(com.mikepenz.aboutlibraries.LibsBuilder) Intent(android.content.Intent) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)265 FragmentTransaction (android.support.v4.app.FragmentTransaction)98 Fragment (android.support.v4.app.Fragment)76 View (android.view.View)46 TextView (android.widget.TextView)34 OnClickListener (android.view.View.OnClickListener)24 Bundle (android.os.Bundle)23 Intent (android.content.Intent)20 ImageView (android.widget.ImageView)15 ScrollView (android.widget.ScrollView)14 DialogFragment (android.support.v4.app.DialogFragment)13 ListFragment (android.support.v4.app.ListFragment)12 Button (android.widget.Button)11 FragmentActivity (android.support.v4.app.FragmentActivity)6 ArrayList (java.util.ArrayList)6 ViewPager (android.support.v4.view.ViewPager)5 UiThreadTest (android.test.UiThreadTest)5 BackStackEntry (android.support.v4.app.FragmentManager.BackStackEntry)4 AppCompatActivity (android.support.v7.app.AppCompatActivity)4 Time (android.text.format.Time)4