mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Fix crash
This commit is contained in:
parent
d389581d96
commit
8db4da5473
4 changed files with 20 additions and 28 deletions
|
@ -17,7 +17,6 @@ package im.vector.app.core.ui.views
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.IntRange
|
||||
import androidx.core.content.ContextCompat
|
||||
|
@ -87,8 +86,7 @@ class PasswordStrengthBar @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context)
|
||||
.inflate(R.layout.view_password_strength_bar, this, true)
|
||||
inflate(context, R.layout.view_password_strength_bar, this)
|
||||
views = ViewPasswordStrengthBarBinding.bind(this)
|
||||
orientation = HORIZONTAL
|
||||
strength = 0
|
||||
|
|
|
@ -51,8 +51,6 @@ import javax.inject.Inject
|
|||
class EmojiReactionPickerActivity : VectorBaseActivity<ActivityEmojiReactionPickerBinding>(),
|
||||
EmojiCompatFontProvider.FontProviderListener {
|
||||
|
||||
private lateinit var tabLayout: TabLayout
|
||||
|
||||
lateinit var viewModel: EmojiChooserViewModel
|
||||
|
||||
override fun getMenuRes() = R.menu.menu_emoji_reaction_picker
|
||||
|
@ -90,30 +88,28 @@ class EmojiReactionPickerActivity : VectorBaseActivity<ActivityEmojiReactionPick
|
|||
it.addListener(this)
|
||||
}
|
||||
|
||||
tabLayout = findViewById(R.id.tabs)
|
||||
|
||||
viewModel = viewModelProvider.get(EmojiChooserViewModel::class.java)
|
||||
|
||||
viewModel.eventId = intent.getStringExtra(EXTRA_EVENT_ID)
|
||||
|
||||
emojiDataSource.rawData.categories.forEach { category ->
|
||||
val s = category.emojis[0]
|
||||
tabLayout.newTab()
|
||||
views.tabs.newTab()
|
||||
.also { tab ->
|
||||
tab.text = emojiDataSource.rawData.emojis[s]!!.emoji
|
||||
tab.contentDescription = category.name
|
||||
}
|
||||
.also { tab ->
|
||||
tabLayout.addTab(tab)
|
||||
views.tabs.addTab(tab)
|
||||
}
|
||||
}
|
||||
tabLayout.addOnTabSelectedListener(tabLayoutSelectionListener)
|
||||
views.tabs.addOnTabSelectedListener(tabLayoutSelectionListener)
|
||||
|
||||
viewModel.currentSection.observe(this, Observer { section ->
|
||||
section?.let {
|
||||
tabLayout.removeOnTabSelectedListener(tabLayoutSelectionListener)
|
||||
tabLayout.getTabAt(it)?.select()
|
||||
tabLayout.addOnTabSelectedListener(tabLayoutSelectionListener)
|
||||
views.tabs.removeOnTabSelectedListener(tabLayoutSelectionListener)
|
||||
views.tabs.getTabAt(it)?.select()
|
||||
views.tabs.addOnTabSelectedListener(tabLayoutSelectionListener)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -130,7 +126,7 @@ class EmojiReactionPickerActivity : VectorBaseActivity<ActivityEmojiReactionPick
|
|||
|
||||
views.emojiPickerWholeListFragmentContainer.isVisible = true
|
||||
views.emojiPickerFilteredListFragmentContainer.isVisible = false
|
||||
tabLayout.isVisible = true
|
||||
views.tabs.isVisible = true
|
||||
}
|
||||
|
||||
override fun compatibilityFontUpdate(typeface: Typeface?) {
|
||||
|
@ -191,11 +187,11 @@ class EmojiReactionPickerActivity : VectorBaseActivity<ActivityEmojiReactionPick
|
|||
|
||||
private fun onQueryText(query: String) {
|
||||
if (query.isEmpty()) {
|
||||
tabLayout.isVisible = true
|
||||
views.tabs.isVisible = true
|
||||
views.emojiPickerWholeListFragmentContainer.isVisible = true
|
||||
views.emojiPickerFilteredListFragmentContainer.isVisible = false
|
||||
} else {
|
||||
tabLayout.isVisible = false
|
||||
views.tabs.isVisible = false
|
||||
views.emojiPickerWholeListFragmentContainer.isVisible = false
|
||||
views.emojiPickerFilteredListFragmentContainer.isVisible = true
|
||||
searchResultViewModel.handle(EmojiSearchAction.UpdateQuery(query))
|
||||
|
|
|
@ -23,15 +23,14 @@ import android.content.Context
|
|||
import android.content.res.TypedArray
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.view.animation.OvershootInterpolator
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.withStyledAttributes
|
||||
import im.vector.app.EmojiCompatWrapper
|
||||
|
@ -48,7 +47,7 @@ import javax.inject.Inject
|
|||
class ReactionButton @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0)
|
||||
: FrameLayout(context, attrs, defStyleAttr), View.OnClickListener, View.OnLongClickListener {
|
||||
: ConstraintLayout(context, attrs, defStyleAttr), View.OnClickListener, View.OnLongClickListener {
|
||||
|
||||
init {
|
||||
if (context is HasScreenInjector) {
|
||||
|
@ -96,7 +95,7 @@ class ReactionButton @JvmOverloads constructor(context: Context,
|
|||
private var offDrawable: Drawable? = null
|
||||
|
||||
init {
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.reaction_button, this, true)
|
||||
inflate(context, R.layout.reaction_button, this)
|
||||
views = ReactionButtonBinding.bind(this)
|
||||
views.reactionCount.text = TextUtils.formatCountToShortDecimal(reactionCount)
|
||||
|
||||
|
@ -158,7 +157,7 @@ class ReactionButton @JvmOverloads constructor(context: Context,
|
|||
isChecked = !isChecked
|
||||
|
||||
// icon!!.setImageDrawable(if (isChecked) likeDrawable else unLikeDrawable)
|
||||
views.reactionSelector.background = if (isChecked) onDrawable else offDrawable
|
||||
background = if (isChecked) onDrawable else offDrawable
|
||||
|
||||
if (isChecked) {
|
||||
reactedListener?.onReacted(this)
|
||||
|
@ -320,10 +319,10 @@ class ReactionButton @JvmOverloads constructor(context: Context,
|
|||
fun setChecked(status: Boolean?) {
|
||||
if (status!!) {
|
||||
isChecked = true
|
||||
views.reactionSelector.background = onDrawable
|
||||
background = onDrawable
|
||||
} else {
|
||||
isChecked = false
|
||||
views.reactionSelector.background = offDrawable
|
||||
background = offDrawable
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/reactionSelector"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="26dp"
|
||||
android:background="@drawable/reaction_rounded_rect_shape"
|
||||
android:clipChildren="false"
|
||||
android:minWidth="44dp">
|
||||
|
||||
android:minWidth="44dp"
|
||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
||||
|
||||
<!--<View-->
|
||||
<!--android:id="@+id/reactionSelector"-->
|
||||
|
@ -74,4 +73,4 @@
|
|||
app:layout_constraintStart_toEndOf="@id/reactionText"
|
||||
tools:text="13450" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</merge>
|
||||
|
|
Loading…
Reference in a new issue