All Projects → lion4ik → aac-navigation-shared-elements-transition

lion4ik / aac-navigation-shared-elements-transition

Licence: MIT license
No description or website provided.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to aac-navigation-shared-elements-transition

Android-MVI-Clean-Arch-Sample
A Simple Android Project demonstrating Clean Arch + MVI with https://api.nasa.gov/api.html#apod as use-case example
Stars: ✭ 20 (-41.18%)
Mutual labels:  android-architecture
android-clean-code
Writing Clean Code in Android
Stars: ✭ 22 (-35.29%)
Mutual labels:  android-architecture
GithubApp-android-architecture
Let's learn a deep look at the Android architecture
Stars: ✭ 16 (-52.94%)
Mutual labels:  android-architecture
GithubTrendingRepos
Android - MVVM with Clean Architecture Blueprint Written In Kotlin
Stars: ✭ 50 (+47.06%)
Mutual labels:  android-architecture
Android-MonetizeApp
A sample which uses Google's Play Billing Library and it makes In-app Purchases and Subscriptions.
Stars: ✭ 149 (+338.24%)
Mutual labels:  android-architecture
android-architecture
MVI architecture Implementation of the ToDo app.
Stars: ✭ 668 (+1864.71%)
Mutual labels:  android-architecture
kotlin-mvvm-boilerplate
💡💡 An Android boilerplate project with: Kotlin, MVVM, Room, Dagger2, RxJava, Retrofit and more.
Stars: ✭ 32 (-5.88%)
Mutual labels:  android-architecture
android-interview-questions
I'm contributing to help others!
Stars: ✭ 24 (-29.41%)
Mutual labels:  android-architecture
TDDWeatherApp
Android App trying to apply TDD and using MVVM, Kotlin Coroutines
Stars: ✭ 38 (+11.76%)
Mutual labels:  android-architecture
Android-Clean-Architecture
🚀A basic sample android application to understand Clean Architecture in a very simple way and is written in Kotlin.
Stars: ✭ 39 (+14.71%)
Mutual labels:  android-architecture
android-mvvm-dagger-2-rxjava-example
Sample Android Application - MVVM, Dagger 2, RxJava, Retrofit
Stars: ✭ 114 (+235.29%)
Mutual labels:  android-architecture
webtrekk-android-sdk-v5
Webtrekk Android SDK V5
Stars: ✭ 13 (-61.76%)
Mutual labels:  android-architecture
NavigationComponentPlayground
Sample app leveraging Android Navigation Component
Stars: ✭ 60 (+76.47%)
Mutual labels:  android-navigation
Einsen
🎯 Einsen is a prioritization app that uses Eisenhower matrix technique as workflow to prioritize a list of tasks & built to Demonstrate use of Jetpack Compose with Modern Android Architecture Components & MVVM Architecture.
Stars: ✭ 821 (+2314.71%)
Mutual labels:  android-architecture
Android-daily-read-tips
log for articles and info in android for every developer
Stars: ✭ 13 (-61.76%)
Mutual labels:  android-architecture
Room-Library-Login-Example
Simple Login Presentation Using Room Database
Stars: ✭ 43 (+26.47%)
Mutual labels:  android-architecture
BottomNavArchDemo
The demo project for Bottom Navigation with Navigation Architecture Components article
Stars: ✭ 53 (+55.88%)
Mutual labels:  android-architecture
PracticeApp
A "must-have a look" project for newcomers in android.
Stars: ✭ 38 (+11.76%)
Mutual labels:  android-architecture
piri
Piri is a lightweight annotation processing library that generates static factory methods for your Activities and Fragments.
Stars: ✭ 53 (+55.88%)
Mutual labels:  android-navigation
media-picker
Easy customizable picker for all your needs in Android application
Stars: ✭ 167 (+391.18%)
Mutual labels:  android-architecture

Download

aac-navigation-shared-elements-transition

aac-navigation-shared-elements-transition allows you to use shared elements transitions between fragments.

Usage

Add in project

Add specific maven repository to repositories closure. For example, you should add it to root of build.gradle:

allprojects {
  repositories {
    maven { url "https://dl.bintray.com/lion4ik/maven" }
  }
}

Add dependency:

dependencies {
   implementation "com.github.lion4ik:arch-navigation-shared-elements:$version"
}

where recommended $version is the latest from Download badge Download .

How to use

To integrate with aac-navigation-shared-elements-transition you need to do several steps

  1. You need to declare navigation fragment in your xml layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark"/>
    <fragment
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/my_nav_host_fragment"
        android:name="com.github.lion4ik.arch.sharedelements.NavHostSharedElementsTransitionFragment"
        app:navGraph="@navigation/mobile_navigation"
        app:defaultNavHost="false"
    />
</LinearLayout>
  1. Fragment which is responsible for navigation to details fragment with shared element transition should implement interface:
interface HasSharedElements {

    fun getSharedElements(): Map<String, View>

    fun hasReorderingAllowed(): Boolean
}

You can do it like this:

class SharedElementFragment : Fragment(), HasSharedElements {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                              savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_shared_element, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        view.findViewById<View>(R.id.imgView).setOnClickListener(
                Navigation.createNavigateOnClickListener(R.id.next_action)
        )
    }

    override fun getSharedElements(): Map<String, View> {
        val view = view?.findViewById<View>(R.id.imgView) ?: throw IllegalArgumentException("view is null")
        return mapOf(view.transitionName to view)
    }

    override fun hasReorderingAllowed(): Boolean = true
}

FragmentManager gets views as shared elements through getSharedElements() method implemented by Fragment. Shared elements will be add to FragmentTransaction by addSharedElement method. Also, in some cases you need to set reordering flag for FragmentTransaction.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].