fade in images and avatars

This commit is contained in:
Christian Schneppe 2018-06-03 21:45:33 +02:00
parent 3710d000f5
commit 6bf3ef887a
6 changed files with 37 additions and 0 deletions

View file

@ -22,6 +22,8 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -799,6 +801,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
cancelPotentialWork(user, imageView); cancelPotentialWork(user, imageView);
imageView.setImageBitmap(bm); imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0x00000000); imageView.setBackgroundColor(0x00000000);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
} else { } else {
String seed = user.getRealJid() != null ? user.getRealJid().asBareJid().toString() : null; String seed = user.getRealJid() != null ? user.getRealJid().asBareJid().toString() : null;
imageView.setBackgroundColor(UIHelper.getColorForName(seed == null ? user.getName() : seed)); imageView.setBackgroundColor(UIHelper.getColorForName(seed == null ? user.getName() : seed));
@ -806,6 +810,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
final AsyncDrawable asyncDrawable = new AsyncDrawable(getResources(), null, task); final AsyncDrawable asyncDrawable = new AsyncDrawable(getResources(), null, task);
imageView.setImageDrawable(asyncDrawable); imageView.setImageDrawable(asyncDrawable);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
try { try {
task.execute(user); task.execute(user);
} catch (final RejectedExecutionException ignored) { } catch (final RejectedExecutionException ignored) {

View file

@ -46,6 +46,8 @@ import android.util.Pair;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Spinner; import android.widget.Spinner;
@ -1095,6 +1097,8 @@ public abstract class XmppActivity extends ActionBarActivity {
cancelPotentialWork(message, imageView); cancelPotentialWork(message, imageView);
imageView.setImageBitmap(bm); imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0x00000000); imageView.setBackgroundColor(0x00000000);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
} else { } else {
if (cancelPotentialWork(message, imageView)) { if (cancelPotentialWork(message, imageView)) {
imageView.setBackgroundColor(0xff333333); imageView.setBackgroundColor(0xff333333);
@ -1103,6 +1107,8 @@ public abstract class XmppActivity extends ActionBarActivity {
final AsyncDrawable asyncDrawable = new AsyncDrawable( final AsyncDrawable asyncDrawable = new AsyncDrawable(
getResources(), null, task); getResources(), null, task);
imageView.setImageDrawable(asyncDrawable); imageView.setImageDrawable(asyncDrawable);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
try { try {
task.execute(message); task.execute(message);
} catch (final RejectedExecutionException ignored) { } catch (final RejectedExecutionException ignored) {

View file

@ -10,6 +10,8 @@ import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -122,12 +124,16 @@ public class AccountAdapter extends ArrayAdapter<Account> {
cancelPotentialWork(account, imageView); cancelPotentialWork(account, imageView);
imageView.setImageBitmap(bm); imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0x00000000); imageView.setBackgroundColor(0x00000000);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(activity, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
} else { } else {
imageView.setBackgroundColor(UIHelper.getColorForName(account.getJid().asBareJid().toString())); imageView.setBackgroundColor(UIHelper.getColorForName(account.getJid().asBareJid().toString()));
imageView.setImageDrawable(null); imageView.setImageDrawable(null);
final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task); final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
imageView.setImageDrawable(asyncDrawable); imageView.setImageDrawable(asyncDrawable);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(activity, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
try { try {
task.executeOnExecutor(BitmapWorkerTask.THREAD_POOL_EXECUTOR, account); task.executeOnExecutor(BitmapWorkerTask.THREAD_POOL_EXECUTOR, account);
} catch (final RejectedExecutionException ignored) { } catch (final RejectedExecutionException ignored) {

View file

@ -16,6 +16,8 @@ import android.util.Pair;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -324,12 +326,16 @@ public class ConversationAdapter extends RecyclerView.Adapter<ConversationAdapte
cancelPotentialWork(conversation, imageView); cancelPotentialWork(conversation, imageView);
imageView.setImageBitmap(bm); imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0x00000000); imageView.setBackgroundColor(0x00000000);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(activity, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
} else { } else {
imageView.setBackgroundColor(UIHelper.getColorForName(conversation.getName().toString())); imageView.setBackgroundColor(UIHelper.getColorForName(conversation.getName().toString()));
imageView.setImageDrawable(null); imageView.setImageDrawable(null);
final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task); final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
imageView.setImageDrawable(asyncDrawable); imageView.setImageDrawable(asyncDrawable);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(activity, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
try { try {
task.executeOnExecutor(BitmapWorkerTask.THREAD_POOL_EXECUTOR, conversation); task.executeOnExecutor(BitmapWorkerTask.THREAD_POOL_EXECUTOR, conversation);
} catch (final RejectedExecutionException ignored) { } catch (final RejectedExecutionException ignored) {

View file

@ -11,6 +11,8 @@ import android.preference.PreferenceManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -165,6 +167,8 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
cancelPotentialWork(item, imageView); cancelPotentialWork(item, imageView);
imageView.setImageBitmap(bm); imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0x00000000); imageView.setBackgroundColor(0x00000000);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(activity, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
} else { } else {
String seed = item.getJid() != null ? item.getJid().asBareJid().toString() : item.getDisplayName(); String seed = item.getJid() != null ? item.getJid().asBareJid().toString() : item.getDisplayName();
imageView.setBackgroundColor(UIHelper.getColorForName(seed)); imageView.setBackgroundColor(UIHelper.getColorForName(seed));
@ -172,6 +176,8 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task); final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
imageView.setImageDrawable(asyncDrawable); imageView.setImageDrawable(asyncDrawable);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(activity, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
try { try {
task.executeOnExecutor(BitmapWorkerTask.THREAD_POOL_EXECUTOR, item); task.executeOnExecutor(BitmapWorkerTask.THREAD_POOL_EXECUTOR, item);
} catch (final RejectedExecutionException ignored) { } catch (final RejectedExecutionException ignored) {

View file

@ -1,6 +1,7 @@
package de.pixart.messenger.ui.adapter; package de.pixart.messenger.ui.adapter;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Intent; import android.content.Intent;
@ -37,6 +38,8 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
@ -1147,6 +1150,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
cancelPotentialWork(message, imageView); cancelPotentialWork(message, imageView);
imageView.setImageBitmap(bm); imageView.setImageBitmap(bm);
imageView.setBackgroundColor(Color.TRANSPARENT); imageView.setBackgroundColor(Color.TRANSPARENT);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(activity, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
} else { } else {
@ColorInt int bg; @ColorInt int bg;
if (message.getType() == Message.TYPE_STATUS && message.getCounterparts() != null && message.getCounterparts().size() > 1) { if (message.getType() == Message.TYPE_STATUS && message.getCounterparts() != null && message.getCounterparts().size() > 1) {
@ -1159,6 +1164,8 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
final BitmapWorkerTask task = new BitmapWorkerTask(imageView, size); final BitmapWorkerTask task = new BitmapWorkerTask(imageView, size);
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task); final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
imageView.setImageDrawable(asyncDrawable); imageView.setImageDrawable(asyncDrawable);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(activity, R.animator.fade_in);
imageView.startAnimation(myFadeInAnimation);
try { try {
task.executeOnExecutor(BitmapWorkerTask.THREAD_POOL_EXECUTOR, message); task.executeOnExecutor(BitmapWorkerTask.THREAD_POOL_EXECUTOR, message);
} catch (final RejectedExecutionException ignored) { } catch (final RejectedExecutionException ignored) {