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();
}
}
Aggregations