Last fixes.
This commit is contained in:
parent
19da8d42f1
commit
8916803f47
|
@ -41,7 +41,6 @@ import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
import android.support.v7.widget.SwitchCompat;
|
import android.support.v7.widget.SwitchCompat;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -155,11 +154,13 @@ public class MainActivity extends AppCompatActivity
|
||||||
if(notificationsFragment != null){
|
if(notificationsFragment != null){
|
||||||
Notification notification = b.getParcelable("data");
|
Notification notification = b.getParcelable("data");
|
||||||
notificationsFragment.refresh(notification);
|
notificationsFragment.refresh(notification);
|
||||||
|
countNewStatus++;
|
||||||
}
|
}
|
||||||
}else if(eventStreaming == StreamingService.EventStreaming.UPDATE){
|
}else if(eventStreaming == StreamingService.EventStreaming.UPDATE){
|
||||||
Status status = b.getParcelable("data");
|
Status status = b.getParcelable("data");
|
||||||
if( homeFragment != null){
|
if( homeFragment != null){
|
||||||
homeFragment.refresh(status);
|
homeFragment.refresh(status);
|
||||||
|
countNewNotifications++;
|
||||||
}
|
}
|
||||||
}else if(eventStreaming == StreamingService.EventStreaming.DELETE){
|
}else if(eventStreaming == StreamingService.EventStreaming.DELETE){
|
||||||
String id = b.getString("id");
|
String id = b.getString("id");
|
||||||
|
|
|
@ -79,6 +79,8 @@ import java.util.regex.Matcher;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMetaDataAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.RetrieveMetaDataAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
|
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
|
||||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
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.client.PatchBaseImageDownloader;
|
||||||
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
|
import fr.gouv.etalab.mastodon.fragments.DisplayAccountsFragment;
|
||||||
import fr.gouv.etalab.mastodon.fragments.DisplayFollowRequestSentFragment;
|
import fr.gouv.etalab.mastodon.fragments.DisplayFollowRequestSentFragment;
|
||||||
|
@ -134,6 +136,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
private static final int ERROR_DIALOG_REQUEST_CODE = 97;
|
private static final int ERROR_DIALOG_REQUEST_CODE = 97;
|
||||||
private BroadcastReceiver receive_data;
|
private BroadcastReceiver receive_data;
|
||||||
private boolean display_local, display_global;
|
private boolean display_local, display_global;
|
||||||
|
public static int countNewStatus = 0;
|
||||||
|
public static int countNewNotifications = 0;
|
||||||
|
|
||||||
public MainActivity() {
|
public MainActivity() {
|
||||||
}
|
}
|
||||||
|
@ -151,11 +155,15 @@ public class MainActivity extends AppCompatActivity
|
||||||
StreamingService.EventStreaming eventStreaming = (StreamingService.EventStreaming) intent.getSerializableExtra("eventStreaming");
|
StreamingService.EventStreaming eventStreaming = (StreamingService.EventStreaming) intent.getSerializableExtra("eventStreaming");
|
||||||
if( eventStreaming == StreamingService.EventStreaming.NOTIFICATION){
|
if( eventStreaming == StreamingService.EventStreaming.NOTIFICATION){
|
||||||
if(notificationsFragment != null){
|
if(notificationsFragment != null){
|
||||||
notificationsFragment.refresh();
|
Notification notification = b.getParcelable("data");
|
||||||
|
notificationsFragment.refresh(notification);
|
||||||
|
countNewStatus++;
|
||||||
}
|
}
|
||||||
}else if(eventStreaming == StreamingService.EventStreaming.UPDATE){
|
}else if(eventStreaming == StreamingService.EventStreaming.UPDATE){
|
||||||
|
Status status = b.getParcelable("data");
|
||||||
if( homeFragment != null){
|
if( homeFragment != null){
|
||||||
homeFragment.refresh();
|
homeFragment.refresh(status);
|
||||||
|
countNewNotifications++;
|
||||||
}
|
}
|
||||||
}else if(eventStreaming == StreamingService.EventStreaming.DELETE){
|
}else if(eventStreaming == StreamingService.EventStreaming.DELETE){
|
||||||
String id = b.getString("id");
|
String id = b.getString("id");
|
||||||
|
@ -261,6 +269,12 @@ public class MainActivity extends AppCompatActivity
|
||||||
tabLayout.addTab(tabPublic);
|
tabLayout.addTab(tabPublic);
|
||||||
|
|
||||||
viewPager = (ViewPager) findViewById(R.id.viewpager);
|
viewPager = (ViewPager) findViewById(R.id.viewpager);
|
||||||
|
int countPage = 2;
|
||||||
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_LOCAL, true))
|
||||||
|
countPage++;
|
||||||
|
if( sharedpreferences.getBoolean(Helper.SET_DISPLAY_GLOBAL, true))
|
||||||
|
countPage++;
|
||||||
|
viewPager.setOffscreenPageLimit(countPage);
|
||||||
main_app_container = (RelativeLayout) findViewById(R.id.main_app_container);
|
main_app_container = (RelativeLayout) findViewById(R.id.main_app_container);
|
||||||
PagerAdapter adapter = new PagerAdapter
|
PagerAdapter adapter = new PagerAdapter
|
||||||
(getSupportFragmentManager(), tabLayout.getTabCount());
|
(getSupportFragmentManager(), tabLayout.getTabCount());
|
||||||
|
@ -287,21 +301,10 @@ public class MainActivity extends AppCompatActivity
|
||||||
if( tab.getPosition() == 0) {
|
if( tab.getPosition() == 0) {
|
||||||
item = navigationView.getMenu().findItem(R.id.nav_home);
|
item = navigationView.getMenu().findItem(R.id.nav_home);
|
||||||
fragmentTag = "HOME_TIMELINE";
|
fragmentTag = "HOME_TIMELINE";
|
||||||
if (homeFragment != null && Helper.getUnreadToots(getApplicationContext(), null) > 0) {
|
|
||||||
homeFragment.refresh();
|
|
||||||
}
|
|
||||||
Helper.cacheStatusClear(getApplicationContext(), null);
|
|
||||||
updateHomeCounter();
|
|
||||||
}else if( tab.getPosition() == 1) {
|
}else if( tab.getPosition() == 1) {
|
||||||
fragmentTag = "NOTIFICATIONS";
|
fragmentTag = "NOTIFICATIONS";
|
||||||
item = navigationView.getMenu().findItem(R.id.nav_notification);
|
item = navigationView.getMenu().findItem(R.id.nav_notification);
|
||||||
if (notificationsFragment != null && Helper.getUnreadNotifications(getApplicationContext(), null) > 0) {
|
|
||||||
notificationsFragment.refresh();
|
|
||||||
}
|
|
||||||
Helper.cacheNotificationsClear(getApplicationContext(), null);
|
|
||||||
updateNotifCounter();
|
|
||||||
}else if( tab.getPosition() == 2 && display_local) {
|
}else if( tab.getPosition() == 2 && display_local) {
|
||||||
|
|
||||||
fragmentTag = "LOCAL_TIMELINE";
|
fragmentTag = "LOCAL_TIMELINE";
|
||||||
item = navigationView.getMenu().findItem(R.id.nav_local);
|
item = navigationView.getMenu().findItem(R.id.nav_local);
|
||||||
}else if( tab.getPosition() == 2 && !display_local) {
|
}else if( tab.getPosition() == 2 && !display_local) {
|
||||||
|
@ -347,10 +350,10 @@ public class MainActivity extends AppCompatActivity
|
||||||
switch (tab.getPosition()){
|
switch (tab.getPosition()){
|
||||||
case 0:
|
case 0:
|
||||||
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
DisplayStatusFragment displayStatusFragment = ((DisplayStatusFragment) fragment);
|
||||||
|
countNewStatus = 0;
|
||||||
|
updateHomeCounter();
|
||||||
if( displayStatusFragment != null )
|
if( displayStatusFragment != null )
|
||||||
displayStatusFragment.scrollToTop();
|
displayStatusFragment.scrollToTop();
|
||||||
Helper.cacheStatusClear(getApplicationContext(), null);
|
|
||||||
updateHomeCounter();
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -360,10 +363,10 @@ public class MainActivity extends AppCompatActivity
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
DisplayNotificationsFragment displayNotificationsFragment = ((DisplayNotificationsFragment) fragment);
|
||||||
|
countNewNotifications = 0;
|
||||||
|
updateNotifCounter();
|
||||||
if( displayNotificationsFragment != null )
|
if( displayNotificationsFragment != null )
|
||||||
displayNotificationsFragment.scrollToTop();
|
displayNotificationsFragment.scrollToTop();
|
||||||
Helper.cacheNotificationsClear(getApplicationContext(), null);
|
|
||||||
updateNotifCounter();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1208,8 +1211,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
if( tabHome == null)
|
if( tabHome == null)
|
||||||
return;
|
return;
|
||||||
TextView tabCounterHome = (TextView) tabHome.findViewById(R.id.tab_counter);
|
TextView tabCounterHome = (TextView) tabHome.findViewById(R.id.tab_counter);
|
||||||
tabCounterHome.setText(String.valueOf(Helper.getUnreadToots(getApplicationContext(), null)));
|
tabCounterHome.setText(String.valueOf(countNewStatus));
|
||||||
if( Helper.getUnreadToots(getApplicationContext(), null) > 0){
|
if( countNewStatus> 0){
|
||||||
//New data are available
|
//New data are available
|
||||||
//The fragment is not displayed, so the counter is displayed
|
//The fragment is not displayed, so the counter is displayed
|
||||||
tabCounterHome.setVisibility(View.VISIBLE);
|
tabCounterHome.setVisibility(View.VISIBLE);
|
||||||
|
@ -1226,8 +1229,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
if( tabNotif == null)
|
if( tabNotif == null)
|
||||||
return;
|
return;
|
||||||
TextView tabCounterNotif = (TextView) tabNotif.findViewById(R.id.tab_counter);
|
TextView tabCounterNotif = (TextView) tabNotif.findViewById(R.id.tab_counter);
|
||||||
tabCounterNotif.setText(String.valueOf(Helper.getUnreadNotifications(getApplicationContext(), null)));
|
tabCounterNotif.setText(String.valueOf(countNewNotifications));
|
||||||
if( Helper.getUnreadNotifications(getApplicationContext(), null) > 0){
|
if( countNewNotifications > 0){
|
||||||
tabCounterNotif.setVisibility(View.VISIBLE);
|
tabCounterNotif.setVisibility(View.VISIBLE);
|
||||||
}else {
|
}else {
|
||||||
tabCounterNotif.setVisibility(View.GONE);
|
tabCounterNotif.setVisibility(View.GONE);
|
||||||
|
|
Loading…
Reference in New Issue