Trials | Time (ms) |
---|---|
1 | 447 |
2 | 413 |
3 | 404 |
4 | 438 |
5 | 473 |
6 | 444 |
7 | 442 |
8 | 422 |
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 lateinit var test: FeedViewTestCase | |
private val intent = FeedViewIntent() | |
@ParameterizedTest | |
@MethodSource("FeedViewTestCaseStream") | |
fun `FeedView`(feedViewTestCase: FeedViewTestCase) = testCoroutineDispatcher.runBlockingTest { | |
test = feedViewTestCase | |
mockComponents(test) | |
val viewModel = FeedViewModel(...) | |
viewModel.bindIntents(object : FeedView { |
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
@ExperimentalCoroutinesApi | |
class FeedViewTestExtension : BeforeEachCallback, AfterEachCallback, ParameterResolver { | |
override fun beforeEach(context: ExtensionContext?) { | |
// Set TestCoroutineDispatcher. | |
Dispatchers.setMain(context?.root | |
?.getStore(TEST_COROUTINE_DISPATCHER_NAMESPACE) | |
?.get(TEST_COROUTINE_DISPATCHER_KEY, TestCoroutineDispatcher::class.java)!!) | |
// Set LiveData Executor. | |
ArchTaskExecutor.getInstance().setDelegate(object : TaskExecutor() { |
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
@ExperimentalCoroutinesApi | |
@ExtendWith(FeedViewTestExtension::class) | |
class FeedViewTest( | |
val testCoroutineDispatcher: TestCoroutineDispatcher, | |
val testCoroutineScope: TestCoroutineScope | |
) { | |
private fun FeedViewTestCaseStream() = feedViewTestCaseStream() | |
private lateinit var test: FeedViewTestCase | |
private val repository = mockkClass(FeedRepository::class) |
Trials | Time (ms) |
---|---|
1 | 872 |
2 | 478 |
3 | 393 |
4 | 506 |
5 | 439 |
6 | 443 |
7 | 520 |
8 | 461 |
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
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/placeholder"> | |
<stroke | |
android:width="1dp" | |
android:color="@color/colorAccent"/> | |
<padding | |
android:bottom="2dp" | |
android:left="2dp" | |
android:right="2dp" |
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 MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val appBarConfiguration = AppBarConfiguration(setOf(R.id.nav_home, R.id.nav_screenTwo)) | |
val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment | |
val navController = navHostFragment.navController | |
setupActionBarWithNavController(navController, appBarConfiguration) | |
bottomNavigation.setupWithNavController(navController) | |
} |
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
<uses-feature android:name="android.hardware.camera" /> | |
<uses-permission android:name="android.permission.CAMERA" /> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
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
/** | |
* From Google's CameraXbasic sample app's MainActivity.kt and GalleryFragment.kt | |
* See: [https://github.com/android/camera-samples/tree/master/CameraXBasic#cameraxbasic] | |
*/ | |
val EXTENSION_WHITELIST = arrayOf("JPG") | |
/** Use external media if it is available, our app's file directory otherwise */ | |
fun getOutputDirectory(context: Context): File { | |
val appContext = context.applicationContext |
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
// Pass method | |
layoutName.setOnClickListener(onItemClicked); | |
private View.OnClickListener onItemClicked = view → // Do something; | |
// Or | |
private View.OnClickListener onItemClicked = | |
view → { | |
// Do something; | |
}; |