Last active
April 24, 2018 13:05
-
-
Save vorobeij/cbfcfed1cf33e10991fdf5f9dc0baffe to your computer and use it in GitHub Desktop.
transitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_detailed) | |
| var url = intent.getStringExtra("link") | |
| // set same transition name | |
| detailImg.transitionName = url | |
| detailImg.setOnClickListener { | |
| finishAfterTransition() | |
| } | |
| postponeEnterTransition() | |
| Glide.with(this) | |
| .load(url) | |
| .listener(object : RequestListener<Drawable> { | |
| override fun onLoadFailed(e: GlideException?, | |
| model: Any?, | |
| target: Target<Drawable>?, | |
| isFirstResource: Boolean): Boolean { | |
| return false | |
| } | |
| override fun onResourceReady(resource: Drawable?, | |
| model: Any?, | |
| target: Target<Drawable>?, | |
| dataSource: DataSource?, | |
| isFirstResource: Boolean): Boolean { | |
| val bmp = (resource as BitmapDrawable).bitmap | |
| Palette.from(bmp).generate{p-> | |
| var color = p.getMutedColor(Color.parseColor("#fafafa")) | |
| detailedRoot.setBackgroundColor(color) | |
| startPostponedEnterTransition() | |
| } | |
| return false | |
| } | |
| }) | |
| .into(detailImg) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun openRssDetails(dataHolder: DataHolder, | |
| holder: ViewHolder) { | |
| val intent = Intent(this, DetailsActivity::class.java) | |
| val sharedElement = holder.icon | |
| intent.putExtra("dataHolder", dataHolder) | |
| val options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, | |
| sharedElement, | |
| sharedElement.transitionName) | |
| startActivity(intent, options.toBundle()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Base application theme. --> | |
| <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
| <!-- Customize your theme here. --> | |
| <item name="android:windowContentTransitions">true</item> | |
| ... | |
| </style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment