mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
Merge pull request 'Use an OkHttpClient with User-Agent when initializing BigImageViewer' (#185) from tinsukE/Eternity:glide_user_agent into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/185 Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
This commit is contained in:
commit
9406f29562
@ -10,9 +10,9 @@ import javax.inject.Singleton;
|
|||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
||||||
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
|
||||||
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
||||||
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
|
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import okhttp3.ConnectionPool;
|
import okhttp3.ConnectionPool;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
@ -34,6 +34,19 @@ abstract class NetworkModule {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("glide")
|
||||||
|
@Singleton
|
||||||
|
static OkHttpClient provideGlideOkHttp(@Named("base") OkHttpClient baseOkHttp) {
|
||||||
|
return baseOkHttp.newBuilder()
|
||||||
|
.addInterceptor(chain -> chain.proceed(
|
||||||
|
chain.request()
|
||||||
|
.newBuilder()
|
||||||
|
.header("User-Agent", APIUtils.USER_AGENT)
|
||||||
|
.build()
|
||||||
|
))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Named("base")
|
@Named("base")
|
||||||
|
@ -78,6 +78,7 @@ import eu.toldi.infinityforlemmy.font.TitleFontStyle;
|
|||||||
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
|
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
|
public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
|
||||||
|
|
||||||
@ -108,6 +109,9 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("glide")
|
||||||
|
OkHttpClient okHttpClient;
|
||||||
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
private boolean isActionBarHidden = false;
|
private boolean isActionBarHidden = false;
|
||||||
private boolean isDownloading = false;
|
private boolean isDownloading = false;
|
||||||
@ -146,7 +150,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
|
|||||||
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
|
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
|
||||||
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
|
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
|
||||||
|
|
||||||
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext()));
|
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext(), okHttpClient));
|
||||||
|
|
||||||
setContentView(R.layout.activity_view_image_or_gif);
|
setContentView(R.layout.activity_view_image_or_gif);
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@ import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
|||||||
import eu.toldi.infinityforlemmy.readpost.ReadPost;
|
import eu.toldi.infinityforlemmy.readpost.ReadPost;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -147,6 +148,9 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
@Inject
|
||||||
|
@Named("glide")
|
||||||
|
OkHttpClient okHttpClient;
|
||||||
@State
|
@State
|
||||||
ArrayList<Post> posts;
|
ArrayList<Post> posts;
|
||||||
@State
|
@State
|
||||||
@ -195,7 +199,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext()));
|
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext(), okHttpClient));
|
||||||
|
|
||||||
setContentView(R.layout.activity_view_post_detail);
|
setContentView(R.layout.activity_view_post_detail);
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ import java.io.File;
|
|||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -69,6 +70,7 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment
|
|||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
|
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
||||||
|
|
||||||
@ -105,6 +107,9 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
|||||||
ImageView wallpaperImageView;
|
ImageView wallpaperImageView;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
@Inject
|
||||||
|
@Named("glide")
|
||||||
|
OkHttpClient okHttpClient;
|
||||||
|
|
||||||
private ViewRedditGalleryActivity activity;
|
private ViewRedditGalleryActivity activity;
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
@ -122,7 +127,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
BigImageViewer.initialize(GlideImageLoader.with(activity.getApplicationContext()));
|
BigImageViewer.initialize(GlideImageLoader.with(activity.getApplicationContext(), okHttpClient));
|
||||||
|
|
||||||
View rootView = inflater.inflate(R.layout.fragment_view_reddit_gallery_image_or_gif, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_view_reddit_gallery_image_or_gif, container, false);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user