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
cd ~/Library/Android/sdk/platform-tools/ | |
# Get the hash of the mitmproxy-ca certificate. | |
openssl x509 -inform PEM -subject_hash_old -in ~/.mitmproxy/mitmproxy-ca.pem | head -1 | |
# We will use this hash value, append '.0' (dot zero) and use this as the filename for the resulting Android certificate | |
cat ~/.mitmproxy/mitmproxy-ca.pem > c8750f0d.0 | |
openssl x509 -inform PEM -text -in ~/.mitmproxy/mitmproxy-ca.pem -out /dev/null >> c8750f0d.0 | |
# In an other terminal, we will start the emulator with writable /system volume |
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 MainActivity: AppCompatActivity(), Navigable |
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 EditText.afterTextChanged(afterTextChanged: (String) -> Unit) { | |
this.addTextChangedListener(object : TextWatcher { | |
override fun beforeTextChanged(p0: CharSequence, p1: Int, p2: Int, p3: Int) { | |
} | |
override fun onTextChanged(p0: CharSequence, p1: Int, p2: Int, p3: Int) { | |
} | |
override fun afterTextChanged(editable: Editable) { | |
afterTextChanged.invoke(editable.toString()) |
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 AppCompatActivity.configureSlideFromBottomEnterTransition() { | |
val decor = window.decorView | |
val actionBarId = R.id.action_bar_container | |
val transitionSet = TransitionSet() | |
val fadeActionBarAnimation = Fade().apply { duration = 100 } | |
fadeActionBarAnimation.addTarget(decor.findViewById(actionBarId) as? View) | |
transitionSet.addTransition(fadeActionBarAnimation) |
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 UserUnitTest : BaseTest() { | |
... | |
// TESTS | |
@Test | |
fun getUser_whenSuccess() { | |
// Prepare data | |
this.mockHttpResponse("getUser_whenSuccess.json", HttpURLConnection.HTTP_OK) | |
// Pre-test |
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
@RunWith(AndroidJUnit4::class) | |
@LargeTest | |
class SearchUserFragmentTest: BaseIT() { | |
@Rule | |
@JvmField | |
val activityRule = ActivityTestRule(MainActivity::class.java, true, false) | |
@get:Rule | |
var executorRule = CountingTaskExecutorRule() |
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 UserRepositoryTest: BaseUT() { | |
// FOR DATA --- | |
private val userRepository by inject<UserRepository>() | |
// OVERRIDE --- | |
override fun isMockServerEnabled() = true | |
override fun setUp() { | |
super.setUp() |
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
val viewModelModule = module { | |
viewModel { SearchUserViewModel(get(), get()) } | |
} |
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
val networkModule = module { | |
factory<Interceptor> { | |
HttpLoggingInterceptor(HttpLoggingInterceptor.Logger { Log.d("API", it) }) | |
.setLevel(HttpLoggingInterceptor.Level.HEADERS) | |
} | |
factory { OkHttpClient.Builder().addInterceptor(get()).build() } | |
single { |
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 UserDataSourceFactory(private val repository: UserRepository, | |
private var query: String = "", | |
private var sort: String = "", | |
private val scope: CoroutineScope): DataSource.Factory<Int, User>() { | |
val source = MutableLiveData<UserDataSource>() | |
override fun create(): DataSource<Int, User> { | |
val source = UserDataSource(repository, query, sort, scope) | |
this.source.postValue(source) |
NewerOlder