Skip to content

Commit

Permalink
MBL-1068: Remove RXJava1 and related dependencies from our source cod…
Browse files Browse the repository at this point in the history
…e. (#2170)
  • Loading branch information
Arkariang authored Nov 19, 2024
1 parent e62ebf8 commit f7f29a1
Show file tree
Hide file tree
Showing 113 changed files with 379 additions and 6,217 deletions.
9 changes: 0 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,6 @@ dependencies {
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
implementation 'com.jakewharton:process-phoenix:2.1.2'
final rx_binding_version = '1.0.1'
implementation "com.jakewharton.rxbinding:rxbinding:$rx_binding_version"
implementation "com.jakewharton.rxbinding:rxbinding-recyclerview-v7:$rx_binding_version"
implementation "com.jakewharton.rxbinding:rxbinding-support-v4:$rx_binding_version"
implementation "com.jakewharton.timber:timber:5.0.1"
implementation 'com.stripe:stripe-android:20.47.3'
final okhttp_version = '4.10.+'
Expand All @@ -241,14 +237,9 @@ dependencies {

final retrofit_version = "2.9.+"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
final rx_lifecycle_version = "0.3.0"
implementation "com.trello:rxlifecycle:$rx_lifecycle_version"
implementation "com.trello:rxlifecycle-components:$rx_lifecycle_version"
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
implementation 'net.danlew:android.joda:2.10.7'

// Analytics Segment-Braze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import com.kickstarter.ApplicationModule
import com.kickstarter.libs.ApiEndpoint
import com.kickstarter.libs.InternalToolsType
import com.kickstarter.libs.NoopInternalTools
import com.kickstarter.mock.services.MockApiClient
import com.kickstarter.mock.services.MockApolloClient
import com.kickstarter.services.ApiClientType
import com.kickstarter.services.ApiService
import com.kickstarter.services.ApolloClientType
import com.kickstarter.mock.services.MockApiClientV2
import com.kickstarter.mock.services.MockApolloClientV2
import com.kickstarter.services.ApiClientTypeV2
import com.kickstarter.services.ApiServiceV2
import com.kickstarter.services.ApolloClientTypeV2
import dagger.Module
import dagger.Provides
import javax.inject.Singleton
Expand All @@ -35,13 +35,13 @@ class AndroidTestApplicationModule(private val application: Application) : Appli

@Provides
@Singleton
internal fun provideApiClientType(apiService: ApiService, gson: Gson): ApiClientType {
return MockApiClient()
internal fun provideApiClientType(apiService: ApiServiceV2, gson: Gson): ApiClientTypeV2 {
return MockApiClientV2()
}

@Provides
@Singleton
internal fun provideApolloClientType(apolloClient: ApolloClient): ApolloClientType {
return MockApolloClient()
internal fun provideApolloClientType(apolloClient: ApolloClient): ApolloClientTypeV2 {
return MockApolloClientV2()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,12 @@
import com.kickstarter.libs.InternalToolsType;
import com.kickstarter.libs.NoopInternalTools;
import com.kickstarter.libs.utils.Secrets;
import com.kickstarter.mock.services.MockApiClient;
import com.kickstarter.mock.services.MockApiClientV2;
import com.kickstarter.mock.services.MockApolloClient;
import com.kickstarter.mock.services.MockApolloClientV2;
import com.kickstarter.services.ApiClient;
import com.kickstarter.services.ApiClientType;
import com.kickstarter.services.ApiClientTypeV2;
import com.kickstarter.services.ApiClientV2;
import com.kickstarter.services.ApiService;
import com.kickstarter.services.ApiServiceV2;
import com.kickstarter.services.ApolloClientType;
import com.kickstarter.services.ApolloClientTypeV2;
import com.kickstarter.services.KSApolloClient;
import com.kickstarter.services.KSApolloClientV2;

import javax.inject.Singleton;
Expand All @@ -44,26 +37,13 @@ static InternalToolsType providesInternalToolsType() {
return new NoopInternalTools();
}

@Provides
@Singleton
@NonNull
static ApiClientType provideApiClientType(final @NonNull ApiService apiService, final @NonNull Gson gson) {
return Secrets.IS_OSS ? new MockApiClient() : new ApiClient(apiService, gson);
}

@Provides
@Singleton
@NonNull
static ApiClientTypeV2 provideApiClientTypeV2(final @NonNull ApiServiceV2 apiService, final @NonNull Gson gson) {
return Secrets.IS_OSS ? new MockApiClientV2() : new ApiClientV2(apiService, gson);
}

@Provides
@Singleton
@NonNull
static ApolloClientType provideApolloClientType(final @NonNull ApolloClient apolloClient) {
return Secrets.IS_OSS ? new MockApolloClient() : new KSApolloClient(apolloClient);
}

@Provides
@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@
import com.kickstarter.libs.preferences.StringPreferenceType;
import com.kickstarter.libs.qualifiers.ApiEndpointPreference;
import com.kickstarter.libs.utils.Secrets;
import com.kickstarter.mock.services.MockApiClient;
import com.kickstarter.mock.services.MockApiClientV2;
import com.kickstarter.mock.services.MockApolloClient;
import com.kickstarter.mock.services.MockApolloClientV2;
import com.kickstarter.services.ApiClient;
import com.kickstarter.services.ApiClientType;
import com.kickstarter.services.ApiClientTypeV2;
import com.kickstarter.services.ApiClientV2;
import com.kickstarter.services.ApiService;
import com.kickstarter.services.ApiServiceV2;
import com.kickstarter.services.ApolloClientType;
import com.kickstarter.services.ApolloClientTypeV2;
import com.kickstarter.services.KSApolloClient;
import com.kickstarter.services.KSApolloClientV2;

import javax.inject.Singleton;
Expand Down Expand Up @@ -54,12 +47,6 @@ InternalToolsType providesInternalToolsType() {
return new InternalTools();
}

@Provides
@Singleton
@NonNull
static ApolloClientType provideApolloClientType(final @NonNull ApolloClient apolloClient) {
return Secrets.IS_OSS ? new MockApolloClient() : new KSApolloClient(apolloClient);
}

@Provides
@Singleton
Expand All @@ -68,13 +55,6 @@ static ApolloClientTypeV2 provideApolloClientTypeV2(final @NonNull ApolloClient
return Secrets.IS_OSS ? new MockApolloClientV2() : new KSApolloClientV2(apolloClient, gson);
}

@Provides
@Singleton
@NonNull
static ApiClientType provideApiClientType(final @NonNull ApiService apiService, final @NonNull Gson gson) {
return Secrets.IS_OSS ? new MockApiClient() : new ApiClient(apiService, gson);
}

@Provides
@Singleton
@NonNull
Expand Down
83 changes: 7 additions & 76 deletions app/src/main/java/com/kickstarter/ApplicationModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@
import com.kickstarter.libs.ApiEndpoint;
import com.kickstarter.libs.AttributionEvents;
import com.kickstarter.libs.Build;
import com.kickstarter.libs.CurrentConfig;
import com.kickstarter.libs.CurrentConfigV2;
import com.kickstarter.libs.CurrentConfigType;
import com.kickstarter.libs.CurrentConfigTypeV2;
import com.kickstarter.libs.CurrentUser;
import com.kickstarter.libs.CurrentUserType;
import com.kickstarter.libs.CurrentUserTypeV2;
import com.kickstarter.libs.DateTimeTypeConverter;
import com.kickstarter.libs.DeviceRegistrar;
Expand Down Expand Up @@ -56,7 +52,6 @@
import com.kickstarter.libs.preferences.StringPreferenceType;
import com.kickstarter.libs.qualifiers.AccessTokenPreference;
import com.kickstarter.libs.qualifiers.ActivitySamplePreference;
import com.kickstarter.libs.qualifiers.ApiRetrofit;
import com.kickstarter.libs.qualifiers.ApiRetrofitV2;
import com.kickstarter.libs.qualifiers.AppRatingPreference;
import com.kickstarter.libs.qualifiers.ApplicationContext;
Expand All @@ -69,11 +64,8 @@
import com.kickstarter.libs.qualifiers.WebRetrofit;
import com.kickstarter.libs.utils.PlayServicesCapability;
import com.kickstarter.libs.utils.Secrets;
import com.kickstarter.services.ApiClientType;
import com.kickstarter.services.ApiClientTypeV2;
import com.kickstarter.services.ApiService;
import com.kickstarter.services.ApiServiceV2;
import com.kickstarter.services.ApolloClientType;
import com.kickstarter.services.ApolloClientTypeV2;
import com.kickstarter.services.KSWebViewClient;
import com.kickstarter.services.interceptors.ApiRequestInterceptor;
Expand All @@ -97,16 +89,14 @@
import androidx.preference.PreferenceManager;
import dagger.Module;
import dagger.Provides;
import io.reactivex.Scheduler;
import okhttp3.CookieJar;
import okhttp3.JavaNetCookieJar;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import type.CustomType;

@Module
Expand All @@ -120,15 +110,11 @@ public ApplicationModule(final @NonNull Application application) {
@Provides
@Singleton
static Environment provideEnvironment(final @NonNull @ActivitySamplePreference IntPreferenceType activitySamplePreference,
final @NonNull ApiClientType apiClient,
final @NonNull ApiClientTypeV2 apiClientV2,
final @NonNull ApolloClientType apolloClient,
final @NonNull ApolloClientTypeV2 apolloClientV2,
final @NonNull Build build,
final @NonNull CookieManager cookieManager,
final @NonNull CurrentConfigType currentConfig,
final @NonNull CurrentConfigTypeV2 currentConfig2,
final @NonNull CurrentUserType currentUser,
final @NonNull CurrentUserTypeV2 currentUser2,
final @NonNull @FirstSessionPreference BooleanPreferenceType firstSessionPreference,
final @NonNull Gson gson,
Expand All @@ -141,8 +127,7 @@ static Environment provideEnvironment(final @NonNull @ActivitySamplePreference I
final @NonNull AttributionEvents attributionEvents,
final @NonNull Logout logout,
final @NonNull PlayServicesCapability playServicesCapability,
final @NonNull Scheduler scheduler,
final @NonNull io.reactivex.Scheduler schedulerV2,
final @NonNull Scheduler schedulerV2,
final @NonNull SharedPreferences sharedPreferences,
final @NonNull Stripe stripe,
final @NonNull @WebEndpoint String webEndpoint,
Expand All @@ -151,15 +136,11 @@ static Environment provideEnvironment(final @NonNull @ActivitySamplePreference I

return Environment.builder()
.activitySamplePreference(activitySamplePreference)
.apiClient(apiClient)
.apiClientV2(apiClientV2)
.apolloClient(apolloClient)
.apolloClientV2(apolloClientV2)
.build(build)
.cookieManager(cookieManager)
.currentConfig(currentConfig)
.currentConfig2(currentConfig2)
.currentUser(currentUser)
.currentUserV2(currentUser2)
.firstSessionPreference(firstSessionPreference)
.gson(gson)
Expand All @@ -172,7 +153,6 @@ static Environment provideEnvironment(final @NonNull @ActivitySamplePreference I
.attributionEvents(attributionEvents)
.logout(logout)
.playServicesCapability(playServicesCapability)
.scheduler(scheduler)
.schedulerV2(schedulerV2)
.sharedPreferences(sharedPreferences)
.stripe(stripe)
Expand Down Expand Up @@ -252,16 +232,6 @@ static OkHttpClient provideOkHttpClient(final @NonNull ApiRequestInterceptor api
.build();
}

@Provides
@Singleton
@ApiRetrofit
@NonNull
static Retrofit provideApiRetrofit(final @NonNull ApiEndpoint apiEndpoint,
final @NonNull Gson gson,
final @NonNull OkHttpClient okHttpClient) {
return createRetrofit(apiEndpoint.url(), gson, okHttpClient);
}

@Provides
@Singleton
@ApiRetrofitV2
Expand Down Expand Up @@ -289,13 +259,6 @@ static GraphQLInterceptor provideGraphQLInterceptor(final @NonNull String client
return new GraphQLInterceptor(clientId, currentUser, build);
}

@Provides
@Singleton
@NonNull
static ApiService provideApiService(final @ApiRetrofit @NonNull Retrofit retrofit) {
return retrofit.create(ApiService.class);
}

@Provides
@Singleton
@NonNull
Expand Down Expand Up @@ -334,26 +297,17 @@ static HttpLoggingInterceptor provideHttpLoggingInterceptor() {
static Retrofit provideWebRetrofit(@NonNull @WebEndpoint final String webEndpoint,
final @NonNull Gson gson,
final @NonNull OkHttpClient okHttpClient) {
return createRetrofit(webEndpoint, gson, okHttpClient);
return createRetrofitV2(webEndpoint, gson, okHttpClient);
}

@Provides
@Singleton
@NonNull
static WebRequestInterceptor provideWebRequestInterceptor(final @NonNull CurrentUserType currentUser,
static WebRequestInterceptor provideWebRequestInterceptor(final @NonNull CurrentUserTypeV2 currentUser,
@NonNull @WebEndpoint final String endpoint, final @NonNull InternalToolsType internalTools, final @NonNull Build build) {
return new WebRequestInterceptor(currentUser, endpoint, internalTools, build);
}

private static @NonNull Retrofit createRetrofit(final @NonNull String baseUrl, final @NonNull Gson gson, final @NonNull OkHttpClient okHttpClient) {
return new Retrofit.Builder()
.client(okHttpClient)
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
}

private static @NonNull Retrofit createRetrofitV2(final @NonNull String baseUrl, final @NonNull Gson gson, final @NonNull OkHttpClient okHttpClient) {
return new Retrofit.Builder()
.client(okHttpClient)
Expand Down Expand Up @@ -438,9 +392,8 @@ SegmentTrackingClient provideSegmentTrackingClient(
@Singleton
static AnalyticEvents provideAnalytics(
final @ApplicationContext @NonNull Context context,
final @NonNull CurrentUserType currentUser,
final @NonNull CurrentUserTypeV2 currentUser,
final @NonNull Build build,
final @NonNull CurrentConfigType currentConfig,
final @NonNull FeatureFlagClientType ffClient,
final @NonNull SegmentTrackingClient segmentClient) {
final List<TrackingClientType> clients = Arrays.asList(segmentClient);
Expand All @@ -454,12 +407,6 @@ static AttributionEvents provideAttributionEvents(
return new AttributionEvents(apolloClient);
}

@Provides
@Singleton
static Scheduler provideScheduler() {
return Schedulers.computation();
}

@Provides
@Singleton
static io.reactivex.Scheduler provideSchedulerV2() {
Expand All @@ -486,14 +433,6 @@ static Build provideBuild(final @NonNull PackageInfo packageInfo) {
return new Build(packageInfo);
}

@Provides
@Singleton
static CurrentConfigType provideCurrentConfig(final @NonNull AssetManager assetManager,
final @NonNull Gson gson,
final @ConfigPreference @NonNull StringPreferenceType configPreference) {
return new CurrentConfig(assetManager, gson, configPreference);
}

@Provides
@Singleton
static CurrentConfigTypeV2 provideCurrentConfig2(final @NonNull AssetManager assetManager,
Expand All @@ -514,14 +453,6 @@ static CookieManager provideCookieManager() {
return new CookieManager();
}

@Provides
@Singleton
static CurrentUserType provideCurrentUser(final @AccessTokenPreference @NonNull StringPreferenceType accessTokenPreference,
final @NonNull DeviceRegistrarType deviceRegistrar, final @NonNull Gson gson,
final @NonNull @UserPreference StringPreferenceType userPreference) {
return new CurrentUser(accessTokenPreference, deviceRegistrar, gson, userPreference);
}

@Provides
@Singleton
static CurrentUserTypeV2 provideCurrentUser2(final @AccessTokenPreference @NonNull StringPreferenceType accessTokenPreference,
Expand Down Expand Up @@ -593,8 +524,8 @@ static KSWebViewClient provideKSWebViewClient(final @NonNull OkHttpClient okHttp

@Provides
@Singleton
static Logout provideLogout(final @NonNull CookieManager cookieManager, final @NonNull CurrentUserType currentUser, final @NonNull CurrentUserTypeV2 currentUserV2) {
return new Logout(cookieManager, currentUser, currentUserV2);
static Logout provideLogout(final @NonNull CookieManager cookieManager, final @NonNull CurrentUserTypeV2 currentUser, final @NonNull CurrentUserTypeV2 currentUserV2) {
return new Logout(cookieManager, currentUserV2);
}

@Provides
Expand Down
17 changes: 0 additions & 17 deletions app/src/main/java/com/kickstarter/libs/ActivityLifecycleType.java

This file was deleted.

Loading

0 comments on commit f7f29a1

Please sign in to comment.