Search in sources :

Example 1 with SubFragment

use of com.kogitune.prelollipoptransition.fragment.SubFragment in project PreLollipopTransition by takahirom.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final Intent intent = new Intent(MainActivity.this, SubActivity.class);
            ActivityTransitionLauncher.with(MainActivity.this).from(v).launch(intent);
        }
    });
    findViewById(R.id.imageView2).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final Intent intent = new Intent(MainActivity.this, SubActivity2.class);
            // set bitmap for animation
            // use startActivityForResult
            Bundle transitionBundle = ActivityTransitionLauncher.with(MainActivity.this).image(BitmapFactory.decodeResource(getResources(), R.drawable.photo)).from(v).createBundle();
            intent.putExtras(transitionBundle);
            startActivityForResult(intent, REQUEST_CODE);
            // you should prevent default activity tansition animation
            overridePendingTransition(0, 0);
        }
    });
    findViewById(R.id.imageView3).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final Fragment toFragment = new SubFragment();
            //init your bundle first!!
            Bundle bundle = new Bundle();
            bundle.putString("Test", "Test");
            toFragment.setArguments(bundle);
            //You should call this method after init your argumentsBundle.
            FragmentTransitionLauncher.with(v.getContext()).from(v).prepare(toFragment);
            getSupportFragmentManager().beginTransaction().replace(R.id.parent_container, toFragment).addToBackStack(null).commit();
        }
    });
    findViewById(R.id.listViewExampleButton).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final Intent intent = new Intent(MainActivity.this, ListViewActivity.class);
            Bundle transitionBundle = ActivityTransitionLauncher.with(MainActivity.this).from(v).createBundle();
            intent.putExtras(transitionBundle);
            startActivity(intent);
            // you should prevent default activity tansition animation
            overridePendingTransition(0, 0);
        }
    });
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.support_content, new SupportStartFragment()).commit();
        getFragmentManager().beginTransaction().add(R.id.content, new com.kogitune.prelollipoptransition.fragment.StartFragment()).commit();
    }
}
Also used : Bundle(android.os.Bundle) SupportStartFragment(com.kogitune.prelollipoptransition.support_fragment.SupportStartFragment) SupportStartFragment(com.kogitune.prelollipoptransition.support_fragment.SupportStartFragment) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) View(android.view.View) SupportStartFragment(com.kogitune.prelollipoptransition.support_fragment.SupportStartFragment) Fragment(android.support.v4.app.Fragment) SubFragment(com.kogitune.prelollipoptransition.fragment.SubFragment) EndFragment(com.kogitune.prelollipoptransition.fragment.EndFragment) SubFragment(com.kogitune.prelollipoptransition.fragment.SubFragment) OnClickListener(android.view.View.OnClickListener)

Aggregations

Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Fragment (android.support.v4.app.Fragment)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 EndFragment (com.kogitune.prelollipoptransition.fragment.EndFragment)1 SubFragment (com.kogitune.prelollipoptransition.fragment.SubFragment)1 SupportStartFragment (com.kogitune.prelollipoptransition.support_fragment.SupportStartFragment)1