Loading app/src/main/java/app/fedilab/android/activities/CacheActivity.java +26 −19 Original line number Diff line number Diff line Loading @@ -70,8 +70,10 @@ public class CacheActivity extends BaseActivity { new Thread(() -> { List<BaseAccount> accounts = new Account(CacheActivity.this).getPushNotificationAccounts(); List<BaseAccount> accounts; cacheAccounts = new ArrayList<>(); try { accounts = new Account(CacheActivity.this).getAll(); for (BaseAccount baseAccount : accounts) { CacheAccount cacheAccount = new CacheAccount(); cacheAccount.account = baseAccount; Loading @@ -92,6 +94,11 @@ public class CacheActivity extends BaseActivity { } cacheAccounts.add(cacheAccount); } } catch (DBException e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { cacheAdapter = new CacheAdapter(cacheAccounts); Loading app/src/main/java/app/fedilab/android/client/entities/app/StatusCache.java +3 −3 Original line number Diff line number Diff line Loading @@ -759,7 +759,7 @@ public class StatusCache { Pagination pagination = new Pagination(); if (notificationList != null && notificationList.size() > 0) { //Status list is inverted, it happens for min_id due to ASC ordering if (notificationList.get(0).id.compareTo(notificationList.get(notificationList.size() - 1).id) < 0) { if (Helper.compareTo(notificationList.get(0).id, notificationList.get(notificationList.size() - 1).id) < 0) { Collections.reverse(notificationList); notifications.notifications = notificationList; } Loading @@ -783,7 +783,7 @@ public class StatusCache { Pagination pagination = new Pagination(); if (conversationList != null && conversationList.size() > 0) { //Status list is inverted, it happens for min_id due to ASC ordering if (conversationList.get(0).id.compareTo(conversationList.get(conversationList.size() - 1).id) < 0) { if (Helper.compareTo(conversationList.get(0).id, conversationList.get(conversationList.size() - 1).id) < 0) { Collections.reverse(conversationList); conversations.conversations = conversationList; } Loading @@ -806,7 +806,7 @@ public class StatusCache { Pagination pagination = new Pagination(); if (statusList != null && statusList.size() > 0) { //Status list is inverted, it happens for min_id due to ASC ordering if (statusList.get(0).id.compareTo(statusList.get(statusList.size() - 1).id) < 0) { if (Helper.compareTo(statusList.get(0).id, statusList.get(statusList.size() - 1).id) < 0) { Collections.reverse(statusList); statuses.statuses = statusList; } Loading app/src/main/java/app/fedilab/android/helper/Helper.java +9 −0 Original line number Diff line number Diff line Loading @@ -1882,6 +1882,15 @@ public class Helper { } } public static int compareTo(String value1, String value2) { try { long val1 = Long.parseLong(value1); long val2 = Long.parseLong(value2); return Long.compare(val1, val2); } catch (Exception e) { return value1.compareTo(value2); } } //Enum that described actions to replace inside a toot content public enum PatternType { Loading app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java +3 −3 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ public class NotificationsHelper { final List<Notification> notifications = new ArrayList<>(); int pos = 0; for (Notification notif : notificationsReceived) { if (max_id == null || notif.id.compareTo(max_id) > 0) { if (max_id == null || Helper.compareTo(notif.id, max_id) > 0) { notifications.add(pos, notif); pos++; } Loading Loading @@ -338,7 +338,7 @@ public class NotificationsHelper { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null); if (lastNotif == null || notification.id.compareTo(lastNotif) > 0) { if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) { SharedPreferences.Editor editor = prefs.edit(); since_ids.put(account.user_id + "@" + account.instance, lastNotif); editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id); Loading @@ -353,7 +353,7 @@ public class NotificationsHelper { @Override public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null); if (lastNotif == null || notification.id.compareTo(lastNotif) > 0) { if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) { SharedPreferences.Editor editor = prefs.edit(); editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id); editor.apply(); Loading app/src/main/java/app/fedilab/android/helper/ZoomOutPageTransformer.javadeleted 100644 → 0 +0 −44 Original line number Diff line number Diff line package app.fedilab.android.helper; import android.view.View; import androidx.viewpager2.widget.ViewPager2; public class ZoomOutPageTransformer implements ViewPager2.PageTransformer { private static final float MIN_SCALE = 0.85f; private static final float MIN_ALPHA = 0.5f; public void transformPage(View view, float position) { int pageWidth = view.getWidth(); int pageHeight = view.getHeight(); if (position < -1) { // [-Infinity,-1) // This page is way off-screen to the left. view.setAlpha(0f); } else if (position <= 1) { // [-1,1] // Modify the default slide transition to shrink the page as well float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); float vertMargin = pageHeight * (1 - scaleFactor) / 2; float horzMargin = pageWidth * (1 - scaleFactor) / 2; if (position < 0) { view.setTranslationX(horzMargin - vertMargin / 2); } else { view.setTranslationX(-horzMargin + vertMargin / 2); } // Scale the page down (between MIN_SCALE and 1) view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); // Fade the page relative to its size. view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA)); } else { // (1,+Infinity] // This page is way off-screen to the right. view.setAlpha(0f); } } } No newline at end of file Loading
app/src/main/java/app/fedilab/android/activities/CacheActivity.java +26 −19 Original line number Diff line number Diff line Loading @@ -70,8 +70,10 @@ public class CacheActivity extends BaseActivity { new Thread(() -> { List<BaseAccount> accounts = new Account(CacheActivity.this).getPushNotificationAccounts(); List<BaseAccount> accounts; cacheAccounts = new ArrayList<>(); try { accounts = new Account(CacheActivity.this).getAll(); for (BaseAccount baseAccount : accounts) { CacheAccount cacheAccount = new CacheAccount(); cacheAccount.account = baseAccount; Loading @@ -92,6 +94,11 @@ public class CacheActivity extends BaseActivity { } cacheAccounts.add(cacheAccount); } } catch (DBException e) { e.printStackTrace(); } Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { cacheAdapter = new CacheAdapter(cacheAccounts); Loading
app/src/main/java/app/fedilab/android/client/entities/app/StatusCache.java +3 −3 Original line number Diff line number Diff line Loading @@ -759,7 +759,7 @@ public class StatusCache { Pagination pagination = new Pagination(); if (notificationList != null && notificationList.size() > 0) { //Status list is inverted, it happens for min_id due to ASC ordering if (notificationList.get(0).id.compareTo(notificationList.get(notificationList.size() - 1).id) < 0) { if (Helper.compareTo(notificationList.get(0).id, notificationList.get(notificationList.size() - 1).id) < 0) { Collections.reverse(notificationList); notifications.notifications = notificationList; } Loading @@ -783,7 +783,7 @@ public class StatusCache { Pagination pagination = new Pagination(); if (conversationList != null && conversationList.size() > 0) { //Status list is inverted, it happens for min_id due to ASC ordering if (conversationList.get(0).id.compareTo(conversationList.get(conversationList.size() - 1).id) < 0) { if (Helper.compareTo(conversationList.get(0).id, conversationList.get(conversationList.size() - 1).id) < 0) { Collections.reverse(conversationList); conversations.conversations = conversationList; } Loading @@ -806,7 +806,7 @@ public class StatusCache { Pagination pagination = new Pagination(); if (statusList != null && statusList.size() > 0) { //Status list is inverted, it happens for min_id due to ASC ordering if (statusList.get(0).id.compareTo(statusList.get(statusList.size() - 1).id) < 0) { if (Helper.compareTo(statusList.get(0).id, statusList.get(statusList.size() - 1).id) < 0) { Collections.reverse(statusList); statuses.statuses = statusList; } Loading
app/src/main/java/app/fedilab/android/helper/Helper.java +9 −0 Original line number Diff line number Diff line Loading @@ -1882,6 +1882,15 @@ public class Helper { } } public static int compareTo(String value1, String value2) { try { long val1 = Long.parseLong(value1); long val2 = Long.parseLong(value2); return Long.compare(val1, val2); } catch (Exception e) { return value1.compareTo(value2); } } //Enum that described actions to replace inside a toot content public enum PatternType { Loading
app/src/main/java/app/fedilab/android/helper/NotificationsHelper.java +3 −3 Original line number Diff line number Diff line Loading @@ -161,7 +161,7 @@ public class NotificationsHelper { final List<Notification> notifications = new ArrayList<>(); int pos = 0; for (Notification notif : notificationsReceived) { if (max_id == null || notif.id.compareTo(max_id) > 0) { if (max_id == null || Helper.compareTo(notif.id, max_id) > 0) { notifications.add(pos, notif); pos++; } Loading Loading @@ -338,7 +338,7 @@ public class NotificationsHelper { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null); if (lastNotif == null || notification.id.compareTo(lastNotif) > 0) { if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) { SharedPreferences.Editor editor = prefs.edit(); since_ids.put(account.user_id + "@" + account.instance, lastNotif); editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id); Loading @@ -353,7 +353,7 @@ public class NotificationsHelper { @Override public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { String lastNotif = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, null); if (lastNotif == null || notification.id.compareTo(lastNotif) > 0) { if (lastNotif == null || Helper.compareTo(notification.id, lastNotif) > 0) { SharedPreferences.Editor editor = prefs.edit(); editor.putString(context.getString(R.string.LAST_NOTIFICATION_ID) + account.user_id + "@" + account.instance, notifications.get(0).id); editor.apply(); Loading
app/src/main/java/app/fedilab/android/helper/ZoomOutPageTransformer.javadeleted 100644 → 0 +0 −44 Original line number Diff line number Diff line package app.fedilab.android.helper; import android.view.View; import androidx.viewpager2.widget.ViewPager2; public class ZoomOutPageTransformer implements ViewPager2.PageTransformer { private static final float MIN_SCALE = 0.85f; private static final float MIN_ALPHA = 0.5f; public void transformPage(View view, float position) { int pageWidth = view.getWidth(); int pageHeight = view.getHeight(); if (position < -1) { // [-Infinity,-1) // This page is way off-screen to the left. view.setAlpha(0f); } else if (position <= 1) { // [-1,1] // Modify the default slide transition to shrink the page as well float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); float vertMargin = pageHeight * (1 - scaleFactor) / 2; float horzMargin = pageWidth * (1 - scaleFactor) / 2; if (position < 0) { view.setTranslationX(horzMargin - vertMargin / 2); } else { view.setTranslationX(-horzMargin + vertMargin / 2); } // Scale the page down (between MIN_SCALE and 1) view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); // Fade the page relative to its size. view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA)); } else { // (1,+Infinity] // This page is way off-screen to the right. view.setAlpha(0f); } } } No newline at end of file