update ktlint plugin to 11.3.1, format code (#3442)
This commit is contained in:
parent
774d79d666
commit
d839f18267
141 changed files with 589 additions and 428 deletions
|
|
@ -107,8 +107,10 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
|
||||
@Inject
|
||||
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Any>
|
||||
|
||||
@Inject
|
||||
lateinit var viewModelFactory: ViewModelFactory
|
||||
|
||||
@Inject
|
||||
lateinit var draftsAlert: DraftsAlert
|
||||
|
||||
|
|
@ -134,14 +136,18 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
// fields for scroll animation
|
||||
private var hideFab: Boolean = false
|
||||
private var oldOffset: Int = 0
|
||||
|
||||
@ColorInt
|
||||
private var toolbarColor: Int = 0
|
||||
|
||||
@ColorInt
|
||||
private var statusBarColorTransparent: Int = 0
|
||||
|
||||
@ColorInt
|
||||
private var statusBarColorOpaque: Int = 0
|
||||
|
||||
private var avatarSize: Float = 0f
|
||||
|
||||
@Px
|
||||
private var titleVisibleHeight: Int = 0
|
||||
private lateinit var domain: String
|
||||
|
|
@ -342,7 +348,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
binding.accountAppBarLayout.addOnOffsetChangedListener(object : AppBarLayout.OnOffsetChangedListener {
|
||||
|
||||
override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) {
|
||||
|
||||
if (verticalOffset == oldOffset) {
|
||||
return
|
||||
}
|
||||
|
|
@ -650,10 +655,11 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
binding.accountSubscribeButton.setOnClickListener {
|
||||
viewModel.changeSubscribingState()
|
||||
}
|
||||
if (relation.notifying != null)
|
||||
if (relation.notifying != null) {
|
||||
subscribing = relation.notifying
|
||||
else if (relation.subscribing != null)
|
||||
} else if (relation.subscribing != null) {
|
||||
subscribing = relation.subscribing
|
||||
}
|
||||
}
|
||||
|
||||
// remove the listener so it doesn't fire on non-user changes
|
||||
|
|
@ -717,7 +723,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
invalidateOptionsMenu()
|
||||
|
||||
if (loadedAccount?.moved == null) {
|
||||
|
||||
binding.accountFollowButton.show()
|
||||
updateFollowButton()
|
||||
updateSubscribeButton()
|
||||
|
|
@ -750,7 +755,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
}
|
||||
|
||||
if (!viewModel.isSelf) {
|
||||
|
||||
val block = menu.findItem(R.id.action_block)
|
||||
block.title = if (blocking) {
|
||||
getString(R.string.action_unblock)
|
||||
|
|
@ -908,7 +912,8 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
R.id.action_open_as -> {
|
||||
loadedAccount?.let { loadedAccount ->
|
||||
showAccountChooserDialog(
|
||||
item.title, false,
|
||||
item.title,
|
||||
false,
|
||||
object : AccountSelectionListener {
|
||||
override fun onAccountSelected(account: AccountEntity) {
|
||||
openAsAccount(loadedAccount.url, account)
|
||||
|
|
@ -979,7 +984,9 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
|
|||
override fun getActionButton(): FloatingActionButton? {
|
||||
return if (!blocking) {
|
||||
binding.accountFloatingActionButton
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFullUsername(account: Account): String {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ class AccountViewModel @Inject constructor(
|
|||
|
||||
private fun obtainRelationship(reload: Boolean = false) {
|
||||
if (relationshipData.value == null || reload) {
|
||||
|
||||
relationshipData.postValue(Loading())
|
||||
|
||||
mastodonApi.relationships(listOf(accountId))
|
||||
|
|
@ -209,14 +208,18 @@ class AccountViewModel @Inject constructor(
|
|||
RelationShipAction.MUTE -> relation.copy(muting = true)
|
||||
RelationShipAction.UNMUTE -> relation.copy(muting = false)
|
||||
RelationShipAction.SUBSCRIBE -> {
|
||||
if (isMastodon)
|
||||
if (isMastodon) {
|
||||
relation.copy(notifying = true)
|
||||
else relation.copy(subscribing = true)
|
||||
} else {
|
||||
relation.copy(subscribing = true)
|
||||
}
|
||||
}
|
||||
RelationShipAction.UNSUBSCRIBE -> {
|
||||
if (isMastodon)
|
||||
if (isMastodon) {
|
||||
relation.copy(notifying = false)
|
||||
else relation.copy(subscribing = false)
|
||||
} else {
|
||||
relation.copy(subscribing = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
relationshipData.postValue(Loading(newRelation))
|
||||
|
|
@ -238,14 +241,18 @@ class AccountViewModel @Inject constructor(
|
|||
)
|
||||
RelationShipAction.UNMUTE -> mastodonApi.unmuteAccount(accountId)
|
||||
RelationShipAction.SUBSCRIBE -> {
|
||||
if (isMastodon)
|
||||
if (isMastodon) {
|
||||
mastodonApi.followAccount(accountId, notify = true)
|
||||
else mastodonApi.subscribeAccount(accountId)
|
||||
} else {
|
||||
mastodonApi.subscribeAccount(accountId)
|
||||
}
|
||||
}
|
||||
RelationShipAction.UNSUBSCRIBE -> {
|
||||
if (isMastodon)
|
||||
if (isMastodon) {
|
||||
mastodonApi.followAccount(accountId, notify = false)
|
||||
else mastodonApi.unsubscribeAccount(accountId)
|
||||
} else {
|
||||
mastodonApi.unsubscribeAccount(accountId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,12 +301,14 @@ class AccountViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun reload(isReload: Boolean = false) {
|
||||
if (isDataLoading)
|
||||
if (isDataLoading) {
|
||||
return
|
||||
}
|
||||
accountId.let {
|
||||
obtainAccount(isReload)
|
||||
if (!isSelf)
|
||||
if (!isSelf) {
|
||||
obtainRelationship(isReload)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class ListsForAccountFragment : DialogFragment(), Injectable {
|
|||
dialog?.apply {
|
||||
window?.setLayout(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ class ListsForAccountFragment : DialogFragment(), Injectable {
|
|||
ListAdapter<AccountListState, BindingHolder<ItemAddOrRemoveFromListBinding>>(Differ) {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int,
|
||||
viewType: Int
|
||||
): BindingHolder<ItemAddOrRemoveFromListBinding> {
|
||||
val binding =
|
||||
ItemAddOrRemoveFromListBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
|
|
|
|||
|
|
@ -35,23 +35,23 @@ import javax.inject.Inject
|
|||
|
||||
data class AccountListState(
|
||||
val list: MastoList,
|
||||
val includesAccount: Boolean,
|
||||
val includesAccount: Boolean
|
||||
)
|
||||
|
||||
data class ActionError(
|
||||
val error: Throwable,
|
||||
val type: Type,
|
||||
val listId: String,
|
||||
val listId: String
|
||||
) : Throwable(error) {
|
||||
enum class Type {
|
||||
ADD,
|
||||
REMOVE,
|
||||
REMOVE
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class ListsForAccountViewModel @Inject constructor(
|
||||
private val mastodonApi: MastodonApi,
|
||||
private val mastodonApi: MastodonApi
|
||||
) : ViewModel() {
|
||||
|
||||
private lateinit var accountId: String
|
||||
|
|
@ -75,14 +75,14 @@ class ListsForAccountViewModel @Inject constructor(
|
|||
runCatching {
|
||||
val (all, includes) = listOf(
|
||||
async { mastodonApi.getLists() },
|
||||
async { mastodonApi.getListsIncludesAccount(accountId) },
|
||||
async { mastodonApi.getListsIncludesAccount(accountId) }
|
||||
).awaitAll()
|
||||
|
||||
_states.emit(
|
||||
all.getOrThrow().map { list ->
|
||||
AccountListState(
|
||||
list = list,
|
||||
includesAccount = includes.getOrThrow().any { it.id == list.id },
|
||||
includesAccount = includes.getOrThrow().any { it.id == list.id }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class AccountMediaPagingSource(
|
|||
override fun getRefreshKey(state: PagingState<String, AttachmentViewData>): String? = null
|
||||
|
||||
override suspend fun load(params: LoadParams<String>): LoadResult<String, AttachmentViewData> {
|
||||
|
||||
return if (params is LoadParams.Refresh) {
|
||||
val list = viewModel.attachmentData.toList()
|
||||
LoadResult.Page(list, null, list.lastOrNull()?.statusId)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ class AccountMediaRemoteMediator(
|
|||
loadType: LoadType,
|
||||
state: PagingState<String, AttachmentViewData>
|
||||
): MediatorResult {
|
||||
|
||||
try {
|
||||
val statusResponse = when (loadType) {
|
||||
LoadType.REFRESH -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue