Skip to content

Commit

Permalink
chore: Migrate to KSP for Glide and Toothpick
Browse files Browse the repository at this point in the history
  • Loading branch information
kingargyle committed Dec 15, 2024
1 parent c40e06e commit 2037b0d
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 53 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ buildscript {

plugins {
id "com.diffplug.spotless" version "6.18.0"
id 'com.google.devtools.ksp' version "1.9.25-1.0.20" apply false
}

repositories {
Expand Down Expand Up @@ -60,7 +61,7 @@ subprojects {
}
}

tasks.withType(Test) {
tasks.withType(Test).configureEach {

testLogging {
exceptionFormat = "full"
Expand Down
6 changes: 4 additions & 2 deletions emby-lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("com.android.library")
kotlin("android")
kotlin("kapt")
id("com.google.devtools.ksp")
}

android {
Expand Down Expand Up @@ -63,7 +64,8 @@ dependencies {
debugImplementation(libs.toothpick.smoothie)

releaseApi(libs.toothpick.javax.annotations)
kapt(libs.toothpick.compiler)
// kapt(libs.toothpick.compiler)
ksp(libs.toothpick.ksp.compiler)

implementation(libs.android.priority.jobqueue)
implementation(libs.eventbus)
Expand All @@ -89,5 +91,5 @@ dependencies {
testImplementation(libs.kotlin.coroutines.test)

testImplementation(libs.toothpick.testing)
kaptTest(libs.toothpick.compiler)
kspTest(libs.toothpick.ksp.compiler)
}
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ fragmentKtxVersion = "1.8.5"
glide = "4.12.0"
junit = "1.2.1"
juniversalchardetVersion = "1.0.3"
kotlinVersion = "1.9.24"
kotlinVersion = "1.9.25"
kotlinCoroutinesVersion = "1.7.3"
kotlinKSPVersion = "1.9.25-1.0.20"
androidPluginVersion = "8.7.3"
leanbackPreferenceVersion = "1.1.0-rc01"
leanbackVersion = "1.1.0-rc02"
Expand Down Expand Up @@ -48,6 +49,7 @@ robolectricVersion = "4.14.1"
openglApiVersion = "gl1.1-android-2.1_r1"
assertJAndroidVersion = "1.1.1"
toothPickVersion = "3.1.0"
toothPickKspVersion = "1.1.0"
easydeviceInfoVersion = "2.4.1"

androidxTestCoreVersion = "1.6.1"
Expand Down Expand Up @@ -111,8 +113,10 @@ simple-xml = { group = "org.simpleframework", name = "simple-xml", version.ref =
toothpick-runtime = { group = "com.github.stephanenicolas.toothpick", name = "toothpick-runtime", version.ref = "toothPickVersion"}
toothpick-smoothie = { group = "com.github.stephanenicolas.toothpick", name = "smoothie", version.ref = "toothPickVersion" }
toothpick-compiler = { group = "com.github.stephanenicolas.toothpick", name = "toothpick-compiler", version.ref = "toothPickVersion" }
toothpick-ksp-compiler = { group = "com.github.bedrockstreaming.toothpick-ksp", name = "compiler", version.ref = "toothPickKspVersion" }
toothpick-javax-annotations = { group = "com.github.stephanenicolas.toothpick", name = "toothpick-javax-annotations", version.ref = "toothPickVersion" }


# Tests
junit = { group = "junit", name = "junit", version.ref = "junitVersion" }
assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertjVersion" }
Expand Down
5 changes: 3 additions & 2 deletions serenity-android-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("com.android.library")
kotlin("android")
kotlin("kapt")
id("com.google.devtools.ksp")
}

android {
Expand Down Expand Up @@ -55,7 +56,7 @@ dependencies {
debugApi(libs.toothpick.smoothie)

releaseApi(libs.toothpick.javax.annotations)
kapt(libs.toothpick.compiler)
ksp(libs.toothpick.ksp.compiler)

testImplementation(libs.junit)
testImplementation(libs.assertj.core)
Expand All @@ -67,5 +68,5 @@ dependencies {
testImplementation(libs.opengl.api)

testImplementation(libs.toothpick.testing)
kaptTest(libs.toothpick.compiler)
kspTest(libs.toothpick.ksp.compiler)
}
8 changes: 5 additions & 3 deletions serenity-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id("org.sonarqube")
id("com.google.firebase.crashlytics")
id("com.google.gms.google-services") version "4.4.0"
id("com.google.devtools.ksp")
}

apply(from = "../jacoco.gradle")
Expand Down Expand Up @@ -145,7 +146,7 @@ dependencies {
implementation(libs.moxy.community.moxy.app.compat)
implementation(libs.moxy.ktx)
implementation(libs.github.glide)
kapt(libs.glide.compiler)
ksp(libs.glide.compiler)
implementation(libs.android.priority.jobqueue)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.leanback)
Expand All @@ -172,7 +173,7 @@ dependencies {
debugImplementation(libs.toothpick.runtime)

releaseImplementation(libs.toothpick.javax.annotations)
kapt(libs.toothpick.compiler)
ksp(libs.toothpick.ksp.compiler)

implementation(libs.moshi)
implementation(libs.retrofit.moshi)
Expand Down Expand Up @@ -218,7 +219,8 @@ dependencies {
testImplementation(libs.opengl.api)
testImplementation(libs.androidx.junit)

kaptTest(libs.toothpick.compiler)
// kaptTest(libs.toothpick.compiler)
kspTest(libs.toothpick.ksp.compiler)

kapt(libs.moxy.compiler)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import android.view.View
import android.view.animation.AnimationUtils
import android.widget.ImageView
import androidx.core.content.ContextCompat
import com.bumptech.glide.Glide
import us.nineworlds.serenity.core.menus.MenuItem
import us.nineworlds.serenity.fragments.mainmenu.MainMenuPresenter
import javax.inject.Provider
Expand Down Expand Up @@ -90,7 +91,7 @@ class GalleryOnItemSelectedListener(private val adapter: MainMenuTextViewAdapter
if (hasFocus && view != null) {
mainGalleryBackgroundView = context.findViewById(R.id.mainGalleryBackground)
mainGalleryBackgroundView.clearAnimation()
GlideApp.with(context).load(getBackgroundImageId(menuItem)).into(mainGalleryBackgroundView)
Glide.with(context).load(getBackgroundImageId(menuItem)).into(mainGalleryBackgroundView)
view.clearAnimation()
view.background = ContextCompat.getDrawable(view.context, R.drawable.rounded_transparent_border)
if (shouldFadeIn()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import androidx.core.app.NotificationCompat;
import android.util.Log;

import com.bumptech.glide.Glide;

import java.io.IOException;

import us.nineworlds.serenity.GlideApp;
import us.nineworlds.serenity.injection.BaseInjector;

/*
Expand Down Expand Up @@ -137,7 +138,7 @@ public Notification build() throws IOException {
.setExtras(extras);

try {
Bitmap image = GlideApp.with(mContext).asBitmap().load(mImageUri).into(176, 313).get();
Bitmap image = Glide.with(mContext).asBitmap().load(mImageUri).into(176, 313).get();

builder = builder.setLargeIcon(image);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
*/
public class MenuMediaContainer extends AbstractMediaContainer {

@Inject protected SharedPreferences preferences;
@Inject protected Resources resources;
@Inject public SharedPreferences preferences;
@Inject public Resources resources;

private static final String SETTINGS_SECTION_KEY = "0";
private static final String SETTINGS_TYPE = "settings";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import androidx.leanback.widget.*
import us.nineworlds.serenity.core.model.CategoryInfo
import android.content.Intent
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import toothpick.Toothpick
import us.nineworlds.serenity.GlideApp
import us.nineworlds.serenity.R
import us.nineworlds.serenity.common.annotations.InjectionConstants
import us.nineworlds.serenity.common.rest.Types
Expand Down Expand Up @@ -65,7 +65,7 @@ class MainMenuVideoContentVerticalGridFragment : RowsSupportFragment() {

val imageView = requireActivity().findViewById<ImageView>(R.id.mainGalleryBackground)

GlideApp.with(requireActivity()).load(videoCategory.item.backgroundURL).transition(DrawableTransitionOptions.withCrossFade()).fitCenter().into(imageView)
Glide.with(requireActivity()).load(videoCategory.item.backgroundURL).transition(DrawableTransitionOptions.withCrossFade()).fitCenter().into(imageView)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.birbit.android.jobqueue.Job;
import com.birbit.android.jobqueue.Params;
import com.birbit.android.jobqueue.RetryConstraint;
import com.bumptech.glide.Glide;

import us.nineworlds.serenity.GlideApp;

/**
* Created by dcarver on 7/2/17.
Expand All @@ -27,8 +27,8 @@ public GlideClearCacheJob(Context context) {
}

@Override public void onRun() throws Throwable {
GlideApp.get(context).clearDiskCache();
GlideApp.get(context).clearMemory();
Glide.get(context).clearDiskCache();
Glide.get(context).clearMemory();
}

@Override protected void onCancel(int cancelReason, @Nullable Throwable throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import androidx.core.content.ContextCompat
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import us.nineworlds.serenity.GlideApp
import com.bumptech.glide.Glide
import us.nineworlds.serenity.R
import us.nineworlds.serenity.core.model.VideoContentInfo

Expand Down Expand Up @@ -100,7 +100,7 @@ class CardPresenter(private val context: Context) : Presenter() {
}

fun updateCardViewImage(url: String) {
GlideApp.with(context).load(url).fitCenter().into(cardView.mainImageView)
Glide.with(context).load(url).fitCenter().into(cardView.mainImageView)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@
import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import toothpick.Toothpick;
import us.nineworlds.serenity.GlideApp;
import us.nineworlds.serenity.R;
import us.nineworlds.serenity.common.annotations.InjectionConstants;
import us.nineworlds.serenity.common.rest.SerenityClient;
Expand Down Expand Up @@ -123,7 +124,7 @@ public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? sup
}
};

GlideApp.with(getContext()).asBitmap().load(transcodingURL).into(target);
Glide.with(requireContext()).asBitmap().load(transcodingURL).into(target);
}
});

Expand All @@ -137,12 +138,12 @@ private void queryByWords(String words) {
searchHandler = new MovieSearchHandler();
Messenger messenger = new Messenger(searchHandler);

Intent searchIntent = new Intent(getActivity(), MovieSearchIntentService.class);
Intent searchIntent = new Intent(requireActivity(), MovieSearchIntentService.class);

searchIntent.putExtra("key", key);
searchIntent.putExtra("query", URLEncoder.encode(words));
searchIntent.putExtra("MESSENGER", messenger);
getActivity().startService(searchIntent);
requireActivity().startService(searchIntent);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import android.widget.RatingBar;
import android.widget.TextView;
import com.birbit.android.jobqueue.JobManager;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import us.nineworlds.serenity.GlideApp;
import us.nineworlds.serenity.R;
import us.nineworlds.serenity.common.rest.SerenityClient;
import us.nineworlds.serenity.core.imageloader.BackgroundBitmapDisplayer;
Expand Down Expand Up @@ -178,7 +178,7 @@ public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? sup
}
};

GlideApp.with(context).asBitmap().load(transcodingURL).into(target);
Glide.with(context).asBitmap().load(transcodingURL).into(target);
}

public abstract void onItemSelected(View view, int i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import android.widget.TextView;
import moxy.MvpPresenter;
import moxy.presenter.InjectPresenter;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import us.nineworlds.serenity.GlideApp;
import us.nineworlds.serenity.R;
import us.nineworlds.serenity.common.rest.Types;
import us.nineworlds.serenity.core.model.VideoContentInfo;
Expand Down Expand Up @@ -135,7 +136,7 @@ protected void initPosterMetaData(VideoContentInfo pi, int width, int height) {
ColorDrawable colorDrawable =
new ColorDrawable(ContextCompat.getColor(roundedImageView.getContext(), android.R.color.black));

GlideApp.with(getContext())
Glide.with(getContext())
.load(url)
.fitCenter()
.diskCacheStrategy(DiskCacheStrategy.ALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import us.nineworlds.serenity.GlideApp;
import us.nineworlds.serenity.R;
import us.nineworlds.serenity.core.model.ContentInfo;
import us.nineworlds.serenity.widgets.RoundedImageView;
Expand Down Expand Up @@ -54,7 +54,7 @@ public View getItemView() {
public void loadImage(String url) {
ColorDrawable colorDrawable = new ColorDrawable(
ContextCompat.getColor(posterImageView.getContext(), android.R.color.black));
GlideApp.with(posterImageView.getContext())
Glide.with(posterImageView.getContext())
.load(url)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(colorDrawable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,17 @@ import us.nineworlds.serenity.common.annotations.InjectionConstants
import javax.inject.Inject
import javax.inject.Provider
import moxy.MvpDelegate
import us.nineworlds.serenity.GlideApp
import us.nineworlds.serenity.core.model.ContentInfo

import android.content.res.Resources

import android.view.LayoutInflater
import android.view.ViewGroup.MarginLayoutParams
import android.widget.LinearLayout
import androidx.leanback.widget.*
import com.bumptech.glide.Glide

import us.nineworlds.serenity.core.model.SeriesContentInfo
import us.nineworlds.serenity.core.model.VideoContentInfo
import us.nineworlds.serenity.core.model.impl.EpisodePosterInfo
import us.nineworlds.serenity.ui.util.VideoPlayerIntentUtils

import androidx.leanback.widget.ItemAlignmentFacet.ItemAlignmentDef
import us.nineworlds.serenity.R
import us.nineworlds.serenity.core.model.impl.MoviePosterInfo
import us.nineworlds.serenity.core.model.impl.TVShowSeriesInfo
import us.nineworlds.serenity.ui.leanback.presenters.*
import us.nineworlds.serenity.ui.leanback.presenters.DetailsOverviewRow
Expand Down Expand Up @@ -204,7 +197,7 @@ class DetailsFragment : DetailsSupportFragment(), MvpDelegateHolder, DetailsView
override fun updateDetails(videoInfo: ContentInfo) {
val imageView = requireActivity().findViewById<ImageView>(R.id.detail_background_image)

GlideApp.with(requireActivity()).load(videoInfo.backgroundURL).fitCenter().into(imageView)
Glide.with(requireActivity()).load(videoInfo.backgroundURL).fitCenter().into(imageView)

when (videoInfo) {
is TVShowSeriesInfo -> setupTVShowDetails(videoInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import toothpick.Toothpick
import us.nineworlds.serenity.GlideApp
import us.nineworlds.serenity.R
import us.nineworlds.serenity.common.annotations.InjectionConstants
import us.nineworlds.serenity.common.rest.SerenityClient
Expand All @@ -31,7 +31,7 @@ class LoginUserViewHolder(view: View) : ViewHolder(view) {
val placeHolder = ContextCompat.getDrawable(profileImage.context, R.drawable.ic_generic_user)
DrawableCompat.setTint(placeHolder!!, ContextCompat.getColor(profileImage.context, R.color.white))

GlideApp.with(profileImage.context)
Glide.with(profileImage.context)
.asDrawable()
.load(serenityClient.createUserImageUrl(user, 150, 150))
.placeholder(placeHolder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.widget.ImageView
import androidx.core.content.ContextCompat
import androidx.leanback.widget.ImageCardView
import androidx.leanback.widget.Presenter
import us.nineworlds.serenity.GlideApp
import us.nineworlds.serenity.R
import us.nineworlds.serenity.common.rest.Types
import us.nineworlds.serenity.core.model.VideoCategory
Expand Down
Loading

0 comments on commit 2037b0d

Please sign in to comment.