This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun observe(permissions: List<MintPermission>): Flow<List<MintPermissionStatus>> { | |
return statusesController.observe() | |
.combine(permissions.asFlow()) { statuses, permission -> | |
statuses.getStatus(permission) | |
} | |
.runningList() | |
.distinctUntilChanged() | |
} | |
fun <T> Flow<T>.runningList(): Flow<List<T>> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FragmentViewBindingProperty<T : ViewBinding>( | |
private val viewBinder: ViewBinder<T> | |
) : ReadOnlyProperty<Fragment, T> { | |
private var viewBinding: T? = null | |
private val lifecycleObserver = BindingLifecycleObserver() | |
@MainThread | |
override fun getValue(thisRef: Fragment, property: KProperty<*>): T { | |
checkIsMainThread() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProfileFragment() : Fragment(R.layout.profile) { | |
private val viewBinding: ProfileBinding by viewBinding() | |
override fun onDestroyView() { | |
super.onDestroyView() | |
// Clear data in views from viewBinding | |
// ViewBinding inside viewBinding is null | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProfileFragment : Fragment(R.layout.profile) { | |
private val viewBinding: ProfileBinding by viewBinding() | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
// Use viewBinding | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProfileFragment : Fragment(R.layout.profile) { | |
private var viewBinding: ProfileBinding? = null | |
override fun onViewCreated(view: View, savedState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
viewBinding = ProfileBinding.bind(view) | |
// Use viewBinding | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FragmentViewBindingProperty<T : ViewBinding>( | |
private val viewBinder: ViewBinder<T> | |
) : ReadOnlyProperty<Fragment, T> { | |
private var viewBinding: T? = null | |
private val lifecycleObserver = BindingLifecycleObserver() | |
@MainThread | |
override fun getValue(thisRef: Fragment, property: KProperty<*>): T { | |
checkIsMainThread() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SetFragmentFactoryActivityCallback( | |
private val newFragmentFactory: FragmentFactory | |
) : EmptyActivityLifecycleCallbacks { | |
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { | |
if (activity is FragmentActivity) { | |
activity.supportFragmentManager.fragmentFactory = newFragmentFactory | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MapKey | |
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER) | |
@Retention(AnnotationRetention.RUNTIME) | |
annotation class ActivityKey(val value: KClass<out Activity>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MapKey | |
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER) | |
@Retention(AnnotationRetention.RUNTIME) | |
annotation class FragmentKey(val value: KClass<out Fragment>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
interface FragmentBindsModule { | |
@Binds | |
@IntoMap | |
@FragmentKey(MessageFragment::class) | |
fun bindMessageFragmentToFragmentForMultiBinding(fragment: MessageFragment): Fragment | |
} |
NewerOlder