diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-02-21 09:50:49 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-02-21 09:50:49 +0000 |
commit | 3d9d98467ac63efa980ef0592455fc6c10abfc27 (patch) | |
tree | 4521209ca84b1437061d538f88d96aa9393bc25c /app/src/main | |
parent | a54a3395f8d5c2b61905f4c0ae77c4b7d11b3a16 (diff) | |
download | infinity-for-reddit-3d9d98467ac63efa980ef0592455fc6c10abfc27.tar infinity-for-reddit-3d9d98467ac63efa980ef0592455fc6c10abfc27.tar.gz infinity-for-reddit-3d9d98467ac63efa980ef0592455fc6c10abfc27.tar.bz2 infinity-for-reddit-3d9d98467ac63efa980ef0592455fc6c10abfc27.tar.lz infinity-for-reddit-3d9d98467ac63efa980ef0592455fc6c10abfc27.tar.xz infinity-for-reddit-3d9d98467ac63efa980ef0592455fc6c10abfc27.tar.zst infinity-for-reddit-3d9d98467ac63efa980ef0592455fc6c10abfc27.zip |
Fix post card has empty space under vote buttons once again by upgrading google's material library. Add an Okhttp3 interceptor for debug usage.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java | 1 | ||||
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Okhttp3DebugInterceptor.java | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java index a3792492..8bdf0d5d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java @@ -79,6 +79,7 @@ class AppModule { OkHttpClient provideOkHttpClient(@Named("no_oauth") Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase) { OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder(); okHttpClientBuilder.authenticator(new AccessTokenAuthenticator(retrofit, accountRoomDatabase)); + //.addInterceptor(new Okhttp3DebugInterceptor(mApplication)); return okHttpClientBuilder.build(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Okhttp3DebugInterceptor.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Okhttp3DebugInterceptor.java new file mode 100644 index 00000000..3443fdc6 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Okhttp3DebugInterceptor.java @@ -0,0 +1,40 @@ +package ml.docilealligator.infinityforreddit; + +import android.app.Application; + +import androidx.annotation.NonNull; +import androidx.core.app.NotificationCompat; +import androidx.core.app.NotificationManagerCompat; + +import java.io.IOException; + +import okhttp3.Interceptor; +import okhttp3.Response; + +public class Okhttp3DebugInterceptor implements Interceptor { + private Application context; + + public Okhttp3DebugInterceptor(Application context) { + this.context = context; + } + + @NonNull + @Override + public Response intercept(Chain chain) throws IOException { + Response response = chain.proceed(chain.request()); + if (!response.isSuccessful()) { + String message = "No body"; + if (response.body() != null) { + message = response.body().string(); + } + NotificationManagerCompat notificationManager = NotificationUtils.getNotificationManager(context); + NotificationCompat.Builder builder = NotificationUtils.buildNotification(notificationManager, + context, "debug", message, Integer.toString(response.code()), + NotificationUtils.CHANNEL_ID_NEW_MESSAGES, + NotificationUtils.CHANNEL_NEW_MESSAGES, + NotificationUtils.getAccountGroupName("Debug")); + notificationManager.notify(9765, builder.build()); + } + return response; + } +} |