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 class PlaybackSeekMetadataDataProvider extends PlaybackSeekDataProvider { | |
//… | |
public PlaybackSeekMetadataDataProvider(Context context, | |
String videoUrl, | |
long interval) { | |
mContext = context; | |
mVideoUrl = videoUrl; | |
MediaMetadataRetriever retriever = new MediaMetadataRetriever(); | |
retriever.setDataSource(mVideoUrl, new HashMap<>()); |
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, final ResultCallback callback) { | |
// Step 1. Get position from the index. | |
long position = getSeekPositions()[index]; | |
// Step 2. Retrieve thumbnail in the background to not block the UI thread. | |
retrieveThumbnailForPosition(position, index, (bitmap) -> { | |
// Step 3. Return the thumbnail to be presented in the UI. | |
callback.onThumbnailLoaded(bitmap, index); | |
}); |
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 = new LoadBitmapAsyncTask(index, callback); | |
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); | |
} | |
class LoadBitmapAsyncTask extends AsyncTask<Void, Void, Bitmap> { | |
final int mIndex; | |
final ResultCallback mResultCallback; |
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); | |
} | |
} |
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
/* | |
* 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
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
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 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
# 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' |
OlderNewer