-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 395ebf4
Showing
104 changed files
with
2,678 additions
and
0 deletions.
There are no files selected for viewing
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,35 @@ | ||
.project | ||
.apt_generated | ||
.settings | ||
.DS_Store | ||
.classpath | ||
.idea | ||
.factorypath | ||
.gradle | ||
|
||
|
||
/*/build/ | ||
*/build/ | ||
/gen | ||
/bin | ||
/out | ||
/generated | ||
/build | ||
.iml | ||
|
||
RouteCalculator.iml | ||
local.properties | ||
|
||
bin/classes/com/actionbarsherlock/R$layout.class | ||
bin/R.txt | ||
/*.iml | ||
|
||
com_crashlytics_export_strings.xml | ||
crashlytics-build.properties | ||
|
||
*.iml | ||
app/src/main/res/values-iw/strings.xml | ||
package-lock.json | ||
**/node_modules | ||
*.log | ||
**/.kotlintest |
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,5 @@ | ||
# Trending giphy | ||
|
||
This app displays a list of trending gifs from https://giphy.com/. Example usage of Coroutines, Retrofit, Dagger2, Mvvm+databinding. | ||
|
||
![](https://github.com/VolodymyrMachekhin/Trending-Gifs/blob/master/app.gif?raw=true) |
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,85 @@ | ||
import com.vmac.giphy.Deps | ||
import com.vmac.giphy.Versions | ||
|
||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-kapt' | ||
|
||
// To disable debug obfuscation Settings -> Compiler -> Command line options -> -PdisableObfuscation | ||
def enableDebugObfuscation = !project.hasProperty('disableObfuscation') | ||
|
||
android { | ||
compileSdkVersion Versions.compileSdkVer | ||
|
||
defaultConfig { | ||
applicationId "com.vmac.giphy" | ||
minSdkVersion Versions.minSdkVer | ||
targetSdkVersion Versions.targetSdkVer | ||
versionCode Versions.appVerCode | ||
versionName Versions.appVerName | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildFeatures { | ||
buildConfig = true | ||
viewBinding = true | ||
dataBinding = true | ||
aidl = true | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
buildTypes { | ||
|
||
debug { | ||
debuggable true | ||
minifyEnabled enableDebugObfuscation | ||
shrinkResources enableDebugObfuscation | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
|
||
release { | ||
debuggable false | ||
minifyEnabled true | ||
shrinkResources true | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: "libs", include: ["*.jar"]) | ||
|
||
|
||
kapt Deps.daggerCompiler | ||
kapt Deps.glideCompiler | ||
|
||
List implementationList = [ | ||
Deps.kotlinStdLib, | ||
Deps.androidxAppCompat, | ||
Deps.androidxConstraintlayout, | ||
Deps.androidxFragment, | ||
Deps.okhttp3, | ||
Deps.dagger, | ||
Deps.retrofit2Moshi, | ||
Deps.retrofit2, | ||
Deps.retrofit2Coroutines, | ||
Deps.glide, | ||
Deps.kotlinCoroutines, | ||
Deps.kotlinCoroutinesAndroid, | ||
Deps.loggingInterceptor, | ||
Deps.bindingcollectionadapterRecyclerview, | ||
Deps.bindingcollectionadapter | ||
] | ||
|
||
implementation implementationList | ||
implementation project(":domain") | ||
implementation project(":network") | ||
implementation project(":common-utils") | ||
|
||
testImplementation project(":test-commons") | ||
} |
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,57 @@ | ||
-keep class com.vmac.giphy.network.entity.** { *; } | ||
-keep class com.vmac.giphy.ui.TrendingGifsFragment | ||
|
||
#OkHttp | ||
-dontwarn okhttp3.** | ||
-dontwarn okio.** | ||
-dontwarn javax.annotation.** | ||
-dontwarn org.conscrypt.** | ||
# A resource is loaded with a relative path so the package of this class must be preserved. | ||
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase | ||
|
||
#Okio | ||
-dontwarn okio.** | ||
|
||
#Retrofit | ||
# Retain generic type information for use by reflection by converters and adapters. | ||
-keepattributes Signature | ||
# Retain service method parameters. | ||
-keepclassmembernames interface * { | ||
@retrofit2.http.* <methods>; | ||
} | ||
|
||
#Glide | ||
-keep public class * implements com.bumptech.glide.module.GlideModule | ||
-keep class * extends com.bumptech.glide.module.AppGlideModule { | ||
<init>(...); | ||
} | ||
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** { | ||
**[] $VALUES; | ||
public *; | ||
} | ||
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { | ||
*** rewind(); | ||
} | ||
|
||
# JSR 305 annotations are for embedding nullability information. | ||
-dontwarn javax.annotation.** | ||
|
||
-keepclasseswithmembers class * { | ||
@com.squareup.moshi.* <methods>; | ||
} | ||
|
||
-keep @com.squareup.moshi.JsonQualifier interface * | ||
|
||
# Enum field names are used by the integrated EnumJsonAdapter. | ||
# values() is synthesized by the Kotlin compiler and is used by EnumJsonAdapter indirectly | ||
# Annotate enums with @JsonClass(generateAdapter = false) to use them with Moshi. | ||
-keepclassmembers @com.squareup.moshi.JsonClass class * extends java.lang.Enum { | ||
<fields>; | ||
**[] values(); | ||
} | ||
|
||
-keep class kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoaderImpl | ||
|
||
-keepclassmembers class kotlin.Metadata { | ||
public <methods>; | ||
} |
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,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.vmac.giphy"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name="com.vmac.giphy.ui.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
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,18 @@ | ||
package com.vmac.giphy.di | ||
|
||
import com.vmac.giphy.ui.TrendingGifsFragment | ||
import dagger.Component | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
@Component( | ||
modules = [ | ||
UtilsModule::class, | ||
RepositoryModule::class, | ||
RetrofitModule::class | ||
] | ||
) | ||
interface MainComponent { | ||
|
||
fun inject(fragment: TrendingGifsFragment) | ||
} |
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,15 @@ | ||
package com.vmac.giphy.di | ||
|
||
import com.vmac.giphy.domain.GifRepository | ||
import com.vmac.giphy.network.repository.NetworkGifRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
|
||
@Module | ||
abstract class RepositoryModule { | ||
|
||
@Binds | ||
abstract fun provideRepository( | ||
networkGifRepository: NetworkGifRepository | ||
): GifRepository | ||
} |
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,53 @@ | ||
package com.vmac.giphy.di | ||
|
||
import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory | ||
import com.vmac.giphy.BuildConfig | ||
import com.vmac.giphy.network.client.GiphyClient | ||
import com.vmac.giphy.domain.logging.Logger | ||
import dagger.Module | ||
import dagger.Provides | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import retrofit2.Retrofit | ||
import retrofit2.converter.moshi.MoshiConverterFactory | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
class RetrofitModule { | ||
|
||
@Singleton | ||
@Provides | ||
fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit { | ||
return Retrofit.Builder() | ||
.baseUrl(API_BASE_URL) | ||
.client(okHttpClient) | ||
.addCallAdapterFactory(CoroutineCallAdapterFactory()) | ||
.addConverterFactory(MoshiConverterFactory.create()) | ||
.build() | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun provideOkHttpClient(logger: Logger): OkHttpClient { | ||
val builder = OkHttpClient.Builder() | ||
|
||
if (BuildConfig.DEBUG) { | ||
builder.addInterceptor(HttpLoggingInterceptor(object : HttpLoggingInterceptor.Logger { | ||
override fun log(message: String) { | ||
logger.d(message = message) | ||
} | ||
}).setLevel(HttpLoggingInterceptor.Level.BODY)) | ||
} | ||
|
||
return builder.build() | ||
} | ||
|
||
@Provides | ||
fun provideGiphyClient(retrofit: Retrofit): GiphyClient { | ||
return retrofit.create(GiphyClient::class.java) | ||
} | ||
|
||
companion object { | ||
private const val API_BASE_URL: String = "https://api.giphy.com" | ||
} | ||
} |
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,23 @@ | ||
package com.vmac.giphy.di | ||
|
||
import com.vmac.giphy.common.utils.logging.LoggerImpl | ||
import com.vmac.giphy.domain.coroutines.DispatchersProvider | ||
import com.vmac.giphy.domain.coroutines.DispatchersProviderImpl | ||
import com.vmac.giphy.domain.logging.Logger | ||
import com.vmac.giphy.ui.image.GlideImageLoader | ||
import com.vmac.giphy.ui.image.ImageLoader | ||
import dagger.Binds | ||
import dagger.Module | ||
|
||
@Module | ||
abstract class UtilsModule { | ||
|
||
@Binds | ||
abstract fun provideLogger(loggerImpl: LoggerImpl): Logger | ||
|
||
@Binds | ||
abstract fun provideImageLoader(glideImageLoader: GlideImageLoader): ImageLoader | ||
|
||
@Binds | ||
abstract fun provideDispatchersProvider(glideImageLoader: DispatchersProviderImpl): DispatchersProvider | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/vmac/giphy/ui/GiphyListBindingProvider.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,22 @@ | ||
package com.vmac.giphy.ui | ||
|
||
import com.vmac.giphy.BR | ||
import com.vmac.giphy.R | ||
import com.vmac.giphy.ui.adapter.GiphyListItem | ||
import me.tatarka.bindingcollectionadapter2.ItemBinding | ||
import me.tatarka.bindingcollectionadapter2.itembindings.OnItemBindClass | ||
import javax.inject.Inject | ||
import javax.inject.Provider | ||
|
||
class GiphyListBindingProvider @Inject constructor() : Provider<OnItemBindClass<GiphyListItem>> { | ||
|
||
override fun get(): OnItemBindClass<GiphyListItem> { | ||
return OnItemBindClass<GiphyListItem>() | ||
.map(GiphyListItem.DisplayGiphy::class.java) { itemBinding, _, _ -> | ||
itemBinding.set(BR.item, R.layout.item_gif) | ||
} | ||
.map(GiphyListItem.LoadMore::class.java) { itemBinding, _, _ -> | ||
itemBinding.set(ItemBinding.VAR_NONE, R.layout.item_progress) | ||
} | ||
} | ||
} |
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,24 @@ | ||
package com.vmac.giphy.ui | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.vmac.giphy.R | ||
import com.vmac.giphy.di.DaggerMainComponent | ||
import com.vmac.giphy.di.MainComponent | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
lateinit var viewModel: TrendingViewModel | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
mainComponent = DaggerMainComponent | ||
.builder() | ||
.build() | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
} | ||
|
||
companion object { | ||
lateinit var mainComponent: MainComponent | ||
} | ||
} |
Oops, something went wrong.