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 ToolbarBehavior : CoordinatorLayout.Behavior<AppBarLayout>() { | |
/** Consume if vertical scroll because we don't care about other scrolls */ | |
override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: AppBarLayout, | |
directTargetChild: View, target: View, axes: Int, type: Int): Boolean { | |
getViews(child) | |
return axes == ViewCompat.SCROLL_AXIS_VERTICAL || | |
super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type) | |
} |
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
inline fun getValueAnimator(forward: Boolean = true, duration: Long, interpolator: TimeInterpolator, | |
crossinline updateListener: (progress: Float) -> Unit | |
): ValueAnimator { | |
val a = | |
if (forward) ValueAnimator.ofFloat(0f, 1f) | |
else ValueAnimator.ofFloat(1f, 0f) | |
a.addUpdateListener { updateListener(it.animatedValue as Float) } | |
a.duration = duration | |
a.interpolator = interpolator | |
return a |
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
package com.example | |
import android.app.Instrumentation | |
import android.os.Bundle | |
import android.util.Log | |
import androidx.test.internal.runner.listener.InstrumentationResultPrinter | |
import androidx.test.platform.app.InstrumentationRegistry | |
import org.junit.runner.Description | |
import org.junit.runner.notification.RunListener |
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
plugins { | |
`android-base-app` | |
`android-base` | |
id("io.fabric") | |
} | |
android { | |
defaultConfig { | |
versionCode = 20 | |
versionName = "1.6.3" |
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
import java.io.*; | |
public class JavaDeserial{ | |
public static void main(String args[]) throws Exception{ | |
FileInputStream fis = new FileInputStream("/tmp/normalObj.serial"); | |
ObjectInputStream ois = new ObjectInputStream(fis); | |
NormalObj unserObj = (NormalObj)ois.readObject(); | |
ois.close(); |
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
package be.digitalia.samples.utils | |
import android.view.MotionEvent | |
import androidx.recyclerview.widget.RecyclerView | |
import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener | |
import kotlin.math.abs | |
fun RecyclerView.enforceSingleScrollDirection() { | |
val enforcer = SingleScrollDirectionEnforcer() | |
addOnItemTouchListener(enforcer) |
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
// domain | |
sealed class ErrorEntity { | |
sealed class ApiError: ErrorEntity() { | |
// ..... | |
} | |
sealed class FileError: ErrorEntity() { | |
object NotFound: FileError() |
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
@Suppress("UNCHECKED_CAST") | |
class ViewModelFactory @Inject constructor( | |
private val creators: Map<Class<out ViewModel>, Provider<ViewModel>> | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
val creator = creators[modelClass] | |
?: creators.asIterable().find { (key, _) -> modelClass.isAssignableFrom(key) }?.value | |
?: throw IllegalArgumentException("Unknown ViewModel class $modelClass") |
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 OurViewModel(observeGithubReposUseCase: ObserveGithubReposUseCase): ViewModel { | |
val githubRepos: LiveData<List<GithubRepoItem>> | |
get() = observeGithubReposUseCase | |
.observe() | |
.map { reposList -> | |
reposList | |
.sortedByDescending { it.stars } | |
.map { |
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 OverlappingPanelsLayout : FrameLayout { | |
private var scrollingSlopPx: Float = 0f | |
private var velocityTracker: VelocityTracker? = null | |
private var isScrollingHorizontally = false | |
private var xFromInterceptActionDown: Float = 0f | |
private var yFromInterceptActionDown: Float = 0f | |
... // initialize scrollingSlopPx and VelocityTracker |