Skip to content

Commit

Permalink
Merge pull request #56 from hoc081098/update-deps
Browse files Browse the repository at this point in the history
update deps
  • Loading branch information
hoc081098 authored Oct 19, 2021
2 parents ef527ff + 5f1a655 commit 741479b
Show file tree
Hide file tree
Showing 36 changed files with 211 additions and 184 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Spotless check
run: ./gradlew spotlessCheck

- name: Build debug APK
run: ./gradlew assembleDebug --warning-mode all --stacktrace

Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/remove-old-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Remove old artifacts

on:
# push:
# branches: [ master ]

schedule:
# Runs at 01:00 UTC on the 1, 8, 15, 22 and 29th of every month.
- cron: '0 1 */7 * *'

jobs:
remove-old-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
age: '1 month'
skip-tags: true
skip-recent: 5
25 changes: 25 additions & 0 deletions .github/workflows/spotless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Spotless check

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Spotless check
run: ./gradlew spotlessCheck
5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This project brings to the table set of best practices, tools, and solutions:
[Download latest debug APK here](https://nightly.link/hoc081098/ComicReaderApp_MVI_Coroutine_RxKotlin_Jetpack/workflows/build/master/app-debug.zip)

# Develop
- You must use **Android Studio Bumblebee (2021.1.1) Canary 1** (**note: Java 11 is now the minimum version required**)
- You must use **Android Studio Arctic Fox (2020.3.1)** (**note: Java 11 is now the minimum version required**)
- Clone: `git clone https://github.com/hoc081098/ComicReaderApp_MVI_Coroutine_RxKotlin.git`
- _Optional: **Delete `.idea` folder** if cannot open project_
- Open project by `Android Studio` and run as usual
Expand Down Expand Up @@ -69,21 +69,3 @@ Clone this repository: https://github.com/hoc081098/comic_app_server_nodejs
MIT License

Copyright (c) 2019-2021 Petrus Nguyễn Thái Học

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file removed app/release/app-release.apk
Binary file not shown.
18 changes: 0 additions & 18 deletions app/release/output-metadata.json

This file was deleted.

1 change: 0 additions & 1 deletion app/release/output.json

This file was deleted.

12 changes: 6 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<activity
android:name=".activity.SplashActivity"
android:exported="true"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -60,14 +61,13 @@
android:name="com.hoc.comicapp.initializer.AnalyticsInitializer"
android:value="androidx.startup" />

<!-- If you are using androidx.startup to initialize other components -->
<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
android:exported="false"
tools:node="remove" />

<receiver
android:name=".worker.ComicAppBroadcastReceiver"
android:exported="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class MainActivity : ScopeActivity(R.layout.activity_main) {
.height(size)
.endConfig()
.buildRect(
firstLetter.toUpperCase().toString(),
firstLetter.uppercase(),
ColorGenerator.MATERIAL.getColor(user.email)
)
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/hoc/comicapp/activity/main/MainVM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.jakewharton.rxrelay3.PublishRelay
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Observable.mergeArray
import io.reactivex.rxjava3.core.ObservableTransformer
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.kotlin.addTo
import io.reactivex.rxjava3.kotlin.ofType
import io.reactivex.rxjava3.kotlin.subscribeBy
Expand All @@ -23,7 +24,7 @@ class MainVM(
) : BaseViewModel<ViewIntent, ViewState, SingleEvent>(ViewState.initial()) {
private val intentS = PublishRelay.create<ViewIntent>()

override fun processIntents(intents: Observable<ViewIntent>) = intents.subscribe(intentS)!!
override fun processIntents(intents: Observable<ViewIntent>): Disposable = intents.subscribe(intentS)

private val initialProcessor =
ObservableTransformer<ViewIntent.Initial, PartialChange> { intent ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AnalyticsServiceImpl : AnalyticsService {

class SnakeCaseFirebaseAnalyticsEventMapper {
fun nameFor(event: String): String =
CAMEL_REGEX.replace(event) { "_" + it.value }.toLowerCase()
CAMEL_REGEX.replace(event) { "_" + it.value }.lowercase()

fun paramsFor(params: Map<String, Any>?): Bundle? {
return bundleOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.hoc.comicapp.domain.models.AuthError
import com.hoc.comicapp.domain.thread.CoroutinesDispatchersProvider
import com.hoc.comicapp.domain.thread.RxSchedulerProvider
import com.hoc.comicapp.utils.snapshots
import com.hoc.comicapp.utils.unit
import io.reactivex.rxjava3.core.Observable
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ObsoleteCoroutinesApi
Expand Down Expand Up @@ -138,9 +139,7 @@ class FavoriteComicsDataSourceImpl(
}
}

override fun update(comics: List<_FavoriteComic>) {
actor.offer(comics)
}
override fun update(comics: List<_FavoriteComic>) = actor.trySend(comics).unit

private val favoriteCollectionForCurrentUserOrNull: CollectionReference?
get() = firebaseAuth.currentUser?.uid?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
import timber.log.Timber
import kotlin.time.Duration.Companion.seconds
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime
import kotlin.time.seconds

@OptIn(
ExperimentalTime::class,
Expand Down Expand Up @@ -259,7 +259,7 @@ class ComicRepositoryImpl(
favoriteComicsDataSource.update(listOf(entity))

// update downloaded
actor.offer(Mappers.responseToLocalEntity(comicDetail))
actor.trySend(Mappers.responseToLocalEntity(comicDetail))
}

private companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import kotlinx.coroutines.withContext
import timber.log.Timber
import java.io.File
import java.util.Date
import kotlin.time.DurationUnit
import kotlin.time.ExperimentalTime
import kotlin.time.TimeSource

Expand Down Expand Up @@ -279,7 +280,7 @@ class DownloadComicsRepositoryImpl(
chapterName = chapterDetail.chapterName,
comicLink = chapterDetail.comicLink,
comicName = chapterDetail.comicName,
elapsedInMilliseconds = elapsed.inMilliseconds,
elapsedInMilliseconds = elapsed.toDouble(DurationUnit.MILLISECONDS),
elapsedInString = elapsed.toString()
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.hoc.comicapp.utils.notOfType
import com.jakewharton.rxrelay3.PublishRelay
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.ObservableTransformer
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.kotlin.addTo
import io.reactivex.rxjava3.kotlin.cast
import io.reactivex.rxjava3.kotlin.ofType
Expand Down Expand Up @@ -87,6 +88,7 @@ class CategoryViewModel(
when (it) {
is CategoryPartialChange.RefreshPartialChange.Error -> sendMessageEvent(message = "Refresh error occurred: ${it.error.getMessage()}")
is CategoryPartialChange.RefreshPartialChange.Data -> sendMessageEvent(message = "Refresh success")
CategoryPartialChange.RefreshPartialChange.Loading -> return@doOnNext
}
}
.cast<CategoryPartialChange>()
Expand All @@ -109,8 +111,8 @@ class CategoryViewModel(
}
}

override fun processIntents(intents: Observable<CategoryViewIntent>) =
intents.subscribe(intentS)!!
override fun processIntents(intents: Observable<CategoryViewIntent>): Disposable =
intents.subscribe(intentS)

init {
intentS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.OnLifecycleEvent
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.LinearSmoothScroller
Expand All @@ -33,6 +31,7 @@ import com.hoc.comicapp.ui.category_detail.CategoryDetailContract.ViewState.Head
import com.hoc.comicapp.ui.category_detail.CategoryDetailContract.ViewState.Item
import com.hoc.comicapp.utils.asObservable
import com.hoc.comicapp.utils.inflater
import com.hoc.comicapp.utils.unit
import com.jakewharton.rxbinding4.recyclerview.scrollStateChanges
import com.jakewharton.rxbinding4.view.clicks
import com.jakewharton.rxbinding4.view.detaches
Expand Down Expand Up @@ -186,11 +185,10 @@ class CategoryDetailAdapter(
lifecycleOwner
.lifecycle
.addObserver(
object : LifecycleObserver {
object : DefaultLifecycleObserver {
var disposable: Disposable? = null

@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
private fun onCreate() {
override fun onCreate(owner: LifecycleOwner) {
disposable = startStopAutoScrollS
.mergeWith(
binding.popularRecyclerHorizontal
Expand Down Expand Up @@ -229,14 +227,11 @@ class CategoryDetailAdapter(
)
}

@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
private fun onResume() = startStopAutoScrollS.accept(true)
override fun onResume(owner: LifecycleOwner) = startStopAutoScrollS.accept(true)

@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
private fun onPause() = startStopAutoScrollS.accept(false)
override fun onPause(owner: LifecycleOwner) = startStopAutoScrollS.accept(false)

@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
private fun onDestroy() = disposable?.dispose()
override fun onDestroy(owner: LifecycleOwner) = disposable?.dispose().unit
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.jakewharton.rxrelay3.PublishRelay
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Observable.mergeArray
import io.reactivex.rxjava3.core.ObservableTransformer
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.kotlin.addTo
import io.reactivex.rxjava3.kotlin.ofType
import io.reactivex.rxjava3.kotlin.subscribeBy
Expand All @@ -27,7 +28,7 @@ class CategoryDetailVM(
private val intentS = PublishRelay.create<ViewIntent>()
private val stateS = BehaviorRelay.createDefault(initialState)

override fun processIntents(intents: Observable<ViewIntent>) = intents.subscribe(intentS)!!
override fun processIntents(intents: Observable<ViewIntent>): Disposable = intents.subscribe(intentS)

private val initialProcessor =
ObservableTransformer<ViewIntent.Initial, PartialChange> { intent ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.hoc.comicapp.utils.notOfType
import com.jakewharton.rxrelay3.PublishRelay
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.ObservableTransformer
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.kotlin.addTo
import io.reactivex.rxjava3.kotlin.ofType
import io.reactivex.rxjava3.kotlin.subscribeBy
Expand Down Expand Up @@ -120,8 +121,8 @@ class ChapterDetailViewModel(
)
}

override fun processIntents(intents: Observable<ViewIntent>) =
intents.subscribe(intentS)!!
override fun processIntents(intents: Observable<ViewIntent>): Disposable =
intents.subscribe(intentS)

init {
intentS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.jakewharton.rxrelay3.BehaviorRelay
import com.jakewharton.rxrelay3.PublishRelay
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.ObservableTransformer
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.kotlin.addTo
import io.reactivex.rxjava3.kotlin.ofType
import io.reactivex.rxjava3.kotlin.subscribeBy
Expand All @@ -52,8 +53,8 @@ class ComicDetailViewModel(
private val intentS = PublishRelay.create<ComicDetailIntent>()
private val stateS = BehaviorRelay.createDefault(initialState)

override fun processIntents(intents: Observable<ComicDetailIntent>) =
intents.subscribe(intentS)!!
override fun processIntents(intents: Observable<ComicDetailIntent>): Disposable =
intents.subscribe(intentS)

private val initialProcessor =
ObservableTransformer<ComicDetailIntent.Initial, ComicDetailPartialChange> { intent ->
Expand Down Expand Up @@ -225,6 +226,9 @@ class ComicDetailViewModel(
Timber.d("$operation error $it")
sendMessageEvent("$operation error: ${event.chapter.chapterName}")
}
is ComicDetailSingleEvent.EnqueuedDownloadFailure -> return@subscribeBy
is ComicDetailSingleEvent.EnqueuedDownloadSuccess -> return@subscribeBy
is ComicDetailSingleEvent.MessageEvent -> return@subscribeBy
}
}
.addTo(compositeDisposable)
Expand Down
Loading

0 comments on commit 741479b

Please sign in to comment.