Skip to content

Commit 5062d38

Browse files
Merge pull request #11237 from TeamNewPipe/revert-11201-Coil
Revert "Migrate image loading from Picasso to Coil"
2 parents 73e3a69 + 82b492c commit 5062d38

File tree

92 files changed

+596
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+596
-330
lines changed

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ dependencies {
267267
implementation "com.github.lisawray.groupie:groupie-viewbinding:${groupieVersion}"
268268

269269
// Image loading
270-
implementation 'io.coil-kt:coil:2.6.0'
270+
//noinspection GradleDependency --> 2.8 is the last version, not 2.71828!
271+
implementation "com.squareup.picasso:picasso:2.8"
271272

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

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.schabi.newpipe;
22

3-
import android.app.ActivityManager;
43
import android.app.Application;
54
import android.content.Context;
65
import android.content.SharedPreferences;
@@ -9,7 +8,6 @@
98
import androidx.annotation.NonNull;
109
import androidx.core.app.NotificationChannelCompat;
1110
import androidx.core.app.NotificationManagerCompat;
12-
import androidx.core.content.ContextCompat;
1311
import androidx.preference.PreferenceManager;
1412

1513
import com.jakewharton.processphoenix.ProcessPhoenix;
@@ -22,9 +20,10 @@
2220
import org.schabi.newpipe.ktx.ExceptionUtils;
2321
import org.schabi.newpipe.settings.NewPipeSettings;
2422
import org.schabi.newpipe.util.Localization;
23+
import org.schabi.newpipe.util.image.ImageStrategy;
24+
import org.schabi.newpipe.util.image.PicassoHelper;
2525
import org.schabi.newpipe.util.ServiceHelper;
2626
import org.schabi.newpipe.util.StateSaver;
27-
import org.schabi.newpipe.util.image.ImageStrategy;
2827
import org.schabi.newpipe.util.image.PreferredImageQuality;
2928

3029
import java.io.IOException;
@@ -33,9 +32,6 @@
3332
import java.util.List;
3433
import java.util.Objects;
3534

36-
import coil.ImageLoader;
37-
import coil.ImageLoaderFactory;
38-
import coil.util.DebugLogger;
3935
import io.reactivex.rxjava3.exceptions.CompositeException;
4036
import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
4137
import io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException;
@@ -61,7 +57,7 @@
6157
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
6258
*/
6359

64-
public class App extends Application implements ImageLoaderFactory {
60+
public class App extends Application {
6561
public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID;
6662
private static final String TAG = App.class.toString();
6763

@@ -112,22 +108,20 @@ public void onCreate() {
112108

113109
// Initialize image loader
114110
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
111+
PicassoHelper.init(this);
115112
ImageStrategy.setPreferredImageQuality(PreferredImageQuality.fromPreferenceKey(this,
116113
prefs.getString(getString(R.string.image_quality_key),
117114
getString(R.string.image_quality_default))));
115+
PicassoHelper.setIndicatorsEnabled(MainActivity.DEBUG
116+
&& prefs.getBoolean(getString(R.string.show_image_indicators_key), false));
118117

119118
configureRxJavaErrorHandler();
120119
}
121120

122-
@NonNull
123121
@Override
124-
public ImageLoader newImageLoader() {
125-
return new ImageLoader.Builder(this)
126-
.allowRgb565(ContextCompat.getSystemService(this, ActivityManager.class)
127-
.isLowRamDevice())
128-
.logger(BuildConfig.DEBUG ? new DebugLogger() : null)
129-
.crossfade(true)
130-
.build();
122+
public void onTerminate() {
123+
super.onTerminate();
124+
PicassoHelper.terminate();
131125
}
132126

133127
protected Downloader getDownloader() {

app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ class AboutActivity : AppCompatActivity() {
167167
"https://square.github.io/okhttp/", StandardLicenses.APACHE2
168168
),
169169
SoftwareComponent(
170-
"Coil", "2023", "Coil Contributors",
171-
"https://coil-kt.github.io/coil/", StandardLicenses.APACHE2
170+
"Picasso", "2013", "Square, Inc.",
171+
"https://square.github.io/picasso/", StandardLicenses.APACHE2
172172
),
173173
SoftwareComponent(
174174
"PrettyTime", "2012 - 2020", "Lincoln Baxter, III",

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
import org.schabi.newpipe.util.ThemeHelper;
117117
import org.schabi.newpipe.util.external_communication.KoreUtils;
118118
import org.schabi.newpipe.util.external_communication.ShareUtils;
119-
import org.schabi.newpipe.util.image.CoilHelper;
119+
import org.schabi.newpipe.util.image.PicassoHelper;
120120

121121
import java.util.ArrayList;
122122
import java.util.Iterator;
@@ -127,7 +127,6 @@
127127
import java.util.concurrent.TimeUnit;
128128
import java.util.function.Consumer;
129129

130-
import coil.util.CoilUtils;
131130
import icepick.State;
132131
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
133132
import io.reactivex.rxjava3.disposables.CompositeDisposable;
@@ -160,6 +159,8 @@ public final class VideoDetailFragment
160159
private static final String DESCRIPTION_TAB_TAG = "DESCRIPTION TAB";
161160
private static final String EMPTY_TAB_TAG = "EMPTY TAB";
162161

162+
private static final String PICASSO_VIDEO_DETAILS_TAG = "PICASSO_VIDEO_DETAILS_TAG";
163+
163164
// tabs
164165
private boolean showComments;
165166
private boolean showRelatedItems;
@@ -1470,10 +1471,7 @@ public void showLoading() {
14701471
}
14711472
}
14721473

1473-
CoilUtils.dispose(binding.detailThumbnailImageView);
1474-
CoilUtils.dispose(binding.detailSubChannelThumbnailView);
1475-
CoilUtils.dispose(binding.overlayThumbnail);
1476-
1474+
PicassoHelper.cancelTag(PICASSO_VIDEO_DETAILS_TAG);
14771475
binding.detailThumbnailImageView.setImageBitmap(null);
14781476
binding.detailSubChannelThumbnailView.setImageBitmap(null);
14791477
}
@@ -1564,8 +1562,8 @@ public void handleResult(@NonNull final StreamInfo info) {
15641562
binding.detailSecondaryControlPanel.setVisibility(View.GONE);
15651563

15661564
checkUpdateProgressInfo(info);
1567-
CoilHelper.INSTANCE.loadDetailsThumbnail(binding.detailThumbnailImageView,
1568-
info.getThumbnails());
1565+
PicassoHelper.loadDetailsThumbnail(info.getThumbnails()).tag(PICASSO_VIDEO_DETAILS_TAG)
1566+
.into(binding.detailThumbnailImageView);
15691567
showMetaInfoInTextView(info.getMetaInfo(), binding.detailMetaInfoTextView,
15701568
binding.detailMetaInfoSeparator, disposables);
15711569

@@ -1615,8 +1613,8 @@ private void displayUploaderAsSubChannel(final StreamInfo info) {
16151613
binding.detailUploaderTextView.setVisibility(View.GONE);
16161614
}
16171615

1618-
CoilHelper.INSTANCE.loadAvatar(binding.detailSubChannelThumbnailView,
1619-
info.getUploaderAvatars());
1616+
PicassoHelper.loadAvatar(info.getUploaderAvatars()).tag(PICASSO_VIDEO_DETAILS_TAG)
1617+
.into(binding.detailSubChannelThumbnailView);
16201618
binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE);
16211619
binding.detailUploaderThumbnailView.setVisibility(View.GONE);
16221620
}
@@ -1647,11 +1645,11 @@ private void displayBothUploaderAndSubChannel(final StreamInfo info) {
16471645
binding.detailUploaderTextView.setVisibility(View.GONE);
16481646
}
16491647

1650-
CoilHelper.INSTANCE.loadAvatar(binding.detailSubChannelThumbnailView,
1651-
info.getSubChannelAvatars());
1648+
PicassoHelper.loadAvatar(info.getSubChannelAvatars()).tag(PICASSO_VIDEO_DETAILS_TAG)
1649+
.into(binding.detailSubChannelThumbnailView);
16521650
binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE);
1653-
CoilHelper.INSTANCE.loadAvatar(binding.detailUploaderThumbnailView,
1654-
info.getUploaderAvatars());
1651+
PicassoHelper.loadAvatar(info.getUploaderAvatars()).tag(PICASSO_VIDEO_DETAILS_TAG)
1652+
.into(binding.detailUploaderThumbnailView);
16551653
binding.detailUploaderThumbnailView.setVisibility(View.VISIBLE);
16561654
}
16571655

@@ -2405,7 +2403,8 @@ private void updateOverlayData(@Nullable final String overlayTitle,
24052403
binding.overlayTitleTextView.setText(isEmpty(overlayTitle) ? "" : overlayTitle);
24062404
binding.overlayChannelTextView.setText(isEmpty(uploader) ? "" : uploader);
24072405
binding.overlayThumbnail.setImageDrawable(null);
2408-
CoilHelper.INSTANCE.loadDetailsThumbnail(binding.overlayThumbnail, thumbnails);
2406+
PicassoHelper.loadDetailsThumbnail(thumbnails).tag(PICASSO_VIDEO_DETAILS_TAG)
2407+
.into(binding.overlayThumbnail);
24092408
}
24102409

24112410
private void setOverlayPlayPauseImage(final boolean playerIsPlaying) {

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,15 @@
5050
import org.schabi.newpipe.util.Localization;
5151
import org.schabi.newpipe.util.NavigationHelper;
5252
import org.schabi.newpipe.util.StateSaver;
53+
import org.schabi.newpipe.util.image.ImageStrategy;
54+
import org.schabi.newpipe.util.image.PicassoHelper;
5355
import org.schabi.newpipe.util.ThemeHelper;
5456
import org.schabi.newpipe.util.external_communication.ShareUtils;
55-
import org.schabi.newpipe.util.image.CoilHelper;
56-
import org.schabi.newpipe.util.image.ImageStrategy;
5757

5858
import java.util.List;
5959
import java.util.Queue;
6060
import java.util.concurrent.TimeUnit;
6161

62-
import coil.util.CoilUtils;
6362
import icepick.State;
6463
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
6564
import io.reactivex.rxjava3.core.Observable;
@@ -74,6 +73,7 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
7473
implements StateSaver.WriteRead {
7574

7675
private static final int BUTTON_DEBOUNCE_INTERVAL = 100;
76+
private static final String PICASSO_CHANNEL_TAG = "PICASSO_CHANNEL_TAG";
7777

7878
@State
7979
protected int serviceId = Constants.NO_SERVICE_ID;
@@ -576,9 +576,7 @@ private void runWorker(final boolean forceLoad) {
576576
@Override
577577
public void showLoading() {
578578
super.showLoading();
579-
CoilUtils.dispose(binding.channelAvatarView);
580-
CoilUtils.dispose(binding.channelBannerImage);
581-
CoilUtils.dispose(binding.subChannelAvatarView);
579+
PicassoHelper.cancelTag(PICASSO_CHANNEL_TAG);
582580
animate(binding.channelSubscribeButton, false, 100);
583581
}
584582

@@ -589,15 +587,17 @@ public void handleResult(@NonNull final ChannelInfo result) {
589587
setInitialData(result.getServiceId(), result.getOriginalUrl(), result.getName());
590588

591589
if (ImageStrategy.shouldLoadImages() && !result.getBanners().isEmpty()) {
592-
CoilHelper.INSTANCE.loadBanner(binding.channelBannerImage, result.getBanners());
590+
PicassoHelper.loadBanner(result.getBanners()).tag(PICASSO_CHANNEL_TAG)
591+
.into(binding.channelBannerImage);
593592
} else {
594593
// do not waste space for the banner, if the user disabled images or there is not one
595594
binding.channelBannerImage.setImageDrawable(null);
596595
}
597596

598-
CoilHelper.INSTANCE.loadAvatar(binding.channelAvatarView, result.getAvatars());
599-
CoilHelper.INSTANCE.loadAvatar(binding.subChannelAvatarView,
600-
result.getParentChannelAvatars());
597+
PicassoHelper.loadAvatar(result.getAvatars()).tag(PICASSO_CHANNEL_TAG)
598+
.into(binding.channelAvatarView);
599+
PicassoHelper.loadAvatar(result.getParentChannelAvatars()).tag(PICASSO_CHANNEL_TAG)
600+
.into(binding.subChannelAvatarView);
601601

602602
binding.channelTitleView.setText(result.getName());
603603
binding.channelSubscriberView.setVisibility(View.VISIBLE);

app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentRepliesFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import org.schabi.newpipe.util.ExtractorHelper;
2424
import org.schabi.newpipe.util.Localization;
2525
import org.schabi.newpipe.util.NavigationHelper;
26-
import org.schabi.newpipe.util.image.CoilHelper;
2726
import org.schabi.newpipe.util.image.ImageStrategy;
27+
import org.schabi.newpipe.util.image.PicassoHelper;
2828
import org.schabi.newpipe.util.text.TextLinkifier;
2929

3030
import java.util.Queue;
@@ -82,7 +82,7 @@ protected Supplier<View> getListHeaderSupplier() {
8282
final CommentsInfoItem item = commentsInfoItem;
8383

8484
// load the author avatar
85-
CoilHelper.INSTANCE.loadAvatar(binding.authorAvatar, item.getUploaderAvatars());
85+
PicassoHelper.loadAvatar(item.getUploaderAvatars()).into(binding.authorAvatar);
8686
binding.authorAvatar.setVisibility(ImageStrategy.shouldLoadImages()
8787
? View.VISIBLE : View.GONE);
8888

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import org.schabi.newpipe.util.NavigationHelper;
5454
import org.schabi.newpipe.util.PlayButtonHelper;
5555
import org.schabi.newpipe.util.external_communication.ShareUtils;
56-
import org.schabi.newpipe.util.image.CoilHelper;
56+
import org.schabi.newpipe.util.image.PicassoHelper;
5757
import org.schabi.newpipe.util.text.TextEllipsizer;
5858

5959
import java.util.ArrayList;
@@ -62,7 +62,6 @@
6262
import java.util.function.Supplier;
6363
import java.util.stream.Collectors;
6464

65-
import coil.util.CoilUtils;
6665
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
6766
import io.reactivex.rxjava3.core.Flowable;
6867
import io.reactivex.rxjava3.core.Single;
@@ -72,6 +71,8 @@
7271
public class PlaylistFragment extends BaseListInfoFragment<StreamInfoItem, PlaylistInfo>
7372
implements PlaylistControlViewHolder {
7473

74+
private static final String PICASSO_PLAYLIST_TAG = "PICASSO_PLAYLIST_TAG";
75+
7576
private CompositeDisposable disposables;
7677
private Subscription bookmarkReactor;
7778
private AtomicBoolean isBookmarkButtonReady;
@@ -275,7 +276,7 @@ public void showLoading() {
275276
animate(headerBinding.getRoot(), false, 200);
276277
animateHideRecyclerViewAllowingScrolling(itemsList);
277278

278-
CoilUtils.dispose(headerBinding.uploaderAvatarView);
279+
PicassoHelper.cancelTag(PICASSO_PLAYLIST_TAG);
279280
animate(headerBinding.uploaderLayout, false, 200);
280281
}
281282

@@ -326,8 +327,8 @@ public void handleResult(@NonNull final PlaylistInfo result) {
326327
R.drawable.ic_radio)
327328
);
328329
} else {
329-
CoilHelper.INSTANCE.loadAvatar(headerBinding.uploaderAvatarView,
330-
result.getUploaderAvatars());
330+
PicassoHelper.loadAvatar(result.getUploaderAvatars()).tag(PICASSO_PLAYLIST_TAG)
331+
.into(headerBinding.uploaderAvatarView);
331332
}
332333

333334
streamCount = result.getStreamCount();
Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
package org.schabi.newpipe.info_list
22

33
import android.view.View
4-
import com.xwray.groupie.viewbinding.BindableItem
5-
import com.xwray.groupie.viewbinding.GroupieViewHolder
4+
import android.widget.ImageView
5+
import android.widget.TextView
6+
import com.xwray.groupie.GroupieViewHolder
7+
import com.xwray.groupie.Item
68
import org.schabi.newpipe.R
7-
import org.schabi.newpipe.databinding.ItemStreamSegmentBinding
89
import org.schabi.newpipe.extractor.stream.StreamSegment
910
import org.schabi.newpipe.util.Localization
10-
import org.schabi.newpipe.util.image.CoilHelper
11+
import org.schabi.newpipe.util.image.PicassoHelper
1112

1213
class StreamSegmentItem(
1314
private val item: StreamSegment,
1415
private val onClick: StreamSegmentAdapter.StreamSegmentListener
15-
) : BindableItem<ItemStreamSegmentBinding>() {
16+
) : Item<GroupieViewHolder>() {
1617

1718
companion object {
1819
const val PAYLOAD_SELECT = 1
1920
}
2021

2122
var isSelected = false
2223

23-
override fun bind(viewBinding: ItemStreamSegmentBinding, position: Int) {
24-
CoilHelper.loadThumbnail(viewBinding.previewImage, item.previewUrl)
25-
viewBinding.textViewTitle.text = item.title
24+
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
25+
item.previewUrl?.let {
26+
PicassoHelper.loadThumbnail(it)
27+
.into(viewHolder.root.findViewById<ImageView>(R.id.previewImage))
28+
}
29+
viewHolder.root.findViewById<TextView>(R.id.textViewTitle).text = item.title
2630
if (item.channelName == null) {
27-
viewBinding.textViewChannel.visibility = View.GONE
31+
viewHolder.root.findViewById<TextView>(R.id.textViewChannel).visibility = View.GONE
2832
// When the channel name is displayed there is less space
2933
// and thus the segment title needs to be only one line height.
3034
// But when there is no channel name displayed, the title can be two lines long.
3135
// The default maxLines value is set to 1 to display all elements in the AS preview,
32-
viewBinding.textViewTitle.maxLines = 2
36+
viewHolder.root.findViewById<TextView>(R.id.textViewTitle).maxLines = 2
3337
} else {
34-
viewBinding.textViewChannel.text = item.channelName
35-
viewBinding.textViewChannel.visibility = View.VISIBLE
38+
viewHolder.root.findViewById<TextView>(R.id.textViewChannel).text = item.channelName
39+
viewHolder.root.findViewById<TextView>(R.id.textViewChannel).visibility = View.VISIBLE
3640
}
37-
viewBinding.textViewStartSeconds.text =
41+
viewHolder.root.findViewById<TextView>(R.id.textViewStartSeconds).text =
3842
Localization.getDurationString(item.startTimeSeconds.toLong())
39-
viewBinding.root.setOnClickListener { onClick.onItemClick(this, item.startTimeSeconds) }
40-
viewBinding.root.setOnLongClickListener { onClick.onItemLongClick(this, item.startTimeSeconds); true }
41-
viewBinding.root.isSelected = isSelected
43+
viewHolder.root.setOnClickListener { onClick.onItemClick(this, item.startTimeSeconds) }
44+
viewHolder.root.setOnLongClickListener { onClick.onItemLongClick(this, item.startTimeSeconds); true }
45+
viewHolder.root.isSelected = isSelected
4246
}
4347

44-
override fun bind(
45-
viewHolder: GroupieViewHolder<ItemStreamSegmentBinding>,
46-
position: Int,
47-
payloads: MutableList<Any>
48-
) {
48+
override fun bind(viewHolder: GroupieViewHolder, position: Int, payloads: MutableList<Any>) {
4949
if (payloads.contains(PAYLOAD_SELECT)) {
5050
viewHolder.root.isSelected = isSelected
5151
return
@@ -54,6 +54,4 @@ class StreamSegmentItem(
5454
}
5555

5656
override fun getLayout() = R.layout.item_stream_segment
57-
58-
override fun initializeViewBinding(view: View) = ItemStreamSegmentBinding.bind(view)
5957
}

0 commit comments

Comments
 (0)