Code cleanups (#3264)

* Kotlin 1.8.10

https://github.com/JetBrains/kotlin/releases/tag/v1.8.10

* Migrate onActivityCreated to onViewCreated

* More final modifiers

* Java Cleanups

* Kotlin cleanups

* More final modifiers

* Const value TOOLBAR_HIDE_DELAY_MS

* Revert
This commit is contained in:
Goooler 2023-02-21 02:58:37 +08:00 committed by GitHub
commit cfea5700b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 123 additions and 133 deletions

View file

@ -941,13 +941,13 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
}
private fun getFullUsername(account: Account): String {
if (account.isRemote()) {
return "@" + account.username
return if (account.isRemote()) {
"@" + account.username
} else {
val localUsername = account.localUsername
// Note: !! here will crash if this pane is ever shown to a logged-out user. With AccountActivity this is believed to be impossible.
val domain = accountManager.activeAccount!!.domain
return "@$localUsername@$domain"
"@$localUsername@$domain"
}
}

View file

@ -697,7 +697,7 @@ class ComposeActivity :
var oneMediaWithoutDescription = false
for (media in viewModel.media.value) {
if (media.description == null || media.description.isEmpty()) {
if (media.description.isNullOrEmpty()) {
oneMediaWithoutDescription = true
break
}

View file

@ -70,9 +70,7 @@ class FocusIndicatorView
if (event.actionMasked == MotionEvent.ACTION_CANCEL)
return false
val imageSize = this.imageSize
if (imageSize == null)
return false
val imageSize = this.imageSize ?: return false
// Convert touch xy to point inside image
focus = Attachment.Focus(axisToFocus(event.x, imageSize.x, this.width), -axisToFocus(event.y, imageSize.y, this.height))

View file

@ -44,7 +44,7 @@ import javax.inject.Inject
class DraftHelper @Inject constructor(
val context: Context,
val okHttpClient: OkHttpClient,
private val okHttpClient: OkHttpClient,
db: AppDatabase
) {
@ -140,7 +140,7 @@ class DraftHelper @Inject constructor(
}
}
suspend fun deleteDraftAndAttachments(draft: DraftEntity) {
private suspend fun deleteDraftAndAttachments(draft: DraftEntity) {
deleteAttachments(draft)
draftDao.delete(draft.id)
}

View file

@ -33,7 +33,7 @@ class DraftsViewModel @Inject constructor(
val database: AppDatabase,
val accountManager: AccountManager,
val api: MastodonApi,
val draftHelper: DraftHelper
private val draftHelper: DraftHelper
) : ViewModel() {
val drafts = Pager(

View file

@ -55,8 +55,8 @@ class ProxyPreferencesFragment : PreferenceFragmentCompat() {
val portErrorMessage = getString(
R.string.pref_title_http_proxy_port_message,
ProxyConfiguration.MIN_PROXY_PORT,
ProxyConfiguration.MAX_PROXY_PORT
MIN_PROXY_PORT,
MAX_PROXY_PORT
)
validatedEditTextPreference(portErrorMessage, ProxyConfiguration::isValidProxyPort) {

View file

@ -55,7 +55,7 @@ abstract class TimelineViewModel(
private val api: MastodonApi,
private val eventHub: EventHub,
protected val accountManager: AccountManager,
protected val sharedPreferences: SharedPreferences,
private val sharedPreferences: SharedPreferences,
private val filterModel: FilterModel
) : ViewModel() {
@ -69,7 +69,7 @@ abstract class TimelineViewModel(
private set
protected var alwaysShowSensitiveMedia = false
protected var alwaysOpenSpoilers = false
private var alwaysOpenSpoilers = false
private var filterRemoveReplies = false
private var filterRemoveReblogs = false
protected var readingOrder: ReadingOrder = ReadingOrder.OLDEST_FIRST

View file

@ -256,7 +256,7 @@ class ViewThreadFragment : SFragment(), OnRefreshListener, StatusActionListener,
* When started the job will wait `delayMs` then show `view`. If the job is cancelled at
* any time `view` is hidden.
*/
@CheckResult()
@CheckResult
private fun getProgressBarJob(view: View, delayMs: Long) = viewLifecycleOwner.lifecycleScope.launch(
start = CoroutineStart.LAZY
) {