PreLollipopTransition


Source link: https://github.com/takahirom/PreLollipopTransition

PreLollipopTransition

Simple tool which help you to implement activity and fragment transition for pre-Lollipop devices.

Download

In your app build.gradle add

dependencies {

  compile 'com.kogitune:pre-lollipop-activity-transition:1.x.x' 
}

Code

Activity

Start Activity in first activity.

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);

  
}
 
}
);

Receive intent in second activity.

@Override protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_sub);

  ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState);
 
}

If you want the exit animation, you can do like this.

private ExitActivityTransition exitTransition; @Override protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_sub2);

  exitTransition = ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState);
 
}
 @Override public void onBackPressed() {

  exitTransition.exit(this);
 
}

If you want to use startActivityForResult, you should do below.

  1. Use createBundle().
  2. Put Extra to intent.
  3. Call overridePendingTransition after startActivityForResult.
Bundle transitionBundle = ActivityTransitionLauncher.with(MainActivity.this).from(v).createBundle();
 intent.putExtras(transitionBundle);
 startActivityForResult(intent, REQUEST_CODE);
 // you should prevent default activity transition animation overridePendingTransition(0, 0);

Fragment

Start fragment transition in first fragment.

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

  View v = inflater.inflate(R.layout.support_fragment_start, container, false);

  v.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

 final EndFragment toFragment = new EndFragment();

 FragmentTransitionLauncher

.with(view.getContext())

.image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))

.from(view.findViewById(R.id.imageView)).prepare(toFragment);

 getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit();

}

  
}
);

  return v; 
}

Start animation in second fragment.

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

  View v = inflater.inflate(R.layout.support_fragment_end, container, false);

  final ExitFragmentTransition exitFragmentTransition = FragmentTransition.with(this).to(v.findViewById(R.id.fragment_imageView)).start(savedInstanceState);

  exitFragmentTransition.startExitListening();

  return v; 
}

If you want to pass argument to second fragment, you should use Fragment#getArguments() after call prepare().

final EndFragment toFragment = new EndFragment();
 FragmentTransitionLauncher

.with(view.getContext())

.image(BitmapFactory.decodeResource(getResources(), R.drawable.photo))

.from(view.findViewById(R.id.imageView)).prepare(toFragment);
 toFragment.getArguments().putString("stringArgKey", "this is value");
 getFragmentManager().beginTransaction().replace(R.id.content, toFragment).addToBackStack(null).commit();

Sample

Contributors

Thanks

Sample Photo Luke Ma https://www.flickr.com/photos/lukema/12499338274/in/photostream/

DevBytes: Custom Activity Animations https://www.youtube.com/watch?v=CPxkoe2MraA

License

This project is released under the Apache License, Version 2.0.

Resources

A ViewPager with ability to auto scrolling and looping.

A view that displays states of screen like loading, error, empty.

A simple ImageView which allows you to create diagonal cut views easily.

A wrapper for the ADB tool. It's just adb on steroids.

Features

  • Set device and app id and save them into a config file. This file could be stored locally or globally
  • Kill an app
  • Kill all background processes
  • Clear the app data
  • Input a text
  • Input a key event
  • Take a screen capture and save it into a file
  • Execute every adb command
  • List all available devices

This library directly talks to the private Instagram API, anything (well quite a lot) you can do on the Instagram app you can replicate with this library. You also bypass the public API's rate limits.

Android utilities for easier and faster Kotlin programming.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes