Skip to content

Commit 91bbd7f

Browse files
committed
Various code style fixes and styles.xml improvements
1 parent 3f2a474 commit 91bbd7f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+254
-149
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Rocket Science
1+
# Android-Kotlin-Modulerized-CleanArchitecture
22

33
[![Actions](https://github.com/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture/workflows/Android%20CI/badge.svg)](https://github.com/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture/actions) [![CircleCI](https://circleci.com/gh/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture/tree/master.svg?style=svg)](https://circleci.com/gh/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture/tree/master) [![codebeat badge](https://codebeat.co/badges/542fb08a-b3cc-4ff8-b1bb-35a66932f12f)](https://codebeat.co/projects/github-com-melihaksoy-rocketscience-master) [![codecov](https://codecov.io/gh/melihaksoy/RocketScience/branch/master/graph/badge.svg?token=pXPKpV5dz6)](https://codecov.io/gh/melihaksoy/RocketScience) [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)
44

5-
RocketScience is a prototype application tries to serve an example for modularization & clean architecture in Android.
5+
This is a prototype application tries to serve an example for modularization & clean architecture in Android.
66

77
While there are many blogs about good practices, it's hard to come by a complete example that merges these different popular topics & approaches.
88

9-
RocketScience takes popular approaches and libraries to create an example on how to actually bind these components with each other.
9+
This project takes popular approaches and libraries to create an example on how to actually bind these components with each other.
1010

1111
I'll soon be writing small series about roadmap, challanges, alternatives and try - fails I've encountered during development in [Medium](https://medium.com/@aksoymelihcan).
1212

app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ apply plugin: 'kotlin-kapt'
44

55
apply from: "$rootProject.projectDir/scripts/default_android_config.gradle"
66
apply from: "$rootProject.projectDir/scripts/sources.gradle"
7-
apply from: "$rootProject.projectDir/scripts/flavors.gradle"
87

98
android {
109
defaultConfig {

core/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ apply plugin: 'kotlin-kapt'
44

55
apply from: "$rootProject.projectDir/scripts/default_android_config.gradle"
66
apply from: "$rootProject.projectDir/scripts/sources.gradle"
7-
apply from: "$rootProject.projectDir/scripts/flavors.gradle"
87

98
android {
109
dataBinding {

core/src/main/kotlin/com/melih/core/base/lifecycle/BaseDaggerFragment.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ import javax.inject.Inject
1414
* Parent of fragments which has injections. Aim is to seperate [BaseFragment] functionality for fragments which
1515
* won't need any injection.
1616
*
17-
* Note that fragments that extends from [BaseDaggerFragment] should contribute android injector.
17+
* Note that fragments that extends from [BaseDaggerFragment] should contribute their injector.
1818
*
1919
* This class provides [viewModelFactory] which serves as factory for view models
2020
* in the project. It's injected by map of view models that this app is serving. Check [ViewModelFactory]
2121
* to see how it works.
2222
*/
2323
abstract class BaseDaggerFragment<T : ViewDataBinding> : BaseFragment<T>(), HasAndroidInjector {
2424

25-
// region Properties
25+
//region Properties
2626

2727
@get:Inject
2828
internal var androidInjector: DispatchingAndroidInjector<Any>? = null
2929

3030
@Inject
3131
lateinit var viewModelFactory: ViewModelFactory
32-
// endregion
32+
//endregion
3333

34-
// region Functions
34+
//region Functions
3535

3636
override fun onAttach(context: Context) {
3737
AndroidSupportInjection.inject(this)
3838
super.onAttach(context)
3939
}
4040

4141
override fun androidInjector(): AndroidInjector<Any>? = androidInjector
42-
// endregion
42+
//endregion
4343
}

core/src/main/kotlin/com/melih/core/base/lifecycle/BaseFragment.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ import com.melih.repository.interactors.base.Reason
2020
*/
2121
abstract class BaseFragment<T : ViewDataBinding> : Fragment() {
2222

23-
// region Properties
23+
//region Abstractions
24+
25+
@LayoutRes
26+
abstract fun getLayoutId(): Int
27+
//endregion
28+
29+
//region Properties
2430

2531
protected lateinit var binding: T
26-
// endregion
32+
//endregion
2733

28-
// region Functions
34+
//region Functions
2935

3036
override fun onCreateView(
3137
inflater: LayoutInflater,
@@ -46,8 +52,5 @@ abstract class BaseFragment<T : ViewDataBinding> : Fragment() {
4652
block()
4753
}.show()
4854
}
49-
50-
@LayoutRes
51-
abstract fun getLayoutId(): Int
52-
// endregion
55+
//endregion
5356
}

core/src/main/kotlin/com/melih/core/base/paging/BasePagingDataSource.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ const val INITIAL_PAGE = 0
3737
@UseExperimental(ExperimentalCoroutinesApi::class)
3838
abstract class BasePagingDataSource<T> : PageKeyedDataSource<Int, T>() {
3939

40-
// region Abstractions
40+
//region Abstractions
4141

4242
abstract fun loadDataForPage(page: Int): Flow<Result<List<T>>> // Load next page(s)
43-
// endregion
43+
//endregion
4444

45-
// region Properties
45+
//region Properties
4646

4747
private val _stateData = MutableLiveData<State>()
4848
private val _reasonData = MutableLiveData<Reason>()
@@ -59,9 +59,9 @@ abstract class BasePagingDataSource<T> : PageKeyedDataSource<Int, T>() {
5959
*/
6060
val reasonData: LiveData<Reason>
6161
get() = _reasonData
62-
// endregion
62+
//endregion
6363

64-
// region Functions
64+
//region Functions
6565

6666
override fun loadInitial(params: LoadInitialParams<Int>, callback: LoadInitialCallback<Int, T>) {
6767
// Looping through channel as we'll receive any state, error or data here
@@ -136,5 +136,5 @@ abstract class BasePagingDataSource<T> : PageKeyedDataSource<Int, T>() {
136136
coroutineScope.cancel()
137137
super.invalidate()
138138
}
139-
// endregion
139+
//endregion
140140
}

core/src/main/kotlin/com/melih/core/base/paging/BasePagingFactory.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ import androidx.paging.DataSource
1616
*/
1717
abstract class BasePagingFactory<T> : DataSource.Factory<Int, T>() {
1818

19-
// region Abstractions
19+
//region Abstractions
2020

2121
abstract fun createSource(): BasePagingDataSource<T>
22-
// endregion
22+
//endregion
2323

24-
// region Properties
24+
//region Properties
2525

2626
private val _currentSource = MutableLiveData<BasePagingDataSource<T>>()
2727

2828
val currentSource: LiveData<BasePagingDataSource<T>>
2929
get() = _currentSource
30-
// endregion
30+
//endregion
3131

32-
// region Functions
32+
//region Functions
3333

3434
override fun create(): DataSource<Int, T> = createSource().apply { _currentSource.postValue(this) }
3535

@@ -38,5 +38,5 @@ abstract class BasePagingFactory<T> : DataSource.Factory<Int, T>() {
3838
* by calling [BasePagingDataSource.invalidate]
3939
*/
4040
fun invalidateDataSource() = currentSource.value?.invalidate()
41-
// endregion
41+
//endregion
4242
}

core/src/main/kotlin/com/melih/core/base/recycler/BasePagingListAdapter.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ abstract class BasePagingListAdapter<T>(
1515
private val clickListener: (T) -> Unit
1616
) : PagedListAdapter<T, BaseViewHolder<T>>(callback) {
1717

18+
//region Abstractions
19+
1820
/**
1921
* This method will be called to create view holder to obfuscate layout inflation creation / process
2022
*
@@ -27,6 +29,9 @@ abstract class BasePagingListAdapter<T>(
2729
parent: ViewGroup,
2830
viewType: Int
2931
): BaseViewHolder<T>
32+
//endregion
33+
34+
//region Functions
3035

3136
/**
3237
* [createViewHolder] will provide holders, no need to override this
@@ -51,18 +56,22 @@ abstract class BasePagingListAdapter<T>(
5156
holder.bind(item)
5257
}
5358
}
59+
//endregion
5460
}
5561

5662
/**
5763
* Base view holder takes view data binding
5864
*/
5965
abstract class BaseViewHolder<T>(binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root) {
6066

67+
//region Functions
68+
6169
/**
6270
* Items are delivered to [bind] via [BaseListAdapter.onBindViewHolder]
6371
*
6472
* @param item entity
6573
* @param position position from adapter
6674
*/
6775
abstract fun bind(item: T)
76+
//endregion
6877
}

core/src/main/kotlin/com/melih/core/base/viewmodel/BasePagingViewModel.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.melih.core.base.viewmodel
22

33
import androidx.lifecycle.LiveData
4-
import androidx.lifecycle.Transformations
4+
import androidx.lifecycle.Transformations.switchMap
55
import androidx.lifecycle.ViewModel
66
import androidx.paging.PagedList
77
import androidx.paging.toLiveData
@@ -20,19 +20,19 @@ import com.melih.repository.interactors.base.State
2020
*/
2121
abstract class BasePagingViewModel<T> : ViewModel() {
2222

23-
// region Abstractions
23+
//region Abstractions
2424

2525
abstract val factory: BasePagingFactory<T>
2626
abstract val config: PagedList.Config
27-
// endregion
27+
//endregion
2828

29-
// region Properties
29+
//region Properties
3030

3131
/**
3232
* Observe [stateData] to get notified of state of data
3333
*/
3434
val stateData: LiveData<State> by lazy {
35-
Transformations.switchMap(factory.currentSource) {
35+
switchMap(factory.currentSource) {
3636
it.stateData
3737
}
3838
}
@@ -41,7 +41,7 @@ abstract class BasePagingViewModel<T> : ViewModel() {
4141
* Observe [errorData] to get notified if an error occurs
4242
*/
4343
val errorData: LiveData<Reason> by lazy {
44-
Transformations.switchMap(factory.currentSource) {
44+
switchMap(factory.currentSource) {
4545
it.reasonData
4646
}
4747
}
@@ -52,9 +52,9 @@ abstract class BasePagingViewModel<T> : ViewModel() {
5252
val pagedList: LiveData<PagedList<T>> by lazy {
5353
factory.toLiveData(config)
5454
}
55-
// endregion
55+
//endregion
5656

57-
// region Functions
57+
//region Functions
5858

5959
fun refresh() {
6060
factory.currentSource.value?.invalidate()
@@ -66,5 +66,5 @@ abstract class BasePagingViewModel<T> : ViewModel() {
6666
fun retry() {
6767
factory.currentSource.value?.invalidate()
6868
}
69-
// endregion
69+
//endregion
7070
}

core/src/main/kotlin/com/melih/core/base/viewmodel/BaseViewModel.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ import kotlinx.coroutines.launch
1515
*/
1616
abstract class BaseViewModel<T> : ViewModel() {
1717

18-
// region Abstractions
18+
//region Abstractions
1919

2020
abstract suspend fun loadData()
21-
// endregion
21+
//endregion
2222

2323
init {
2424
viewModelScope.launch {
2525
loadData()
2626
}
2727
}
2828

29-
// region Properties
29+
//region Properties
3030

3131
private val _successData = MutableLiveData<T>()
3232
private val _stateData = MutableLiveData<State>()
@@ -49,9 +49,9 @@ abstract class BaseViewModel<T> : ViewModel() {
4949
*/
5050
val errorData: LiveData<Reason>
5151
get() = _errorData
52-
// endregion
52+
//endregion
5353

54-
// region Functions
54+
//region Functions
5555

5656
/**
5757
* Default success handler which assigns given [data] to [successData]
@@ -97,5 +97,5 @@ abstract class BaseViewModel<T> : ViewModel() {
9797
loadData()
9898
}
9999
}
100-
// endregion
100+
//endregion
101101
}

0 commit comments

Comments
 (0)