-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #881 from Automattic/update/wear-network-call-factory
Prefer faster networks for downloads on watch
- Loading branch information
Showing
10 changed files
with
421 additions
and
29 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
app/src/main/java/au/com/shiftyjelly/pocketcasts/di/AppModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package au.com.shiftyjelly.pocketcasts.di | ||
|
||
import android.content.Context | ||
import android.net.ConnectivityManager | ||
import au.com.shiftyjelly.pocketcasts.repositories.di.DownloadCallFactory | ||
import au.com.shiftyjelly.pocketcasts.repositories.di.DownloadOkHttpClient | ||
import au.com.shiftyjelly.pocketcasts.repositories.di.DownloadRequestBuilder | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import okhttp3.Call | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object AppModule { | ||
|
||
@Provides | ||
fun connectivityManager(@ApplicationContext application: Context): ConnectivityManager = | ||
application.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | ||
|
||
@Provides | ||
@Singleton | ||
@DownloadCallFactory | ||
fun downloadCallFactory( | ||
@DownloadOkHttpClient phoneCallFactory: OkHttpClient, | ||
): Call.Factory = phoneCallFactory | ||
|
||
@Provides | ||
@DownloadRequestBuilder | ||
fun downloadRequestBuilder(): Request.Builder = Request.Builder() | ||
} |
29 changes: 29 additions & 0 deletions
29
automotive/src/main/java/au/com/shiftyjelly/pocketcasts/di/AutomotiveAppModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package au.com.shiftyjelly.pocketcasts.di | ||
|
||
import au.com.shiftyjelly.pocketcasts.repositories.di.DownloadCallFactory | ||
import au.com.shiftyjelly.pocketcasts.repositories.di.DownloadOkHttpClient | ||
import au.com.shiftyjelly.pocketcasts.repositories.di.DownloadRequestBuilder | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import okhttp3.Call | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object AutomotiveAppModule { | ||
|
||
@Provides | ||
@Singleton | ||
@DownloadCallFactory | ||
fun downloadCallFactory( | ||
@DownloadOkHttpClient phoneCallFactory: OkHttpClient, | ||
): Call.Factory = phoneCallFactory | ||
|
||
@Provides | ||
@DownloadRequestBuilder | ||
fun downloadRequestBuilder(): Request.Builder = Request.Builder() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
.../repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/di/Annotations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package au.com.shiftyjelly.pocketcasts.repositories.di | ||
|
||
import javax.inject.Qualifier | ||
|
||
/** | ||
* Annotation for providing the Call.Factory used for downloads. The provides method | ||
* for this annotation must be provided in the relevant application module because | ||
* the Call.Factory is different for Wear. | ||
*/ | ||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class DownloadCallFactory | ||
|
||
/** | ||
* Annotation for providing the OkhttpClient for download calls. | ||
*/ | ||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class DownloadOkHttpClient | ||
|
||
/** | ||
* Annotation for providing the Request.Builder used for download calls. The provides method | ||
* for this annotation must be provided in the relevant application module because | ||
* the Request.Builder is different for Wear. | ||
*/ | ||
@Qualifier | ||
@Retention(AnnotationRetention.BINARY) | ||
annotation class DownloadRequestBuilder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.