Skip to content

Instantly share code, notes, and snippets.

class DialogFragmentViewBindingDelegate<out T : ViewBinding>(
val fragment: DialogFragment,
val viewBindingFactory: (LayoutInflater, ViewGroup?, Boolean) -> T
) : ReadOnlyProperty<DialogFragment, T> {
private var binding: T? = null
init {
fragment.lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onDestroy(owner: LifecycleOwner) {
Timber.d("Removing viewbinder")
@bohsen
bohsen / docker-compose.yml
Created May 19, 2020 05:42
Wordpress docker-compose container
# /wordpress-docker/docker-compose.yml
---
version: '3.8'
services:
db:
container_name: 'local-wordpress-db'
image: 'mysql:5.7'
volumes:
- './data/mysql:/var/lib/mysql'
ports:
@bohsen
bohsen / CustomMatchers.java
Last active October 20, 2017 09:15
Custom Matcher that can be used to check if a view is showing a Snackbar with a specific message and/or action
public class CustomMatchers {
/**
* Check that {@link Snackbar} is displayed, with correct message
* @param message Expected message ressourceId
* @return ViewInteraction that checks if {@link Snackbar} is displayed, with correct message
*/
public static ViewInteraction assertSnackbarWithMessage(@StringRes int message) {
return onView(withSnackbar())
.check(matches(allOf(
withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE),
@bohsen
bohsen / ExaminationListFragmentTest.java
Created October 16, 2017 06:26
An Instruction that waits for the Snackbar to be dismissed before continuing with the test.
private class SnackbarDismissed<T extends BaseActivity> extends Instruction {
private final T mActivity;
SnackbarDismissed(T activity) {
mActivity = activity;
}
@Override
public String getDescription() {