diff --git a/mastodon/build.gradle b/mastodon/build.gradle index ec05e528..8068c52b 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -90,7 +90,7 @@ dependencies { implementation 'me.grishka.litex:viewpager:1.0.0' implementation 'me.grishka.litex:viewpager2:1.0.0' implementation 'me.grishka.litex:palette:1.0.0' - implementation 'me.grishka.appkit:appkit:1.3.0' + implementation 'me.grishka.appkit:appkit:1.4.0' implementation 'com.google.code.gson:gson:2.8.9' implementation 'org.jsoup:jsoup:1.14.3' implementation 'com.squareup:otto:1.3.8' diff --git a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java index d7d18c3d..424a284b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java +++ b/mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java @@ -36,6 +36,8 @@ import java.util.stream.Collectors; import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.imageloader.ImageCache; +import me.grishka.appkit.imageloader.ImageLoaderCallback; +import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest; import me.grishka.appkit.utils.V; @@ -103,6 +105,24 @@ public class PushNotificationReceiver extends BroadcastReceiver{ } private void notify(Context context, PushNotification pn, String accountID, org.joinmastodon.android.model.Notification notification){ + if(TextUtils.isEmpty(pn.icon)){ + doNotify(context, pn, accountID, notification, null); + }else{ + ImageCache.getInstance(context).get(new UrlImageLoaderRequest(pn.icon, V.dp(50), V.dp(50)), null, new ImageLoaderCallback(){ + @Override + public void onImageLoaded(ImageLoaderRequest req, Drawable image){ + doNotify(context, pn, accountID, notification, image); + } + + @Override + public void onImageLoadingFailed(ImageLoaderRequest req, Throwable error){ + doNotify(context, pn, accountID, notification, null); + } + }, true); + } + } + + private void doNotify(Context context, PushNotification pn, String accountID, org.joinmastodon.android.model.Notification notification, Drawable avatar){ NotificationManager nm=context.getSystemService(NotificationManager.class); Account self=AccountSessionManager.getInstance().getAccount(accountID).self; String accountName="@"+self.username+"@"+AccountSessionManager.getInstance().getAccount(accountID).domain; @@ -136,7 +156,6 @@ public class PushNotificationReceiver extends BroadcastReceiver{ .setPriority(Notification.PRIORITY_DEFAULT) .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); } - Drawable avatar=ImageCache.getInstance(context).get(new UrlImageLoaderRequest(pn.icon, V.dp(50), V.dp(50))); Intent contentIntent=new Intent(context, MainActivity.class); contentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); contentIntent.putExtra("fromNotification", true); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileAboutFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileAboutFragment.java index a5678804..e3fe3433 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileAboutFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileAboutFragment.java @@ -36,7 +36,6 @@ import me.grishka.appkit.fragments.WindowInsetsAwareFragment; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.ListImageLoaderWrapper; -import me.grishka.appkit.imageloader.RecyclerViewDelegate; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; import me.grishka.appkit.utils.BindableViewHolder; import me.grishka.appkit.utils.CubicBezierInterpolator; @@ -72,7 +71,7 @@ public class ProfileAboutFragment extends Fragment implements WindowInsetsAwareF list.setItemAnimator(new BetterItemAnimator()); list.setDrawSelectorOnTop(true); list.setLayoutManager(new LinearLayoutManager(getActivity())); - imgLoader=new ListImageLoaderWrapper(getActivity(), list, new RecyclerViewDelegate(list), null); + imgLoader=new ListImageLoaderWrapper(getActivity(), list, list, null); list.setAdapter(adapter=new AboutAdapter()); list.setPadding(0, V.dp(16), 0, 0); list.setClipToPadding(false); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/CustomEmojiPopupKeyboard.java b/mastodon/src/main/java/org/joinmastodon/android/ui/CustomEmojiPopupKeyboard.java index 9d1fcb7b..8bb38919 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/CustomEmojiPopupKeyboard.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/CustomEmojiPopupKeyboard.java @@ -36,7 +36,6 @@ import androidx.recyclerview.widget.RecyclerView; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.ListImageLoaderWrapper; -import me.grishka.appkit.imageloader.RecyclerViewDelegate; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest; import me.grishka.appkit.utils.BindableViewHolder; @@ -82,7 +81,7 @@ public class CustomEmojiPopupKeyboard extends PopupKeyboard{ }); list.setLayoutManager(lm); list.setPadding(V.dp(16), 0, V.dp(16), 0); - imgLoader=new ListImageLoaderWrapper(activity, list, new RecyclerViewDelegate(list), null); + imgLoader=new ListImageLoaderWrapper(activity, list, list, null); for(EmojiCategory category:emojis) adapter.addAdapter(new SingleCategoryAdapter(category)); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/AccountSwitcherSheet.java b/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/AccountSwitcherSheet.java index df176cde..3105c4ca 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/AccountSwitcherSheet.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/sheets/AccountSwitcherSheet.java @@ -44,7 +44,6 @@ import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.ListImageLoaderWrapper; -import me.grishka.appkit.imageloader.RecyclerViewDelegate; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest; import me.grishka.appkit.utils.BindableViewHolder; @@ -70,7 +69,7 @@ public class AccountSwitcherSheet extends BottomSheet{ accounts=AccountSessionManager.getInstance().getLoggedInAccounts().stream().map(WrappedAccount::new).collect(Collectors.toList()); list=new UsableRecyclerView(activity); - imgLoader=new ListImageLoaderWrapper(activity, list, new RecyclerViewDelegate(list), null); + imgLoader=new ListImageLoaderWrapper(activity, list, list, null); list.setClipToPadding(false); list.setLayoutManager(new LinearLayoutManager(activity)); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 1ee8af26..e064780b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -355,7 +355,7 @@ public class UiUtils{ public View getView(){ return view; } - }, null, new UrlImageLoaderRequest(emoji.getKey().url, emojiSize, emojiSize), null, false, true); + }, null, new UrlImageLoaderRequest(emoji.getKey().url, emojiSize, emojiSize), false, true); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java index 52fa556b..3afb1859 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeAutocompleteViewController.java @@ -40,7 +40,6 @@ import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.ListImageLoaderWrapper; -import me.grishka.appkit.imageloader.RecyclerViewDelegate; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; import me.grishka.appkit.imageloader.requests.UrlImageLoaderRequest; import me.grishka.appkit.utils.BindableViewHolder; @@ -123,7 +122,7 @@ public class ComposeAutocompleteViewController{ } }); - imgLoader=new ListImageLoaderWrapper(activity, list, new RecyclerViewDelegate(list), null); + imgLoader=new ListImageLoaderWrapper(activity, list, list, null); } public void setText(String text){