fix: compile on latest tools
@@ -1,14 +1,16 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.1'
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
||||
#Tue Apr 18 11:58:38 MSK 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.novoda:bintray-release:0.4.0'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'bintray-release'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '25.0.2'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 23
|
||||
versionCode 22
|
||||
versionName '2.7.1'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@@ -36,14 +33,25 @@ idea {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'org.slf4j:slf4j-android:1.7.21'
|
||||
implementation 'org.slf4j:slf4j-android:1.7.34'
|
||||
}
|
||||
|
||||
publish {
|
||||
userOrg = 'alexeydanilov'
|
||||
groupId = 'com.danikula'
|
||||
artifactId = 'videocache'
|
||||
publishVersion = android.defaultConfig.versionName
|
||||
description = 'Cache support for android VideoView'
|
||||
website = 'https://github.com/danikula/AndroidVideoCache'
|
||||
publishing {
|
||||
publications {
|
||||
myPulication(MavenPublication) {
|
||||
groupId 'com.danikula'
|
||||
version '2.7.1'
|
||||
artifactId 'videocache'
|
||||
artifact("$buildDir/outputs/aar/library-release.aar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//publish {
|
||||
// userOrg = 'alexeydanilov'
|
||||
// groupId = 'com.danikula'
|
||||
// artifactId = 'videocache'
|
||||
// publishVersion = android.defaultConfig.versionName
|
||||
// description = 'Cache support for android VideoView'
|
||||
// website = 'https://github.com/danikula/AndroidVideoCache'
|
||||
//}
|
||||
|
||||
@@ -7,7 +7,7 @@ package com.danikula.videocache;
|
||||
*/
|
||||
public class ProxyCacheException extends Exception {
|
||||
|
||||
private static final String LIBRARY_VERSION = ". Version: " + BuildConfig.VERSION_NAME;
|
||||
private static final String LIBRARY_VERSION = ". Version: 2.7.1";
|
||||
|
||||
public ProxyCacheException(String message) {
|
||||
super(message + LIBRARY_VERSION);
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url 'https://github.com/dahlgren/vpi-aar/raw/master' }
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.neenbedankt.android-apt'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '25.0.2'
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'com.danikula.videocache.sample'
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 23
|
||||
versionCode 1
|
||||
versionName '1.0'
|
||||
}
|
||||
}
|
||||
|
||||
apt {
|
||||
arguments {
|
||||
androidManifestFile variant.outputs[0].processResources.manifestFile
|
||||
resourcePackageName android.defaultConfig.applicationId
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// compile project(':library')
|
||||
compile 'com.android.support:support-v4:23.1.0'
|
||||
compile 'org.androidannotations:androidannotations-api:3.3.2'
|
||||
compile 'com.danikula:videocache:2.7.1'
|
||||
compile 'com.viewpagerindicator:library:2.4.2-SNAPSHOT@aar'
|
||||
apt 'org.androidannotations:androidannotations:3.3.2'
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest
|
||||
package="com.danikula.videocache.sample"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.Holo.Light.NoActionBar">
|
||||
<activity
|
||||
android:name=".MenuActivity_"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".SingleVideoActivity_" />
|
||||
<activity android:name=".MultipleVideosActivity_" />
|
||||
<activity android:name=".VideoGalleryActivity_" />
|
||||
<activity android:name=".SharedCacheActivity_" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.danikula.videocache.HttpProxyCacheServer;
|
||||
|
||||
/**
|
||||
* @author Alexey Danilov (danikula@gmail.com).
|
||||
*/
|
||||
public class App extends Application {
|
||||
|
||||
private HttpProxyCacheServer proxy;
|
||||
|
||||
public static HttpProxyCacheServer getProxy(Context context) {
|
||||
App app = (App) context.getApplicationContext();
|
||||
return app.proxy == null ? (app.proxy = app.newProxy()) : app.proxy;
|
||||
}
|
||||
|
||||
private HttpProxyCacheServer newProxy() {
|
||||
return new HttpProxyCacheServer.Builder(this)
|
||||
.cacheDirectory(Utils.getVideoCacheDir(this))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.danikula.videocache.CacheListener;
|
||||
import com.danikula.videocache.HttpProxyCacheServer;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.EFragment;
|
||||
import org.androidannotations.annotations.FragmentArg;
|
||||
import org.androidannotations.annotations.InstanceState;
|
||||
import org.androidannotations.annotations.SeekBarTouchStop;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@EFragment(R.layout.fragment_video)
|
||||
public class GalleryVideoFragment extends Fragment implements CacheListener {
|
||||
|
||||
@FragmentArg String url;
|
||||
|
||||
@InstanceState int position;
|
||||
@InstanceState boolean playerStarted;
|
||||
|
||||
@ViewById VideoView videoView;
|
||||
@ViewById ProgressBar progressBar;
|
||||
|
||||
private boolean visibleForUser;
|
||||
|
||||
private final VideoProgressUpdater updater = new VideoProgressUpdater();
|
||||
|
||||
public static Fragment build(String url) {
|
||||
return GalleryVideoFragment_.builder()
|
||||
.url(url)
|
||||
.build();
|
||||
}
|
||||
|
||||
@AfterViews
|
||||
void afterViewInjected() {
|
||||
startProxy();
|
||||
|
||||
if (visibleForUser) {
|
||||
startPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
private void startPlayer() {
|
||||
videoView.seekTo(position);
|
||||
videoView.start();
|
||||
playerStarted = true;
|
||||
}
|
||||
|
||||
private void startProxy() {
|
||||
HttpProxyCacheServer proxy = App.getProxy(getActivity());
|
||||
proxy.registerCacheListener(this, url);
|
||||
videoView.setVideoPath(proxy.getProxyUrl(url));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
|
||||
visibleForUser = isVisibleToUser;
|
||||
if (videoView != null) {
|
||||
if (visibleForUser) {
|
||||
startPlayer();
|
||||
} else if (playerStarted) {
|
||||
position = videoView.getCurrentPosition();
|
||||
videoView.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updater.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
updater.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
videoView.stopPlayback();
|
||||
App.getProxy(getActivity()).unregisterCacheListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCacheAvailable(File file, String url, int percentsAvailable) {
|
||||
progressBar.setSecondaryProgress(percentsAvailable);
|
||||
}
|
||||
|
||||
private void updateVideoProgress() {
|
||||
int videoProgress = videoView.getCurrentPosition() * 100 / videoView.getDuration();
|
||||
progressBar.setProgress(videoProgress);
|
||||
}
|
||||
|
||||
@SeekBarTouchStop(R.id.progressBar)
|
||||
void seekVideo() {
|
||||
int videoPosition = videoView.getDuration() * progressBar.getProgress() / 100;
|
||||
videoView.seekTo(videoPosition);
|
||||
}
|
||||
|
||||
private final class VideoProgressUpdater extends Handler {
|
||||
|
||||
public void start() {
|
||||
sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
removeMessages(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
updateVideoProgress();
|
||||
sendEmptyMessageDelayed(0, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.Click;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ItemClick;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@EActivity(R.layout.activity_menu)
|
||||
public class MenuActivity extends FragmentActivity {
|
||||
|
||||
@ViewById ListView listView;
|
||||
|
||||
@AfterViews
|
||||
void onViewInjected() {
|
||||
ListAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, buildListData());
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private List<ListEntry> buildListData() {
|
||||
return Arrays.asList(
|
||||
new ListEntry("Single Video", SingleVideoActivity_.class),
|
||||
new ListEntry("Multiple Videos", MultipleVideosActivity_.class),
|
||||
new ListEntry("Video Gallery with pre-caching", VideoGalleryActivity_.class),
|
||||
new ListEntry("Shared Cache", SharedCacheActivity_.class)
|
||||
);
|
||||
}
|
||||
|
||||
@ItemClick(R.id.listView)
|
||||
void onListItemClicked(int position) {
|
||||
ListEntry item = (ListEntry) listView.getAdapter().getItem(position);
|
||||
startActivity(new Intent(this, item.activityClass));
|
||||
}
|
||||
|
||||
@Click(R.id.cleanCacheButton)
|
||||
void onClearCacheButtonClick() {
|
||||
try {
|
||||
|
||||
Utils.cleanVideoCacheDir(this);
|
||||
} catch (IOException e) {
|
||||
Log.e(null, "Error cleaning cache", e);
|
||||
Toast.makeText(this, "Error cleaning cache", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ListEntry {
|
||||
|
||||
private final String title;
|
||||
private final Class activityClass;
|
||||
|
||||
public ListEntry(String title, Class activityClass) {
|
||||
this.title = title;
|
||||
this.activityClass = activityClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
|
||||
@EActivity(R.layout.activity_multiple_videos)
|
||||
public class MultipleVideosActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
if (state == null) {
|
||||
addVideoFragment(Video.ORANGE_1, R.id.videoContainer0);
|
||||
addVideoFragment(Video.ORANGE_2, R.id.videoContainer1);
|
||||
addVideoFragment(Video.ORANGE_3, R.id.videoContainer2);
|
||||
addVideoFragment(Video.ORANGE_4, R.id.videoContainer3);
|
||||
}
|
||||
}
|
||||
|
||||
private void addVideoFragment(Video video, int containerViewId) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(containerViewId, VideoFragment.build(video.url))
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
|
||||
@EActivity(R.layout.activity_multiple_videos)
|
||||
public class SharedCacheActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
if (state == null) {
|
||||
addVideoFragment(Video.ORANGE_1, R.id.videoContainer0);
|
||||
addVideoFragment(Video.ORANGE_1, R.id.videoContainer1);
|
||||
addVideoFragment(Video.ORANGE_1, R.id.videoContainer2);
|
||||
addVideoFragment(Video.ORANGE_1, R.id.videoContainer3);
|
||||
}
|
||||
}
|
||||
|
||||
private void addVideoFragment(Video video, int containerViewId) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(containerViewId, VideoFragment.build(video.url))
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
|
||||
@EActivity(R.layout.activity_single_video)
|
||||
public class SingleVideoActivity extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
if (state == null) {
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.containerView, VideoFragment.build(Video.ORANGE_1.url))
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Some utils methods.
|
||||
*
|
||||
* @author Alexey Danilov (danikula@gmail.com).
|
||||
*/
|
||||
public class Utils {
|
||||
|
||||
public static File getVideoCacheDir(Context context) {
|
||||
return new File(context.getExternalCacheDir(), "video-cache");
|
||||
}
|
||||
|
||||
public static void cleanVideoCacheDir(Context context) throws IOException {
|
||||
File videoCacheDir = getVideoCacheDir(context);
|
||||
cleanDirectory(videoCacheDir);
|
||||
}
|
||||
|
||||
private static void cleanDirectory(File file) throws IOException {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
File[] contentFiles = file.listFiles();
|
||||
if (contentFiles != null) {
|
||||
for (File contentFile : contentFiles) {
|
||||
delete(contentFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void delete(File file) throws IOException {
|
||||
if (file.isFile() && file.exists()) {
|
||||
deleteOrThrow(file);
|
||||
} else {
|
||||
cleanDirectory(file);
|
||||
deleteOrThrow(file);
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteOrThrow(File file) throws IOException {
|
||||
if (file.exists()) {
|
||||
boolean isDeleted = file.delete();
|
||||
if (!isDeleted) {
|
||||
throw new IOException(String.format("File %s can't be deleted", file.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
public enum Video {
|
||||
|
||||
ORANGE_1(Config.ROOT + "orange1.mp4"),
|
||||
ORANGE_2(Config.ROOT + "orange2.mp4"),
|
||||
ORANGE_3(Config.ROOT + "orange3.mp4"),
|
||||
ORANGE_4(Config.ROOT + "orange4.mp4"),
|
||||
ORANGE_5(Config.ROOT + "orange5.mp4");
|
||||
|
||||
public final String url;
|
||||
|
||||
Video(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
private class Config {
|
||||
private static final String ROOT = "https://raw.githubusercontent.com/danikula/AndroidVideoCache/master/files/";
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.danikula.videocache.CacheListener;
|
||||
import com.danikula.videocache.HttpProxyCacheServer;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.EFragment;
|
||||
import org.androidannotations.annotations.FragmentArg;
|
||||
import org.androidannotations.annotations.SeekBarTouchStop;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@EFragment(R.layout.fragment_video)
|
||||
public class VideoFragment extends Fragment implements CacheListener {
|
||||
|
||||
private static final String LOG_TAG = "VideoFragment";
|
||||
|
||||
@FragmentArg String url;
|
||||
|
||||
@ViewById ImageView cacheStatusImageView;
|
||||
@ViewById VideoView videoView;
|
||||
@ViewById ProgressBar progressBar;
|
||||
|
||||
private final VideoProgressUpdater updater = new VideoProgressUpdater();
|
||||
|
||||
public static Fragment build(String url) {
|
||||
return VideoFragment_.builder()
|
||||
.url(url)
|
||||
.build();
|
||||
}
|
||||
|
||||
@AfterViews
|
||||
void afterViewInjected() {
|
||||
checkCachedState();
|
||||
startVideo();
|
||||
}
|
||||
|
||||
private void checkCachedState() {
|
||||
HttpProxyCacheServer proxy = App.getProxy(getActivity());
|
||||
boolean fullyCached = proxy.isCached(url);
|
||||
setCachedState(fullyCached);
|
||||
if (fullyCached) {
|
||||
progressBar.setSecondaryProgress(100);
|
||||
}
|
||||
}
|
||||
|
||||
private void startVideo() {
|
||||
HttpProxyCacheServer proxy = App.getProxy(getActivity());
|
||||
proxy.registerCacheListener(this, url);
|
||||
String proxyUrl = proxy.getProxyUrl(url);
|
||||
Log.d(LOG_TAG, "Use proxy url " + proxyUrl + " instead of original url " + url);
|
||||
videoView.setVideoPath(proxyUrl);
|
||||
videoView.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updater.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
updater.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
videoView.stopPlayback();
|
||||
App.getProxy(getActivity()).unregisterCacheListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCacheAvailable(File file, String url, int percentsAvailable) {
|
||||
progressBar.setSecondaryProgress(percentsAvailable);
|
||||
setCachedState(percentsAvailable == 100);
|
||||
Log.d(LOG_TAG, String.format("onCacheAvailable. percents: %d, file: %s, url: %s", percentsAvailable, file, url));
|
||||
}
|
||||
|
||||
private void updateVideoProgress() {
|
||||
int videoProgress = videoView.getCurrentPosition() * 100 / videoView.getDuration();
|
||||
progressBar.setProgress(videoProgress);
|
||||
}
|
||||
|
||||
@SeekBarTouchStop(R.id.progressBar)
|
||||
void seekVideo() {
|
||||
int videoPosition = videoView.getDuration() * progressBar.getProgress() / 100;
|
||||
videoView.seekTo(videoPosition);
|
||||
}
|
||||
|
||||
private void setCachedState(boolean cached) {
|
||||
int statusIconId = cached ? R.drawable.ic_cloud_done : R.drawable.ic_cloud_download;
|
||||
cacheStatusImageView.setImageResource(statusIconId);
|
||||
}
|
||||
|
||||
private final class VideoProgressUpdater extends Handler {
|
||||
|
||||
public void start() {
|
||||
sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
removeMessages(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
updateVideoProgress();
|
||||
sendEmptyMessageDelayed(0, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.danikula.videocache.sample;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
|
||||
import com.viewpagerindicator.CirclePageIndicator;
|
||||
|
||||
import org.androidannotations.annotations.AfterViews;
|
||||
import org.androidannotations.annotations.EActivity;
|
||||
import org.androidannotations.annotations.ViewById;
|
||||
|
||||
@EActivity(R.layout.activity_video_gallery)
|
||||
public class VideoGalleryActivity extends FragmentActivity {
|
||||
|
||||
@ViewById ViewPager viewPager;
|
||||
@ViewById CirclePageIndicator viewPagerIndicator;
|
||||
|
||||
@AfterViews
|
||||
void afterViewInjected() {
|
||||
ViewsPagerAdapter viewsPagerAdapter = new ViewsPagerAdapter(this);
|
||||
viewPager.setAdapter(viewsPagerAdapter);
|
||||
viewPagerIndicator.setViewPager(viewPager);
|
||||
}
|
||||
|
||||
private static final class ViewsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
public ViewsPagerAdapter(FragmentActivity activity) {
|
||||
super(activity.getSupportFragmentManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
Video video = Video.values()[position];
|
||||
return GalleryVideoFragment.build(video.url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return Video.values().length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
return Video.values()[position].name();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 353 B |
|
Before Width: | Height: | Size: 265 B |
|
Before Width: | Height: | Size: 242 B |
|
Before Width: | Height: | Size: 449 B |
|
Before Width: | Height: | Size: 417 B |
|
Before Width: | Height: | Size: 672 B |
|
Before Width: | Height: | Size: 610 B |
|
Before Width: | Height: | Size: 855 B |
|
Before Width: | Height: | Size: 789 B |
@@ -1,23 +0,0 @@
|
||||
<LinearLayout
|
||||
android:id="@+id/containerView"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@android:drawable/divider_horizontal_dark"
|
||||
android:orientation="vertical"
|
||||
android:showDividers="middle"
|
||||
tools:context=".MenuActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cleanCacheButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Clean cache" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/listView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,58 +0,0 @@
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#CCC"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/videoContainer0"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_weight="1"
|
||||
android:background="#FFF" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/videoContainer1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_weight="1"
|
||||
android:background="#FFF" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/videoContainer2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_weight="1"
|
||||
android:background="#FFF" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/videoContainer3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_weight="1"
|
||||
android:background="#FFF" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,7 +0,0 @@
|
||||
<FrameLayout
|
||||
android:id="@+id/containerView"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".VideoActivity" />
|
||||
@@ -1,23 +0,0 @@
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<com.viewpagerindicator.CirclePageIndicator
|
||||
android:id="@+id/viewPagerIndicator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
app:fillColor="#800F"
|
||||
app:radius="10dp"
|
||||
app:strokeColor="#800F" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,30 +0,0 @@
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".VideoActivity">
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/videoView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cacheStatusImageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:src="@drawable/ic_cloud_download" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/progressBar"
|
||||
style="@android:style/Widget.Holo.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_margin="16dp"
|
||||
android:max="100" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
Before Width: | Height: | Size: 7.5 KiB |
@@ -1,3 +0,0 @@
|
||||
<resources>
|
||||
<string name="app_name">VideoCacheSample</string>
|
||||
</resources>
|
||||
@@ -1 +1 @@
|
||||
include ':sample', ':library', ':test'
|
||||
include ':library', ':test'
|
||||
|
||||
@@ -6,7 +6,6 @@ apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion '25.0.2'
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'com.danikula.proxycache.test'
|
||||
@@ -58,14 +57,14 @@ tasks.withType(Test) {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':library')
|
||||
testCompile 'org.slf4j:slf4j-simple:1.7.21'
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.robolectric:robolectric:3.3.2'
|
||||
testCompile 'com.squareup:fest-android:1.0.0'
|
||||
testCompile 'com.google.guava:guava-jdk5:17.0'
|
||||
testCompile('com.danikula:android-garden:2.1.4') {
|
||||
implementation project(':library')
|
||||
testImplementation 'org.slf4j:slf4j-simple:1.7.21'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.robolectric:robolectric:3.3.2'
|
||||
testImplementation 'com.squareup:fest-android:1.0.0'
|
||||
testImplementation 'com.google.guava:guava-jdk5:17.0'
|
||||
testImplementation('com.danikula:android-garden:2.1.4') {
|
||||
exclude group: 'com.google.android'
|
||||
}
|
||||
testCompile 'org.mockito:mockito-all:1.9.5'
|
||||
testImplementation 'org.mockito:mockito-all:1.9.5'
|
||||
}
|
||||
|
||||