Change timer task
This commit is contained in:
parent
f6e508517f
commit
d0cb35e01e
|
@ -109,7 +109,6 @@ import app.fedilab.android.interfaces.OnRetrieveEmojiInterface;
|
|||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
import static app.fedilab.android.activities.BaseMainActivity.social;
|
||||
import static app.fedilab.android.drawers.StatusListAdapter.tmr;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -155,22 +154,6 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
};
|
||||
private Handler mHandler = new Handler();
|
||||
|
||||
private void startUpdateTimer() {
|
||||
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
|
||||
if( !disableAnimatedEmoji ){
|
||||
if( tmr == null){
|
||||
tmr = new Timer();
|
||||
}
|
||||
tmr.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
mHandler.post(updateAnimatedEmoji);
|
||||
}
|
||||
}, 0, 130);
|
||||
}
|
||||
}
|
||||
|
||||
public NotificationsListAdapter(boolean isOnWifi, int behaviorWithAttachments, List<Notification> notifications){
|
||||
this.notifications = notifications;
|
||||
|
@ -208,11 +191,11 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
holder = (NotificationsListAdapter.ViewHolder) viewHolder;
|
||||
context = holder.status_document_container.getContext();
|
||||
|
||||
startUpdateTimer();
|
||||
|
||||
synchronized (lock) {
|
||||
lstHolders.add(holder);
|
||||
}
|
||||
|
||||
holder.startUpdateTimer();
|
||||
final Notification notification = notifications.get(position);
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
|
||||
|
@ -1495,6 +1478,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
TextView number_votes, remaining_time;
|
||||
Button submit_vote, refresh_poll;
|
||||
|
||||
Timer tmr;
|
||||
public View getView(){
|
||||
return itemView;
|
||||
}
|
||||
|
@ -1555,6 +1539,23 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On
|
|||
notification_status_content.invalidate();
|
||||
notification_account_username.invalidate();
|
||||
}
|
||||
|
||||
void startUpdateTimer() {
|
||||
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
|
||||
if( !disableAnimatedEmoji ){
|
||||
if( tmr == null){
|
||||
tmr = new Timer();
|
||||
}
|
||||
tmr.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
mHandler.post(updateAnimatedEmoji);
|
||||
}
|
||||
}, 0, 130);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -219,7 +219,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
private Status tootReply;
|
||||
private long currentToId = -1;
|
||||
private RecyclerView mRecyclerView;
|
||||
static Timer tmr;
|
||||
|
||||
private List<ViewHolder> lstHolders;
|
||||
private final Object lock = new Object();
|
||||
|
||||
|
@ -259,23 +259,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
mRecyclerView = null;
|
||||
}
|
||||
|
||||
private void startUpdateTimer() {
|
||||
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
|
||||
if( !disableAnimatedEmoji ){
|
||||
if( tmr == null){
|
||||
tmr = new Timer();
|
||||
}
|
||||
tmr.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
mHandler.post(updateAnimatedEmoji);
|
||||
}
|
||||
}, 0, 130);
|
||||
}
|
||||
}
|
||||
|
||||
public StatusListAdapter(RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){
|
||||
super();
|
||||
this.statuses = statuses;
|
||||
|
@ -710,6 +693,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
ImageView quick_reply_emoji;
|
||||
Button quick_reply_button;
|
||||
ImageView quick_reply_privacy;
|
||||
Timer tmr;
|
||||
|
||||
public View getView(){
|
||||
return itemView;
|
||||
|
@ -837,6 +821,25 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
status_content.invalidate();
|
||||
}
|
||||
|
||||
|
||||
private void startUpdateTimer() {
|
||||
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||
boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
|
||||
if( !disableAnimatedEmoji ){
|
||||
if( tmr == null){
|
||||
tmr = new Timer();
|
||||
}
|
||||
tmr.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
mHandler.post(updateAnimatedEmoji);
|
||||
}
|
||||
}, 0, 130);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Status getItem(int position){
|
||||
|
@ -867,7 +870,6 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
|
||||
context = parent.getContext();
|
||||
layoutInflater = LayoutInflater.from(this.context);
|
||||
startUpdateTimer();
|
||||
if( viewType == DISPLAYED_STATUS)
|
||||
return new ViewHolder(layoutInflater.inflate(R.layout.drawer_status, parent, false));
|
||||
else if(viewType == COMPACT_STATUS)
|
||||
|
@ -893,6 +895,9 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
synchronized (lock) {
|
||||
lstHolders.add(holder);
|
||||
}
|
||||
|
||||
|
||||
holder.startUpdateTimer();
|
||||
final Status status = statuses.get(i);
|
||||
if( status == null)
|
||||
return;
|
||||
|
|
|
@ -847,18 +847,12 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
*/
|
||||
public void refreshFilter(){
|
||||
|
||||
switch (instanceType) {
|
||||
case "MASTODON":
|
||||
case "MISSKEY":
|
||||
case "GNU":
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
case "PIXELFED":
|
||||
pixelfedListAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
case "ART":
|
||||
artListAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
if( statusListAdapter != null) {
|
||||
statusListAdapter.notifyDataSetChanged();
|
||||
}else if( pixelfedListAdapter != null) {
|
||||
pixelfedListAdapter.notifyDataSetChanged();
|
||||
}else if( artListAdapter != null){
|
||||
artListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue