Skip to content

Instantly share code, notes, and snippets.

Avatar
🐘
.

Patryk Kosieradzki k0siara

🐘
.
View GitHub Profile
View ScreenshotUtils.kt
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()
}
View build.gradle
android {
// The rest of you build.gradle
adbOptions {
installOptions '-g', '-r'
}
}
View MyScreenCaptureProcessor.kt
class MyScreenCaptureProcessor : BasicScreenCaptureProcessor() {
init {
this.mDefaultScreenshotPath = File(
File(
getExternalStoragePublicDirectory(DIRECTORY_PICTURES),
"${BuildConfig.APPLICATION_ID}/${BuildConfig.BUILD_TYPE}"
).absolutePath,
SCREENSHOTS_FOLDER_NAME
)
View ScreenshotUtils.kt
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)
View build.gradle
android {
defaultConfig {
...
testInstrumentationRunnerArguments clearPackageData: 'true'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
testOptions {
execution 'ANDROID_TEST_ORCHESTRATOR'
}
View build.gradle
android {
testOptions {
...
animationsDisabled = true
}
}
View build.gradle
def appId = "com.patrykkosieradzki.moviebox"
android {
...
defaultConfig {
...
applicationId appId
}
}
@k0siara
k0siara / OnCreateViewHolder.kt
Created May 30, 2021
OnCreateViewHolder.kt
View OnCreateViewHolder.kt
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
// return new ViewHolder reference here based on the viewType
}
View OnBindViewHolder.kt
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if (holder is CustomViewHolder) {
// bind data to the views of CustomViewHolder
}
...
}
View GetItemCount.kt
@Override
public int getItemCount() {
if (dataset == null)
return 0;
return dataset.size();
}