From 188d924c18f24dffa796425c9ba528ac03ce9a74 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Mon, 23 Jul 2018 19:43:42 +0200 Subject: [PATCH] Watchlist : Edit button animations --- .../HomeActivityFragments/Watchlist.java | 20 +++++++++++-- app/src/main/res/drawable/check_to_edit.xml | 27 ++++++++++++++++++ app/src/main/res/drawable/edit_to_check.xml | 28 +++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/check_to_edit.xml create mode 100644 app/src/main/res/drawable/edit_to_check.xml diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java index 01654a4..d4d1e2f 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java +++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Watchlist.java @@ -3,7 +3,9 @@ package com.herbron.moodl.Activities.HomeActivityFragments; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.drawable.AnimatedVectorDrawable; import android.os.AsyncTask; +import android.os.Build; import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.os.Bundle; @@ -143,14 +145,20 @@ public class Watchlist extends Fragment { private void setupEditButton() { - ImageButton editButton = view.findViewById(R.id.edit_button); + final ImageButton editButton = view.findViewById(R.id.edit_button); editButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(editModeEnabled) { - ((ImageView) view.findViewById(R.id.edit_button)).setBackground(MoodlBox.getDrawable(R.drawable.ic_mode_edit_white_24dp, getContext())); + editButton.setBackground(MoodlBox.getDrawable(R.drawable.check_to_edit, getContext())); + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) + { + AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) editButton.getBackground(); + animatedVectorDrawable.start(); + } editModeEnabled = false; @@ -168,7 +176,13 @@ public class Watchlist extends Fragment { } else { - ((ImageView) view.findViewById(R.id.edit_button)).setBackground(MoodlBox.getDrawable(R.drawable.ic_check_white_24dp, getContext())); + editButton.setBackground(MoodlBox.getDrawable(R.drawable.edit_to_check, getContext())); + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) + { + AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) editButton.getBackground(); + animatedVectorDrawable.start(); + } editModeEnabled = true; diff --git a/app/src/main/res/drawable/check_to_edit.xml b/app/src/main/res/drawable/check_to_edit.xml new file mode 100644 index 0000000..83ceb8f --- /dev/null +++ b/app/src/main/res/drawable/check_to_edit.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/edit_to_check.xml b/app/src/main/res/drawable/edit_to_check.xml new file mode 100644 index 0000000..350bbbb --- /dev/null +++ b/app/src/main/res/drawable/edit_to_check.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + +