Fixes last issues

This commit is contained in:
tom79 2017-08-25 15:30:35 +02:00
parent f89692411c
commit 69b6ec73f0
6 changed files with 14 additions and 22 deletions

View File

@ -809,7 +809,7 @@ public class MainActivity extends AppCompatActivity
handler.postDelayed(new Runnable() {
@Override
public void run() {refreshData();}
}, 500);
}, 1000);
}
//Proceeds to update of the authenticated account
if(Helper.isLoggedIn(getApplicationContext()))
@ -1011,9 +1011,9 @@ public class MainActivity extends AppCompatActivity
if( account != null){
String last_refresh = sharedpreferences.getString(Helper.LAST_BUBBLE_REFRESH_NOTIF + account.getId(), null);
Date last_refresh_date = Helper.stringToDate(getApplicationContext(), last_refresh);
if (last_refresh_date == null || (new Date().getTime() - last_refresh_date.getTime()) >= TimeUnit.SECONDS.toMillis(60)) {
if (last_refresh_date == null || (new Date().getTime() - last_refresh_date.getTime()) >= TimeUnit.SECONDS.toMillis(5)) {
if( notificationsFragment != null && notificationsFragment.isAdded()){
if( notificationsFragment != null ){
notificationsFragment.update();
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_BUBBLE_REFRESH_NOTIF+ account.getId(),Helper.dateToString(getApplicationContext(), new Date()));
@ -1023,9 +1023,8 @@ public class MainActivity extends AppCompatActivity
last_refresh = sharedpreferences.getString(Helper.LAST_BUBBLE_REFRESH_HOME + account.getId(), null);
last_refresh_date = Helper.stringToDate(getApplicationContext(), last_refresh);
if (last_refresh_date == null || (new Date().getTime() - last_refresh_date.getTime()) >= TimeUnit.SECONDS.toMillis(60)) {
if( homeFragment != null && homeFragment.isAdded()){
if (last_refresh_date == null || (new Date().getTime() - last_refresh_date.getTime()) >= TimeUnit.SECONDS.toMillis(5)) {
if( homeFragment != null ){
homeFragment.update();
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_BUBBLE_REFRESH_HOME+ account.getId(),Helper.dateToString(getApplicationContext(), new Date()));

View File

@ -239,11 +239,8 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
}
new_data.setVisibility(View.VISIBLE);
}
}
}
}
private void manageNotifications(List<Notification> notifications, String max_id){
@ -275,7 +272,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
if( currentAccount != null && firstLoad){
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + currentAccount.getId(), notifications.get(0).getId());
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + currentAccount.getId(), max_id);
editor.apply();
}
}

View File

@ -361,7 +361,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
Account currentAccount = new AccountDAO(context, db).getAccountByID(userId);
if( currentAccount != null && firstLoad){
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + currentAccount.getId(), statuses.get(0).getId());
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + currentAccount.getId(), max_id);
editor.apply();
}
}

View File

@ -32,7 +32,6 @@ import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.support.v7.widget.SwitchCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

View File

@ -154,11 +154,10 @@ public class HomeTimelineSyncJob extends Job implements OnRetrieveHomeTimelineSe
intent.putExtra(PREF_KEY_ID, userId);
long notif_id = Long.parseLong(userId);
final int notificationId = ((notif_id + 2) > 2147483647) ? (int) (2147483647 - notif_id - 2) : (int) (notif_id + 2);
if( apiResponse.getMax_id() != null) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, apiResponse.getMax_id());
editor.apply();
}
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_HOMETIMELINE_MAX_ID + userId, apiResponse.getMax_id());
editor.apply();
if( notificationUrl != null){
ImageLoader imageLoaderNoty = ImageLoader.getInstance();

View File

@ -257,11 +257,9 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications
}
}
if(apiResponse.getMax_id() != null) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, apiResponse.getMax_id());
editor.apply();
}
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, apiResponse.getMax_id());
editor.apply();
}