Watchlist : Edit button animations
This commit is contained in:
parent
08434128b1
commit
188d924c18
@ -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;
|
||||
|
||||
|
27
app/src/main/res/drawable/check_to_edit.xml
Normal file
27
app/src/main/res/drawable/check_to_edit.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="check"
|
||||
android:pathData="M 9 16.17 L 4.83 12 L 3.41 13.41 L 9 19 L 21 7 L 19.59 5.59 Z"
|
||||
android:fillColor="#FFFFFFFF"/>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="check">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:propertyName="pathData"
|
||||
android:duration="200"
|
||||
android:valueFrom="M 3.41 13.41 L 6.205 16.205 L 9 19 L 21 7 L 19.59 5.59 L 9 16.17 L 4.83 12 L 3.41 13.41 M 18.216 5.784 L 18.216 5.784 L 18.216 5.784 L 18.216 5.784 L 18.216 5.784 C 18.216 5.784 18.216 5.784 18.216 5.784 L 18.216 5.784 C 18.216 5.784 18.216 5.784 18.216 5.784"
|
||||
android:valueTo="M 3 17.25 L 3 21 L 6.75 21 L 17.81 9.94 L 14.06 6.19 L 8.53 11.72 L 3 17.25 L 3 17.25 M 20.71 7.04 L 20.71 7.04 L 18.88 8.87 L 15.13 5.12 L 16.96 3.29 C 17.35 2.9 17.98 2.9 18.37 3.29 L 20.71 5.63 C 21.1 6.02 21.1 6.65 20.71 7.04"
|
||||
android:valueType="pathType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"/>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
28
app/src/main/res/drawable/edit_to_check.xml
Normal file
28
app/src/main/res/drawable/edit_to_check.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<animated-vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt">
|
||||
<aapt:attr name="android:drawable">
|
||||
<vector
|
||||
android:name="vector"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:name="edit"
|
||||
android:pathData="M 3 17.25 L 3 21 L 6.75 21 L 17.81 9.94 L 14.06 6.19 L 3 17.25 Z M 20.71 7.04 C 21.1 6.65 21.1 6.02 20.71 5.63 L 18.37 3.29 C 17.98 2.9 17.35 2.9 16.96 3.29 L 15.13 5.12 L 18.88 8.87 L 20.71 7.04 Z"
|
||||
android:fillColor="#FFFFFFFF"/>
|
||||
</vector>
|
||||
</aapt:attr>
|
||||
<target android:name="edit">
|
||||
<aapt:attr name="android:animation">
|
||||
<objectAnimator
|
||||
android:propertyName="pathData"
|
||||
android:duration="200"
|
||||
android:valueFrom="M 3 17.25 L 3 17.25 L 3 21 L 6.75 21 L 17.81 9.94 L 14.06 6.19 L 3 17.25 M 20.71 5.63 L 18.37 3.29 C 17.98 2.9 17.35 2.9 16.96 3.29 L 15.13 5.12 L 18.88 8.87 L 20.71 7.04 L 20.71 7.04 C 21.1 6.65 21.1 6.02 20.71 5.63"
|
||||
android:valueTo="M 9 16.17 L 4.83 12 L 3.41 13.41 L 9 19 L 21 7 L 19.59 5.59 L 9 16.17 M 18.216 5.784 L 18.216 5.784 C 18.216 5.784 18.216 5.784 18.216 5.784 L 18.216 5.784 L 18.216 5.784 L 18.216 5.784 L 18.216 5.784 C 18.216 5.784 18.216 5.784 18.216 5.784"
|
||||
android:valueType="pathType"
|
||||
android:interpolator="@android:interpolator/fast_out_slow_in"/>
|
||||
</aapt:attr>
|
||||
</target>
|
||||
</animated-vector>
|
Loading…
Reference in New Issue
Block a user