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
adb shell cmd package compile -m speed-profile -f <package name> | |
adb shell am force-stop <package name> | |
# Download record_android_trace following the instructions here: | |
# https://perfetto.dev/docs/quickstart/android-tracing#recording-a-trace-through-the-cmdline | |
~/android-scripts/traces/record_android_trace -c /path/to/default_perfetto_config.textproto |
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
public void two_truths_and_a_lie() { | |
assertThat(benjamin.lovesRoadTrips()).isTrue() | |
assertThat(benjamin.lovesSkiing()).isTrue() | |
assertThat(benjamin.lovesPizza()).isTrue() | |
} |
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
# Copyright 2020 Google LLC. | |
# SPDX-License-Identifier: Apache-2.0 | |
function talkback() { | |
if [[ -z $1 ]]; then | |
echo "Usage: $0 [on/off]" | |
exit | |
fi | |
if [[ $1 == 'on' ]]; then |
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
# This is for ATV only | |
alias adb-dev-options='adb shell am start -n com.android.tv.settings/.system.development.DevelopmentActivity' | |
# For mobile use: | |
#alias adb-dev-options='adb shell am start -n com.android.settings/.DevelopmentSettings' | |
# Animations | |
alias animations-off='adb shell settings put global animator_duration_scale 0' | |
alias animations-slow='adb shell settings put global animator_duration_scale 10' | |
alias animations-normal='adb shell settings put global animator_duration_scale 1' | |
alias animations-fast='adb shell settings put global animator_duration_scale 0.5' |
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
public void setItems(final List itemList, final DiffCallback callback) { | |
if (callback == null) { | |
// shortcut when DiffCallback is not provided | |
mItems.clear(); | |
mItems.addAll(itemList); | |
notifyChanged(); | |
return; | |
} | |
//... | |
} |
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 diffCallback = object : DiffCallback<DummyItem>() { | |
override fun areItemsTheSame(oldItem: DummyItem, newItem: DummyItem): Boolean = | |
oldItem.id == newItem.id | |
override fun areContentsTheSame(oldItem: DummyItem, newItem: DummyItem): Boolean = | |
oldItem == newItem | |
} | |
itemsAdapter.setItems(randomItems(), diffCallback) |
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
public abstract class DiffCallback<Value> { | |
public abstract boolean areItemsTheSame(@NonNull Value oldItem, | |
@NonNull Value newItem); | |
public abstract boolean areContentsTheSame(@NonNull Value oldItem, | |
@NonNull Value newItem); | |
@SuppressWarnings("WeakerAccess") | |
public Object getChangePayload(@NonNull Value oldItem, @NonNull Value newItem) { |
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
/* | |
* Copyright (C) 2017 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | |
* in compliance with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software distributed under the License | |
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
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
@Override | |
public void reset() { | |
for (int i = 0; i < mTasks.size(); i++) { | |
LoadBitmapAsyncTask task = mTasks.get(i); | |
task.cancel(true); | |
} | |
mTasks.clear(); | |
} |
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
@Override | |
public void getThumbnail(int index, ResultCallback callback) { | |
LoadBitmapAsyncTask task = mTasks.get(index); | |
if (task == null) { | |
task = new LoadBitmapAsyncTask(index, callback); | |
mTasks.put(index, task); | |
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); | |
} | |
} |
NewerOlder