aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Hubert <aurel.hubert@gmail.com>2016-06-03 10:07:52 +0200
committerJoey Rizzoli <joey@cyanogenmoditalia.it>2016-06-09 22:52:17 +0200
commit98bac947e7d76d346e4e840c6b365edc583f11b1 (patch)
treed369c257cd4099524f0c17ece7754c0af7b76e01
parent4e0849cf226ab0289226a25755a7462bc42badee (diff)
downloadandroid_external_ahbottomnavigation-98bac947e7d76d346e4e840c6b365edc583f11b1.tar.gz
android_external_ahbottomnavigation-98bac947e7d76d346e4e840c6b365edc583f11b1.tar.bz2
android_external_ahbottomnavigation-98bac947e7d76d346e4e840c6b365edc583f11b1.zip
Improved Demo project (added animations)
-rw-r--r--demo/build.gradle2
-rw-r--r--demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java9
-rw-r--r--demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoFragment.java21
-rw-r--r--demo/src/main/res/anim/fade_in.xml17
-rw-r--r--demo/src/main/res/anim/fade_out.xml11
-rw-r--r--demo/src/main/res/animator/fade_in.xml16
-rw-r--r--demo/src/main/res/animator/fade_out.xml8
-rw-r--r--demo/src/main/res/drawable/ic_apps_black_24dp.xml1
-rw-r--r--demo/src/main/res/layout/fragment_demo_list.xml6
-rw-r--r--demo/src/main/res/xml/bottom_fav.xml19
10 files changed, 81 insertions, 29 deletions
diff --git a/demo/build.gradle b/demo/build.gradle
index 219b1cd..c7da17d 100644
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -10,7 +10,9 @@ android {
targetSdkVersion 23
versionCode 1
versionName "1.0"
+
}
+
buildTypes {
release {
minifyEnabled false
diff --git a/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java b/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java
index a7c718e..7d9f14e 100644
--- a/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java
+++ b/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java
@@ -60,13 +60,18 @@ public class DemoActivity extends AppCompatActivity {
bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
@Override
public void onTabSelected(int position, boolean wasSelected) {
-
- currentFragment = adapter.getCurrentFragment();
+;
if (wasSelected) {
currentFragment.refresh();
return;
}
+
+ if (currentFragment != null) {
+ currentFragment.willBeHidden();
+ }
+
viewPager.setCurrentItem(position, false);
+ currentFragment = adapter.getCurrentFragment();
currentFragment.willBeDisplayed();
if (position == 1) {
diff --git a/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoFragment.java b/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoFragment.java
index 2c7c7f5..2d6ace2 100644
--- a/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoFragment.java
+++ b/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoFragment.java
@@ -9,7 +9,10 @@ import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
import android.widget.CompoundButton;
+import android.widget.FrameLayout;
import java.util.ArrayList;
@@ -18,6 +21,7 @@ import java.util.ArrayList;
*/
public class DemoFragment extends Fragment {
+ private FrameLayout fragmentContainer;
private RecyclerView recyclerView;
private RecyclerView.LayoutManager layoutManager;
@@ -50,6 +54,7 @@ public class DemoFragment extends Fragment {
* Init demo settings
*/
private void initDemoSettings(View view) {
+
final DemoActivity demoActivity = (DemoActivity) getActivity();
final SwitchCompat switchColored = (SwitchCompat) view.findViewById(R.id.fragment_demo_switch_colored);
final SwitchCompat switchFiveItems = (SwitchCompat) view.findViewById(R.id.fragment_demo_switch_five_items);
@@ -82,6 +87,8 @@ public class DemoFragment extends Fragment {
* Init the fragment
*/
private void initDemoList(View view) {
+
+ fragmentContainer = (FrameLayout) view.findViewById(R.id.fragment_container);
recyclerView = (RecyclerView) view.findViewById(R.id.fragment_demo_recycler_view);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getActivity());
@@ -110,5 +117,19 @@ public class DemoFragment extends Fragment {
*/
public void willBeDisplayed() {
// Do what you want here, for example animate the content
+ if (fragmentContainer != null) {
+ Animation fadeIn = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in);
+ fragmentContainer.startAnimation(fadeIn);
+ }
+ }
+
+ /**
+ * Called when a fragment will be hidden
+ */
+ public void willBeHidden() {
+ if (fragmentContainer != null) {
+ Animation fadeOut = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_out);
+ fragmentContainer.startAnimation(fadeOut);
+ }
}
}
diff --git a/demo/src/main/res/anim/fade_in.xml b/demo/src/main/res/anim/fade_in.xml
new file mode 100644
index 0000000..c1ef33c
--- /dev/null
+++ b/demo/src/main/res/anim/fade_in.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fillBefore="true"
+ android:fillAfter="true"
+ android:startOffset="50">
+
+ <alpha
+ android:duration="300"
+ android:fromAlpha="0"
+ android:toAlpha="1"/>
+
+ <translate
+ android:duration="300"
+ android:fromYDelta="16"
+ android:toYDelta="0" />
+
+</set> \ No newline at end of file
diff --git a/demo/src/main/res/anim/fade_out.xml b/demo/src/main/res/anim/fade_out.xml
new file mode 100644
index 0000000..dd577b4
--- /dev/null
+++ b/demo/src/main/res/anim/fade_out.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:fillBefore="true"
+ android:fillAfter="true">
+
+ <alpha
+ android:duration="100"
+ android:fromAlpha="1"
+ android:toAlpha="0"/>
+
+</set> \ No newline at end of file
diff --git a/demo/src/main/res/animator/fade_in.xml b/demo/src/main/res/animator/fade_in.xml
deleted file mode 100644
index 6bf26a5..0000000
--- a/demo/src/main/res/animator/fade_in.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<set xmlns:android="http://schemas.android.com/apk/res/android">
-
- <objectAnimator
- android:duration="300"
- android:propertyName="alpha"
- android:valueFrom="0"
- android:valueTo="1"/>
-
- <objectAnimator
- android:duration="300"
- android:propertyName="y"
- android:valueFrom="16"
- android:valueTo="0"/>
-
-</set> \ No newline at end of file
diff --git a/demo/src/main/res/animator/fade_out.xml b/demo/src/main/res/animator/fade_out.xml
deleted file mode 100644
index fc4e8c4..0000000
--- a/demo/src/main/res/animator/fade_out.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<set xmlns:android="http://schemas.android.com/apk/res/android">
- <objectAnimator
- android:valueFrom="1"
- android:valueTo="0"
- android:propertyName="alpha"
- android:duration="150" />
-</set> \ No newline at end of file
diff --git a/demo/src/main/res/drawable/ic_apps_black_24dp.xml b/demo/src/main/res/drawable/ic_apps_black_24dp.xml
index ff485cf..4b055b6 100644
--- a/demo/src/main/res/drawable/ic_apps_black_24dp.xml
+++ b/demo/src/main/res/drawable/ic_apps_black_24dp.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
diff --git a/demo/src/main/res/layout/fragment_demo_list.xml b/demo/src/main/res/layout/fragment_demo_list.xml
index 3e1021b..95437bf 100644
--- a/demo/src/main/res/layout/fragment_demo_list.xml
+++ b/demo/src/main/res/layout/fragment_demo_list.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout android:id="@+id/fragment_container"
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+ android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/fragment_demo_recycler_view"
diff --git a/demo/src/main/res/xml/bottom_fav.xml b/demo/src/main/res/xml/bottom_fav.xml
new file mode 100644
index 0000000..9835899
--- /dev/null
+++ b/demo/src/main/res/xml/bottom_fav.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportHeight="336"
+ android:viewportWidth="351">
+
+ <path
+ android:fillColor="#007BFF"
+ android:pathData="M276.2,336 C274.2,336,272.2,335.5,270.4,334.6 L175.5,284.7 L80.6,334.6
+C76.4,336.8,71.3,336.4,67.4,333.6 C63.6,330.8,61.6,326.1,62.4,321.4 L80.5,215.7
+L3.8,140.8 C0.4,137.5,-0.8,132.5,0.6,128 C2.1,123.5,6,120.2,10.7,119.5
+L116.8,104.1 L164.3,7.9 C166.4,3.6,170.8,0.9,175.5,0.9
+C180.3,0.9,184.6,3.6,186.7,7.9 L234.2,104.1 L340.3,119.5
+C345,120.2,348.9,123.5,350.4,128 C351.9,132.5,350.6,137.5,347.2,140.8
+L270.4,215.6 L288.5,321.3 C289.3,326,287.4,330.7,283.5,333.5
+C281.4,335.1,278.8,336,276.2,336 L276.2,336 L276.2,336 Z"
+ android:strokeWidth="1" />
+</vector> \ No newline at end of file