Skip to content

Commit ca855cb

Browse files
Migrate to Coil 3
1 parent 6a98b1d commit ca855cb

22 files changed

Lines changed: 346 additions & 309 deletions

File tree

app/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ ext {
124124

125125
leakCanaryVersion = '2.12'
126126
stethoVersion = '1.6.0'
127+
128+
coilVersion = '3.0.3'
127129
}
128130

129131
configurations {
@@ -207,7 +209,7 @@ dependencies {
207209
// This works thanks to JitPack: https://jitpack.io/
208210
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
209211
// WORKAROUND: v0.24.2 can't be resolved by jitpack -> use git commit hash instead
210-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:176da72cb4c3ec4679211339b0e59f6b01bf2f52'
212+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:d3d5f2b3f03a5f2b479b9f6fdf1c2555cbb9de0e'
211213
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
212214

213215
/** Checkstyle **/
@@ -272,7 +274,8 @@ dependencies {
272274
implementation "com.github.lisawray.groupie:groupie-viewbinding:${groupieVersion}"
273275

274276
// Image loading
275-
implementation 'io.coil-kt:coil-compose:2.7.0'
277+
implementation "io.coil-kt.coil3:coil-compose:${coilVersion}"
278+
implementation "io.coil-kt.coil3:coil-network-okhttp:${coilVersion}"
276279

277280
// Markdown library for Android
278281
implementation "io.noties.markwon:core:${markwonVersion}"

app/src/main/java/org/schabi/newpipe/App.kt

Lines changed: 205 additions & 211 deletions
Large diffs are not rendered by default.

app/src/main/java/org/schabi/newpipe/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected void onCreate(final Bundle savedInstanceState) {
166166
NotificationWorker.initialize(this);
167167
}
168168
if (!UpdateSettingsFragment.wasUserAskedForConsent(this)
169-
&& !App.getApp().isFirstRun()
169+
&& !App.getInstance().isFirstRun()
170170
&& ReleaseVersionUtil.INSTANCE.isReleaseApk()) {
171171
UpdateSettingsFragment.askForConsentToUpdateChecks(this);
172172
}
@@ -176,7 +176,7 @@ protected void onCreate(final Bundle savedInstanceState) {
176176
protected void onPostCreate(final Bundle savedInstanceState) {
177177
super.onPostCreate(savedInstanceState);
178178

179-
final App app = App.getApp();
179+
final App app = App.getInstance();
180180
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(app);
181181

182182
if (prefs.getBoolean(app.getString(R.string.update_app_key), false)

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
import java.util.concurrent.TimeUnit;
128128
import java.util.function.Consumer;
129129

130-
import coil.util.CoilUtils;
130+
import coil3.util.CoilUtils;
131131
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
132132
import io.reactivex.rxjava3.disposables.CompositeDisposable;
133133
import io.reactivex.rxjava3.disposables.Disposable;

app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
import java.util.Queue;
6161
import java.util.concurrent.TimeUnit;
6262

63-
import coil.util.CoilUtils;
63+
import coil3.util.CoilUtils;
6464
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
6565
import io.reactivex.rxjava3.core.Observable;
6666
import io.reactivex.rxjava3.disposables.CompositeDisposable;

app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
import java.util.function.Supplier;
6363
import java.util.stream.Collectors;
6464

65-
import coil.util.CoilUtils;
65+
import coil3.util.CoilUtils;
6666
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
6767
import io.reactivex.rxjava3.core.Flowable;
6868
import io.reactivex.rxjava3.core.Single;

app/src/main/java/org/schabi/newpipe/info_list/dialog/InfoItemDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public InfoItemDialog create() {
346346

347347
public static void reportErrorDuringInitialization(final Throwable throwable,
348348
final InfoItem item) {
349-
ErrorUtil.showSnackbar(App.getApp().getBaseContext(), new ErrorInfo(
349+
ErrorUtil.showSnackbar(App.getInstance().getBaseContext(), new ErrorInfo(
350350
throwable,
351351
UserAction.OPEN_INFO_ITEM_DIALOG,
352352
"none",

app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class FeedViewModel(
165165
fun getFactory(context: Context, groupId: Long) = viewModelFactory {
166166
initializer {
167167
FeedViewModel(
168-
App.getApp(),
168+
App.instance,
169169
groupId,
170170
// Read initial value from preferences
171171
getShowPlayedItemsFromPreferences(context.applicationContext),

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,20 @@
4646
import static org.schabi.newpipe.util.ListHelper.getResolutionIndex;
4747
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
4848
import static java.util.concurrent.TimeUnit.MILLISECONDS;
49+
import static coil3.Image_androidKt.toBitmap;
4950

5051
import android.content.BroadcastReceiver;
5152
import android.content.Context;
5253
import android.content.Intent;
5354
import android.content.IntentFilter;
5455
import android.content.SharedPreferences;
5556
import android.graphics.Bitmap;
56-
import android.graphics.drawable.Drawable;
5757
import android.media.AudioManager;
5858
import android.util.Log;
5959
import android.view.LayoutInflater;
6060

6161
import androidx.annotation.NonNull;
6262
import androidx.annotation.Nullable;
63-
import androidx.core.graphics.drawable.DrawableKt;
6463
import androidx.core.math.MathUtils;
6564
import androidx.preference.PreferenceManager;
6665

@@ -125,7 +124,7 @@
125124
import java.util.Optional;
126125
import java.util.stream.IntStream;
127126

128-
import coil.target.Target;
127+
import coil3.target.Target;
129128
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
130129
import io.reactivex.rxjava3.core.Observable;
131130
import io.reactivex.rxjava3.disposables.CompositeDisposable;
@@ -193,7 +192,7 @@ public final class Player implements PlaybackListener, Listener {
193192
@Nullable
194193
private Bitmap currentThumbnail;
195194
@Nullable
196-
private coil.request.Disposable thumbnailDisposable;
195+
private coil3.request.Disposable thumbnailDisposable;
197196

198197
/*//////////////////////////////////////////////////////////////////////////
199198
// Player
@@ -789,27 +788,26 @@ private void loadCurrentThumbnail(final List<Image> thumbnails) {
789788
// scale down the notification thumbnail for performance
790789
final var thumbnailTarget = new Target() {
791790
@Override
792-
public void onError(@Nullable final Drawable error) {
791+
public void onError(@Nullable final coil3.Image error) {
793792
Log.e(TAG, "Thumbnail - onError() called");
794793
// there is a new thumbnail, so e.g. the end screen thumbnail needs to change, too.
795794
onThumbnailLoaded(null);
796795
}
797796

798797
@Override
799-
public void onStart(@Nullable final Drawable placeholder) {
798+
public void onStart(@Nullable final coil3.Image placeholder) {
800799
if (DEBUG) {
801800
Log.d(TAG, "Thumbnail - onStart() called");
802801
}
803802
}
804803

805804
@Override
806-
public void onSuccess(@NonNull final Drawable result) {
805+
public void onSuccess(@NonNull final coil3.Image result) {
807806
if (DEBUG) {
808807
Log.d(TAG, "Thumbnail - onSuccess() called with: drawable = [" + result + "]");
809808
}
810809
// there is a new thumbnail, so e.g. the end screen thumbnail needs to change, too.
811-
onThumbnailLoaded(DrawableKt.toBitmapOrNull(result, result.getIntrinsicWidth(),
812-
result.getIntrinsicHeight(), null));
810+
onThumbnailLoaded(toBitmap(result));
813811
}
814812
};
815813
thumbnailDisposable = CoilHelper.INSTANCE

app/src/main/java/org/schabi/newpipe/player/helper/PlayerHolder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import org.schabi.newpipe.App;
1717
import org.schabi.newpipe.MainActivity;
1818
import org.schabi.newpipe.extractor.stream.StreamInfo;
19-
import org.schabi.newpipe.player.PlayerService;
2019
import org.schabi.newpipe.player.Player;
20+
import org.schabi.newpipe.player.PlayerService;
2121
import org.schabi.newpipe.player.PlayerType;
2222
import org.schabi.newpipe.player.event.PlayerServiceEventListener;
2323
import org.schabi.newpipe.player.event.PlayerServiceExtendedEventListener;
@@ -116,7 +116,7 @@ public void setListener(@Nullable final PlayerServiceExtendedEventListener newLi
116116
// helper to handle context in common place as using the same
117117
// context to bind/unbind a service is crucial
118118
private Context getCommonContext() {
119-
return App.getApp();
119+
return App.getInstance();
120120
}
121121

122122
public void startService(final boolean playAfterConnect,

0 commit comments

Comments
 (0)