Skip to content

Instantly share code, notes, and snippets.

View gilgoldzweig's full-sized avatar

Gil Goldzweig gilgoldzweig

View GitHub Profile
class ExamplePresenterTest {
//Setup code...
@Test
fun `test_fetchProfileName_calles_onProfileNameReceived_on_positive_response`() {
Mockito.`when`(presenter.fetchProfileNameFromRepository()))
.thenReturn("Gil Goldzweig")
class ExamplePresenterTest {
//Setup code...
@Test
fun `test_fetchProfileName_calles_onProfileRequestFailed_on_exception`() {
val fakeException = Mockito.mock(IOException::class.java)
Mockito.`when`(presenter.fetchProfileNameFromRepository()))
@gilgoldzweig
gilgoldzweig / ClickDebouncer.kt
Last active October 17, 2019 11:11
ClickDebouncer.kt
import android.os.Handler
import android.view.View
/**
* A class for debouncing clicks
*/
abstract class DebouncingOnClickListener : View.OnClickListener {
private val clickDebouncer = ClickDebouncer()
class ComposeFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
container?.setContent {
}
return container
@gilgoldzweig
gilgoldzweig / sample_layout.xml&env=plain
Last active November 25, 2019 11:50
|-|&tag=Stackoverflow
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<TextView
android:id="@+id/textViewTitle"
android:layout_width="wrap_content"
@gilgoldzweig
gilgoldzweig / sample_collapsing_animation_scene.xml
Last active December 27, 2019 10:20
MotionScene constraint search view|-|&tag=MotionLayout
<Constraint
android:id="@id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:elevation="4dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toBottomOf="@id/navigation_icon" />
@gilgoldzweig
gilgoldzweig / sample_collapsing_animation.xml
Last active December 27, 2019 10:19
MotionLayout layout file root tag|-|&tag=MotionLayout
<androidx.constraintlayout.motion.widget.MotionLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/sample_collapsing_animation_scene">
@gilgoldzweig
gilgoldzweig / sample_collapsing_animation.xml
Last active December 27, 2019 10:24
MotionLayout layout file full|-|&tag=MotionLayout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/sample_collapsing_animation_scene">
<View
android:id="@+id/toolbar"
@gilgoldzweig
gilgoldzweig / sample_collapsing_animation.xml
Last active December 27, 2019 10:21
MotionLayout layout file toolbar |-|&tag=MotionLayout
<View
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/colorPrimary"
android:elevation="4dp"
app:layout_constraintBottom_toTopOf="@id/guidline_toolbar"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
@gilgoldzweig
gilgoldzweig / sample_collapsing_animation.xml
Last active December 27, 2019 10:18
MotionLayout layout search view|-|&tag=MotionLayout
<androidx.appcompat.widget.SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:background="@color/md_white_1000"
android:elevation="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"