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
fun fetchFoo() = GlobalScope.launch { | |
handleNetworkResponse<Foo, Unit>( | |
invokeNetwork = { | |
fooService.fetchFoo() | |
}, | |
successBlock = { r -> | |
// success logic | |
}, | |
errorBlock = { | |
// error logic |
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 one.mixin.android.widget | |
import android.content.Context | |
import android.util.AttributeSet | |
import android.view.MotionEvent | |
import android.view.VelocityTracker | |
import android.view.ViewConfiguration | |
import androidx.recyclerview.widget.RecyclerView | |
import one.mixin.android.R |
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
fun Bitmap.decodeQR(): String? { | |
val width = width | |
val height = height | |
val pixels = IntArray(width * height) | |
getPixels(pixels, 0, width, 0, 0, width, height) | |
val source = RGBLuminanceSource(width, height, pixels) | |
val binaryBitmap = BinaryBitmap(GlobalHistogramBinarizer(source)) | |
val reader = MultiFormatReader() | |
val hints = EnumMap<DecodeHintType, Any>(DecodeHintType::class.java) |