From 670eb7184776f61052f82ce97d8bb9c462d0c551 Mon Sep 17 00:00:00 2001 From: Erkut Aras Date: Wed, 23 Oct 2019 12:57:13 +0300 Subject: [PATCH 1/6] update gradle version --- app/build.gradle | 8 ++++---- app/src/main/java/com/trendyol/medusa/BaseFragment.kt | 2 +- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 4 ++-- medusalib/build.gradle | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e709e72..29ef630 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,15 +22,15 @@ android { dependencies { implementation project(':medusalib') implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.vectordrawable:vectordrawable:1.0.1' + implementation 'androidx.vectordrawable:vectordrawable:1.1.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' } repositories { mavenCentral() diff --git a/app/src/main/java/com/trendyol/medusa/BaseFragment.kt b/app/src/main/java/com/trendyol/medusa/BaseFragment.kt index f3519bc..724e43b 100644 --- a/app/src/main/java/com/trendyol/medusa/BaseFragment.kt +++ b/app/src/main/java/com/trendyol/medusa/BaseFragment.kt @@ -9,7 +9,7 @@ open class BaseFragment : Fragment() { var multipleStackNavigator: MultipleStackNavigator? = null - override fun onAttach(context: Context?) { + override fun onAttach(context: Context) { super.onAttach(context) initStackNavigator(context) } diff --git a/build.gradle b/build.gradle index 4aa9ecd..719cf0c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.21' + ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.1' + classpath 'com.android.tools.build:gradle:3.5.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 44a1682..22461c9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Jan 21 10:31:44 EET 2019 +#Tue Oct 22 10:09:51 EET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/medusalib/build.gradle b/medusalib/build.gradle index 5a75243..4a2f11e 100755 --- a/medusalib/build.gradle +++ b/medusalib/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 15 targetSdkVersion 28 - versionCode 6 - versionName "0.7.0" + versionCode 8 + versionName "0.8" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From ddc79cd43214feb1ab4745b7de0efc061ae4de7d Mon Sep 17 00:00:00 2001 From: "selim.toksal" Date: Sun, 10 Nov 2019 10:06:16 +0300 Subject: [PATCH 2/6] Add anim resources --- medusalib/src/main/res/anim/empty_animation.xml | 6 ++++++ medusalib/src/main/res/anim/enter_from_bottom.xml | 7 +++++++ medusalib/src/main/res/anim/enter_from_left.xml | 8 ++++++++ medusalib/src/main/res/anim/enter_from_right.xml | 8 ++++++++ medusalib/src/main/res/anim/enter_from_top.xml | 7 +++++++ medusalib/src/main/res/anim/exit_to_bottom.xml | 7 +++++++ medusalib/src/main/res/anim/exit_to_left.xml | 8 ++++++++ medusalib/src/main/res/anim/exit_to_right.xml | 8 ++++++++ medusalib/src/main/res/anim/exit_to_top.xml | 7 +++++++ medusalib/src/main/res/anim/fade_in.xml | 7 +++++++ medusalib/src/main/res/anim/fade_out.xml | 7 +++++++ 11 files changed, 80 insertions(+) create mode 100644 medusalib/src/main/res/anim/empty_animation.xml create mode 100644 medusalib/src/main/res/anim/enter_from_bottom.xml create mode 100644 medusalib/src/main/res/anim/enter_from_left.xml create mode 100644 medusalib/src/main/res/anim/enter_from_right.xml create mode 100644 medusalib/src/main/res/anim/enter_from_top.xml create mode 100644 medusalib/src/main/res/anim/exit_to_bottom.xml create mode 100644 medusalib/src/main/res/anim/exit_to_left.xml create mode 100644 medusalib/src/main/res/anim/exit_to_right.xml create mode 100644 medusalib/src/main/res/anim/exit_to_top.xml create mode 100644 medusalib/src/main/res/anim/fade_in.xml create mode 100644 medusalib/src/main/res/anim/fade_out.xml diff --git a/medusalib/src/main/res/anim/empty_animation.xml b/medusalib/src/main/res/anim/empty_animation.xml new file mode 100644 index 0000000..776a81a --- /dev/null +++ b/medusalib/src/main/res/anim/empty_animation.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/enter_from_bottom.xml b/medusalib/src/main/res/anim/enter_from_bottom.xml new file mode 100644 index 0000000..8a3ec99 --- /dev/null +++ b/medusalib/src/main/res/anim/enter_from_bottom.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/enter_from_left.xml b/medusalib/src/main/res/anim/enter_from_left.xml new file mode 100644 index 0000000..5f30762 --- /dev/null +++ b/medusalib/src/main/res/anim/enter_from_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/enter_from_right.xml b/medusalib/src/main/res/anim/enter_from_right.xml new file mode 100644 index 0000000..39217a6 --- /dev/null +++ b/medusalib/src/main/res/anim/enter_from_right.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/enter_from_top.xml b/medusalib/src/main/res/anim/enter_from_top.xml new file mode 100644 index 0000000..3e599d3 --- /dev/null +++ b/medusalib/src/main/res/anim/enter_from_top.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/exit_to_bottom.xml b/medusalib/src/main/res/anim/exit_to_bottom.xml new file mode 100644 index 0000000..152705f --- /dev/null +++ b/medusalib/src/main/res/anim/exit_to_bottom.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/exit_to_left.xml b/medusalib/src/main/res/anim/exit_to_left.xml new file mode 100644 index 0000000..8010de0 --- /dev/null +++ b/medusalib/src/main/res/anim/exit_to_left.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/exit_to_right.xml b/medusalib/src/main/res/anim/exit_to_right.xml new file mode 100644 index 0000000..78c19cd --- /dev/null +++ b/medusalib/src/main/res/anim/exit_to_right.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/exit_to_top.xml b/medusalib/src/main/res/anim/exit_to_top.xml new file mode 100644 index 0000000..efb8582 --- /dev/null +++ b/medusalib/src/main/res/anim/exit_to_top.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/fade_in.xml b/medusalib/src/main/res/anim/fade_in.xml new file mode 100644 index 0000000..1b1f82f --- /dev/null +++ b/medusalib/src/main/res/anim/fade_in.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/medusalib/src/main/res/anim/fade_out.xml b/medusalib/src/main/res/anim/fade_out.xml new file mode 100644 index 0000000..926a3bb --- /dev/null +++ b/medusalib/src/main/res/anim/fade_out.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file From f491fea7495690e75976a32ade268a0f0787d56c Mon Sep 17 00:00:00 2001 From: "selim.toksal" Date: Sun, 10 Nov 2019 10:06:46 +0300 Subject: [PATCH 3/6] Create TransitionAnimationType enum class --- .../navigator/transitionanimation/TransitionAnimationType.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 medusalib/src/main/java/com/trendyol/medusalib/navigator/transitionanimation/TransitionAnimationType.kt diff --git a/medusalib/src/main/java/com/trendyol/medusalib/navigator/transitionanimation/TransitionAnimationType.kt b/medusalib/src/main/java/com/trendyol/medusalib/navigator/transitionanimation/TransitionAnimationType.kt new file mode 100644 index 0000000..029374e --- /dev/null +++ b/medusalib/src/main/java/com/trendyol/medusalib/navigator/transitionanimation/TransitionAnimationType.kt @@ -0,0 +1,5 @@ +package com.trendyol.medusalib.navigator.transitionanimation + +enum class TransitionAnimationType { + LEFT_TO_RIGHT, RIGHT_TO_LEFT, BOTTOM_TO_TOP, TOP_TO_BOTTOM, FADE_IN_OUT +} \ No newline at end of file From efb485119488d9ff02e5ca9e9c87b96297e067a0 Mon Sep 17 00:00:00 2001 From: "selim.toksal" Date: Sun, 10 Nov 2019 10:31:21 +0300 Subject: [PATCH 4/6] Change sample fragment ui Add initial transition animation to MultipleStackNavigator constructor Implement TransitionAnimationType into removeFragment and startFragment --- .../java/com/trendyol/medusa/MainActivity.kt | 4 +- .../com/trendyol/medusa/MainActivity2.java | 52 ++++++++++--------- .../com/trendyol/medusa/SampleFragment.kt | 8 ++- app/src/main/res/layout/fragment_sample.xml | 29 ++++++----- .../navigator/MultipleStackNavigator.kt | 17 ++++-- .../trendyol/medusalib/navigator/Navigator.kt | 5 ++ .../controller/FragmentManagerController.kt | 38 ++++++++++++-- .../medusalib/navigator/data/FragmentData.kt | 3 +- 8 files changed, 106 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/trendyol/medusa/MainActivity.kt b/app/src/main/java/com/trendyol/medusa/MainActivity.kt index 89a27de..77895bf 100644 --- a/app/src/main/java/com/trendyol/medusa/MainActivity.kt +++ b/app/src/main/java/com/trendyol/medusa/MainActivity.kt @@ -15,6 +15,7 @@ import com.trendyol.medusalib.navigator.MultipleStackNavigator import com.trendyol.medusalib.navigator.Navigator import com.trendyol.medusalib.navigator.NavigatorConfiguration import com.trendyol.medusalib.navigator.transaction.NavigatorTransaction +import com.trendyol.medusalib.navigator.transitionanimation.TransitionAnimationType class MainActivity : AppCompatActivity(), Navigator.NavigatorListener { @@ -32,7 +33,8 @@ class MainActivity : AppCompatActivity(), Navigator.NavigatorListener { R.id.fragmentContainer, rootFragmentProvider, navigatorListener = this, - navigatorConfiguration = NavigatorConfiguration(1, true, NavigatorTransaction.SHOW_HIDE)) + navigatorConfiguration = NavigatorConfiguration(1, true, NavigatorTransaction.SHOW_HIDE), + transitionAnimationType = TransitionAnimationType.BOTTOM_TO_TOP) private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item -> when (item.itemId) { diff --git a/app/src/main/java/com/trendyol/medusa/MainActivity2.java b/app/src/main/java/com/trendyol/medusa/MainActivity2.java index 1323371..3fe7fe2 100644 --- a/app/src/main/java/com/trendyol/medusa/MainActivity2.java +++ b/app/src/main/java/com/trendyol/medusa/MainActivity2.java @@ -15,6 +15,7 @@ import com.trendyol.medusalib.navigator.Navigator; import com.trendyol.medusalib.navigator.NavigatorConfiguration; import com.trendyol.medusalib.navigator.transaction.NavigatorTransaction; +import com.trendyol.medusalib.navigator.transitionanimation.TransitionAnimationType; import java.util.Arrays; import java.util.List; @@ -28,26 +29,26 @@ public class MainActivity2 extends AppCompatActivity implements Navigator.Naviga MultipleStackNavigator multipleStackNavigator; private List> rootsFragmentProvider = Arrays - .asList( - new Function0() { - @Override - public Fragment invoke() { - return FragmentGenerator.generateNewFragment(); - } - }, - new Function0() { - @Override - public Fragment invoke() { - return FragmentGenerator.generateNewFragment(); - } - }, - new Function0() { - @Override - public Fragment invoke() { - return FragmentGenerator.generateNewFragment(); - } - } - ); + .asList( + new Function0() { + @Override + public Fragment invoke() { + return FragmentGenerator.generateNewFragment(); + } + }, + new Function0() { + @Override + public Fragment invoke() { + return FragmentGenerator.generateNewFragment(); + } + }, + new Function0() { + @Override + public Fragment invoke() { + return FragmentGenerator.generateNewFragment(); + } + } + ); private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { @Override @@ -75,11 +76,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { navigation = findViewById(R.id.navigation); multipleStackNavigator = new MultipleStackNavigator( - getSupportFragmentManager(), - R.id.fragmentContainer, - rootsFragmentProvider, - this, - new NavigatorConfiguration(1, true, NavigatorTransaction.SHOW_HIDE)); + getSupportFragmentManager(), + R.id.fragmentContainer, + rootsFragmentProvider, + this, + new NavigatorConfiguration(1, true, NavigatorTransaction.SHOW_HIDE), + TransitionAnimationType.BOTTOM_TO_TOP); multipleStackNavigator.initialize(savedInstanceState); final SwitchCompat restartRootFragmentCheckBox = findViewById(R.id.restartSwitch); diff --git a/app/src/main/java/com/trendyol/medusa/SampleFragment.kt b/app/src/main/java/com/trendyol/medusa/SampleFragment.kt index 6daa923..8947f8b 100644 --- a/app/src/main/java/com/trendyol/medusa/SampleFragment.kt +++ b/app/src/main/java/com/trendyol/medusa/SampleFragment.kt @@ -1,17 +1,23 @@ package com.trendyol.medusa +import android.graphics.Color import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button +import android.widget.LinearLayout import android.widget.TextView +import kotlin.random.Random -class SampleFragment : BaseFragment(){ +class SampleFragment : BaseFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_sample, container, false)!! view.findViewById(R.id.textview).text = arguments!!.getString(KEY) + + view.findViewById(R.id.root).setBackgroundColor(Color.argb(255, Random.nextInt(256), Random.nextInt(256), Random.nextInt(256))) + view.findViewById