Improves unread toots/notifications - 2
This commit is contained in:
parent
418c79e64a
commit
83c9a6c22b
|
@ -37,7 +37,6 @@ import android.support.v4.view.ViewPager;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.support.design.widget.NavigationView;
|
||||
|
@ -61,7 +60,6 @@ import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
|||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
|
||||
import com.nostra13.universalimageloader.utils.L;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -72,8 +70,6 @@ import java.util.Stack;
|
|||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMetaDataAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
|
||||
import fr.gouv.etalab.mastodon.fragments.DisplayFollowRequestSentFragment;
|
||||
|
@ -144,22 +140,19 @@ public class MainActivity extends AppCompatActivity
|
|||
Bundle b = intent.getExtras();
|
||||
StreamingService.EventStreaming eventStreaming = (StreamingService.EventStreaming) intent.getSerializableExtra("eventStreaming");
|
||||
if( eventStreaming == StreamingService.EventStreaming.NOTIFICATION){
|
||||
Notification notification = b.getParcelable("data");
|
||||
if(notificationsFragment != null){
|
||||
if(notificationsFragment.getUserVisibleHint() && isActivityVisible()){
|
||||
|
||||
notificationsFragment.updateData(notification);
|
||||
notificationsFragment.showNewContent();
|
||||
}else{
|
||||
notificationsFragment.refresh(notification);
|
||||
notificationsFragment.refresh();
|
||||
}
|
||||
}
|
||||
}else if(eventStreaming == StreamingService.EventStreaming.UPDATE){
|
||||
Status status = b.getParcelable("data");
|
||||
if( homeFragment != null){
|
||||
if(homeFragment.getUserVisibleHint() && isActivityVisible()){
|
||||
homeFragment.updateData(status);
|
||||
homeFragment.showNewContent();
|
||||
}else{
|
||||
homeFragment.refresh(status);
|
||||
homeFragment.refresh();
|
||||
}
|
||||
}
|
||||
}else if(eventStreaming == StreamingService.EventStreaming.DELETE){
|
||||
|
@ -281,7 +274,7 @@ public class MainActivity extends AppCompatActivity
|
|||
item = navigationView.getMenu().findItem(R.id.nav_home);
|
||||
fragmentTag = "HOME_TIMELINE";
|
||||
if (homeFragment != null && Helper.getUnreadToots(getApplicationContext(), null) > 0) {
|
||||
homeFragment.refresh(null);
|
||||
homeFragment.refresh();
|
||||
}
|
||||
Helper.clearUnreadToots(getApplicationContext(), null);
|
||||
updateHomeCounter();
|
||||
|
@ -289,7 +282,7 @@ public class MainActivity extends AppCompatActivity
|
|||
fragmentTag = "NOTIFICATIONS";
|
||||
item = navigationView.getMenu().findItem(R.id.nav_notification);
|
||||
if (notificationsFragment != null && Helper.getUnreadNotifications(getApplicationContext(), null) > 0) {
|
||||
notificationsFragment.refresh(null);
|
||||
notificationsFragment.refresh();
|
||||
}
|
||||
Helper.clearUnreadNotifications(getApplicationContext(), null);
|
||||
updateNotifCounter();
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -134,13 +133,13 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
new_data.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
notificationsTmp = Helper.getTempNotification(context, null);
|
||||
if( notificationsTmp != null){
|
||||
for(int i = notificationsTmp.size() -1 ; i >= 0 ; i--){
|
||||
notifications.add(0,notificationsTmp.get(i));
|
||||
}
|
||||
boolean isOnWifi = Helper.isOnWIFI(context);
|
||||
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||
notifications = new ArrayList<>();
|
||||
for(Notification notification: notificationsTmp){
|
||||
notifications.add(notification);
|
||||
}
|
||||
notificationsListAdapter = new NotificationsListAdapter(context,isOnWifi, behaviorWithAttachments, notifications);
|
||||
lv_notifications.setAdapter(notificationsListAdapter);
|
||||
if( notificationsTmp.size() > 0){
|
||||
|
@ -245,45 +244,19 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
}
|
||||
|
||||
|
||||
public void updateData(Notification notification){
|
||||
if( notificationsTmp != null && notificationsTmp.size() > 0){
|
||||
notificationsTmp.add(0,notification);
|
||||
}else {
|
||||
notificationsTmp = new ArrayList<>();
|
||||
for(Notification notificationTmp: this.notifications){
|
||||
notificationsTmp.add(notificationTmp);
|
||||
}
|
||||
notificationsTmp.add(0,notification);
|
||||
}
|
||||
public void showNewContent(){
|
||||
new_data.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void refresh(Notification notification){
|
||||
if( notification != null){
|
||||
if( notificationsTmp != null && notificationsTmp.size() > 0){
|
||||
notificationsTmp.add(0,notification);
|
||||
}else {
|
||||
notificationsTmp = new ArrayList<>();
|
||||
for(Notification notificationTmp: this.notifications){
|
||||
notificationsTmp.add(notificationTmp);
|
||||
}
|
||||
notificationsTmp.add(0,notification);
|
||||
}
|
||||
}else{
|
||||
notificationsTmp = new ArrayList<>();
|
||||
for(Notification notificationTmp: this.notifications){
|
||||
notificationsTmp.add(notificationTmp);
|
||||
}
|
||||
}
|
||||
public void refresh(){
|
||||
notificationsTmp = Helper.getTempNotification(context, null);
|
||||
if( notificationsTmp.size() > 0){
|
||||
for(int i = notificationsTmp.size() -1 ; i >= 0 ; i--){
|
||||
this.notifications.add(0,notificationsTmp.get(i));
|
||||
}
|
||||
boolean isOnWifi = Helper.isOnWIFI(context);
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||
notifications = new ArrayList<>();
|
||||
for(Notification not_tmp: notificationsTmp){
|
||||
notifications.add(not_tmp);
|
||||
}
|
||||
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notificationsTmp.get(0).getId());
|
||||
|
@ -292,8 +265,8 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
|||
lv_notifications.setAdapter(notificationsListAdapter);
|
||||
if( textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
Helper.cacheNotificationsClear(context, null);
|
||||
}
|
||||
new_data.setVisibility(View.GONE);
|
||||
notificationsTmp = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -218,13 +217,15 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
new_data.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
statusesTmp = Helper.getTempStatus(context, null);
|
||||
if( statusesTmp != null){
|
||||
for(int i = statusesTmp.size() -1 ; i >= 0 ; i--){
|
||||
statuses.add(0,statusesTmp.get(i));
|
||||
}
|
||||
boolean isOnWifi = Helper.isOnWIFI(context);
|
||||
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||
statuses = new ArrayList<>();
|
||||
for(Status status: statusesTmp){
|
||||
statuses.add(status);
|
||||
}
|
||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
if( statusesTmp.size() > 0){
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
|
@ -233,12 +234,11 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
if( statusesTmp.size() > 0 && textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
statusesTmp = new ArrayList<>();
|
||||
}
|
||||
Helper.clearUnreadToots(context, null);
|
||||
new_data.setVisibility(View.GONE);
|
||||
statusesTmp = new ArrayList<>();
|
||||
Helper.clearUnreadToots(context, null);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -353,53 +353,28 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
}
|
||||
}
|
||||
|
||||
public void updateData(Status status){
|
||||
if( statusesTmp != null && statusesTmp.size() > 0){
|
||||
statusesTmp.add(0,status);
|
||||
}else {
|
||||
statusesTmp = new ArrayList<>();
|
||||
for(Status statusTmp: this.statuses){
|
||||
statusesTmp.add(statusTmp);
|
||||
}
|
||||
statusesTmp.add(0,status);
|
||||
}
|
||||
public void showNewContent(){
|
||||
new_data.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void refresh(Status status){
|
||||
if( status != null){
|
||||
if( statusesTmp != null && statusesTmp.size() > 0){
|
||||
statusesTmp.add(0,status);
|
||||
}else {
|
||||
statusesTmp = new ArrayList<>();
|
||||
for(Status statusTmp: this.statuses){
|
||||
statusesTmp.add(statusTmp);
|
||||
}
|
||||
statusesTmp.add(0,status);
|
||||
public void refresh(){
|
||||
statusesTmp = Helper.getTempStatus(context, null);
|
||||
if( statusesTmp.size() > 0){
|
||||
for(int i = statusesTmp.size() -1 ; i >= 0 ; i--){
|
||||
this.statuses.add(0,statusesTmp.get(i));
|
||||
}
|
||||
}else {
|
||||
statusesTmp = new ArrayList<>();
|
||||
for(Status statusTmp: this.statuses){
|
||||
statusesTmp.add(statusTmp);
|
||||
}
|
||||
}
|
||||
if( statusesTmp != null && statusesTmp.size() > 0){
|
||||
boolean isOnWifi = Helper.isOnWIFI(context);
|
||||
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
|
||||
statuses = new ArrayList<>();
|
||||
for(Status st_tmp: statusesTmp){
|
||||
statuses.add(st_tmp);
|
||||
}
|
||||
if( textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, statusesTmp.get(0).getId());
|
||||
editor.apply();
|
||||
statusListAdapter = new StatusListAdapter(context, type, targetedId, isOnWifi, behaviorWithAttachments, positionSpinnerTrans, statuses);
|
||||
lv_status.setAdapter(statusListAdapter);
|
||||
statusesTmp = new ArrayList<>();
|
||||
if( textviewNoAction.getVisibility() == View.VISIBLE)
|
||||
textviewNoAction.setVisibility(View.GONE);
|
||||
Helper.cacheStatusClear(context, null);
|
||||
}
|
||||
new_data.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ import fr.gouv.etalab.mastodon.asynctasks.RemoveAccountAsyncTask;
|
|||
import fr.gouv.etalab.mastodon.client.API;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Mention;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Notification;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Status;
|
||||
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
|
||||
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
|
||||
|
@ -209,8 +210,8 @@ public class Helper {
|
|||
public static final String SET_LED_COLOUR = "set_led_colour";
|
||||
private static final String SET_UNREAD_NOTIFICATIONS = "set_unread_notifications";
|
||||
private static final String SET_UNREAD_TOOTS = "set_unread_toots";
|
||||
private static final String SET_DEVELOPERS = "set_developers";
|
||||
private static final String SET_DEVELOPERS_CACHE_DATE = "set_developers_cache_date";
|
||||
private static final String SET_TEMP_STATUS = "set_temp_status";
|
||||
private static final String SET_TEMP_NOTIFICATIONS = "set_temp_notifications";
|
||||
|
||||
public static final int ATTACHMENT_ALWAYS = 1;
|
||||
public static final int ATTACHMENT_WIFI = 2;
|
||||
|
@ -1686,22 +1687,79 @@ public class Helper {
|
|||
"https://social.tchncs.de/@angrytux"
|
||||
};
|
||||
|
||||
public static void cacheDevelopers(Context context, ArrayList<Account> accounts){
|
||||
public static void cacheStatus(Context context, Status status, String userId){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if( userId == null)
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
ArrayList<Status> statuses = getTempStatus(context, userId);
|
||||
if( statuses == null)
|
||||
statuses = new ArrayList<>();
|
||||
if( status != null)
|
||||
statuses.add(0,status);
|
||||
Gson gson = new Gson();
|
||||
String serializedAccounts = gson.toJson(accounts);
|
||||
editor.putString(Helper.SET_DEVELOPERS, serializedAccounts);
|
||||
editor.putString(Helper.SET_DEVELOPERS_CACHE_DATE, dateToString(context, new Date()));
|
||||
String serializedAccounts = gson.toJson(statuses);
|
||||
editor.putString(Helper.SET_TEMP_STATUS + userId, serializedAccounts);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<Account> getDevelopers(Context context){
|
||||
public static void cacheStatusClear(Context context, String userId){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if( userId == null)
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
ArrayList<Status> statuses = new ArrayList<>();
|
||||
Gson gson = new Gson();
|
||||
String json = sharedpreferences.getString(Helper.SET_DEVELOPERS, null);
|
||||
Type type = new TypeToken<ArrayList<Account>>() {}.getType();
|
||||
String serializedAccounts = gson.toJson(statuses);
|
||||
editor.putString(Helper.SET_TEMP_STATUS + userId, serializedAccounts);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static ArrayList<Status> getTempStatus(Context context, String userId){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if( userId == null)
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Gson gson = new Gson();
|
||||
String json = sharedpreferences.getString(Helper.SET_TEMP_STATUS + userId, null);
|
||||
Type type = new TypeToken<ArrayList<Status>>() {}.getType();
|
||||
return gson.fromJson(json, type);
|
||||
}
|
||||
|
||||
public static void cacheNotifications(Context context, Notification notification, String userId){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if( userId == null)
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
ArrayList<Notification> notifications = getTempNotification(context, userId);
|
||||
if( notifications == null)
|
||||
notifications = new ArrayList<>();
|
||||
if( notification != null)
|
||||
notifications.add(0,notification);
|
||||
Gson gson = new Gson();
|
||||
String serializedAccounts = gson.toJson(notifications);
|
||||
editor.putString(Helper.SET_TEMP_NOTIFICATIONS + userId, serializedAccounts);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void cacheNotificationsClear(Context context, String userId){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if( userId == null)
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
ArrayList<Notification> notifications = new ArrayList<>();
|
||||
Gson gson = new Gson();
|
||||
String serializedAccounts = gson.toJson(notifications);
|
||||
editor.putString(Helper.SET_TEMP_NOTIFICATIONS + userId, serializedAccounts);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static ArrayList<Notification> getTempNotification(Context context, String userId){
|
||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
if( userId == null)
|
||||
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
|
||||
Gson gson = new Gson();
|
||||
String json = sharedpreferences.getString(Helper.SET_TEMP_NOTIFICATIONS + userId, null);
|
||||
Type type = new TypeToken<ArrayList<Notification>>() {}.getType();
|
||||
return gson.fromJson(json, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import android.os.SystemClock;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
|
||||
|
@ -311,8 +310,6 @@ public class StreamingService extends Service {
|
|||
public void onRetrieveStreaming(EventStreaming event, JSONObject response, String acct, String userId) {
|
||||
if( response == null )
|
||||
return;
|
||||
String max_id_notif = null;
|
||||
String max_id_home = null;
|
||||
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||
boolean notif_follow = sharedpreferences.getBoolean(Helper.SET_NOTIF_FOLLOW, true);
|
||||
boolean notif_add = sharedpreferences.getBoolean(Helper.SET_NOTIF_ADD, true);
|
||||
|
@ -374,6 +371,7 @@ public class StreamingService extends Service {
|
|||
break;
|
||||
}
|
||||
Helper.increaseUnreadNotifications(getApplicationContext(), userId);
|
||||
Helper.cacheNotifications(getApplicationContext(), notification, userId);
|
||||
if( notification.getStatus().getContent()!= null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = Html.fromHtml(notification.getStatus().getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
|
@ -391,6 +389,7 @@ public class StreamingService extends Service {
|
|||
status.setReplies(new ArrayList<Status>()); //Force to don't display replies.
|
||||
|
||||
Helper.increaseUnreadToots(getApplicationContext(), userId);
|
||||
Helper.cacheStatus(getApplicationContext(), status, userId);
|
||||
if( status.getContent() != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = Html.fromHtml(status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
|
||||
|
|
|
@ -143,21 +143,19 @@ public class MainActivity extends AppCompatActivity
|
|||
Bundle b = intent.getExtras();
|
||||
StreamingService.EventStreaming eventStreaming = (StreamingService.EventStreaming) intent.getSerializableExtra("eventStreaming");
|
||||
if( eventStreaming == StreamingService.EventStreaming.NOTIFICATION){
|
||||
Notification notification = b.getParcelable("data");
|
||||
if(notificationsFragment != null){
|
||||
if(notificationsFragment.getUserVisibleHint() && isActivityVisible()){
|
||||
notificationsFragment.updateData(notification);
|
||||
notificationsFragment.showNewContent();
|
||||
}else{
|
||||
notificationsFragment.refresh(notification);
|
||||
notificationsFragment.refresh();
|
||||
}
|
||||
}
|
||||
}else if(eventStreaming == StreamingService.EventStreaming.UPDATE){
|
||||
Status status = b.getParcelable("data");
|
||||
if( homeFragment != null){
|
||||
if(homeFragment.getUserVisibleHint() && isActivityVisible()){
|
||||
homeFragment.updateData(status);
|
||||
homeFragment.showNewContent();
|
||||
}else{
|
||||
homeFragment.refresh(status);
|
||||
homeFragment.refresh();
|
||||
}
|
||||
}
|
||||
}else if(eventStreaming == StreamingService.EventStreaming.DELETE){
|
||||
|
@ -282,7 +280,7 @@ public class MainActivity extends AppCompatActivity
|
|||
item = navigationView.getMenu().findItem(R.id.nav_home);
|
||||
fragmentTag = "HOME_TIMELINE";
|
||||
if (homeFragment != null && Helper.getUnreadToots(getApplicationContext(), null) > 0) {
|
||||
homeFragment.refresh(null);
|
||||
homeFragment.refresh();
|
||||
}
|
||||
Helper.clearUnreadToots(getApplicationContext(), null);
|
||||
updateHomeCounter();
|
||||
|
@ -290,7 +288,7 @@ public class MainActivity extends AppCompatActivity
|
|||
fragmentTag = "NOTIFICATIONS";
|
||||
item = navigationView.getMenu().findItem(R.id.nav_notification);
|
||||
if (notificationsFragment != null && Helper.getUnreadNotifications(getApplicationContext(), null) > 0) {
|
||||
notificationsFragment.refresh(null);
|
||||
notificationsFragment.refresh();
|
||||
}
|
||||
Helper.clearUnreadNotifications(getApplicationContext(), null);
|
||||
updateNotifCounter();
|
||||
|
|
Loading…
Reference in New Issue