Replace cascade ifs with whens
This commit is contained in:
parent
50ee094889
commit
966bd2c7b5
|
@ -25,26 +25,38 @@ import java.util.*
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
object LocaleHelperAccessor {
|
object LocaleHelperAccessor {
|
||||||
fun forLanguageTag(str: String): Locale {
|
fun forLanguageTag(str: String): Locale {
|
||||||
if (str.contains("-")) {
|
when {
|
||||||
val args = str.split("-").dropLastWhile { it.isEmpty() }.toTypedArray()
|
str.contains("-") -> {
|
||||||
if (args.size > 2) {
|
val args = str.split("-").dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
return Locale(args[0], args[1], args[2])
|
when {
|
||||||
} else if (args.size > 1) {
|
args.size > 2 -> {
|
||||||
return Locale(args[0], args[1])
|
return Locale(args[0], args[1], args[2])
|
||||||
} else if (args.size == 1) {
|
}
|
||||||
return Locale(args[0])
|
args.size > 1 -> {
|
||||||
|
return Locale(args[0], args[1])
|
||||||
|
}
|
||||||
|
args.size == 1 -> {
|
||||||
|
return Locale(args[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (str.contains("_")) {
|
str.contains("_") -> {
|
||||||
val args = str.split("_").dropLastWhile { it.isEmpty() }.toTypedArray()
|
val args = str.split("_").dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
if (args.size > 2) {
|
when {
|
||||||
return Locale(args[0], args[1], args[2])
|
args.size > 2 -> {
|
||||||
} else if (args.size > 1) {
|
return Locale(args[0], args[1], args[2])
|
||||||
return Locale(args[0], args[1])
|
}
|
||||||
} else if (args.size == 1) {
|
args.size > 1 -> {
|
||||||
return Locale(args[0])
|
return Locale(args[0], args[1])
|
||||||
|
}
|
||||||
|
args.size == 1 -> {
|
||||||
|
return Locale(args[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return Locale(str)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return Locale(str)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw IllegalArgumentException("Can not parse language tag: [$str]")
|
throw IllegalArgumentException("Can not parse language tag: [$str]")
|
||||||
|
|
|
@ -35,20 +35,24 @@ object InternalActivityCreator {
|
||||||
activity.maxSortPosition = activity.minSortPosition
|
activity.maxSortPosition = activity.minSortPosition
|
||||||
activity.createdAt = status.getCreatedAt()
|
activity.createdAt = status.getCreatedAt()
|
||||||
|
|
||||||
if (status.getInReplyToUserId() == accountId) {
|
when {
|
||||||
activity.action = Activity.Action.REPLY
|
status.getInReplyToUserId() == accountId -> {
|
||||||
activity.targetStatuses = arrayOf(status)
|
activity.action = Activity.Action.REPLY
|
||||||
|
activity.targetStatuses = arrayOf(status)
|
||||||
|
|
||||||
//TODO set target statuses (in reply to status)
|
//TODO set target statuses (in reply to status)
|
||||||
activity.targetObjectStatuses = arrayOfNulls<Status>(0)
|
activity.targetObjectStatuses = arrayOfNulls<Status>(0)
|
||||||
} else if (status.quotedStatus?.user?.id == accountId) {
|
}
|
||||||
activity.action = Activity.Action.QUOTE
|
status.quotedStatus?.user?.id == accountId -> {
|
||||||
activity.targetStatuses = arrayOf(status)
|
activity.action = Activity.Action.QUOTE
|
||||||
activity.targetObjectStatuses = arrayOfNulls<Status>(0)
|
activity.targetStatuses = arrayOf(status)
|
||||||
} else {
|
activity.targetObjectStatuses = arrayOfNulls<Status>(0)
|
||||||
activity.action = Activity.Action.MENTION
|
}
|
||||||
activity.targetUsers = arrayOfNulls<User>(0)
|
else -> {
|
||||||
activity.targetObjectStatuses = arrayOf(status)
|
activity.action = Activity.Action.MENTION
|
||||||
|
activity.targetUsers = arrayOfNulls<User>(0)
|
||||||
|
activity.targetObjectStatuses = arrayOf(status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
activity.sourcesSize = 1
|
activity.sourcesSize = 1
|
||||||
activity.sources = arrayOf(status.getUser())
|
activity.sources = arrayOf(status.getUser())
|
||||||
|
|
|
@ -435,7 +435,10 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
val src = MediaPickerActivity.getMediaUris(data)?.takeIf(Array<Uri>::isNotEmpty) ?:
|
val src = MediaPickerActivity.getMediaUris(data)?.takeIf(Array<Uri>::isNotEmpty) ?:
|
||||||
data.getParcelableExtra<Uri>(EXTRA_IMAGE_URI)?.let { arrayOf(it) }
|
data.getParcelableExtra<Uri>(EXTRA_IMAGE_URI)?.let { arrayOf(it) }
|
||||||
if (src != null) {
|
if (src != null) {
|
||||||
TaskStarter.execute(AddMediaTask(this, src, null, false, false))
|
TaskStarter.execute(AddMediaTask(this, src, null,
|
||||||
|
copySrc = false,
|
||||||
|
deleteSrc = false
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1087,16 +1090,20 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
val action = intent.action
|
val action = intent.action
|
||||||
val hasVisibility = intent.hasExtra(EXTRA_VISIBILITY)
|
val hasVisibility = intent.hasExtra(EXTRA_VISIBILITY)
|
||||||
val hasAccountKeys: Boolean
|
val hasAccountKeys: Boolean
|
||||||
if (intent.hasExtra(EXTRA_ACCOUNT_KEYS)) {
|
when {
|
||||||
val accountKeys = intent.getTypedArrayExtra<UserKey>(EXTRA_ACCOUNT_KEYS)
|
intent.hasExtra(EXTRA_ACCOUNT_KEYS) -> {
|
||||||
accountsAdapter.selectedAccountKeys = accountKeys
|
val accountKeys = intent.getTypedArrayExtra<UserKey>(EXTRA_ACCOUNT_KEYS)
|
||||||
hasAccountKeys = true
|
accountsAdapter.selectedAccountKeys = accountKeys
|
||||||
} else if (intent.hasExtra(EXTRA_ACCOUNT_KEY)) {
|
hasAccountKeys = true
|
||||||
val accountKey = intent.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY)
|
}
|
||||||
accountsAdapter.selectedAccountKeys = arrayOf(accountKey)
|
intent.hasExtra(EXTRA_ACCOUNT_KEY) -> {
|
||||||
hasAccountKeys = true
|
val accountKey = intent.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||||
} else {
|
accountsAdapter.selectedAccountKeys = arrayOf(accountKey)
|
||||||
hasAccountKeys = false
|
hasAccountKeys = true
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
hasAccountKeys = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
when (action) {
|
when (action) {
|
||||||
Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE -> {
|
Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE -> {
|
||||||
|
@ -1105,7 +1112,10 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
val stream = intent.getStreamExtra()
|
val stream = intent.getStreamExtra()
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
val src = stream.toTypedArray()
|
val src = stream.toTypedArray()
|
||||||
TaskStarter.execute(AddMediaTask(this, src, null, true, false))
|
TaskStarter.execute(AddMediaTask(this, src, null,
|
||||||
|
copySrc = true,
|
||||||
|
deleteSrc = false
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
@ -1114,7 +1124,10 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
val data = intent.data
|
val data = intent.data
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
val src = arrayOf(data)
|
val src = arrayOf(data)
|
||||||
TaskStarter.execute(AddMediaTask(this, src, null, true, false))
|
TaskStarter.execute(AddMediaTask(this, src, null,
|
||||||
|
copySrc = true,
|
||||||
|
deleteSrc = false
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1820,7 +1833,10 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
})
|
})
|
||||||
editText.customSelectionActionModeCallback = this
|
editText.customSelectionActionModeCallback = this
|
||||||
editText.imageInputListener = { contentInfo ->
|
editText.imageInputListener = { contentInfo ->
|
||||||
val task = AddMediaTask(this, arrayOf(contentInfo.contentUri), null, true, false)
|
val task = AddMediaTask(this, arrayOf(contentInfo.contentUri), null,
|
||||||
|
copySrc = true,
|
||||||
|
deleteSrc = false
|
||||||
|
)
|
||||||
task.callback = {
|
task.callback = {
|
||||||
contentInfo.releasePermission()
|
contentInfo.releasePermission()
|
||||||
}
|
}
|
||||||
|
@ -2123,13 +2139,16 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
textView.spannable = ParcelableLocationUtils.getHumanReadableString(location, 3)
|
textView.spannable = ParcelableLocationUtils.getHumanReadableString(location, 3)
|
||||||
textView.tag = location
|
textView.tag = location
|
||||||
} else {
|
} else {
|
||||||
val tag = textView.tag
|
when (val tag = textView.tag) {
|
||||||
if (tag is Address) {
|
is Address -> {
|
||||||
textView.spannable = tag.locality
|
textView.spannable = tag.locality
|
||||||
} else if (tag is NoAddress) {
|
}
|
||||||
textView.setText(R.string.label_location_your_coarse_location)
|
is NoAddress -> {
|
||||||
} else {
|
textView.setText(R.string.label_location_your_coarse_location)
|
||||||
textView.setText(R.string.getting_location)
|
}
|
||||||
|
else -> {
|
||||||
|
textView.setText(R.string.getting_location)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -87,13 +87,17 @@ class FileSelectorActivity : BaseActivity(), FileSelectorDialogFragment.Callback
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (checkAllSelfPermissionsGranted(AndroidPermissions.READ_EXTERNAL_STORAGE, AndroidPermissions.WRITE_EXTERNAL_STORAGE)) {
|
when {
|
||||||
showPickFileDialog()
|
checkAllSelfPermissionsGranted(AndroidPermissions.READ_EXTERNAL_STORAGE, AndroidPermissions.WRITE_EXTERNAL_STORAGE) -> {
|
||||||
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
|
showPickFileDialog()
|
||||||
val permissions = arrayOf(AndroidPermissions.READ_EXTERNAL_STORAGE, AndroidPermissions.WRITE_EXTERNAL_STORAGE)
|
}
|
||||||
ActivityCompat.requestPermissions(this, permissions, REQUEST_REQUEST_PERMISSIONS)
|
Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN -> {
|
||||||
} else {
|
val permissions = arrayOf(AndroidPermissions.READ_EXTERNAL_STORAGE, AndroidPermissions.WRITE_EXTERNAL_STORAGE)
|
||||||
finishWithDeniedMessage()
|
ActivityCompat.requestPermissions(this, permissions, REQUEST_REQUEST_PERMISSIONS)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
finishWithDeniedMessage()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -428,23 +428,30 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher,
|
||||||
internal fun onSignInError(exception: Exception) {
|
internal fun onSignInError(exception: Exception) {
|
||||||
DebugLog.w(LOGTAG, "Sign in error", exception)
|
DebugLog.w(LOGTAG, "Sign in error", exception)
|
||||||
var errorReason: String? = null
|
var errorReason: String? = null
|
||||||
if (exception is AuthenticityTokenException) {
|
when (exception) {
|
||||||
Toast.makeText(this, R.string.message_toast_wrong_api_key, Toast.LENGTH_SHORT).show()
|
is AuthenticityTokenException -> {
|
||||||
errorReason = "wrong_api_key"
|
Toast.makeText(this, R.string.message_toast_wrong_api_key, Toast.LENGTH_SHORT).show()
|
||||||
} else if (exception is WrongUserPassException) {
|
errorReason = "wrong_api_key"
|
||||||
Toast.makeText(this, R.string.message_toast_wrong_username_password, Toast.LENGTH_SHORT).show()
|
}
|
||||||
errorReason = "wrong_username_password"
|
is WrongUserPassException -> {
|
||||||
} else if (exception is SignInTask.WrongBasicCredentialException) {
|
Toast.makeText(this, R.string.message_toast_wrong_username_password, Toast.LENGTH_SHORT).show()
|
||||||
Toast.makeText(this, R.string.message_toast_wrong_username_password, Toast.LENGTH_SHORT).show()
|
errorReason = "wrong_username_password"
|
||||||
errorReason = "wrong_username_password"
|
}
|
||||||
} else if (exception is SignInTask.WrongAPIURLFormatException) {
|
is SignInTask.WrongBasicCredentialException -> {
|
||||||
Toast.makeText(this, R.string.message_toast_wrong_api_key, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.message_toast_wrong_username_password, Toast.LENGTH_SHORT).show()
|
||||||
errorReason = "wrong_api_key"
|
errorReason = "wrong_username_password"
|
||||||
} else if (exception is LoginVerificationException) {
|
}
|
||||||
Toast.makeText(this, R.string.message_toast_login_verification_failed, Toast.LENGTH_SHORT).show()
|
is SignInTask.WrongAPIURLFormatException -> {
|
||||||
errorReason = "login_verification_failed"
|
Toast.makeText(this, R.string.message_toast_wrong_api_key, Toast.LENGTH_SHORT).show()
|
||||||
} else {
|
errorReason = "wrong_api_key"
|
||||||
Toast.makeText(this, exception.getErrorMessage(this), Toast.LENGTH_SHORT).show()
|
}
|
||||||
|
is LoginVerificationException -> {
|
||||||
|
Toast.makeText(this, R.string.message_toast_login_verification_failed, Toast.LENGTH_SHORT).show()
|
||||||
|
errorReason = "login_verification_failed"
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Toast.makeText(this, exception.getErrorMessage(this), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Analyzer.log(SignIn(false, credentialsType = apiConfig.credentialsType,
|
Analyzer.log(SignIn(false, credentialsType = apiConfig.credentialsType,
|
||||||
errorReason = errorReason, accountType = apiConfig.type))
|
errorReason = errorReason, accountType = apiConfig.type))
|
||||||
|
|
|
@ -129,12 +129,16 @@ class UserSelectorActivity : BaseActivity(), OnItemClickListener, LoaderManager.
|
||||||
listContainer.visibility = View.VISIBLE
|
listContainer.visibility = View.VISIBLE
|
||||||
adapter.setData(data, true)
|
adapter.setData(data, true)
|
||||||
loader as CacheUserSearchLoader
|
loader as CacheUserSearchLoader
|
||||||
if (data.isNotNullOrEmpty()) {
|
when {
|
||||||
showList()
|
data.isNotNullOrEmpty() -> {
|
||||||
} else if (loader.query.isEmpty()) {
|
showList()
|
||||||
showSearchHint()
|
}
|
||||||
} else {
|
loader.query.isEmpty() -> {
|
||||||
showNotFound()
|
showSearchHint()
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
showNotFound()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,14 +80,18 @@ class DummyItemAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStatus(position: Int, raw: Boolean): ParcelableStatus {
|
override fun getStatus(position: Int, raw: Boolean): ParcelableStatus {
|
||||||
if (adapter is ParcelableStatusesAdapter) {
|
return when (adapter) {
|
||||||
return adapter.getStatus(position, raw)
|
is ParcelableStatusesAdapter -> {
|
||||||
} else if (adapter is VariousItemsAdapter) {
|
adapter.getStatus(position, raw)
|
||||||
return adapter.getItem(position) as ParcelableStatus
|
}
|
||||||
} else if (adapter is ParcelableActivitiesAdapter) {
|
is VariousItemsAdapter -> {
|
||||||
return adapter.getActivity(position).activityStatus!!
|
adapter.getItem(position) as ParcelableStatus
|
||||||
|
}
|
||||||
|
is ParcelableActivitiesAdapter -> {
|
||||||
|
adapter.getActivity(position).activityStatus!!
|
||||||
|
}
|
||||||
|
else -> throw IndexOutOfBoundsException()
|
||||||
}
|
}
|
||||||
throw IndexOutOfBoundsException()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStatusCount(raw: Boolean) = 0
|
override fun getStatusCount(raw: Boolean) = 0
|
||||||
|
|
|
@ -171,25 +171,29 @@ abstract class ParcelableStatusesAdapter(
|
||||||
|
|
||||||
override fun setData(data: List<ParcelableStatus>?): Boolean {
|
override fun setData(data: List<ParcelableStatus>?): Boolean {
|
||||||
var changed = true
|
var changed = true
|
||||||
if (data == null) {
|
when (data) {
|
||||||
displayPositions = null
|
null -> {
|
||||||
displayDataCount = 0
|
displayPositions = null
|
||||||
} else if (data is ObjectCursor) {
|
displayDataCount = 0
|
||||||
displayPositions = null
|
}
|
||||||
displayDataCount = data.size
|
is ObjectCursor -> {
|
||||||
} else {
|
displayPositions = null
|
||||||
var filteredCount = 0
|
displayDataCount = data.size
|
||||||
displayPositions = IntArray(data.size).apply {
|
}
|
||||||
data.forEachIndexed { i, item ->
|
else -> {
|
||||||
if (!item.is_gap && item.is_filtered) {
|
var filteredCount = 0
|
||||||
filteredCount++
|
displayPositions = IntArray(data.size).apply {
|
||||||
} else {
|
data.forEachIndexed { i, item ->
|
||||||
this[i - filteredCount] = i
|
if (!item.is_gap && item.is_filtered) {
|
||||||
|
filteredCount++
|
||||||
|
} else {
|
||||||
|
this[i - filteredCount] = i
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
displayDataCount = data.size - filteredCount
|
||||||
|
changed = this.data != data
|
||||||
}
|
}
|
||||||
displayDataCount = data.size - filteredCount
|
|
||||||
changed = this.data != data
|
|
||||||
}
|
}
|
||||||
this.data = data
|
this.data = data
|
||||||
this.infoCache = if (data != null) arrayOfNulls(data.size) else null
|
this.infoCache = if (data != null) arrayOfNulls(data.size) else null
|
||||||
|
|
|
@ -43,15 +43,19 @@ fun View.getFrame(rect: Rect) {
|
||||||
@UiThread
|
@UiThread
|
||||||
fun View.getFrameRelatedTo(rect: Rect, other: View? = null) {
|
fun View.getFrameRelatedTo(rect: Rect, other: View? = null) {
|
||||||
this.getFrame(rect)
|
this.getFrame(rect)
|
||||||
if (other == null) {
|
when {
|
||||||
offsetToRoot(this, rect)
|
other == null -> {
|
||||||
} else if (other === this) {
|
offsetToRoot(this, rect)
|
||||||
rect.offsetTo(0, 0)
|
}
|
||||||
} else if (other !== parent) {
|
other === this -> {
|
||||||
offsetToRoot(this, rect)
|
rect.offsetTo(0, 0)
|
||||||
other.getFrame(tempRect)
|
}
|
||||||
offsetToRoot(other, tempRect)
|
other !== parent -> {
|
||||||
rect.offset(-tempRect.left, -tempRect.top)
|
offsetToRoot(this, rect)
|
||||||
|
other.getFrame(tempRect)
|
||||||
|
offsetToRoot(other, tempRect)
|
||||||
|
rect.offset(-tempRect.left, -tempRect.top)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,14 +29,18 @@ fun Attachment.toParcelable(externalUrl: String?) : ParcelableMedia? {
|
||||||
val mimeType = mimetype ?: return null
|
val mimeType = mimetype ?: return null
|
||||||
val result = ParcelableMedia()
|
val result = ParcelableMedia()
|
||||||
|
|
||||||
if (mimeType.startsWith("image/")) {
|
when {
|
||||||
result.type = ParcelableMedia.Type.IMAGE
|
mimeType.startsWith("image/") -> {
|
||||||
} else if (mimeType.startsWith("video/")) {
|
result.type = ParcelableMedia.Type.IMAGE
|
||||||
result.type = ParcelableMedia.Type.VIDEO
|
}
|
||||||
} else {
|
mimeType.startsWith("video/") -> {
|
||||||
// https://github.com/TwidereProject/Twidere-Android/issues/729
|
result.type = ParcelableMedia.Type.VIDEO
|
||||||
// Skip unsupported attachment
|
}
|
||||||
return null
|
else -> {
|
||||||
|
// https://github.com/TwidereProject/Twidere-Android/issues/729
|
||||||
|
// Skip unsupported attachment
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result.width = width
|
result.width = width
|
||||||
result.height = height
|
result.height = height
|
||||||
|
|
|
@ -48,14 +48,19 @@ class APIEditorDialogFragment : BaseDialogFragment() {
|
||||||
val targetFragment = this.targetFragment
|
val targetFragment = this.targetFragment
|
||||||
val parentFragment = this.parentFragment
|
val parentFragment = this.parentFragment
|
||||||
val host = this.host
|
val host = this.host
|
||||||
if (targetFragment is APIEditorCallback) {
|
when {
|
||||||
targetFragment.onSaveAPIConfig(applyCustomAPIConfig())
|
targetFragment is APIEditorCallback -> {
|
||||||
} else if (parentFragment is APIEditorCallback) {
|
targetFragment.onSaveAPIConfig(applyCustomAPIConfig())
|
||||||
parentFragment.onSaveAPIConfig(applyCustomAPIConfig())
|
}
|
||||||
} else if (host is APIEditorCallback) {
|
parentFragment is APIEditorCallback -> {
|
||||||
host.onSaveAPIConfig(applyCustomAPIConfig())
|
parentFragment.onSaveAPIConfig(applyCustomAPIConfig())
|
||||||
} else {
|
}
|
||||||
kPreferences[defaultAPIConfigKey] = applyCustomAPIConfig()
|
host is APIEditorCallback -> {
|
||||||
|
host.onSaveAPIConfig(applyCustomAPIConfig())
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
kPreferences[defaultAPIConfigKey] = applyCustomAPIConfig()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builder.setNegativeButton(android.R.string.cancel, null)
|
builder.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
|
|
@ -290,12 +290,16 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
|
||||||
} else {
|
} else {
|
||||||
firstVisibleItemPosition
|
firstVisibleItemPosition
|
||||||
}.coerceInOr(statusRange, -1)
|
}.coerceInOr(statusRange, -1)
|
||||||
lastReadId = if (lastReadPosition < 0) {
|
lastReadId = when {
|
||||||
-1
|
lastReadPosition < 0 -> {
|
||||||
} else if (useSortIdAsReadPosition) {
|
-1
|
||||||
adapter.getStatusSortId(lastReadPosition, false)
|
}
|
||||||
} else {
|
useSortIdAsReadPosition -> {
|
||||||
adapter.getStatusPositionKey(lastReadPosition)
|
adapter.getStatusSortId(lastReadPosition, false)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
adapter.getStatusPositionKey(lastReadPosition)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lastReadViewTop = layoutManager.findViewByPosition(lastReadPosition)?.top ?: 0
|
lastReadViewTop = layoutManager.findViewByPosition(lastReadPosition)?.top ?: 0
|
||||||
loadMore = statusRange.last in 0..lastVisibleItemPosition
|
loadMore = statusRange.last in 0..lastVisibleItemPosition
|
||||||
|
@ -623,15 +627,19 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.favorite -> {
|
R.id.favorite -> {
|
||||||
if (fragment.preferences[favoriteConfirmationKey]) {
|
when {
|
||||||
fragment.executeAfterFragmentResumed {
|
fragment.preferences[favoriteConfirmationKey] -> {
|
||||||
FavoriteConfirmDialogFragment.show(it.childFragmentManager,
|
fragment.executeAfterFragmentResumed {
|
||||||
|
FavoriteConfirmDialogFragment.show(it.childFragmentManager,
|
||||||
status.account_key, status.id, status)
|
status.account_key, status.id, status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status.is_favorite -> {
|
||||||
|
fragment.twitterWrapper.destroyFavoriteAsync(status.account_key, status.id)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
holder.playLikeAnimation(DefaultOnLikedListener(fragment.twitterWrapper, status))
|
||||||
}
|
}
|
||||||
} else if (status.is_favorite) {
|
|
||||||
fragment.twitterWrapper.destroyFavoriteAsync(status.account_key, status.id)
|
|
||||||
} else {
|
|
||||||
holder.playLikeAnimation(DefaultOnLikedListener(fragment.twitterWrapper, status))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -721,16 +729,20 @@ abstract class AbsStatusesFragment : AbsContentListRecyclerViewFragment<Parcelab
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
ACTION_STATUS_FAVORITE -> {
|
ACTION_STATUS_FAVORITE -> {
|
||||||
if (fragment.preferences[favoriteConfirmationKey]) {
|
when {
|
||||||
fragment.executeAfterFragmentResumed {
|
fragment.preferences[favoriteConfirmationKey] -> {
|
||||||
FavoriteConfirmDialogFragment.show(it.childFragmentManager,
|
fragment.executeAfterFragmentResumed {
|
||||||
|
FavoriteConfirmDialogFragment.show(it.childFragmentManager,
|
||||||
status.account_key, status.id, status)
|
status.account_key, status.id, status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status.is_favorite -> {
|
||||||
|
fragment.twitterWrapper.destroyFavoriteAsync(status.account_key, status.id)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
val holder = fragment.recyclerView.findViewHolderForLayoutPosition(position) as StatusViewHolder
|
||||||
|
holder.playLikeAnimation(DefaultOnLikedListener(fragment.twitterWrapper, status))
|
||||||
}
|
}
|
||||||
} else if (status.is_favorite) {
|
|
||||||
fragment.twitterWrapper.destroyFavoriteAsync(status.account_key, status.id)
|
|
||||||
} else {
|
|
||||||
val holder = fragment.recyclerView.findViewHolderForLayoutPosition(position) as StatusViewHolder
|
|
||||||
holder.playLikeAnimation(DefaultOnLikedListener(fragment.twitterWrapper, status))
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,12 +532,16 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
||||||
val width = if (bannerWidth > 0) bannerWidth else defWidth
|
val width = if (bannerWidth > 0) bannerWidth else defWidth
|
||||||
val bannerView = accountProfileBanner.nextView as ImageView
|
val bannerView = accountProfileBanner.nextView as ImageView
|
||||||
val user = account.user
|
val user = account.user
|
||||||
val fallbackBanner = if (user.link_color != 0) {
|
val fallbackBanner = when {
|
||||||
ColorDrawable(user.link_color)
|
user.link_color != 0 -> {
|
||||||
} else if (user.account_color != 0) {
|
ColorDrawable(user.link_color)
|
||||||
ColorDrawable(user.account_color)
|
}
|
||||||
} else {
|
user.account_color != 0 -> {
|
||||||
ColorDrawable(Chameleon.getOverrideTheme(requireActivity(), activity).colorPrimary)
|
ColorDrawable(user.account_color)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
ColorDrawable(Chameleon.getOverrideTheme(requireActivity(), activity).colorPrimary)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requestManager.loadProfileBanner(requireContext(), account.user, width).fallback(fallbackBanner)
|
requestManager.loadProfileBanner(requireContext(), account.user, width).fallback(fallbackBanner)
|
||||||
|
|
|
@ -87,24 +87,29 @@ class AddStatusFilterDialogFragment : BaseDialogFragment() {
|
||||||
}
|
}
|
||||||
val info = filterItems!![checkPositions.keyAt(i)]
|
val info = filterItems!![checkPositions.keyAt(i)]
|
||||||
val value = info.value
|
val value = info.value
|
||||||
if (value is ParcelableUserMention) {
|
when {
|
||||||
userKeys.add(value.key)
|
value is ParcelableUserMention -> {
|
||||||
userValues.add(ContentValuesCreator.createFilteredUser(value))
|
userKeys.add(value.key)
|
||||||
} else if (value is UserItem) {
|
userValues.add(ContentValuesCreator.createFilteredUser(value))
|
||||||
userKeys.add(value.key)
|
}
|
||||||
userValues.add(createFilteredUser(value))
|
value is UserItem -> {
|
||||||
} else if (info.type == FilterItemInfo.FILTER_TYPE_KEYWORD) {
|
userKeys.add(value.key)
|
||||||
val keyword = ParseUtils.parseString(value)
|
userValues.add(createFilteredUser(value))
|
||||||
keywords.add(keyword)
|
}
|
||||||
val values = ContentValues()
|
info.type == FilterItemInfo.FILTER_TYPE_KEYWORD -> {
|
||||||
values.put(Filters.Keywords.VALUE, "#$keyword")
|
val keyword = ParseUtils.parseString(value)
|
||||||
keywordValues.add(values)
|
keywords.add(keyword)
|
||||||
} else if (info.type == FilterItemInfo.FILTER_TYPE_SOURCE) {
|
val values = ContentValues()
|
||||||
val source = ParseUtils.parseString(value)
|
values.put(Filters.Keywords.VALUE, "#$keyword")
|
||||||
sources.add(source)
|
keywordValues.add(values)
|
||||||
val values = ContentValues()
|
}
|
||||||
values.put(Filters.Sources.VALUE, source)
|
info.type == FilterItemInfo.FILTER_TYPE_SOURCE -> {
|
||||||
sourceValues.add(values)
|
val source = ParseUtils.parseString(value)
|
||||||
|
sources.add(source)
|
||||||
|
val values = ContentValues()
|
||||||
|
values.put(Filters.Sources.VALUE, source)
|
||||||
|
sourceValues.add(values)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context?.contentResolver?.let { resolver ->
|
context?.contentResolver?.let { resolver ->
|
||||||
|
@ -164,12 +169,15 @@ class AddStatusFilterDialogFragment : BaseDialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getName(manager: UserColorNameManager, value: Any, nameFirst: Boolean): String {
|
private fun getName(manager: UserColorNameManager, value: Any, nameFirst: Boolean): String {
|
||||||
return if (value is ParcelableUserMention) {
|
return when (value) {
|
||||||
manager.getDisplayName(value.key, value.name, value.screen_name, nameFirst)
|
is ParcelableUserMention -> {
|
||||||
} else if (value is UserItem) {
|
manager.getDisplayName(value.key, value.name, value.screen_name, nameFirst)
|
||||||
manager.getDisplayName(value.key, value.name, value.screen_name, nameFirst)
|
}
|
||||||
} else
|
is UserItem -> {
|
||||||
ParseUtils.parseString(value)
|
manager.getDisplayName(value.key, value.name, value.screen_name, nameFirst)
|
||||||
|
}
|
||||||
|
else -> ParseUtils.parseString(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal data class FilterItemInfo(
|
internal data class FilterItemInfo(
|
||||||
|
|
|
@ -89,14 +89,19 @@ class ExtraFeaturesIntroductionDialogFragment : BaseDialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startActivityForResultOnTarget(intent: Intent) {
|
private fun startActivityForResultOnTarget(intent: Intent) {
|
||||||
if (targetFragment != null) {
|
when {
|
||||||
targetFragment?.startActivityForResult(intent, targetRequestCode)
|
targetFragment != null -> {
|
||||||
} else if (requestCode == 0) {
|
targetFragment?.startActivityForResult(intent, targetRequestCode)
|
||||||
startActivity(intent)
|
}
|
||||||
} else if (parentFragment != null) {
|
requestCode == 0 -> {
|
||||||
parentFragment?.startActivityForResult(intent, requestCode)
|
startActivity(intent)
|
||||||
} else {
|
}
|
||||||
activity?.startActivityForResult(intent, requestCode)
|
parentFragment != null -> {
|
||||||
|
parentFragment?.startActivityForResult(intent, requestCode)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
activity?.startActivityForResult(intent, requestCode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,12 +113,16 @@ class GroupFragment : AbsToolbarTabPagesFragment(), LoaderCallbacks<SingleRespon
|
||||||
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey) ?:
|
val twitter = MicroBlogAPIFactory.getInstance(context, accountKey) ?:
|
||||||
throw MicroBlogException("No account")
|
throw MicroBlogException("No account")
|
||||||
val group: Group
|
val group: Group
|
||||||
group = if (groupId != null) {
|
group = when {
|
||||||
twitter.showGroup(groupId)
|
groupId != null -> {
|
||||||
} else if (groupName != null) {
|
twitter.showGroup(groupId)
|
||||||
twitter.showGroupByName(groupName)
|
}
|
||||||
} else {
|
groupName != null -> {
|
||||||
return SingleResponse()
|
twitter.showGroupByName(groupName)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return SingleResponse()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SingleResponse.getInstance(ParcelableGroupUtils.from(group, accountKey, 0,
|
return SingleResponse.getInstance(ParcelableGroupUtils.from(group, accountKey, 0,
|
||||||
group.isMember))
|
group.isMember))
|
||||||
|
|
|
@ -48,12 +48,16 @@ class SettingsDetailsFragment : BasePreferenceFragment(), OnSharedPreferenceChan
|
||||||
val args = arguments
|
val args = arguments
|
||||||
val rawResId = args?.get(EXTRA_RESID)
|
val rawResId = args?.get(EXTRA_RESID)
|
||||||
val resId: Int
|
val resId: Int
|
||||||
resId = if (rawResId is Int) {
|
resId = when (rawResId) {
|
||||||
rawResId
|
is Int -> {
|
||||||
} else if (rawResId is String) {
|
rawResId
|
||||||
Utils.getResId(activity, rawResId)
|
}
|
||||||
} else {
|
is String -> {
|
||||||
0
|
Utils.getResId(activity, rawResId)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (resId != 0) {
|
if (resId != 0) {
|
||||||
addPreferencesFromResource(resId)
|
addPreferencesFromResource(resId)
|
||||||
|
@ -81,12 +85,16 @@ class SettingsDetailsFragment : BasePreferenceFragment(), OnSharedPreferenceChan
|
||||||
val currentActivity = activity ?: return
|
val currentActivity = activity ?: return
|
||||||
val extras = preference.extras
|
val extras = preference.extras
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
if (extras.containsKey(EXTRA_SHOULD_RESTART)) {
|
when {
|
||||||
SettingsActivity.setShouldRestart(currentActivity)
|
extras.containsKey(EXTRA_SHOULD_RESTART) -> {
|
||||||
} else if (extras.containsKey(EXTRA_SHOULD_RECREATE)) {
|
SettingsActivity.setShouldRestart(currentActivity)
|
||||||
SettingsActivity.setShouldRecreate(currentActivity)
|
}
|
||||||
} else if (extras.containsKey(EXTRA_SHOULD_TERMINATE)) {
|
extras.containsKey(EXTRA_SHOULD_RECREATE) -> {
|
||||||
SettingsActivity.setShouldTerminate(currentActivity)
|
SettingsActivity.setShouldRecreate(currentActivity)
|
||||||
|
}
|
||||||
|
extras.containsKey(EXTRA_SHOULD_TERMINATE) -> {
|
||||||
|
SettingsActivity.setShouldTerminate(currentActivity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (extras.containsKey(EXTRA_RECREATE_ACTIVITY)) {
|
if (extras.containsKey(EXTRA_RECREATE_ACTIVITY)) {
|
||||||
currentActivity.recreate()
|
currentActivity.recreate()
|
||||||
|
|
|
@ -244,38 +244,42 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
override fun onLoadFinished(loader: Loader<SingleResponse<ParcelableUser>>,
|
override fun onLoadFinished(loader: Loader<SingleResponse<ParcelableUser>>,
|
||||||
data: SingleResponse<ParcelableUser>) {
|
data: SingleResponse<ParcelableUser>) {
|
||||||
val activity = activity ?: return
|
val activity = activity ?: return
|
||||||
if (data.data != null) {
|
when {
|
||||||
val user = data.data
|
data.data != null -> {
|
||||||
cardContent.visibility = View.VISIBLE
|
val user = data.data
|
||||||
errorContainer.visibility = View.GONE
|
cardContent.visibility = View.VISIBLE
|
||||||
progressContainer.visibility = View.GONE
|
errorContainer.visibility = View.GONE
|
||||||
val account: AccountDetails = data.extras.getParcelable(EXTRA_ACCOUNT)!!
|
progressContainer.visibility = View.GONE
|
||||||
displayUser(user, account)
|
val account: AccountDetails = data.extras.getParcelable(EXTRA_ACCOUNT)!!
|
||||||
if (user.is_cache) {
|
displayUser(user, account)
|
||||||
val args = Bundle()
|
if (user.is_cache) {
|
||||||
args.putParcelable(EXTRA_ACCOUNT_KEY, user.account_key)
|
val args = Bundle()
|
||||||
args.putParcelable(EXTRA_USER_KEY, user.key)
|
args.putParcelable(EXTRA_ACCOUNT_KEY, user.account_key)
|
||||||
args.putString(EXTRA_SCREEN_NAME, user.screen_name)
|
args.putParcelable(EXTRA_USER_KEY, user.key)
|
||||||
args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, true)
|
args.putString(EXTRA_SCREEN_NAME, user.screen_name)
|
||||||
loaderManager.restartLoader(LOADER_ID_USER, args, this)
|
args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, true)
|
||||||
|
loaderManager.restartLoader(LOADER_ID_USER, args, this)
|
||||||
|
}
|
||||||
|
updateOptionsMenuVisibility()
|
||||||
}
|
}
|
||||||
updateOptionsMenuVisibility()
|
user?.is_cache == true -> {
|
||||||
} else if (user?.is_cache == true) {
|
cardContent.visibility = View.VISIBLE
|
||||||
cardContent.visibility = View.VISIBLE
|
errorContainer.visibility = View.GONE
|
||||||
errorContainer.visibility = View.GONE
|
progressContainer.visibility = View.GONE
|
||||||
progressContainer.visibility = View.GONE
|
displayUser(user, account)
|
||||||
displayUser(user, account)
|
updateOptionsMenuVisibility()
|
||||||
updateOptionsMenuVisibility()
|
}
|
||||||
} else {
|
else -> {
|
||||||
if (data.hasException()) {
|
if (data.hasException()) {
|
||||||
errorText.text = data.exception?.getErrorMessage(activity)
|
errorText.text = data.exception?.getErrorMessage(activity)
|
||||||
errorText.visibility = View.VISIBLE
|
errorText.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
cardContent.visibility = View.GONE
|
||||||
|
errorContainer.visibility = View.VISIBLE
|
||||||
|
progressContainer.visibility = View.GONE
|
||||||
|
displayUser(null, null)
|
||||||
|
updateOptionsMenuVisibility()
|
||||||
}
|
}
|
||||||
cardContent.visibility = View.GONE
|
|
||||||
errorContainer.visibility = View.VISIBLE
|
|
||||||
progressContainer.visibility = View.GONE
|
|
||||||
displayUser(null, null)
|
|
||||||
updateOptionsMenuVisibility()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,13 +499,17 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
listedContainer.visibility = if (user.listed_count < 0) View.GONE else View.VISIBLE
|
listedContainer.visibility = if (user.listed_count < 0) View.GONE else View.VISIBLE
|
||||||
groupsContainer.visibility = if (user.groups_count < 0) View.GONE else View.VISIBLE
|
groupsContainer.visibility = if (user.groups_count < 0) View.GONE else View.VISIBLE
|
||||||
|
|
||||||
if (user.color != 0) {
|
when {
|
||||||
setUiColor(user.color)
|
user.color != 0 -> {
|
||||||
} else if (user.link_color != 0) {
|
setUiColor(user.color)
|
||||||
setUiColor(user.link_color)
|
}
|
||||||
} else {
|
user.link_color != 0 -> {
|
||||||
val theme = Chameleon.getOverrideTheme(activity, activity)
|
setUiColor(user.link_color)
|
||||||
setUiColor(theme.colorPrimary)
|
}
|
||||||
|
else -> {
|
||||||
|
val theme = Chameleon.getOverrideTheme(activity, activity)
|
||||||
|
setUiColor(theme.colorPrimary)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val defWidth = resources.displayMetrics.widthPixels
|
val defWidth = resources.displayMetrics.widthPixels
|
||||||
val width = if (bannerWidth > 0) bannerWidth else defWidth
|
val width = if (bannerWidth > 0) bannerWidth else defWidth
|
||||||
|
@ -1227,14 +1235,19 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
val userRelationship = relationship
|
val userRelationship = relationship
|
||||||
val twitter = twitterWrapper
|
val twitter = twitterWrapper
|
||||||
if (userRelationship == null) return
|
if (userRelationship == null) return
|
||||||
if (userRelationship.blocking) {
|
when {
|
||||||
twitter.destroyBlockAsync(accountKey, user.key)
|
userRelationship.blocking -> {
|
||||||
} else if (userRelationship.blocked_by) {
|
twitter.destroyBlockAsync(accountKey, user.key)
|
||||||
CreateUserBlockDialogFragment.show(childFragmentManager, user)
|
}
|
||||||
} else if (userRelationship.following) {
|
userRelationship.blocked_by -> {
|
||||||
DestroyFriendshipDialogFragment.show(fragmentManager, user)
|
CreateUserBlockDialogFragment.show(childFragmentManager, user)
|
||||||
} else {
|
}
|
||||||
twitter.createFriendshipAsync(accountKey, user.key, user.screen_name)
|
userRelationship.following -> {
|
||||||
|
DestroyFriendshipDialogFragment.show(fragmentManager, user)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
twitter.createFriendshipAsync(accountKey, user.key, user.screen_name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,12 +49,16 @@ class GroupTimelineFragment : ParcelableStatusesFragment() {
|
||||||
val result = ArrayList<String>()
|
val result = ArrayList<String>()
|
||||||
result.add(AUTHORITY_GROUP_TIMELINE)
|
result.add(AUTHORITY_GROUP_TIMELINE)
|
||||||
result.add("account=$accountKey")
|
result.add("account=$accountKey")
|
||||||
if (groupId != null) {
|
when {
|
||||||
result.add("group_id=$groupId")
|
groupId != null -> {
|
||||||
} else if (groupName != null) {
|
result.add("group_id=$groupId")
|
||||||
result.add("group_name=$groupName")
|
}
|
||||||
} else {
|
groupName != null -> {
|
||||||
return null
|
result.add("group_name=$groupName")
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result.toTypedArray()
|
return result.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,16 @@ class UserFavoritesFragment : ParcelableStatusesFragment() {
|
||||||
val result = ArrayList<String>()
|
val result = ArrayList<String>()
|
||||||
result.add(AUTHORITY_USER_FAVORITES)
|
result.add(AUTHORITY_USER_FAVORITES)
|
||||||
result.add("account=$accountKey")
|
result.add("account=$accountKey")
|
||||||
if (userKey != null) {
|
when {
|
||||||
result.add("user_id=$userKey")
|
userKey != null -> {
|
||||||
} else if (screenName != null) {
|
result.add("user_id=$userKey")
|
||||||
result.add("screen_name=$screenName")
|
}
|
||||||
} else {
|
screenName != null -> {
|
||||||
return null
|
result.add("screen_name=$screenName")
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result.toTypedArray()
|
return result.toTypedArray()
|
||||||
}
|
}
|
||||||
|
@ -65,12 +69,16 @@ class UserFavoritesFragment : ParcelableStatusesFragment() {
|
||||||
|
|
||||||
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||||
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
||||||
if (userKey != null) {
|
when {
|
||||||
sb.append(userKey)
|
userKey != null -> {
|
||||||
} else if (screenName != null) {
|
sb.append(userKey)
|
||||||
sb.append(screenName)
|
}
|
||||||
} else {
|
screenName != null -> {
|
||||||
return null
|
sb.append(screenName)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sb.toString()
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,17 +49,21 @@ class UserListTimelineFragment : ParcelableStatusesFragment() {
|
||||||
val result = ArrayList<String>()
|
val result = ArrayList<String>()
|
||||||
result.add(TwidereConstants.AUTHORITY_USER_LIST_TIMELINE)
|
result.add(TwidereConstants.AUTHORITY_USER_LIST_TIMELINE)
|
||||||
result.add("account=$accountKey")
|
result.add("account=$accountKey")
|
||||||
if (listId != null) {
|
when {
|
||||||
result.add("list_id=$listId")
|
listId != null -> {
|
||||||
} else if (listName != null) {
|
result.add("list_id=$listId")
|
||||||
if (userKey != null) {
|
}
|
||||||
result.add("user_id=$userKey")
|
listName != null -> {
|
||||||
} else if (screenName != null) {
|
if (userKey != null) {
|
||||||
result.add("screen_name=$screenName")
|
result.add("user_id=$userKey")
|
||||||
|
} else if (screenName != null) {
|
||||||
|
result.add("screen_name=$screenName")
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
return null
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
return result.toTypedArray()
|
return result.toTypedArray()
|
||||||
}
|
}
|
||||||
|
@ -72,22 +76,30 @@ class UserListTimelineFragment : ParcelableStatusesFragment() {
|
||||||
if (tabPosition < 0) return null
|
if (tabPosition < 0) return null
|
||||||
val listId = arguments.getString(EXTRA_LIST_ID)
|
val listId = arguments.getString(EXTRA_LIST_ID)
|
||||||
val listName = arguments.getString(EXTRA_LIST_NAME)
|
val listName = arguments.getString(EXTRA_LIST_NAME)
|
||||||
if (listId != null) {
|
when {
|
||||||
sb.append(listId)
|
listId != null -> {
|
||||||
} else if (listName != null) {
|
sb.append(listId)
|
||||||
val userKey = arguments.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
}
|
||||||
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
listName != null -> {
|
||||||
if (userKey != null) {
|
val userKey = arguments.getParcelable<UserKey?>(EXTRA_USER_KEY)
|
||||||
sb.append(userKey)
|
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
||||||
} else if (screenName != null) {
|
when {
|
||||||
sb.append(screenName)
|
userKey != null -> {
|
||||||
} else {
|
sb.append(userKey)
|
||||||
|
}
|
||||||
|
screenName != null -> {
|
||||||
|
sb.append(screenName)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append('_')
|
||||||
|
sb.append(listName)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
sb.append('_')
|
|
||||||
sb.append(listName)
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
return sb.toString()
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,12 +61,16 @@ class UserTimelineFragment : ParcelableStatusesFragment() {
|
||||||
val result = ArrayList<String>()
|
val result = ArrayList<String>()
|
||||||
result.add(AUTHORITY_USER_TIMELINE)
|
result.add(AUTHORITY_USER_TIMELINE)
|
||||||
result.add("account=$accountKey")
|
result.add("account=$accountKey")
|
||||||
if (userKey != null) {
|
when {
|
||||||
result.add("user_id=$userKey")
|
userKey != null -> {
|
||||||
} else if (screenName != null) {
|
result.add("user_id=$userKey")
|
||||||
result.add("screen_name=$screenName")
|
}
|
||||||
} else {
|
screenName != null -> {
|
||||||
return null
|
result.add("screen_name=$screenName")
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
(timelineFilter as? UserTimelineFilter)?.let {
|
(timelineFilter as? UserTimelineFilter)?.let {
|
||||||
if (it.isIncludeReplies) {
|
if (it.isIncludeReplies) {
|
||||||
|
@ -87,12 +91,16 @@ class UserTimelineFragment : ParcelableStatusesFragment() {
|
||||||
|
|
||||||
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
val userKey = arguments.getParcelable<UserKey>(EXTRA_USER_KEY)
|
||||||
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
val screenName = arguments.getString(EXTRA_SCREEN_NAME)
|
||||||
if (userKey != null) {
|
when {
|
||||||
sb.append(userKey)
|
userKey != null -> {
|
||||||
} else if (screenName != null) {
|
sb.append(userKey)
|
||||||
sb.append(screenName)
|
}
|
||||||
} else {
|
screenName != null -> {
|
||||||
return null
|
sb.append(screenName)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sb.toString()
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,20 +140,24 @@ class UserTimelineLoader(
|
||||||
option.setExcludeReplies(!timelineFilter.isIncludeReplies)
|
option.setExcludeReplies(!timelineFilter.isIncludeReplies)
|
||||||
option.setIncludeRetweets(timelineFilter.isIncludeRetweets)
|
option.setIncludeRetweets(timelineFilter.isIncludeRetweets)
|
||||||
}
|
}
|
||||||
if (userKey != null) {
|
when {
|
||||||
if (account.type == AccountType.STATUSNET && userKey.host != account.key.host
|
userKey != null -> {
|
||||||
|
if (account.type == AccountType.STATUSNET && userKey.host != account.key.host
|
||||||
&& profileUrl != null) {
|
&& profileUrl != null) {
|
||||||
try {
|
try {
|
||||||
return showStatusNetExternalTimeline(profileUrl, paging)
|
return showStatusNetExternalTimeline(profileUrl, paging)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
throw MicroBlogException(e)
|
throw MicroBlogException(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return microBlog.getUserTimeline(userKey.id, paging, option)
|
||||||
|
}
|
||||||
|
screenName != null -> {
|
||||||
|
return microBlog.getUserTimelineByScreenName(screenName, paging, option)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
throw MicroBlogException("Invalid user")
|
||||||
}
|
}
|
||||||
return microBlog.getUserTimeline(userKey.id, paging, option)
|
|
||||||
} else if (screenName != null) {
|
|
||||||
return microBlog.getUserTimelineByScreenName(screenName, paging, option)
|
|
||||||
} else {
|
|
||||||
throw MicroBlogException("Invalid user")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,22 +229,26 @@ class ActivityTitleSummaryMessage private constructor(val icon: Int, val color:
|
||||||
nameFirst))
|
nameFirst))
|
||||||
firstDisplayName.setSpan(StyleSpan(Typeface.BOLD), 0, firstDisplayName.length,
|
firstDisplayName.setSpan(StyleSpan(Typeface.BOLD), 0, firstDisplayName.length,
|
||||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
if (sources.size == 1) {
|
when (sources.size) {
|
||||||
val format = resources.getString(stringRes)
|
1 -> {
|
||||||
return SpanFormatter.format(format, firstDisplayName)
|
val format = resources.getString(stringRes)
|
||||||
} else if (sources.size == 2) {
|
return SpanFormatter.format(format, firstDisplayName)
|
||||||
val format = resources.getString(stringResMulti)
|
}
|
||||||
val secondDisplayName = SpannableString(manager.getDisplayName(sources[1],
|
2 -> {
|
||||||
|
val format = resources.getString(stringResMulti)
|
||||||
|
val secondDisplayName = SpannableString(manager.getDisplayName(sources[1],
|
||||||
nameFirst))
|
nameFirst))
|
||||||
secondDisplayName.setSpan(StyleSpan(Typeface.BOLD), 0, secondDisplayName.length,
|
secondDisplayName.setSpan(StyleSpan(Typeface.BOLD), 0, secondDisplayName.length,
|
||||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
return SpanFormatter.format(format, firstDisplayName,
|
return SpanFormatter.format(format, firstDisplayName,
|
||||||
secondDisplayName)
|
secondDisplayName)
|
||||||
} else {
|
}
|
||||||
val othersCount = sources.size - 1
|
else -> {
|
||||||
val nOthers = resources.getQuantityString(R.plurals.N_others, othersCount, othersCount)
|
val othersCount = sources.size - 1
|
||||||
val format = resources.getString(stringResMulti)
|
val nOthers = resources.getQuantityString(R.plurals.N_others, othersCount, othersCount)
|
||||||
return SpanFormatter.format(format, firstDisplayName, nOthers)
|
val format = resources.getString(stringResMulti)
|
||||||
|
return SpanFormatter.format(format, firstDisplayName, nOthers)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,13 +414,17 @@ class TwidereDataProvider : ContentProvider(), LazyLoadCallback {
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val conflictAlgorithm = getConflictAlgorithm(tableId)
|
val conflictAlgorithm = getConflictAlgorithm(tableId)
|
||||||
rowId = if (conflictAlgorithm != SQLiteDatabase.CONFLICT_NONE) {
|
rowId = when {
|
||||||
databaseWrapper.insertWithOnConflict(table, null, values,
|
conflictAlgorithm != SQLiteDatabase.CONFLICT_NONE -> {
|
||||||
conflictAlgorithm)
|
databaseWrapper.insertWithOnConflict(table, null, values,
|
||||||
} else if (table != null) {
|
conflictAlgorithm)
|
||||||
databaseWrapper.insert(table, null, values)
|
}
|
||||||
} else {
|
table != null -> {
|
||||||
return null
|
databaseWrapper.insert(table, null, values)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,12 +119,16 @@ class HtmlBuilder(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun appendSource(builder: StringBuilder, start: Int, end: Int, escapeSource: Boolean, sourceEscaped: Boolean) {
|
private fun appendSource(builder: StringBuilder, start: Int, end: Int, escapeSource: Boolean, sourceEscaped: Boolean) {
|
||||||
if (sourceEscaped == escapeSource) {
|
when {
|
||||||
builder.append(source.substring(start, end), escapeSource, sourceEscaped)
|
sourceEscaped == escapeSource -> {
|
||||||
} else if (escapeSource) {
|
builder.append(source.substring(start, end), escapeSource, sourceEscaped)
|
||||||
builder.append(HtmlEscapeHelper.escape(source.substring(start, end)), true, sourceEscaped)
|
}
|
||||||
} else {
|
escapeSource -> {
|
||||||
builder.append(HtmlEscapeHelper.unescape(source.substring(start, end)), false, sourceEscaped)
|
builder.append(HtmlEscapeHelper.escape(source.substring(start, end)), true, sourceEscaped)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
builder.append(HtmlEscapeHelper.unescape(source.substring(start, end)), false, sourceEscaped)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,12 +170,16 @@ class HtmlBuilder(
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private fun StringBuilder.append(text: String, escapeText: Boolean, textEscaped: Boolean) {
|
private fun StringBuilder.append(text: String, escapeText: Boolean, textEscaped: Boolean) {
|
||||||
if (textEscaped == escapeText) {
|
when {
|
||||||
append(text)
|
textEscaped == escapeText -> {
|
||||||
} else if (escapeText) {
|
append(text)
|
||||||
append(HtmlEscapeHelper.escape(text))
|
}
|
||||||
} else {
|
escapeText -> {
|
||||||
append(HtmlEscapeHelper.unescape(text))
|
append(HtmlEscapeHelper.escape(text))
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
append(HtmlEscapeHelper.unescape(text))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,13 +125,17 @@ object MenuUtils {
|
||||||
val favoriteHighlight = ContextCompat.getColor(context, R.color.highlight_favorite)
|
val favoriteHighlight = ContextCompat.getColor(context, R.color.highlight_favorite)
|
||||||
val likeHighlight = ContextCompat.getColor(context, R.color.highlight_like)
|
val likeHighlight = ContextCompat.getColor(context, R.color.highlight_like)
|
||||||
val isMyRetweet: Boolean =
|
val isMyRetweet: Boolean =
|
||||||
if (RetweetStatusTask.isCreatingRetweet(status.account_key, status.id)) {
|
when {
|
||||||
true
|
RetweetStatusTask.isCreatingRetweet(status.account_key, status.id) -> {
|
||||||
} else if (twitter.isDestroyingStatus(status.account_key, status.id)) {
|
true
|
||||||
false
|
}
|
||||||
} else {
|
twitter.isDestroyingStatus(status.account_key, status.id) -> {
|
||||||
status.retweeted || Utils.isMyRetweet(status)
|
false
|
||||||
}
|
}
|
||||||
|
else -> {
|
||||||
|
status.retweeted || Utils.isMyRetweet(status)
|
||||||
|
}
|
||||||
|
}
|
||||||
val isMyStatus = Utils.isMyStatus(status)
|
val isMyStatus = Utils.isMyStatus(status)
|
||||||
menu.setItemAvailability(R.id.delete, isMyStatus)
|
menu.setItemAvailability(R.id.delete, isMyStatus)
|
||||||
if (isMyStatus) {
|
if (isMyStatus) {
|
||||||
|
@ -165,13 +169,17 @@ object MenuUtils {
|
||||||
val favorite = menu.findItem(R.id.favorite)
|
val favorite = menu.findItem(R.id.favorite)
|
||||||
if (favorite != null) {
|
if (favorite != null) {
|
||||||
val isFavorite: Boolean =
|
val isFavorite: Boolean =
|
||||||
if (CreateFavoriteTask.isCreatingFavorite(status.account_key, status.id)) {
|
when {
|
||||||
true
|
CreateFavoriteTask.isCreatingFavorite(status.account_key, status.id) -> {
|
||||||
} else if (DestroyFavoriteTask.isDestroyingFavorite(status.account_key, status.id)) {
|
true
|
||||||
false
|
}
|
||||||
} else {
|
DestroyFavoriteTask.isDestroyingFavorite(status.account_key, status.id) -> {
|
||||||
status.is_favorite
|
false
|
||||||
}
|
}
|
||||||
|
else -> {
|
||||||
|
status.is_favorite
|
||||||
|
}
|
||||||
|
}
|
||||||
val provider = MenuItemCompat.getActionProvider(favorite)
|
val provider = MenuItemCompat.getActionProvider(favorite)
|
||||||
val useStar = preferences[iWantMyStarsBackKey]
|
val useStar = preferences[iWantMyStarsBackKey]
|
||||||
if (provider is FavoriteItemProvider) {
|
if (provider is FavoriteItemProvider) {
|
||||||
|
@ -205,20 +213,25 @@ object MenuUtils {
|
||||||
INTENT_ACTION_EXTENSION_OPEN_STATUS, EXTRA_STATUS, EXTRA_STATUS_JSON, status)
|
INTENT_ACTION_EXTENSION_OPEN_STATUS, EXTRA_STATUS, EXTRA_STATUS_JSON, status)
|
||||||
val shareItem = menu.findItem(R.id.share)
|
val shareItem = menu.findItem(R.id.share)
|
||||||
val shareProvider = MenuItemCompat.getActionProvider(shareItem)
|
val shareProvider = MenuItemCompat.getActionProvider(shareItem)
|
||||||
if (shareProvider is SupportStatusShareProvider) {
|
when {
|
||||||
shareProvider.status = status
|
shareProvider is SupportStatusShareProvider -> {
|
||||||
} else if (shareProvider is ShareActionProvider) {
|
shareProvider.status = status
|
||||||
val shareIntent = Utils.createStatusShareIntent(context, status)
|
}
|
||||||
shareProvider.setShareIntent(shareIntent)
|
shareProvider is ShareActionProvider -> {
|
||||||
} else if (shareItem.hasSubMenu()) {
|
val shareIntent = Utils.createStatusShareIntent(context, status)
|
||||||
val shareSubMenu = shareItem.subMenu
|
shareProvider.setShareIntent(shareIntent)
|
||||||
val shareIntent = Utils.createStatusShareIntent(context, status)
|
}
|
||||||
shareSubMenu.removeGroup(MENU_GROUP_STATUS_SHARE)
|
shareItem.hasSubMenu() -> {
|
||||||
addIntentToMenu(context, shareSubMenu, shareIntent, MENU_GROUP_STATUS_SHARE)
|
val shareSubMenu = shareItem.subMenu
|
||||||
} else {
|
val shareIntent = Utils.createStatusShareIntent(context, status)
|
||||||
val shareIntent = Utils.createStatusShareIntent(context, status)
|
shareSubMenu.removeGroup(MENU_GROUP_STATUS_SHARE)
|
||||||
val chooserIntent = Intent.createChooser(shareIntent, context.getString(R.string.share_status))
|
addIntentToMenu(context, shareSubMenu, shareIntent, MENU_GROUP_STATUS_SHARE)
|
||||||
shareItem.intent = chooserIntent
|
}
|
||||||
|
else -> {
|
||||||
|
val shareIntent = Utils.createStatusShareIntent(context, status)
|
||||||
|
val chooserIntent = Intent.createChooser(shareIntent, context.getString(R.string.share_status))
|
||||||
|
shareItem.intent = chooserIntent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -233,19 +246,23 @@ object MenuUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.retweet -> {
|
R.id.retweet -> {
|
||||||
if (fragment is BaseFragment) {
|
when {
|
||||||
fragment.executeAfterFragmentResumed {
|
fragment is BaseFragment -> {
|
||||||
RetweetQuoteDialogFragment.show(it.childFragmentManager, status.account_key,
|
fragment.executeAfterFragmentResumed {
|
||||||
|
RetweetQuoteDialogFragment.show(it.childFragmentManager, status.account_key,
|
||||||
status.id, status)
|
status.id, status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (context is BaseActivity) {
|
context is BaseActivity -> {
|
||||||
context.executeAfterFragmentResumed {
|
context.executeAfterFragmentResumed {
|
||||||
RetweetQuoteDialogFragment.show(it.supportFragmentManager, status.account_key,
|
RetweetQuoteDialogFragment.show(it.supportFragmentManager, status.account_key,
|
||||||
status.id, status)
|
status.id, status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
else -> {
|
||||||
RetweetQuoteDialogFragment.show(fm, status.account_key,
|
RetweetQuoteDialogFragment.show(fm, status.account_key,
|
||||||
status.id, status)
|
status.id, status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.quote -> {
|
R.id.quote -> {
|
||||||
|
@ -260,19 +277,23 @@ object MenuUtils {
|
||||||
}
|
}
|
||||||
R.id.favorite -> {
|
R.id.favorite -> {
|
||||||
if (preferences[favoriteConfirmationKey]) {
|
if (preferences[favoriteConfirmationKey]) {
|
||||||
if (fragment is BaseFragment) {
|
when {
|
||||||
fragment.executeAfterFragmentResumed {
|
fragment is BaseFragment -> {
|
||||||
FavoriteConfirmDialogFragment.show(it.childFragmentManager,
|
fragment.executeAfterFragmentResumed {
|
||||||
|
FavoriteConfirmDialogFragment.show(it.childFragmentManager,
|
||||||
status.account_key, status.id, status)
|
status.account_key, status.id, status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (context is BaseActivity) {
|
context is BaseActivity -> {
|
||||||
context.executeAfterFragmentResumed {
|
context.executeAfterFragmentResumed {
|
||||||
FavoriteConfirmDialogFragment.show(it.supportFragmentManager,
|
FavoriteConfirmDialogFragment.show(it.supportFragmentManager,
|
||||||
status.account_key, status.id, status)
|
status.account_key, status.id, status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
else -> {
|
||||||
FavoriteConfirmDialogFragment.show(fm, status.account_key, status.id,
|
FavoriteConfirmDialogFragment.show(fm, status.account_key, status.id,
|
||||||
status)
|
status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (status.is_favorite) {
|
} else if (status.is_favorite) {
|
||||||
twitter.destroyFavoriteAsync(status.account_key, status.id)
|
twitter.destroyFavoriteAsync(status.account_key, status.id)
|
||||||
|
|
|
@ -116,12 +116,16 @@ object ThemeUtils {
|
||||||
|
|
||||||
fun getCardBackgroundColor(context: Context, backgroundOption: String, themeAlpha: Int): Int {
|
fun getCardBackgroundColor(context: Context, backgroundOption: String, themeAlpha: Int): Int {
|
||||||
val color = getColorFromAttribute(context, R.attr.cardItemBackgroundColor)
|
val color = getColorFromAttribute(context, R.attr.cardItemBackgroundColor)
|
||||||
return if (isTransparentBackground(backgroundOption)) {
|
return when {
|
||||||
ColorUtils.setAlphaComponent(color, themeAlpha)
|
isTransparentBackground(backgroundOption) -> {
|
||||||
} else if (isSolidBackground(backgroundOption)) {
|
ColorUtils.setAlphaComponent(color, themeAlpha)
|
||||||
TwidereColorUtils.getContrastYIQ(color, Color.WHITE, Color.BLACK)
|
}
|
||||||
} else {
|
isSolidBackground(backgroundOption) -> {
|
||||||
color
|
TwidereColorUtils.getContrastYIQ(color, Color.WHITE, Color.BLACK)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
color
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,15 +167,20 @@ object ThemeUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun applyWindowBackground(context: Context, window: Window, backgroundOption: String, alpha: Int) {
|
fun applyWindowBackground(context: Context, window: Window, backgroundOption: String, alpha: Int) {
|
||||||
if (isWindowFloating(context)) {
|
when {
|
||||||
window.setBackgroundDrawable(getWindowBackground(context))
|
isWindowFloating(context) -> {
|
||||||
} else if (VALUE_THEME_BACKGROUND_TRANSPARENT == backgroundOption) {
|
window.setBackgroundDrawable(getWindowBackground(context))
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER)
|
}
|
||||||
window.setBackgroundDrawable(getWindowBackgroundFromThemeApplyAlpha(context, alpha))
|
VALUE_THEME_BACKGROUND_TRANSPARENT == backgroundOption -> {
|
||||||
} else if (VALUE_THEME_BACKGROUND_SOLID == backgroundOption) {
|
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER)
|
||||||
window.setBackgroundDrawable(ColorDrawable(if (isLightTheme(context)) Color.WHITE else Color.BLACK))
|
window.setBackgroundDrawable(getWindowBackgroundFromThemeApplyAlpha(context, alpha))
|
||||||
} else {
|
}
|
||||||
window.setBackgroundDrawable(getWindowBackground(context))
|
VALUE_THEME_BACKGROUND_SOLID == backgroundOption -> {
|
||||||
|
window.setBackgroundDrawable(ColorDrawable(if (isLightTheme(context)) Color.WHITE else Color.BLACK))
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
window.setBackgroundDrawable(getWindowBackground(context))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,25 +160,29 @@ object Utils {
|
||||||
|
|
||||||
fun getAccountKeys(context: Context, args: Bundle?): Array<UserKey>? {
|
fun getAccountKeys(context: Context, args: Bundle?): Array<UserKey>? {
|
||||||
if (args == null) return null
|
if (args == null) return null
|
||||||
if (args.containsKey(EXTRA_ACCOUNT_KEYS)) {
|
when {
|
||||||
return args.getNullableTypedArray(EXTRA_ACCOUNT_KEYS)
|
args.containsKey(EXTRA_ACCOUNT_KEYS) -> {
|
||||||
} else if (args.containsKey(EXTRA_ACCOUNT_KEY)) {
|
return args.getNullableTypedArray(EXTRA_ACCOUNT_KEYS)
|
||||||
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY) ?: return emptyArray()
|
|
||||||
return arrayOf(accountKey)
|
|
||||||
} else if (args.containsKey(EXTRA_ACCOUNT_ID)) {
|
|
||||||
val accountId = args.get(EXTRA_ACCOUNT_ID).toString()
|
|
||||||
try {
|
|
||||||
if (java.lang.Long.parseLong(accountId) <= 0) return null
|
|
||||||
} catch (e: NumberFormatException) {
|
|
||||||
// Ignore
|
|
||||||
}
|
}
|
||||||
|
args.containsKey(EXTRA_ACCOUNT_KEY) -> {
|
||||||
|
val accountKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY) ?: return emptyArray()
|
||||||
|
return arrayOf(accountKey)
|
||||||
|
}
|
||||||
|
args.containsKey(EXTRA_ACCOUNT_ID) -> {
|
||||||
|
val accountId = args.get(EXTRA_ACCOUNT_ID).toString()
|
||||||
|
try {
|
||||||
|
if (java.lang.Long.parseLong(accountId) <= 0) return null
|
||||||
|
} catch (e: NumberFormatException) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
|
||||||
val accountKey = DataStoreUtils.findAccountKey(context, accountId)
|
val accountKey = DataStoreUtils.findAccountKey(context, accountId)
|
||||||
args.putParcelable(EXTRA_ACCOUNT_KEY, accountKey)
|
args.putParcelable(EXTRA_ACCOUNT_KEY, accountKey)
|
||||||
if (accountKey == null) return arrayOf(UserKey(accountId, null))
|
if (accountKey == null) return arrayOf(UserKey(accountId, null))
|
||||||
return arrayOf(accountKey)
|
return arrayOf(accountKey)
|
||||||
|
}
|
||||||
|
else -> return null
|
||||||
}
|
}
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAccountKey(context: Context, args: Bundle?): UserKey? {
|
fun getAccountKey(context: Context, args: Bundle?): UserKey? {
|
||||||
|
@ -456,12 +460,16 @@ object Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getInsetsTopWithoutActionBarHeight(context: Context, top: Int): Int {
|
fun getInsetsTopWithoutActionBarHeight(context: Context, top: Int): Int {
|
||||||
val actionBarHeight: Int = if (context is AppCompatActivity) {
|
val actionBarHeight: Int = when (context) {
|
||||||
getActionBarHeight(context.supportActionBar)
|
is AppCompatActivity -> {
|
||||||
} else if (context is Activity) {
|
getActionBarHeight(context.supportActionBar)
|
||||||
getActionBarHeight(context.actionBar)
|
}
|
||||||
} else {
|
is Activity -> {
|
||||||
return top
|
getActionBarHeight(context.actionBar)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return top
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (actionBarHeight > top) {
|
if (actionBarHeight > top) {
|
||||||
return top
|
return top
|
||||||
|
|
|
@ -35,12 +35,16 @@ import java.io.IOException
|
||||||
object TwidereExceptionFactory : ExceptionFactory<MicroBlogException> {
|
object TwidereExceptionFactory : ExceptionFactory<MicroBlogException> {
|
||||||
|
|
||||||
override fun newException(cause: Throwable?, request: HttpRequest?, response: HttpResponse?): MicroBlogException {
|
override fun newException(cause: Throwable?, request: HttpRequest?, response: HttpResponse?): MicroBlogException {
|
||||||
val te = if (cause != null) {
|
val te = when {
|
||||||
MicroBlogException(cause)
|
cause != null -> {
|
||||||
} else if (response != null) {
|
MicroBlogException(cause)
|
||||||
parseTwitterException(response)
|
}
|
||||||
} else {
|
response != null -> {
|
||||||
MicroBlogException()
|
parseTwitterException(response)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
MicroBlogException()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
te.httpRequest = request
|
te.httpRequest = request
|
||||||
te.httpResponse = response
|
te.httpResponse = response
|
||||||
|
|
|
@ -123,16 +123,20 @@ class ContentNotificationManager(
|
||||||
val displayName = userColorNameManager.getDisplayName(userCursor.getString(userIndices[Statuses.USER_KEY]),
|
val displayName = userColorNameManager.getDisplayName(userCursor.getString(userIndices[Statuses.USER_KEY]),
|
||||||
userCursor.getString(userIndices[Statuses.USER_NAME]), userCursor.getString(userIndices[Statuses.USER_SCREEN_NAME]),
|
userCursor.getString(userIndices[Statuses.USER_NAME]), userCursor.getString(userIndices[Statuses.USER_SCREEN_NAME]),
|
||||||
nameFirst)
|
nameFirst)
|
||||||
notificationContent = if (usersCount == 1) {
|
notificationContent = when (usersCount) {
|
||||||
context.getString(R.string.from_name, displayName)
|
1 -> {
|
||||||
} else if (usersCount == 2) {
|
context.getString(R.string.from_name, displayName)
|
||||||
userCursor.moveToPosition(1)
|
}
|
||||||
val othersName = userColorNameManager.getDisplayName(userCursor.getString(userIndices[Statuses.USER_KEY]),
|
2 -> {
|
||||||
userCursor.getString(userIndices[Statuses.USER_NAME]), userCursor.getString(userIndices[Statuses.USER_SCREEN_NAME]),
|
userCursor.moveToPosition(1)
|
||||||
nameFirst)
|
val othersName = userColorNameManager.getDisplayName(userCursor.getString(userIndices[Statuses.USER_KEY]),
|
||||||
resources.getString(R.string.from_name_and_name, displayName, othersName)
|
userCursor.getString(userIndices[Statuses.USER_NAME]), userCursor.getString(userIndices[Statuses.USER_SCREEN_NAME]),
|
||||||
} else {
|
nameFirst)
|
||||||
resources.getString(R.string.from_name_and_N_others, displayName, usersCount - 1)
|
resources.getString(R.string.from_name_and_name, displayName, othersName)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
resources.getString(R.string.from_name_and_N_others, displayName, usersCount - 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup notification
|
// Setup notification
|
||||||
|
|
|
@ -72,20 +72,25 @@ abstract class FileBasedDraftsSyncAction<RemoteFileInfo>(val context: Context) :
|
||||||
|
|
||||||
remoteDrafts.forEach { remoteDraft ->
|
remoteDrafts.forEach { remoteDraft ->
|
||||||
val localDraft = localDrafts.find { it.filename == remoteDraft.draftFileName }
|
val localDraft = localDrafts.find { it.filename == remoteDraft.draftFileName }
|
||||||
if (remoteDraft.draftFileName.substringBefore(".eml") in localRemovedIds) {
|
when {
|
||||||
// Local removed, remove remote
|
remoteDraft.draftFileName.substringBefore(".eml") in localRemovedIds -> {
|
||||||
removeRemoteInfoList.add(remoteDraft)
|
// Local removed, remove remote
|
||||||
} else if (localDraft == null) {
|
removeRemoteInfoList.add(remoteDraft)
|
||||||
// Local doesn't exist, download remote
|
}
|
||||||
downloadRemoteInfoList.add(remoteDraft)
|
localDraft == null -> {
|
||||||
} else if (remoteDraft.draftTimestamp - localDraft.timestamp > 1000) {
|
// Local doesn't exist, download remote
|
||||||
// Local is older, update from remote
|
downloadRemoteInfoList.add(remoteDraft)
|
||||||
localDraft.remote_extras = remoteDraft.draftRemoteExtras
|
}
|
||||||
updateLocalInfoList[localDraft._id] = remoteDraft
|
remoteDraft.draftTimestamp - localDraft.timestamp > 1000 -> {
|
||||||
} else if (localDraft.timestamp - remoteDraft.draftTimestamp > 1000) {
|
// Local is older, update from remote
|
||||||
// Local is newer, upload local
|
localDraft.remote_extras = remoteDraft.draftRemoteExtras
|
||||||
localDraft.remote_extras = remoteDraft.draftRemoteExtras
|
updateLocalInfoList[localDraft._id] = remoteDraft
|
||||||
uploadLocalList.add(localDraft)
|
}
|
||||||
|
localDraft.timestamp - remoteDraft.draftTimestamp > 1000 -> {
|
||||||
|
// Local is newer, upload local
|
||||||
|
localDraft.remote_extras = remoteDraft.draftRemoteExtras
|
||||||
|
uploadLocalList.add(localDraft)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,14 +53,18 @@ abstract class TwitterCardViewFactory {
|
||||||
private fun createCardFragment(status: ParcelableStatus): ContainerView.ViewController? {
|
private fun createCardFragment(status: ParcelableStatus): ContainerView.ViewController? {
|
||||||
val card = status.card
|
val card = status.card
|
||||||
if (card?.name == null) return null
|
if (card?.name == null) return null
|
||||||
if (TwitterCardUtils.CARD_NAME_PLAYER == card.name) {
|
return when {
|
||||||
return createGenericPlayerFragment(card)
|
TwitterCardUtils.CARD_NAME_PLAYER == card.name -> {
|
||||||
} else if (TwitterCardUtils.CARD_NAME_AUDIO == card.name) {
|
createGenericPlayerFragment(card)
|
||||||
return createGenericPlayerFragment(card)
|
}
|
||||||
} else if (TwitterCardUtils.isPoll(card)) {
|
TwitterCardUtils.CARD_NAME_AUDIO == card.name -> {
|
||||||
return createCardPollFragment(status)
|
createGenericPlayerFragment(card)
|
||||||
|
}
|
||||||
|
TwitterCardUtils.isPoll(card) -> {
|
||||||
|
createCardPollFragment(status)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
}
|
}
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,12 +97,16 @@ class ActionIconThemedTextView(
|
||||||
for (d in TextViewSupport.getCompoundDrawablesRelative(this)) {
|
for (d in TextViewSupport.getCompoundDrawablesRelative(this)) {
|
||||||
if (d == null) continue
|
if (d == null) continue
|
||||||
d.mutate()
|
d.mutate()
|
||||||
val color: Int = if (isActivated) {
|
val color: Int = when {
|
||||||
activatedColor
|
isActivated -> {
|
||||||
} else if (isEnabled) {
|
activatedColor
|
||||||
defaultColor
|
}
|
||||||
} else {
|
isEnabled -> {
|
||||||
disabledColor
|
defaultColor
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
disabledColor
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iconWidth > 0 && iconHeight > 0) {
|
if (iconWidth > 0 && iconHeight > 0) {
|
||||||
|
|
|
@ -65,14 +65,18 @@ class CardMediaContainer(context: Context, attrs: AttributeSet? = null) : ViewGr
|
||||||
val k = imageRes.size
|
val k = imageRes.size
|
||||||
for (i in 0 until childCount) {
|
for (i in 0 until childCount) {
|
||||||
val child = getChildAt(i)
|
val child = getChildAt(i)
|
||||||
if (child !is ImageView) {
|
when {
|
||||||
child.visibility = View.GONE
|
child !is ImageView -> {
|
||||||
} else if (i < k) {
|
child.visibility = View.GONE
|
||||||
child.setImageResource(imageRes[i])
|
}
|
||||||
child.visibility = View.VISIBLE
|
i < k -> {
|
||||||
} else {
|
child.setImageResource(imageRes[i])
|
||||||
child.setImageDrawable(null)
|
child.visibility = View.VISIBLE
|
||||||
child.visibility = View.GONE
|
}
|
||||||
|
else -> {
|
||||||
|
child.setImageDrawable(null)
|
||||||
|
child.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,12 +163,16 @@ class CardMediaContainer(context: Context, attrs: AttributeSet? = null) : ViewGr
|
||||||
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
||||||
val childCount = rebuildChildInfo()
|
val childCount = rebuildChildInfo()
|
||||||
if (childCount > 0) {
|
if (childCount > 0) {
|
||||||
if (childCount == 1) {
|
when (childCount) {
|
||||||
layout1Media(childIndices)
|
1 -> {
|
||||||
} else if (childCount == 3) {
|
layout1Media(childIndices)
|
||||||
layout3Media(horizontalSpacing, verticalSpacing, childIndices)
|
}
|
||||||
} else {
|
3 -> {
|
||||||
layoutGridMedia(childCount, 2, horizontalSpacing, verticalSpacing, childIndices)
|
layout3Media(horizontalSpacing, verticalSpacing, childIndices)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
layoutGridMedia(childCount, 2, horizontalSpacing, verticalSpacing, childIndices)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,16 +190,21 @@ class CardMediaContainer(context: Context, attrs: AttributeSet? = null) : ViewGr
|
||||||
val childCount = rebuildChildInfo()
|
val childCount = rebuildChildInfo()
|
||||||
var heightSum = 0
|
var heightSum = 0
|
||||||
if (childCount > 0) {
|
if (childCount > 0) {
|
||||||
heightSum = if (childCount == 1) {
|
heightSum = when (childCount) {
|
||||||
measure1Media(contentWidth, childIndices, ratioMultiplier)
|
1 -> {
|
||||||
} else if (childCount == 2) {
|
measure1Media(contentWidth, childIndices, ratioMultiplier)
|
||||||
measureGridMedia(childCount, 2, contentWidth, ratioMultiplier, horizontalSpacing,
|
}
|
||||||
verticalSpacing, childIndices)
|
2 -> {
|
||||||
} else if (childCount == 3) {
|
measureGridMedia(childCount, 2, contentWidth, ratioMultiplier, horizontalSpacing,
|
||||||
measure3Media(contentWidth, horizontalSpacing, childIndices, ratioMultiplier)
|
verticalSpacing, childIndices)
|
||||||
} else {
|
}
|
||||||
measureGridMedia(childCount, 2, contentWidth,
|
3 -> {
|
||||||
WIDTH_HEIGHT_RATIO * ratioMultiplier, horizontalSpacing, verticalSpacing, childIndices)
|
measure3Media(contentWidth, horizontalSpacing, childIndices, ratioMultiplier)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
measureGridMedia(childCount, 2, contentWidth,
|
||||||
|
WIDTH_HEIGHT_RATIO * ratioMultiplier, horizontalSpacing, verticalSpacing, childIndices)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (contentHeight > 0) {
|
if (contentHeight > 0) {
|
||||||
heightSum = contentHeight
|
heightSum = contentHeight
|
||||||
|
|
|
@ -111,12 +111,16 @@ class IconActionButton(
|
||||||
|
|
||||||
fun IIconActionButton.updateColorFilter() {
|
fun IIconActionButton.updateColorFilter() {
|
||||||
this as ImageView
|
this as ImageView
|
||||||
if (isActivated) {
|
when {
|
||||||
setColorFilter(activatedColor)
|
isActivated -> {
|
||||||
} else if (isEnabled) {
|
setColorFilter(activatedColor)
|
||||||
setColorFilter(defaultColor)
|
}
|
||||||
} else {
|
isEnabled -> {
|
||||||
setColorFilter(disabledColor)
|
setColorFilter(defaultColor)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
setColorFilter(disabledColor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,12 +76,16 @@ class DraftViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
} else {
|
} else {
|
||||||
contentView.drawEnd()
|
contentView.drawEnd()
|
||||||
}
|
}
|
||||||
if (summaryText != null) {
|
when {
|
||||||
textView.spannable = summaryText
|
summaryText != null -> {
|
||||||
} else if (draft.text.isNullOrEmpty()) {
|
textView.spannable = summaryText
|
||||||
textView.setText(R.string.empty_content)
|
}
|
||||||
} else {
|
draft.text.isNullOrEmpty() -> {
|
||||||
textView.spannable = draft.text
|
textView.setText(R.string.empty_content)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
textView.spannable = draft.text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (draft.timestamp > 0) {
|
if (draft.timestamp > 0) {
|
||||||
|
|
|
@ -167,18 +167,22 @@ class DetailStatusViewHolder(
|
||||||
|
|
||||||
val quotedMedia = status.quoted_media
|
val quotedMedia = status.quoted_media
|
||||||
|
|
||||||
if (quotedMedia?.isEmpty() != false) {
|
when {
|
||||||
itemView.quotedMediaLabel.visibility = View.GONE
|
quotedMedia?.isEmpty() != false -> {
|
||||||
itemView.quotedMediaPreview.visibility = View.GONE
|
itemView.quotedMediaLabel.visibility = View.GONE
|
||||||
} else if (adapter.isDetailMediaExpanded) {
|
itemView.quotedMediaPreview.visibility = View.GONE
|
||||||
itemView.quotedMediaLabel.visibility = View.GONE
|
}
|
||||||
itemView.quotedMediaPreview.visibility = View.VISIBLE
|
adapter.isDetailMediaExpanded -> {
|
||||||
itemView.quotedMediaPreview.displayMedia(adapter.requestManager,
|
itemView.quotedMediaLabel.visibility = View.GONE
|
||||||
|
itemView.quotedMediaPreview.visibility = View.VISIBLE
|
||||||
|
itemView.quotedMediaPreview.displayMedia(adapter.requestManager,
|
||||||
media = quotedMedia, accountKey = status.account_key,
|
media = quotedMedia, accountKey = status.account_key,
|
||||||
mediaClickListener = adapter.fragment)
|
mediaClickListener = adapter.fragment)
|
||||||
} else {
|
}
|
||||||
itemView.quotedMediaLabel.visibility = View.VISIBLE
|
else -> {
|
||||||
itemView.quotedMediaPreview.visibility = View.GONE
|
itemView.quotedMediaLabel.visibility = View.VISIBLE
|
||||||
|
itemView.quotedMediaPreview.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
itemView.quotedName.visibility = View.GONE
|
itemView.quotedName.visibility = View.GONE
|
||||||
|
@ -299,22 +303,26 @@ class DetailStatusViewHolder(
|
||||||
|
|
||||||
val media = status.media
|
val media = status.media
|
||||||
|
|
||||||
if (media?.isEmpty() != false) {
|
when {
|
||||||
itemView.mediaPreviewContainer.visibility = View.GONE
|
media?.isEmpty() != false -> {
|
||||||
itemView.mediaPreview.visibility = View.GONE
|
itemView.mediaPreviewContainer.visibility = View.GONE
|
||||||
itemView.mediaPreviewLoad.visibility = View.GONE
|
itemView.mediaPreview.visibility = View.GONE
|
||||||
itemView.mediaPreview.displayMedia()
|
itemView.mediaPreviewLoad.visibility = View.GONE
|
||||||
} else if (adapter.isDetailMediaExpanded) {
|
itemView.mediaPreview.displayMedia()
|
||||||
itemView.mediaPreviewContainer.visibility = View.VISIBLE
|
}
|
||||||
itemView.mediaPreview.visibility = View.VISIBLE
|
adapter.isDetailMediaExpanded -> {
|
||||||
itemView.mediaPreviewLoad.visibility = View.GONE
|
itemView.mediaPreviewContainer.visibility = View.VISIBLE
|
||||||
itemView.mediaPreview.displayMedia(adapter.requestManager, media = media,
|
itemView.mediaPreview.visibility = View.VISIBLE
|
||||||
|
itemView.mediaPreviewLoad.visibility = View.GONE
|
||||||
|
itemView.mediaPreview.displayMedia(adapter.requestManager, media = media,
|
||||||
accountKey = status.account_key, mediaClickListener = adapter.fragment)
|
accountKey = status.account_key, mediaClickListener = adapter.fragment)
|
||||||
} else {
|
}
|
||||||
itemView.mediaPreviewContainer.visibility = View.VISIBLE
|
else -> {
|
||||||
itemView.mediaPreview.visibility = View.GONE
|
itemView.mediaPreviewContainer.visibility = View.VISIBLE
|
||||||
itemView.mediaPreviewLoad.visibility = View.VISIBLE
|
itemView.mediaPreview.visibility = View.GONE
|
||||||
itemView.mediaPreview.displayMedia()
|
itemView.mediaPreviewLoad.visibility = View.VISIBLE
|
||||||
|
itemView.mediaPreview.displayMedia()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TwitterCardUtils.isCardSupported(status)) {
|
if (TwitterCardUtils.isCardSupported(status)) {
|
||||||
|
|
|
@ -26,12 +26,16 @@ object AccountsSelectorTransformer : ViewPager.PageTransformer {
|
||||||
internal const val selectorAccountsCount: Int = 3
|
internal const val selectorAccountsCount: Int = 3
|
||||||
|
|
||||||
override fun transformPage(page: View, position: Float) {
|
override fun transformPage(page: View, position: Float) {
|
||||||
if (position < 0) {
|
when {
|
||||||
page.alpha = 1 + position * selectorAccountsCount
|
position < 0 -> {
|
||||||
} else if (position > (selectorAccountsCount - 1f) / selectorAccountsCount) {
|
page.alpha = 1 + position * selectorAccountsCount
|
||||||
page.alpha = (1 - position) * selectorAccountsCount
|
}
|
||||||
} else {
|
position > (selectorAccountsCount - 1f) / selectorAccountsCount -> {
|
||||||
page.alpha = 1f
|
page.alpha = (1 - position) * selectorAccountsCount
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
page.alpha = 1f
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue