Improve animations
This commit is contained in:
parent
a39fb00cb9
commit
2805a86bc5
|
@ -34,6 +34,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
|
@ -124,13 +125,26 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
private boolean isOnWifi;
|
private boolean isOnWifi;
|
||||||
private NotificationsListAdapter.ViewHolder holder;
|
private NotificationsListAdapter.ViewHolder holder;
|
||||||
private int style;
|
private int style;
|
||||||
|
private RecyclerView mRecyclerView;
|
||||||
private List<NotificationsListAdapter.ViewHolder> lstHolders;
|
private List<NotificationsListAdapter.ViewHolder> lstHolders;
|
||||||
private Runnable updateAnimatedEmoji = new Runnable() {
|
private Runnable updateAnimatedEmoji = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
synchronized (lstHolders) {
|
synchronized (lstHolders) {
|
||||||
for (NotificationsListAdapter.ViewHolder holder : lstHolders) {
|
if( (mRecyclerView.getLayoutManager()) != null) {
|
||||||
holder.updateAnimatedEmoji();
|
int firstPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
|
||||||
|
int lastPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findLastCompletelyVisibleItemPosition();
|
||||||
|
|
||||||
|
for (NotificationsListAdapter.ViewHolder holder : lstHolders) {
|
||||||
|
|
||||||
|
if (holder.getLayoutPosition() >= firstPosition && holder.getLayoutPosition() <= lastPosition) {
|
||||||
|
holder.updateAnimatedEmoji();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
for (NotificationsListAdapter.ViewHolder holder : lstHolders) {
|
||||||
|
holder.updateAnimatedEmoji();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +176,13 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
startUpdateTimer();
|
startUpdateTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||||
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
|
|
||||||
|
mRecyclerView = recyclerView;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
@ -1494,8 +1514,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
||||||
|
|
||||||
|
|
||||||
void updateAnimatedEmoji() {
|
void updateAnimatedEmoji() {
|
||||||
holder.notification_account_username.invalidate();
|
notification_status_content.invalidate();
|
||||||
holder.notification_status_content.invalidate();
|
notification_account_username.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
@ -215,19 +216,38 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
private TextView warning_message;
|
private TextView warning_message;
|
||||||
private Status tootReply;
|
private Status tootReply;
|
||||||
private long currentToId = -1;
|
private long currentToId = -1;
|
||||||
|
private RecyclerView mRecyclerView;
|
||||||
|
|
||||||
private List<ViewHolder> lstHolders;
|
private List<ViewHolder> lstHolders;
|
||||||
private Runnable updateAnimatedEmoji = new Runnable() {
|
private Runnable updateAnimatedEmoji = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
synchronized (lstHolders) {
|
synchronized (lstHolders) {
|
||||||
for (ViewHolder holder : lstHolders) {
|
if( (mRecyclerView.getLayoutManager()) != null) {
|
||||||
holder.updateAnimatedEmoji();
|
int firstPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
|
||||||
|
int lastPosition = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findLastCompletelyVisibleItemPosition();
|
||||||
|
for (ViewHolder holder : lstHolders) {
|
||||||
|
if (holder.getLayoutPosition() >= firstPosition && holder.getLayoutPosition() <= lastPosition) {
|
||||||
|
holder.updateAnimatedEmoji();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
for (ViewHolder holder : lstHolders) {
|
||||||
|
holder.updateAnimatedEmoji();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||||
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
|
|
||||||
|
mRecyclerView = recyclerView;
|
||||||
|
}
|
||||||
|
|
||||||
private void startUpdateTimer() {
|
private void startUpdateTimer() {
|
||||||
|
|
||||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
|
@ -809,7 +829,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
||||||
|
|
||||||
warning_message = itemView.findViewById(R.id.warning_message);
|
warning_message = itemView.findViewById(R.id.warning_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateAnimatedEmoji() {
|
void updateAnimatedEmoji() {
|
||||||
status_account_displayname.invalidate();
|
status_account_displayname.invalidate();
|
||||||
status_content.invalidate();
|
status_content.invalidate();
|
||||||
|
|
Loading…
Reference in New Issue