├── .gitignore ├── .idea ├── .name ├── compiler.xml └── misc.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── in_ │ │ └── turker │ │ └── baseapp │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── in_ │ │ │ └── turker │ │ │ └── baseapp │ │ │ ├── MyApplication.kt │ │ │ ├── base │ │ │ ├── BaseActivity.kt │ │ │ ├── BaseAdapter.kt │ │ │ ├── BaseFragment.kt │ │ │ ├── BaseHolder.kt │ │ │ ├── BaseRepository.kt │ │ │ └── BaseViewModel.kt │ │ │ ├── model │ │ │ └── CarItem.kt │ │ │ ├── network │ │ │ ├── APIClientImpl.kt │ │ │ ├── DataModule.kt │ │ │ └── Endpoints.kt │ │ │ ├── repository │ │ │ └── CarsRepository.kt │ │ │ ├── ui │ │ │ ├── activity │ │ │ │ ├── SingleActivity.kt │ │ │ │ └── SingleVM.kt │ │ │ └── fragment │ │ │ │ ├── detail │ │ │ │ ├── DetailVM.kt │ │ │ │ └── FragmentDetail.kt │ │ │ │ └── list │ │ │ │ ├── CarListAdapter.kt │ │ │ │ ├── FragmentList.kt │ │ │ │ └── ListVM.kt │ │ │ └── utils │ │ │ ├── ApiState.kt │ │ │ ├── Constants.kt │ │ │ ├── NavigateFragmentParams.kt │ │ │ ├── SingleLiveEvent.kt │ │ │ └── ViewExtensions.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_single.xml │ │ ├── fragment_detail.xml │ │ ├── fragment_list.xml │ │ └── item_car.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── navigation │ │ └── navigation.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ ├── style_textview.xml │ │ └── themes.xml │ └── test │ └── java │ └── in_ │ └── turker │ └── baseapp │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.aar 4 | *.ap_ 5 | *.aab 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | # Uncomment the following line in case you need and you don't have the release build type files in your app 18 | # release/ 19 | 20 | # Gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # IntelliJ 40 | *.iml 41 | .idea/workspace.xml 42 | .idea/tasks.xml 43 | .idea/gradle.xml 44 | .idea/assetWizardSettings.xml 45 | .idea/dictionaries 46 | .idea/libraries 47 | # Android Studio 3 in .gitignore file. 48 | .idea/caches 49 | .idea/modules.xml 50 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 51 | .idea/navEditor.xml 52 | 53 | # Keystore files 54 | # Uncomment the following lines if you do not want to check your keystore files in. 55 | #*.jks 56 | #*.keystore 57 | 58 | # External native build folder generated in Android Studio 2.2 and later 59 | .externalNativeBuild 60 | .cxx/ 61 | 62 | # Google Services (e.g. APIs or Firebase) 63 | # google-services.json 64 | 65 | # Freeline 66 | freeline.py 67 | freeline/ 68 | freeline_project_description.json 69 | 70 | # fastlane 71 | fastlane/report.xml 72 | fastlane/Preview.html 73 | fastlane/screenshots 74 | fastlane/test_output 75 | fastlane/readme.md 76 | 77 | # Version control 78 | vcs.xml 79 | 80 | # lint 81 | lint/intermediates/ 82 | lint/generated/ 83 | lint/outputs/ 84 | lint/tmp/ 85 | # lint/reports/ 86 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Base App -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Base App 2 | Data is fetched from https://turker.in/cars/cars.php 3 | 4 | ## Latest android components are used to make this app 5 | - MVVM Architecture 6 | - Base Class Structure (BaseActivity,BaseFragment,BaseViewModel,BaseRepository,BaseAdapter) 7 | - Dagger Hilt 8 | - Kotlin Flow(State Flow) 9 | - Retrofit 10 | - ViewBinding 11 | - Coroutines 12 | - Jetpack Navigation 13 | - Single Activity Architecture 14 | - Glide 15 | - Stetho 16 | - Extension 17 | 18 | 19 | 20 | ### Screenshot 21 | 22 | 23 | Social | Profile 24 | --- | --- | 25 | *Twitter* | [`@keremturkerr`](https://twitter.com/keremturkerr) 26 | *LinkedIn* | [`@keremturker`](https://www.linkedin.com/in/keremturker/) 27 | 28 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'org.jetbrains.kotlin.android' 4 | id 'kotlin-kapt' 5 | id 'dagger.hilt.android.plugin' 6 | id 'androidx.navigation.safeargs.kotlin' 7 | } 8 | 9 | android { 10 | compileSdk 31 11 | 12 | defaultConfig { 13 | applicationId "in_.turker.baseapp" 14 | minSdk 23 15 | targetSdk 31 16 | versionCode 1 17 | versionName "1.0" 18 | 19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 20 | buildConfigField "String", "BASE_URL", "\"http://turker.in/cars/\"" 21 | 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | kotlinOptions { 35 | jvmTarget = '1.8' 36 | } 37 | buildFeatures { 38 | viewBinding true 39 | } 40 | } 41 | 42 | 43 | def hilt = "2.38.1" 44 | def hilt_lifecycle_view_model = "1.0.0-alpha03" 45 | def activity_version = "1.4.0" 46 | def fragment_version = "1.4.1" 47 | def lifecycle_version = "2.4.1" 48 | def nav_version = "2.4.1" 49 | def glideVersion = '4.12.0' 50 | 51 | dependencies { 52 | 53 | implementation 'androidx.core:core-ktx:1.7.0' 54 | implementation 'androidx.appcompat:appcompat:1.4.1' 55 | implementation 'com.google.android.material:material:1.5.0' 56 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 57 | testImplementation 'junit:junit:4.13.2' 58 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 59 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 60 | 61 | 62 | // Kotlin 63 | implementation "androidx.activity:activity-ktx:$activity_version" 64 | implementation "androidx.fragment:fragment-ktx:$fragment_version" 65 | 66 | // ViewModel 67 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" 68 | // LiveData 69 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" 70 | // Lifecycles only (without ViewModel or LiveData) 71 | implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" 72 | 73 | 74 | //Dagger Hilt 75 | implementation "com.google.dagger:hilt-android:$hilt" 76 | kapt "com.google.dagger:hilt-android-compiler:$hilt" 77 | 78 | implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_lifecycle_view_model" 79 | kapt "androidx.hilt:hilt-compiler:$hilt_lifecycle_view_model" 80 | 81 | //Coroutine 82 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" 83 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" 84 | 85 | //Retrofit 86 | implementation "com.squareup.retrofit2:retrofit:2.9.0" 87 | implementation "com.squareup.retrofit2:converter-gson:2.9.0" 88 | implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2" 89 | implementation "com.google.code.gson:gson:2.8.8" 90 | 91 | //Navigation Component 92 | implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" 93 | implementation "androidx.navigation:navigation-ui-ktx:$nav_version" 94 | 95 | //Stetho 96 | implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0' 97 | 98 | //Image 99 | implementation "com.github.bumptech.glide:glide:$glideVersion" 100 | annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' 101 | 102 | 103 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/in_/turker/baseapp/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("in_.turker.baseapp", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/MyApplication.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp 2 | 3 | import android.app.Application 4 | import com.facebook.stetho.Stetho 5 | import dagger.hilt.android.HiltAndroidApp 6 | 7 | /** 8 | * Created by Kerem TÜRKER on 4.03.2022. 9 | */ 10 | 11 | @HiltAndroidApp 12 | class MyApplication : Application(){ 13 | 14 | 15 | override fun onCreate() { 16 | super.onCreate() 17 | initStetho() 18 | } 19 | 20 | private fun initStetho() { 21 | if (BuildConfig.DEBUG) { 22 | Stetho.initializeWithDefaults(this) 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/base/BaseActivity.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.base 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import androidx.viewbinding.ViewBinding 6 | import in_.turker.baseapp.utils.NavigateFragmentParams 7 | 8 | /** 9 | * Created by Kerem TÜRKER on 4.03.2022. 10 | */ 11 | 12 | abstract class BaseActivity : 13 | AppCompatActivity() { 14 | 15 | lateinit var binding: BindingType 16 | abstract fun onActivityCreated() 17 | abstract fun observe() 18 | abstract fun navigateFragment(params: NavigateFragmentParams) 19 | abstract fun showHideProgress(isShow: Boolean) 20 | abstract fun getViewBinding(): BindingType 21 | protected abstract val viewModel: ViewModelType 22 | 23 | override fun onCreate(savedInstanceState: Bundle?) { 24 | super.onCreate(savedInstanceState) 25 | binding = getViewBinding() 26 | setContentView(binding.root) 27 | onActivityCreated() 28 | observe() 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/base/BaseAdapter.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.base 2 | 3 | import android.annotation.SuppressLint 4 | import androidx.annotation.NonNull 5 | import androidx.recyclerview.widget.RecyclerView 6 | import androidx.viewbinding.ViewBinding 7 | 8 | /** 9 | * Created by Kerem TÜRKER on 4.03.2022. 10 | */ 11 | 12 | /** 13 | * Base Class for [RecyclerView.Adapter] 14 | */ 15 | abstract class BaseAdapter> : 16 | RecyclerView.Adapter() { 17 | 18 | private val itemList: MutableList = ArrayList() 19 | private var itemPosition = -1 20 | 21 | override fun onBindViewHolder(@NonNull holder: ViewHolderType, @SuppressLint("RecyclerView") position: Int) { 22 | val itemData = itemList[position] ?: return 23 | itemPosition = position 24 | holder.item = itemData 25 | holder.bind(holder.viewDataBinding, itemData) 26 | } 27 | 28 | @SuppressLint("NotifyDataSetChanged") 29 | open fun replaceData(newList: List?) { 30 | itemList.clear() 31 | itemList.addAll(newList ?: emptyList()) 32 | notifyDataSetChanged() 33 | } 34 | 35 | override fun getItemCount(): Int = itemList.size 36 | 37 | fun getData(): MutableList { 38 | return itemList 39 | } 40 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/base/BaseFragment.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.base 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import androidx.viewbinding.ViewBinding 9 | import in_.turker.baseapp.utils.observeThis 10 | 11 | /** 12 | * Created by Kerem TÜRKER on 4.03.2022. 13 | */ 14 | 15 | abstract class BaseFragment : 16 | Fragment() { 17 | 18 | private val baseActivity by lazy { activity as BaseActivity<*, *>? } 19 | 20 | lateinit var binding: BindingType 21 | protected abstract val viewModel: ViewModelType 22 | abstract fun getViewBinding(): BindingType 23 | abstract fun onFragmentCreated() 24 | open fun observe() {} 25 | 26 | override fun onCreateView( 27 | inflater: LayoutInflater, 28 | container: ViewGroup?, 29 | savedInstanceState: Bundle? 30 | ): View? { 31 | binding = getViewBinding() 32 | onFragmentCreated() 33 | observe() 34 | observeActions() 35 | return binding.root 36 | } 37 | 38 | private fun observeActions() { 39 | viewModel.navigateFragmentDetection.observeThis(viewLifecycleOwner) { 40 | baseActivity?.navigateFragment(it) 41 | } 42 | viewModel.loadingDetection.observeThis(viewLifecycleOwner) { 43 | baseActivity?.showHideProgress(it) 44 | } 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/base/BaseHolder.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.base 2 | 3 | import androidx.recyclerview.widget.RecyclerView 4 | import androidx.viewbinding.ViewBinding 5 | 6 | /** 7 | * Created by Kerem TÜRKER on 4.03.2022. 8 | */ 9 | 10 | /** 11 | * Base Holder class for [RecyclerView.ViewHolder] 12 | */ 13 | abstract class BaseHolder constructor(internal val viewDataBinding: BindingType) : 14 | RecyclerView.ViewHolder(viewDataBinding.root) { 15 | 16 | /** 17 | * Getter for [DataType] class 18 | */ 19 | var item: DataType? = null 20 | 21 | /** 22 | * Binds holder data 23 | */ 24 | abstract fun bind(binding: BindingType, item: DataType?) 25 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/base/BaseRepository.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.base 2 | 3 | import kotlinx.coroutines.CoroutineScope 4 | import kotlinx.coroutines.Dispatchers 5 | import kotlinx.coroutines.flow.catch 6 | import kotlinx.coroutines.flow.collect 7 | import kotlinx.coroutines.flow.flow 8 | import kotlinx.coroutines.flow.flowOn 9 | import kotlinx.coroutines.launch 10 | 11 | /** 12 | * Created by Kerem TÜRKER on 4.03.2022. 13 | */ 14 | 15 | 16 | open class BaseRepository { 17 | 18 | fun sendRequest( 19 | scope: CoroutineScope, 20 | client: suspend () -> T, 21 | onErrorAction: ((String?) -> Unit)?, 22 | onSuccess: ((T) -> Unit), 23 | ) { 24 | makeAPIRequest(scope, client, onSuccess, onErrorAction) 25 | } 26 | 27 | private fun makeAPIRequest( 28 | scope: CoroutineScope, 29 | client: suspend () -> T, 30 | onSuccess: ((T) -> Unit)? = null, 31 | onErrorAction: ((String?) -> Unit)? = null 32 | ) { 33 | scope.launch { 34 | try { 35 | val request = flow { 36 | emit(client) 37 | }.flowOn(Dispatchers.IO) 38 | 39 | request.catch { e -> 40 | onErrorAction?.invoke(e.message) 41 | }.collect { 42 | onSuccess?.invoke(it.invoke()) 43 | } 44 | 45 | } catch (e: Exception) { 46 | onErrorAction?.invoke(e.message) 47 | } 48 | } 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/base/BaseViewModel.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.base 2 | 3 | import android.app.Application 4 | import android.os.Bundle 5 | import androidx.lifecycle.AndroidViewModel 6 | import androidx.navigation.NavOptions 7 | import androidx.navigation.fragment.FragmentNavigator 8 | import dagger.hilt.android.lifecycle.HiltViewModel 9 | import in_.turker.baseapp.utils.NavigateFragmentParams 10 | import in_.turker.baseapp.utils.SingleLiveEvent 11 | import javax.inject.Inject 12 | 13 | /** 14 | * Created by Kerem TÜRKER on 4.03.2022. 15 | */ 16 | 17 | @HiltViewModel 18 | open class BaseViewModel 19 | @Inject constructor( 20 | app: Application 21 | ) : AndroidViewModel(app) { 22 | 23 | val navigateFragmentDetection by lazy { SingleLiveEvent() } 24 | val loadingDetection by lazy { SingleLiveEvent() } 25 | 26 | 27 | fun navigateFragment( 28 | navAction: Int, 29 | bundle: Bundle? = null, 30 | navOptions: NavOptions? = null, 31 | extras: FragmentNavigator.Extras? = null 32 | ) { 33 | val params = NavigateFragmentParams(navAction, bundle, navOptions, extras) 34 | navigateFragmentDetection.postValue(params) 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/model/CarItem.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.model 2 | 3 | 4 | import com.google.gson.annotations.SerializedName 5 | import java.io.Serializable 6 | 7 | /** 8 | * Created by Kerem TÜRKER on 4.03.2022. 9 | */ 10 | 11 | data class CarItem( 12 | @SerializedName("BrandName") 13 | val brandName: String, 14 | @SerializedName("MediumImageUrl") 15 | val mediumImageUrl: String, 16 | @SerializedName("ModelName") 17 | val modelName: String, 18 | @SerializedName("ModelYear") 19 | val modelYear: String, 20 | @SerializedName("Plate") 21 | val plate: String, 22 | @SerializedName("Price") 23 | val price: String 24 | ) : Serializable -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/network/APIClientImpl.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.network 2 | 3 | import com.facebook.stetho.okhttp3.StethoInterceptor 4 | import com.google.gson.GsonBuilder 5 | import in_.turker.baseapp.BuildConfig 6 | import okhttp3.OkHttpClient 7 | import retrofit2.Retrofit 8 | import retrofit2.converter.gson.GsonConverterFactory 9 | import java.util.concurrent.TimeUnit 10 | import javax.inject.Inject 11 | import javax.inject.Singleton 12 | 13 | /** 14 | * Created by Kerem TÜRKER on 4.03.2022. 15 | */ 16 | 17 | 18 | const val CONNECTION_TIMEOUT_SEC = 5 * 60L 19 | 20 | interface APIClient { 21 | val apiCollect: Endpoints 22 | } 23 | 24 | @Singleton 25 | class APIClientImpl @Inject constructor() : APIClient { 26 | 27 | override val apiCollect: Endpoints by lazy { 28 | clientCollect.create(Endpoints::class.java) 29 | } 30 | 31 | private val clientCollect: Retrofit by lazy { 32 | retrofitBuilderCollect.client(okHttpClientCollect).build() 33 | } 34 | 35 | private val stethoInterceptor: StethoInterceptor? by lazy { 36 | if (BuildConfig.DEBUG) StethoInterceptor() else null 37 | } 38 | 39 | 40 | private val retrofitBuilderCollect: Retrofit.Builder by lazy { 41 | Retrofit.Builder() 42 | .baseUrl(BuildConfig.BASE_URL) 43 | .addConverterFactory(GsonConverterFactory.create(GsonBuilder().create())) 44 | } 45 | 46 | private val okHttpClientCollect: OkHttpClient by lazy { 47 | okHttpClientBuilderCollect.addInterceptor { chain -> 48 | val builder = chain.request().newBuilder() 49 | chain.proceed(builder.build()) 50 | } 51 | okHttpClientBuilderCollect.build() 52 | } 53 | 54 | private val okHttpClientBuilderCollect by lazy { 55 | val builder = OkHttpClient.Builder() 56 | .connectTimeout(CONNECTION_TIMEOUT_SEC, TimeUnit.SECONDS) 57 | .readTimeout(CONNECTION_TIMEOUT_SEC, TimeUnit.SECONDS) 58 | stethoInterceptor?.let { builder.addNetworkInterceptor(it) } 59 | 60 | builder 61 | } 62 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/network/DataModule.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.network 2 | 3 | import dagger.Binds 4 | import dagger.Module 5 | import dagger.hilt.InstallIn 6 | import dagger.hilt.components.SingletonComponent 7 | 8 | /** 9 | * Created by Kerem TÜRKER on 4.03.2022. 10 | */ 11 | 12 | @InstallIn(SingletonComponent::class) 13 | @Module 14 | abstract class DataModule { 15 | @Binds 16 | abstract fun bindAPIClientImpl(impl: APIClientImpl): APIClient 17 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/network/Endpoints.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.network 2 | 3 | import in_.turker.baseapp.model.CarItem 4 | import retrofit2.http.POST 5 | 6 | /** 7 | * Created by Kerem TÜRKER on 4.03.2022. 8 | */ 9 | 10 | interface Endpoints { 11 | 12 | @POST("cars.php") 13 | suspend fun getCars(): List 14 | 15 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/repository/CarsRepository.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.repository 2 | 3 | import in_.turker.baseapp.base.BaseRepository 4 | import in_.turker.baseapp.model.CarItem 5 | import in_.turker.baseapp.network.APIClientImpl 6 | import kotlinx.coroutines.CoroutineScope 7 | import javax.inject.Inject 8 | 9 | /** 10 | * Created by Kerem TÜRKER on 4.03.2022. 11 | */ 12 | class CarsRepository @Inject 13 | constructor(private val apiServiceImpl: APIClientImpl) : BaseRepository() { 14 | 15 | suspend fun getCars( 16 | scope: CoroutineScope, 17 | onSuccess: ((List?) -> Unit), 18 | onErrorAction: ((String?) -> Unit) 19 | ) = 20 | sendRequest( 21 | scope = scope, 22 | client = { apiServiceImpl.apiCollect.getCars() }, 23 | onSuccess = { 24 | onSuccess(it) 25 | }, 26 | onErrorAction = { 27 | onErrorAction(it) 28 | } 29 | ) 30 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/ui/activity/SingleActivity.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.ui.activity 2 | 3 | 4 | import android.content.Intent 5 | import androidx.activity.viewModels 6 | import androidx.navigation.NavController 7 | import androidx.navigation.fragment.NavHostFragment 8 | import dagger.hilt.android.AndroidEntryPoint 9 | import in_.turker.baseapp.R 10 | import in_.turker.baseapp.base.BaseActivity 11 | import in_.turker.baseapp.databinding.ActivitySingleBinding 12 | import in_.turker.baseapp.utils.NavigateFragmentParams 13 | import in_.turker.baseapp.utils.visibleIf 14 | 15 | @AndroidEntryPoint 16 | class SingleActivity : BaseActivity(){ 17 | 18 | override val viewModel: SingleVM by viewModels() 19 | override fun getViewBinding() = ActivitySingleBinding.inflate(layoutInflater) 20 | 21 | private var currentNavController: NavController? = null 22 | 23 | 24 | override fun onActivityCreated() { 25 | val navHostFragment = supportFragmentManager.findFragmentById(R.id.sectionMain) 26 | currentNavController = (navHostFragment as NavHostFragment).navController 27 | } 28 | 29 | override fun supportNavigateUpTo(upIntent: Intent) { 30 | currentNavController?.navigateUp() 31 | } 32 | 33 | override fun observe() {} 34 | 35 | override fun navigateFragment(params: NavigateFragmentParams) { 36 | currentNavController?.navigate( 37 | params.navAction, 38 | params.bundle, 39 | params.navOptions, 40 | params.extras 41 | ) 42 | } 43 | 44 | override fun showHideProgress(isShow: Boolean) { 45 | binding.pbLoading.visibleIf(isShow) 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/ui/activity/SingleVM.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.ui.activity 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.lifecycle.HiltViewModel 5 | import in_.turker.baseapp.base.BaseViewModel 6 | import javax.inject.Inject 7 | 8 | /** 9 | * Created by Kerem TÜRKER on 4.03.2022. 10 | */ 11 | 12 | @HiltViewModel 13 | class SingleVM 14 | @Inject constructor(myApp: Application) : BaseViewModel(app = myApp) -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/ui/fragment/detail/DetailVM.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.ui.fragment.detail 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.lifecycle.HiltViewModel 5 | import in_.turker.baseapp.base.BaseViewModel 6 | import javax.inject.Inject 7 | 8 | /** 9 | * Created by Kerem TÜRKER on 4.03.2022. 10 | */ 11 | 12 | @HiltViewModel 13 | class DetailVM @Inject constructor( 14 | myApp: Application 15 | ) : BaseViewModel(app = myApp) -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/ui/fragment/detail/FragmentDetail.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.ui.fragment.detail 2 | 3 | import androidx.fragment.app.viewModels 4 | import dagger.hilt.android.AndroidEntryPoint 5 | import in_.turker.baseapp.R 6 | import in_.turker.baseapp.base.BaseFragment 7 | import in_.turker.baseapp.databinding.FragmentDetailBinding 8 | import in_.turker.baseapp.model.CarItem 9 | import in_.turker.baseapp.utils.CAR_ITEM 10 | import in_.turker.baseapp.utils.loadImagesWithGlide 11 | 12 | /** 13 | * Created by Kerem TÜRKER on 4.03.2022. 14 | */ 15 | 16 | @AndroidEntryPoint 17 | class FragmentDetail : BaseFragment() { 18 | override val viewModel: DetailVM by viewModels() 19 | 20 | override fun getViewBinding() = FragmentDetailBinding.inflate(layoutInflater) 21 | 22 | override fun onFragmentCreated() { 23 | val car = arguments?.getSerializable(CAR_ITEM) as CarItem? 24 | 25 | binding.apply { 26 | car?.let { 27 | imgCar.loadImagesWithGlide(it.mediumImageUrl) 28 | txtBrandContent.text = it.brandName 29 | txtModelContent.text = it.modelName 30 | txtPlateContent.text = it.plate 31 | txtYearContent.text = it.modelYear 32 | txtPriceContent.text = getString(R.string.price_value, it.price) 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/ui/fragment/list/CarListAdapter.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.ui.fragment.list 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import in_.turker.baseapp.base.BaseAdapter 6 | import in_.turker.baseapp.base.BaseHolder 7 | import in_.turker.baseapp.databinding.ItemCarBinding 8 | import in_.turker.baseapp.model.CarItem 9 | 10 | /** 11 | * Created by Kerem TÜRKER on 4.03.2022. 12 | */ 13 | 14 | class CarListAdapter(private val onClickAction: ((CarItem) -> Unit)) : 15 | BaseAdapter() { 16 | 17 | override fun onCreateViewHolder( 18 | parent: ViewGroup, 19 | viewType: Int 20 | ): CarListHolder { 21 | return CarListHolder( 22 | ItemCarBinding.inflate(LayoutInflater.from(parent.context), parent, false), 23 | onClickAction 24 | ) 25 | } 26 | 27 | } 28 | 29 | class CarListHolder( 30 | viewBinding: ItemCarBinding, 31 | private val onClickAction: ((CarItem) -> Unit) 32 | ) : 33 | BaseHolder(viewBinding) { 34 | override fun bind(binding: ItemCarBinding, item: CarItem?) { 35 | item?.let { car -> 36 | binding.apply { 37 | 38 | txtCarBrand.text = car.brandName 39 | txtCarModel.text = car.modelName 40 | 41 | cvParent.setOnClickListener { 42 | onClickAction.invoke(car) 43 | } 44 | } 45 | } ?: return 46 | } 47 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/ui/fragment/list/FragmentList.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.ui.fragment.list 2 | 3 | import androidx.fragment.app.viewModels 4 | import androidx.lifecycle.lifecycleScope 5 | import dagger.hilt.android.AndroidEntryPoint 6 | import in_.turker.baseapp.base.BaseFragment 7 | import in_.turker.baseapp.databinding.FragmentListBinding 8 | import in_.turker.baseapp.model.CarItem 9 | import in_.turker.baseapp.utils.ApiState 10 | import in_.turker.baseapp.utils.visibleIf 11 | import kotlinx.coroutines.flow.collect 12 | 13 | /** 14 | * Created by Kerem TÜRKER on 4.03.2022. 15 | */ 16 | 17 | @AndroidEntryPoint 18 | class FragmentList : BaseFragment() { 19 | override val viewModel: ListVM by viewModels() 20 | 21 | override fun getViewBinding() = FragmentListBinding.inflate(layoutInflater) 22 | 23 | private val carListAdapter = CarListAdapter(::onClickAction) 24 | 25 | override fun onFragmentCreated() { 26 | binding.rvCar.adapter = carListAdapter 27 | } 28 | 29 | override fun observe() { 30 | 31 | lifecycleScope.launchWhenResumed { 32 | 33 | viewModel.onCarList.collect { 34 | when (it) { 35 | ApiState.Empty -> {} 36 | 37 | ApiState.Loading -> { 38 | viewModel.loadingDetection.postValue(true) 39 | } 40 | 41 | is ApiState.Failure -> { 42 | binding.apply { 43 | rvCar.visibleIf(false) 44 | txtNoRecord.visibleIf(true) 45 | } 46 | } 47 | 48 | is ApiState.Success -> { 49 | binding.apply { 50 | txtNoRecord.visibleIf(false) 51 | rvCar.visibleIf(true) 52 | } 53 | carListAdapter.replaceData(it.data) 54 | } 55 | } 56 | } 57 | } 58 | } 59 | 60 | private fun onClickAction(car: CarItem) { 61 | viewModel.goToDetail(car) 62 | } 63 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/ui/fragment/list/ListVM.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.ui.fragment.list 2 | 3 | import android.app.Application 4 | import android.os.Bundle 5 | import androidx.lifecycle.viewModelScope 6 | import dagger.hilt.android.lifecycle.HiltViewModel 7 | import in_.turker.baseapp.R 8 | import in_.turker.baseapp.base.BaseViewModel 9 | import in_.turker.baseapp.model.CarItem 10 | import in_.turker.baseapp.repository.CarsRepository 11 | import in_.turker.baseapp.utils.ApiState 12 | import in_.turker.baseapp.utils.CAR_ITEM 13 | import kotlinx.coroutines.flow.MutableStateFlow 14 | import kotlinx.coroutines.flow.StateFlow 15 | import kotlinx.coroutines.launch 16 | import javax.inject.Inject 17 | 18 | /** 19 | * Created by Kerem TÜRKER on 4.03.2022. 20 | */ 21 | 22 | @HiltViewModel 23 | class ListVM @Inject constructor( 24 | myApp: Application, 25 | private val carsRepository: CarsRepository 26 | ) : BaseViewModel(app = myApp) { 27 | 28 | private val _onCarList = MutableStateFlow?>>(ApiState.Empty) 29 | val onCarList: StateFlow?>> = _onCarList 30 | 31 | init { 32 | getCars() 33 | } 34 | 35 | private fun getCars() = viewModelScope.launch { 36 | _onCarList.value = ApiState.Loading 37 | carsRepository.getCars( 38 | scope = viewModelScope, 39 | onSuccess = { 40 | loadingDetection.postValue(false) 41 | _onCarList.value = ApiState.Success(it) 42 | }, onErrorAction = { 43 | loadingDetection.postValue(false) 44 | _onCarList.value = ApiState.Failure(it) 45 | }) 46 | } 47 | 48 | fun goToDetail(car: CarItem) { 49 | Bundle().apply { 50 | putSerializable(CAR_ITEM, car) 51 | navigateFragment(R.id.action_global_fragmentDetail, this) 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/utils/ApiState.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.utils 2 | 3 | /** 4 | * Created by Kerem TÜRKER on 4.03.2022. 5 | */ 6 | 7 | sealed class ApiState { 8 | object Loading : ApiState() 9 | 10 | object Empty : ApiState() 11 | 12 | data class Success(val data: T) : ApiState() 13 | 14 | data class Failure( 15 | val errorMessage: String? 16 | ) : ApiState() 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/utils/Constants.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.utils 2 | 3 | /** 4 | * Created by Kerem TÜRKER on 4.03.2022. 5 | */ 6 | 7 | const val CAR_ITEM = "CAR_ITEM" -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/utils/NavigateFragmentParams.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.utils 2 | 3 | import android.os.Bundle 4 | import androidx.navigation.NavOptions 5 | import androidx.navigation.fragment.FragmentNavigator 6 | 7 | /** 8 | * Created by Kerem TÜRKER on 4.03.2022. 9 | */ 10 | 11 | data class NavigateFragmentParams( 12 | val navAction: Int, 13 | val bundle: Bundle? = null, 14 | val navOptions: NavOptions? = null, 15 | val extras: FragmentNavigator.Extras? = null 16 | ) 17 | -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/utils/SingleLiveEvent.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.utils 2 | 3 | import androidx.annotation.MainThread 4 | import androidx.lifecycle.LifecycleOwner 5 | import androidx.lifecycle.MutableLiveData 6 | import androidx.lifecycle.Observer 7 | import java.util.concurrent.atomic.AtomicBoolean 8 | 9 | /** 10 | * Created by Kerem TÜRKER on 4.03.2022. 11 | */ 12 | 13 | 14 | class SingleLiveEvent : MutableLiveData() { 15 | 16 | private val pending = AtomicBoolean(false) 17 | 18 | @MainThread 19 | override fun observe(owner: LifecycleOwner, observer: Observer) { 20 | 21 | if (hasActiveObservers()) { 22 | /* Timber.tag(TAG) 23 | .w("Multiple observers registered but only one will be notified of changes.") 24 | */ } 25 | 26 | // Observe the internal MutableLiveData 27 | super.observe(owner) { t -> 28 | if (pending.compareAndSet(true, false)) { 29 | observer.onChanged(t) 30 | } 31 | } 32 | } 33 | 34 | @MainThread 35 | override fun setValue(t: T?) { 36 | pending.set(true) 37 | super.setValue(t) 38 | } 39 | 40 | /** 41 | * Used for cases where T is Void, to make calls cleaner. 42 | */ 43 | @MainThread 44 | fun call() { 45 | value = null 46 | } 47 | 48 | companion object { 49 | private const val TAG = "SingleLiveEvent" 50 | } 51 | } -------------------------------------------------------------------------------- /app/src/main/java/in_/turker/baseapp/utils/ViewExtensions.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp.utils 2 | 3 | import android.view.View 4 | import android.widget.ImageView 5 | import androidx.lifecycle.LifecycleOwner 6 | import androidx.lifecycle.LiveData 7 | import com.bumptech.glide.Glide 8 | import com.bumptech.glide.load.engine.DiskCacheStrategy 9 | 10 | /** 11 | * Created by Kerem TÜRKER on 4.03.2022. 12 | */ 13 | 14 | fun ImageView.loadImagesWithGlide(url: String) { 15 | Glide.with(this) 16 | .load(url) 17 | .centerCrop() 18 | .diskCacheStrategy(DiskCacheStrategy.ALL) 19 | .into(this) 20 | } 21 | 22 | 23 | fun LiveData.observeThis(owner: LifecycleOwner, function: (T) -> Unit) { 24 | observe(owner) { 25 | it?.let { 26 | function(it) 27 | } 28 | } 29 | } 30 | 31 | 32 | fun View.visibleIf(visible: Boolean) { 33 | visibility = if (visible) View.VISIBLE else View.GONE 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_single.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 20 | 21 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 21 | 22 | 27 | 28 | 29 | 30 | 38 | 39 | 47 | 48 | 49 | 55 | 56 | 63 | 64 | 65 | 71 | 72 | 79 | 80 | 81 | 87 | 88 | 95 | 96 | 102 | 103 | 110 | 111 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 20 | 21 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_car.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | 29 | 30 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/navigation/navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2dp 5 | 4dp 6 | 6dp 7 | 8dp 8 | 12dp 9 | 16dp 10 | 24dp 11 | 32dp 12 | 48dp 13 | 56dp 14 | 64dp 15 | 72dp 16 | 102dp 17 | 124dp 18 | 212dp 19 | 256dp 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Base App 3 | No records found 4 | 5 | Brand: 6 | Model: 7 | Year: 8 | Plate: 9 | Price: 10 | 11 | %1$s TL 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/style_textview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/test/java/in_/turker/baseapp/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package in_.turker.baseapp 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | dependencies { 5 | def nav_version = "2.3.5" 6 | def dagger_version = "2.40.5" 7 | classpath("com.google.dagger:hilt-android-gradle-plugin:$dagger_version") 8 | classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" 9 | } 10 | } 11 | 12 | plugins { 13 | id 'com.android.application' version '7.1.2' apply false 14 | id 'com.android.library' version '7.1.2' apply false 15 | id 'org.jetbrains.kotlin.android' version '1.6.10' apply false 16 | } 17 | 18 | task clean(type: Delete) { 19 | delete rootProject.buildDir 20 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Keremturker/BaseApp-Android-Kotlin/0461c412df0485c1b8768abdaa96cb96e5d4d355/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Mar 04 14:31:27 TRT 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "Base App" 16 | include ':app' 17 | --------------------------------------------------------------------------------