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
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
@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
abstract class BaseViewModel: ViewModel() { | |
/** | |
* This is a scope for all coroutines launched by [BaseViewModel] | |
* that will be dispatched in a Pool of Thread | |
*/ | |
protected val ioScope = CoroutineScope(Dispatchers.Default) | |
/** | |
* Cancel all coroutines when the ViewModel is cleared |
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 SearchUserViewModel(repository: UserRepository, | |
private val sharedPrefsManager: SharedPrefsManager): BaseViewModel() { | |
// FOR DATA --- | |
private val userDataSource = UserDataSourceFactory(repository = repository, scope = ioScope) | |
// OBSERVABLES --- | |
val users = LivePagedListBuilder(userDataSource, pagedListConfig()).build() | |
// PUBLIC API --- |
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) |
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 UserDataSource(private val repository: UserRepository, | |
private val query: String, | |
private val sort: String, | |
private val scope: CoroutineScope): PageKeyedDataSource<Int, User>() { | |
// FOR DATA --- | |
private var supervisorJob = SupervisorJob() | |
//... | |
// OVERRIDE --- |
NewerOlder