Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Find room for improvement: Fix build config, implement TODOs, and enhance code quality #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
Copilot wants to merge 4 commits into master
base: master
Choose a base branch
Loading
from copilot/fix-524e0325-ba2d-4589-8829-7ef06f6d6e8a
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code quality improvements: simplify navigator calls, fix operators, a...
...dd release logging
Co-authored-by: hoc081098 <36917223+hoc081098@users.noreply.github.com>
  • Loading branch information
Copilot and hoc081098 committed Oct 5, 2025
commit 988da4e208860b9aedbfaeded06e716f91451994
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.hoc.flowmvi.initializer

import android.content.Context
import android.util.Log
import androidx.startup.Initializer
import com.hoc.flowmvi.BuildConfig
import timber.log.Timber
Expand All @@ -12,10 +13,34 @@ class TimberInitializer : Initializer<Unit> {
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
} else {
// TODO(Timber): plant release tree
Timber.plant(ReleaseTree())
}
Timber.d("TimberInitializer...")
}

override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
}

/**
* A Timber tree for release builds that only logs warnings and errors.
* This prevents sensitive information from being logged in production.
*/
private class ReleaseTree : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (priority == Log.VERBOSE || priority == Log.DEBUG || priority == Log.INFO) {
return
}

// Log warnings and errors to system log
// In a production app, you might want to send these to a crash reporting service
// like Firebase Crashlytics, Sentry, etc.
if (priority == Log.ERROR && t != null) {
// You could send to crash reporting service here
Log.e(tag, message, t)
} else if (priority == Log.WARN) {
Log.w(tag, message)
} else if (priority == Log.ERROR) {
Log.e(tag, message)
}
}
}
6 changes: 2 additions & 4 deletions core-ui/src/main/java/com/hoc/flowmvi/core_ui/parcelable.kt
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import android.os.Parcelable
* https://stackoverflow.com/a/73311814/11191424
*/
inline fun <reified T : Parcelable> Intent.parcelable(key: String): T? =
// TODO: Use `>`, because https://issuetracker.google.com/issues/240585930#comment6
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
getParcelableExtra(key, T::class.java)
} else {
@Suppress("DEPRECATION")
Expand All @@ -21,8 +20,7 @@ inline fun <reified T : Parcelable> Intent.parcelable(key: String): T? =
* https://stackoverflow.com/a/73311814/11191424
*/
inline fun <reified T : Parcelable> Bundle.parcelable(key: String): T? =
// TODO: Use `>`, because https://issuetracker.google.com/issues/240585930#comment6
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
getParcelable(key, T::class.java)
} else {
@Suppress("DEPRECATION")
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class MainActivity : AbstractMviActivity<ViewIntent, ViewState, SingleEvent, Mai
override fun onOptionsItemSelected(item: MenuItem): Boolean =
when (item.itemId) {
R.id.add_action -> {
navigator.run { navigateToAdd() }
navigator.navigateToAdd()
true
}
R.id.search_action -> {
navigator.run { navigateToSearch() }
navigator.navigateToSearch()
true
}
else -> super.onOptionsItemSelected(item)
Expand Down Expand Up @@ -106,7 +106,7 @@ class MainActivity : AbstractMviActivity<ViewIntent, ViewState, SingleEvent, Mai
userAdapter.submitList(viewState.userItems)

mainBinding.run {
errorGroup.isVisible = viewState.error !== null
errorGroup.isVisible = viewState.error != null
errorMessageTextView.text =
viewState.error?.let {
when (it) {
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SearchActivity : AbstractMviActivity<ViewIntent, ViewState, SingleEvent, S
.setDuration(200),
)

errorGroup.isVisible = viewState.error !== null
errorGroup.isVisible = viewState.error != null
if (errorGroup.isVisible) {
errorMessageTextView.text =
viewState.error?.let {
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class SearchVM(
): Flow<PartialStateChange> =
flatMapFirst {
viewState.value.let { vs ->
if (vs.error !== null) {
if (vs.error != null) {
executeSearch(vs.submittedQuery).takeUntil(searchableQueryFlow)
} else {
emptyFlow()
Expand Down

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /