Skip to content

Instantly share code, notes, and snippets.

View k0siara's full-sized avatar
🧐
Investigating a bug

Patryk Kosieradzki k0siara

🧐
Investigating a bug
View GitHub Profile
android {
// The rest of you build.gradle
adbOptions {
installOptions '-g', '-r'
}
}
private const val TAG = "ScreenshotsUtils"
fun takeScreenshot(screenShotName: String) {
Log.d(TAG, "Taking screenshot of '$screenShotName'")
val screenCapture = Screenshot.capture()
try {
screenCapture.apply {
name = screenShotName
process()
}
class MyScreenCaptureProcessor : BasicScreenCaptureProcessor() {
init {
this.mDefaultScreenshotPath = File(
File(
getExternalStoragePublicDirectory(DIRECTORY_PICTURES),
"${BuildConfig.APPLICATION_ID}/${BuildConfig.BUILD_TYPE}"
).absolutePath,
SCREENSHOTS_FOLDER_NAME
)
private const val TAG = "ScreenshotsUtils"
fun takeScreenshot(screenShotName: String) {
Log.d(TAG, "Taking screenshot of '$screenShotName'")
val screenCapture = Screenshot.capture()
val processors = setOf(MyScreenCaptureProcessor())
try {
screenCapture.apply {
name = screenShotName
process(processors)
android {
testOptions {
...
animationsDisabled = true
}
}
android {
defaultConfig {
...
testInstrumentationRunnerArguments clearPackageData: 'true'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
testOptions {
execution 'ANDROID_TEST_ORCHESTRATOR'
}
def appId = "com.patrykkosieradzki.moviebox"
android {
...
defaultConfig {
...
applicationId appId
}
}
@k0siara
k0siara / OnCreateViewHolder.kt
Created May 30, 2021 23:12
OnCreateViewHolder.kt
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
// return new ViewHolder reference here based on the viewType
}
@k0siara
k0siara / OnBindViewHolder.kt
Created May 30, 2021 23:12
OnBindViewHolder.kt
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if (holder is CustomViewHolder) {
// bind data to the views of CustomViewHolder
}
...
}
@k0siara
k0siara / GetItemCount.kt
Created May 30, 2021 23:13
GetItemCount.kt
@Override
public int getItemCount() {
if (dataset == null)
return 0;
return dataset.size();
}