Skip to content

Commit a561cf7

Browse files
authored
update(dependencies) (#1)
1 parent c93debc commit a561cf7

File tree

10 files changed

+142
-132
lines changed

10 files changed

+142
-132
lines changed

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,41 @@ android {
3838

3939
dependencies {
4040
implementation fileTree(dir: 'libs', include: ['*.jar'])
41-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
41+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
4242

43-
implementation 'androidx.appcompat:appcompat:1.1.0'
44-
implementation 'androidx.core:core-ktx:1.2.0'
43+
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
44+
implementation 'androidx.core:core-ktx:1.3.0-beta01'
4545
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
46-
implementation 'androidx.recyclerview:recyclerview:1.1.0'
47-
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'
48-
implementation 'com.google.android.material:material:1.2.0-alpha04'
46+
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha02'
47+
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-beta01'
48+
implementation 'com.google.android.material:material:1.2.0-alpha05'
4949

5050
// viewModelScope
51-
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
51+
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-alpha01'
5252

5353
// lifecycleScope
54-
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
54+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha01'
5555

5656
// Extensions for LiveData
57-
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
57+
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha01'
5858

5959
// retrofit2
60-
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
61-
implementation 'com.squareup.retrofit2:converter-moshi:2.7.1'
62-
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.1'
60+
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
61+
implementation 'com.squareup.retrofit2:converter-moshi:2.8.1'
62+
implementation 'com.squareup.okhttp3:logging-interceptor:4.4.0'
6363

6464
// moshi
65-
implementation 'com.squareup.moshi:moshi-kotlin:1.8.0'
65+
implementation 'com.squareup.moshi:moshi-kotlin:1.9.2'
6666

6767
// coroutines
68-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
69-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
68+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
69+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
7070

7171
// koin
72-
implementation 'org.koin:koin-androidx-viewmodel:2.0.0'
72+
implementation 'org.koin:koin-androidx-viewmodel:2.1.5'
7373

7474
// coil
75-
implementation 'io.coil-kt:coil:0.8.0'
75+
implementation 'io.coil-kt:coil:0.9.5'
7676

7777
testImplementation 'junit:junit:4.13'
7878
androidTestImplementation 'androidx.test.ext:junit:1.1.1'

app/src/main/java/com/hoc/flowmvi/FlowBinding+Exts+Utils.kt

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ fun View.clicks(): Flow<View> {
3939
}
4040

4141
@ExperimentalCoroutinesApi
42+
@CheckResult
4243
fun EditText.textChanges(): Flow<CharSequence?> {
43-
return callbackFlow {
44+
return callbackFlow<CharSequence?> {
4445
val listener = object : TextWatcher {
4546
override fun afterTextChanged(s: Editable?) = Unit
4647
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit
@@ -55,7 +56,7 @@ fun EditText.textChanges(): Flow<CharSequence?> {
5556

5657
@ExperimentalCoroutinesApi
5758
fun <T, R> Flow<T>.flatMapFirst(transform: suspend (value: T) -> Flow<R>): Flow<R> =
58-
map(transform).flattenFirst()
59+
map(transform).flattenFirst()
5960

6061
@ExperimentalCoroutinesApi
6162
fun <T> Flow<Flow<T>>.flattenFirst(): Flow<T> = channelFlow {
@@ -105,47 +106,48 @@ fun <A, B, R> Flow<A>.withLatestFrom(other: Flow<B>, transform: suspend (A, B) -
105106

106107
fun Context.toast(text: CharSequence) = Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
107108

109+
@ExperimentalCoroutinesApi
108110
suspend fun main() {
109111
(1..2000).asFlow()
110-
.onEach { delay(50) }
111-
.flatMapFirst { v ->
112-
flow {
113-
delay(500)
114-
emit(v)
112+
.onEach { delay(50) }
113+
.flatMapFirst { v ->
114+
flow {
115+
delay(500)
116+
emit(v)
117+
}
115118
}
116-
}
117-
.onEach { println("[*] $it") }
118-
.catch { println("Error $it") }
119-
.collect()
119+
.onEach { println("[*] $it") }
120+
.catch { println("Error $it") }
121+
.collect()
120122
}
121123

122124
class SwipeLeftToDeleteCallback(context: Context, private val onSwipedCallback: (Int) -> Unit) :
123-
ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
125+
ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
124126
private val background: ColorDrawable = ColorDrawable(Color.parseColor("#f44336"))
125127
private val iconDelete =
126-
ContextCompat.getDrawable(context, R.drawable.ic_baseline_delete_white_24)!!
128+
ContextCompat.getDrawable(context, R.drawable.ic_baseline_delete_white_24)!!
127129

128130
override fun onMove(
129-
recyclerView: RecyclerView,
130-
viewHolder: RecyclerView.ViewHolder,
131-
target: RecyclerView.ViewHolder
131+
recyclerView: RecyclerView,
132+
viewHolder: RecyclerView.ViewHolder,
133+
target: RecyclerView.ViewHolder
132134
) = false
133135

134136
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
135-
val position = viewHolder.adapterPosition
137+
val position = viewHolder.bindingAdapterPosition
136138
if (position != RecyclerView.NO_POSITION) {
137139
onSwipedCallback(position)
138140
}
139141
}
140142

141143
override fun onChildDraw(
142-
c: Canvas,
143-
recyclerView: RecyclerView,
144-
viewHolder: RecyclerView.ViewHolder,
145-
dX: Float,
146-
dY: Float,
147-
actionState: Int,
148-
isCurrentlyActive: Boolean
144+
c: Canvas,
145+
recyclerView: RecyclerView,
146+
viewHolder: RecyclerView.ViewHolder,
147+
dX: Float,
148+
dY: Float,
149+
actionState: Int,
150+
isCurrentlyActive: Boolean
149151
) {
150152
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
151153
val itemView = viewHolder.itemView
@@ -161,10 +163,10 @@ class SwipeLeftToDeleteCallback(context: Context, private val onSwipedCallback:
161163

162164
iconDelete.setBounds(iconLeft, iconTop, iconRight, iconBottom)
163165
background.setBounds(
164-
itemView.right + dX.toInt() - 8,
165-
itemView.top,
166-
itemView.right,
167-
itemView.bottom
166+
itemView.right + dX.toInt() - 8,
167+
itemView.top,
168+
itemView.right,
169+
itemView.bottom
168170
)
169171
}
170172
else -> background.setBounds(0, 0, 0, 0)

app/src/main/java/com/hoc/flowmvi/data/UserRepositoryImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import kotlinx.coroutines.channels.Channel
1515
import kotlinx.coroutines.flow.*
1616
import kotlinx.coroutines.withContext
1717

18-
@FlowPreview
1918
@ExperimentalCoroutinesApi
2019
class UserRepositoryImpl(
2120
private val userApiService: UserApiService,
@@ -39,6 +38,7 @@ class UserRepositoryImpl(
3938
}
4039
}
4140

41+
@FlowPreview
4242
override fun getUsers(): Flow<List<User>> {
4343
return flow {
4444
val initial = getUsersFromRemote()

app/src/main/java/com/hoc/flowmvi/koin/DomainModule.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ import org.koin.dsl.module
1818
@ExperimentalCoroutinesApi
1919
@FlowPreview
2020
val domainModule = module {
21-
single { CoroutineDispatchersImpl() as CoroutineDispatchers }
21+
single<CoroutineDispatchers> { CoroutineDispatchersImpl() }
2222

23-
single {
23+
single<UserRepository> {
2424
UserRepositoryImpl(
2525
get(),
2626
get(),
2727
responseToDomain = get<UserResponseToUserDomainMapper>(),
2828
domainToResponse = get<UserDomainToUserResponseMapper>(),
2929
domainToBody = get<UserDomainToUserBodyMapper>()
30-
) as UserRepository
30+
)
3131
}
3232

33-
single { GetUsersUseCase(get()) }
33+
factory { GetUsersUseCase(get()) }
3434

35-
single { RefreshGetUsersUseCase(get()) }
35+
factory { RefreshGetUsersUseCase(get()) }
3636

37-
single { RemoveUserUseCase(get()) }
37+
factory { RemoveUserUseCase(get()) }
3838

39-
single { AddUserUseCase(get()) }
39+
factory { AddUserUseCase(get()) }
4040
}

app/src/main/java/com/hoc/flowmvi/ui/add/AddActivity.kt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ class AddActivity : AppCompatActivity(), View {
4343
// observe view model
4444
addVM.viewState.observe(this, Observer { render(it ?: return@Observer) })
4545
addVM.singleEvent.observe(
46-
this,
47-
Observer { handleSingleEvent(it?.getContentIfNotHandled() ?: return@Observer) }
46+
this,
47+
Observer { handleSingleEvent(it?.getContentIfNotHandled() ?: return@Observer) }
4848
)
4949

5050
// pass view intent to view model
5151
intents()
52-
.onEach { addVM.processIntent(it) }
53-
.launchIn(lifecycleScope)
52+
.onEach { addVM.processIntent(it) }
53+
.launchIn(lifecycleScope)
5454
}
5555

5656
private fun handleSingleEvent(event: SingleEvent) {
@@ -102,25 +102,25 @@ class AddActivity : AppCompatActivity(), View {
102102

103103
override fun intents(): Flow<ViewIntent> {
104104
return merge(
105-
addBinding
106-
.emailEditText
107-
.editText!!
108-
.textChanges()
109-
.map { ViewIntent.EmailChanged(it?.toString()) },
110-
addBinding
111-
.firstNameEditText
112-
.editText!!
113-
.textChanges()
114-
.map { ViewIntent.FirstNameChanged(it?.toString()) },
115-
addBinding
116-
.lastNameEditText
117-
.editText!!
118-
.textChanges()
119-
.map { ViewIntent.LastNameChanged(it?.toString()) },
120-
addBinding
121-
.addButton
122-
.clicks()
123-
.map { ViewIntent.Submit }
105+
addBinding
106+
.emailEditText
107+
.editText!!
108+
.textChanges()
109+
.map { ViewIntent.EmailChanged(it?.toString()) },
110+
addBinding
111+
.firstNameEditText
112+
.editText!!
113+
.textChanges()
114+
.map { ViewIntent.FirstNameChanged(it?.toString()) },
115+
addBinding
116+
.lastNameEditText
117+
.editText!!
118+
.textChanges()
119+
.map { ViewIntent.LastNameChanged(it?.toString()) },
120+
addBinding
121+
.addButton
122+
.clicks()
123+
.map { ViewIntent.Submit }
124124
)
125125
}
126126
}

app/src/main/java/com/hoc/flowmvi/ui/add/AddContract.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ interface AddContract {
1515
}
1616

1717
data class ViewState(
18-
val errors: Set<ValidationError>,
19-
val isLoading: Boolean
18+
val errors: Set<ValidationError>,
19+
val isLoading: Boolean
2020
) {
2121
companion object {
2222
fun initial() = ViewState(
23-
errors = emptySet(),
24-
isLoading = false
23+
errors = emptySet(),
24+
isLoading = false
2525
)
2626
}
2727
}

0 commit comments

Comments
 (0)