Add icon displaying animation

This commit is contained in:
Tanguy Herbron 2018-09-02 01:03:29 +02:00
parent 8ca63b5e85
commit f837372551
5 changed files with 19 additions and 15 deletions

View File

@ -19,6 +19,12 @@ import android.support.v7.widget.CardView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnticipateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@ -52,6 +58,8 @@ import static com.herbron.moodl.MoodlBox.numberConformer;
public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNotifierInterface {
private static final int FADE_IN_DURATION = 300;
private Currency currency;
private Activity parentActivity;
private Context context;
@ -160,7 +168,13 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti
private void updateCurrencyColorRelatedLayouts()
{
((ImageView) findViewById(R.id.currencyIcon)).setImageBitmap(currency.getIcon());
Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setInterpolator(new AccelerateInterpolator());
fadeIn.setDuration(FADE_IN_DURATION);
ImageView currencyIconImageView = findViewById(R.id.currencyIcon);
currencyIconImageView.setImageBitmap(currency.getIcon());
currencyIconImageView.startAnimation(fadeIn);
Drawable arrowDrawable = ((ImageView) findViewById(R.id.detailsArrow)).getDrawable();
arrowDrawable.mutate();
@ -304,16 +318,6 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti
}
}
public double getOwnedValue()
{
return currency.getValue() * currency.getBalance();
}
public double getFluctuation()
{
return getOwnedValue() * (currency.getDayFluctuationPercentage() / 100);
}
private LineData generateData()
{
LineDataSet dataSet;

View File

@ -31,7 +31,7 @@
android:id="@+id/currencyIcon"
android:layout_width="@dimen/currency_icon_cardview_size"
android:layout_height="@dimen/currency_icon_cardview_size"
android:layout_margin="1dp" />
android:layout_margin="1dp"/>
<TextView
android:id="@+id/currencyNameTextView"

View File

@ -51,7 +51,7 @@
android:id="@+id/currencyIcon"
android:layout_width="@dimen/currency_icon_cardview_size"
android:layout_height="@dimen/currency_icon_cardview_size"
android:layout_margin="1dp" />
android:layout_margin="1dp"/>
<TextView
android:id="@+id/currencyNameTextView"

View File

@ -32,7 +32,7 @@
android:id="@+id/currencyIcon"
android:layout_width="@dimen/currency_icon_cardview_size"
android:layout_height="@dimen/currency_icon_cardview_size"
android:layout_margin="1dp" />
android:layout_margin="1dp"/>
<TextView
android:id="@+id/currencyNameTextView"

View File

@ -53,7 +53,7 @@
android:id="@+id/currencyIcon"
android:layout_width="@dimen/currency_icon_cardview_size"
android:layout_height="@dimen/currency_icon_cardview_size"
android:layout_margin="1dp" />
android:layout_margin="1dp"/>
<TextView
android:id="@+id/currencyNameTextView"