Username UX refresh.

This commit is contained in:
Alex Hart
2022-08-16 16:59:12 -03:00
committed by Cody Henthorne
parent 3252871ed5
commit 28310a88f5
24 changed files with 1254 additions and 589 deletions

View File

@@ -0,0 +1,23 @@
package org.thoughtcrime.securesms.util
import android.os.Bundle
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LifecycleOwner
import java.util.function.Consumer
/**
* Generic Fragment result contract.
*/
abstract class FragmentResultContract<T> protected constructor(private val resultKey: String) {
protected abstract fun getResult(bundle: Bundle): T
fun registerForResult(fragmentManager: FragmentManager, lifecycleOwner: LifecycleOwner, consumer: Consumer<T>) {
fragmentManager.setFragmentResultListener(resultKey, lifecycleOwner) { key, bundle ->
if (key == resultKey) {
val result = getResult(bundle)
consumer.accept(result)
}
}
}
}

View File

@@ -0,0 +1,20 @@
package org.thoughtcrime.securesms.util.adapter.mapping
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
/**
* Allows ViewHolders to be generated with a ViewBinding. Intended usage is as follows:
*
* BindingFactory(::MyBindingViewHolder, MyBinding::inflate)
*/
class BindingFactory<T : MappingModel<T>, B : ViewBinding>(
private val creator: (B) -> BindingViewHolder<T, B>,
private val inflater: (LayoutInflater, ViewGroup, Boolean) -> B
) : Factory<T> {
override fun createViewHolder(parent: ViewGroup): MappingViewHolder<T> {
val binding = inflater(LayoutInflater.from(parent.context), parent, false)
return creator(binding)
}
}

View File

@@ -0,0 +1,8 @@
package org.thoughtcrime.securesms.util.adapter.mapping
import androidx.viewbinding.ViewBinding
/**
* A ViewHolder which is populated with a ViewBinding, used in conjunction with BindingFactory
*/
abstract class BindingViewHolder<T, B : ViewBinding>(protected val binding: B) : MappingViewHolder<T>(binding.root)

View File

@@ -13,7 +13,7 @@ import io.reactivex.rxjava3.subjects.PublishSubject
*/
class RxStore<T : Any>(
defaultValue: T,
private val scheduler: Scheduler = Schedulers.computation()
scheduler: Scheduler = Schedulers.computation()
) {
private val behaviorProcessor = BehaviorProcessor.createDefault(defaultValue)