This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| private const val MIRROR = 180F | |
| private const val INITIAL_DELAY = 0.15F | |
| private val translucentBlack = Color.argb(50, 0, 0, 0) | |
| fun speedDial( | |
| anchor: View, | |
| @ColorInt tint: Int = anchor.context.themeColorAt(R.attr.colorPrimary), | |
| @StyleRes animationStyle: Int = android.R.style.Animation_Dialog, | |
| layoutAnimationController: LayoutAnimationController = LayoutAnimationController(speedDialAnimation, INITIAL_DELAY).apply { order = ORDER_NORMAL }, |
This file contains hidden or 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
| public abstract class BaseObservable<LISTENER_CLASS> { | |
| private final Object MONITOR = new Object(); | |
| private final Set<LISTENER_CLASS> mListeners = new HashSet<>(); | |
| public void registerListener(LISTENER_CLASS listener) { | |
| synchronized (MONITOR) { | |
| boolean hadNoListeners = mListeners.size() == 0; | |
| mListeners.add(listener); |
This file contains hidden or 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 EndlessService : Service() { | |
| private var wakeLock: PowerManager.WakeLock? = null | |
| private var isServiceStarted = false | |
| override fun onBind(intent: Intent): IBinder? { | |
| log("Some component want to bind with the service") | |
| // We don't provide binding, so return null | |
| return null | |
| } |