Skip to content

Instantly share code, notes, and snippets.

View vincent-paing's full-sized avatar
🎯
Focusing

Aung Kyaw Paing vincent-paing

🎯
Focusing
View GitHub Profile
@vincent-paing
vincent-paing / NexyConverter.java
Created April 22, 2024 02:40
Decompiled Burglish conversion from Nexy Keyboard
package co.nexlabs.nexyKeyboard.d;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public class NexyConverter {
public static boolean a = false;
public static boolean b = false;
@vincent-paing
vincent-paing / LineLogin.kt
Created January 31, 2024 14:36
Line login implementation with ActivityResultContract
class LineLogin : ActivityResultContract<LineLogin.Input, LineLoginResult>() {
data class Input(
val channelId: String,
val params: LineAuthenticationParams,
val isBrowserLoginOnly: Boolean
)
override fun createIntent(context: Context, input: Input): Intent {
/**
* Modified from https://gist.github.com/fonix232/14294caea86c4161478f5263a41fc50b
* PR : https://github.com/bluelinelabs/Conductor/pull/565
*
* A Mediator that handles bottom nav and router's controller in their own stack
*
* @param host: Host Controller
* @param container Container View that the router will push controller to
* @param bottomNavigationView Bottom Navigation View to link with
* @param menuIdAndTransactionMap A map that MUST contains transaction linked to each menu id defined for [bottomNavigationView]'s menu resource
inline fun ImageView.loadWithDefault(
url: String?,
imageLoader: ImageLoader = Coil.loader(),
builder: LoadRequestBuilder.() -> Unit = {}
): RequestDisposable {
val loadRequestBuilder = LoadRequestBuilder(
this.context, LoadRequest(
this.context,
defaults = DefaultRequestOptions()
)
whenever(imageLoader.load(requestCaptor.capture())).thenAnswer {
//Set a black color drawable
requestCaptor.lastValue.target?.onSuccess(ColorDrawable(Color.BLACK))
object : RequestDisposable {
override fun isDisposed() = true
override fun dispose() {}
}
}
fakeMovieList.forEachIndexed { index, movie ->
//Scroll to position to force onBind
onView(withId(R.id.rvMovie)).perform(
RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(
index
)
)
if (imageLoader is FakeImageLoader) {
val fakeImageLoader = imageLoader as FakeImageLoader
runBlockingTest {
imageLoader = TestApplication.appComponent().imageLoader()
whenever(imageLoader.load(any()))
.thenReturn(object : RequestDisposable {
override fun isDisposed() = true
override fun dispose() {}
})
}
@Module(includes = [TestImageLoaderModule.Provider::class])
abstract class TestImageLoaderModule {
@Module
object Provider {
@Provides @JvmStatic @Singleton fun imageLoader(): ImageLoader {
return mock()
}
}
}
if (imageLoader is FakeImageLoader) {
val fakeImageLoader = imageLoader as FakeImageLoader
val requestSet = fakeImageLoader.requestSet
val request = requestSet.elementAt(index)
val url = request.data as String
Assert.assertEquals(movie.posterPath, url)
}
class FakeImageLoader : ImageLoader {
val requestSet = mutableSetOf<Request>()
override fun load(request: LoadRequest): RequestDisposable {
// Always call onStart before onSuccess.
requestSet.add(request)
request.target?.onStart(drawable)
request.target?.onSuccess(drawable)
return disposable