Initial commit
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/libraries
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
11
WebcamViewer.iml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.id="WebcamViewer" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/build
|
109
app/app.iml
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="WebcamViewer" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="android-gradle" name="Android-Gradle">
|
||||||
|
<configuration>
|
||||||
|
<option name="GRADLE_PROJECT_PATH" value=":app" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
<facet type="android" name="Android">
|
||||||
|
<configuration>
|
||||||
|
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||||
|
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
|
||||||
|
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||||
|
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||||
|
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
|
||||||
|
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
|
||||||
|
<afterSyncTasks>
|
||||||
|
<task>generateDebugAndroidTestSources</task>
|
||||||
|
<task>generateDebugSources</task>
|
||||||
|
</afterSyncTasks>
|
||||||
|
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||||
|
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||||
|
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
||||||
|
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
|
||||||
|
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
|
||||||
|
<output url="file://$MODULE_DIR$/build/retrolambda/debug" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/build/retrolambda/debugAndroidTest" />
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.1/jars" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.bignerdranch.android/expandablerecyclerview/2.0.4/jars" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.zhanghai.android.materialprogressbar/library/1.1.4/jars" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/retrolambda" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="okio-1.6.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="stream-1.0.6" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="library-1.1.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="okhttp-3.1.2" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="expandablerecyclerview-2.0.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="design-23.1.1" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
51
app/build.gradle
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||||
|
classpath 'me.tatarka:gradle-retrolambda:3.2.4'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'me.tatarka.retrolambda'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 23
|
||||||
|
buildToolsVersion "23.0.2"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.annimon.webcamviewer"
|
||||||
|
minSdkVersion 14
|
||||||
|
targetSdkVersion 23
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled true
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||||
|
compile 'com.android.support:support-v4:23.1.1'
|
||||||
|
compile 'com.android.support:recyclerview-v7:23.1.1'
|
||||||
|
compile 'com.android.support:design:23.1.1'
|
||||||
|
compile 'com.bignerdranch.android:expandablerecyclerview:2.0.4'
|
||||||
|
compile 'com.annimon:stream:1.0.6'
|
||||||
|
compile 'com.squareup.okhttp3:okhttp:3.1.2'
|
||||||
|
compile 'me.zhanghai.android.materialprogressbar:library:1.1.4'
|
||||||
|
}
|
18
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# By default, the flags in this file are appended to flags specified
|
||||||
|
# in D:/Android/android-sdk/tools/proguard/proguard-android.txt
|
||||||
|
# You can edit the include path and order by changing the proguardFiles
|
||||||
|
# directive in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# Add any project specific keep options here:
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
-dontwarn java.lang.invoke.*
|
25
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.annimon.webcamviewer" >
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/AppTheme" >
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:label="@string/app_name" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handling exceptions.
|
||||||
|
*
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class ExceptionHandler {
|
||||||
|
|
||||||
|
private static final boolean DEBUG = true;
|
||||||
|
private static final String TAG = "webcamviewer";
|
||||||
|
|
||||||
|
public static void log(String message) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void log(String message, Throwable ex) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.e(TAG, message, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void log(Exception ex) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.e(TAG, getErrorMessage(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getErrorMessage(Exception ex) {
|
||||||
|
return ex.getMessage();
|
||||||
|
}
|
||||||
|
}
|
77
app/src/main/java/com/annimon/webcamviewer/MainActivity.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.Snackbar;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity implements NavigationDrawerCallbacks {
|
||||||
|
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
private View mRootView;
|
||||||
|
private NavigationDrawerFragment mNavigationDrawerFragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
|
||||||
|
setSupportActionBar(mToolbar);
|
||||||
|
|
||||||
|
mRootView = findViewById(R.id.root);
|
||||||
|
|
||||||
|
mNavigationDrawerFragment = (NavigationDrawerFragment)
|
||||||
|
getSupportFragmentManager().findFragmentById(R.id.fragment_drawer);
|
||||||
|
new WebcamListLoader(this, mNavigationDrawerFragment).execute(WebcamListLoader.NORMAL);
|
||||||
|
mNavigationDrawerFragment.setup(R.id.fragment_drawer, (DrawerLayout) findViewById(R.id.drawer), mToolbar);
|
||||||
|
mNavigationDrawerFragment.configureNavHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNavigationDrawerItemSelected(int position, Webcam webcam) {
|
||||||
|
Snackbar.make(mRootView, "Menu item selected -> " + position + "\n" + webcam, Snackbar.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
getSupportFragmentManager()
|
||||||
|
.beginTransaction()
|
||||||
|
.replace(R.id.container, WebcamViewerFragment.newInstance(webcam))
|
||||||
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||||
|
.commit();
|
||||||
|
mNavigationDrawerFragment.closeDrawer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (mNavigationDrawerFragment.isDrawerOpen()) {
|
||||||
|
mNavigationDrawerFragment.closeDrawer();
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
if (!mNavigationDrawerFragment.isDrawerOpen()) {
|
||||||
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_settings:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
public interface NavigationDrawerCallbacks {
|
||||||
|
void onNavigationDrawerItemSelected(int position, Webcam webcam);
|
||||||
|
}
|
@ -0,0 +1,231 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapShader;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.ColorFilter;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PixelFormat;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.Shader;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.app.ActionBarDrawerToggle;
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fragment used for managing interactions for and presentation of a navigation drawer.
|
||||||
|
* See the <a href="https://developer.android.com/design/patterns/navigation-drawer.html#Interaction">
|
||||||
|
* design guidelines</a> for a complete explanation of the behaviors implemented here.
|
||||||
|
*/
|
||||||
|
public class NavigationDrawerFragment extends Fragment implements NavigationDrawerCallbacks {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remember the position of the selected item.
|
||||||
|
*/
|
||||||
|
private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per the design guidelines, you should show the drawer on launch until the user manually
|
||||||
|
* expands it. This shared preference tracks this.
|
||||||
|
*/
|
||||||
|
private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pointer to the current callbacks instance (the Activity).
|
||||||
|
*/
|
||||||
|
private NavigationDrawerCallbacks mCallbacks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper component that ties the action bar to the navigation drawer.
|
||||||
|
*/
|
||||||
|
private ActionBarDrawerToggle mActionBarDrawerToggle;
|
||||||
|
|
||||||
|
private DrawerLayout mDrawerLayout;
|
||||||
|
private RecyclerView mDrawerList;
|
||||||
|
private View mFragmentContainerView;
|
||||||
|
|
||||||
|
private int mCurrentSelectedPosition = 0;
|
||||||
|
private boolean mFromSavedInstanceState;
|
||||||
|
private boolean mUserLearnedDrawer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Read in the flag indicating whether or not the user has demonstrated awareness of the
|
||||||
|
// drawer. See PREF_USER_LEARNED_DRAWER for details.
|
||||||
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
|
||||||
|
mFromSavedInstanceState = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
|
||||||
|
mDrawerList = (RecyclerView) view.findViewById(R.id.drawerList);
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
|
||||||
|
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||||
|
mDrawerList.setLayoutManager(layoutManager);
|
||||||
|
mDrawerList.setHasFixedSize(true);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDrawerOpen() {
|
||||||
|
return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionBarDrawerToggle getActionBarDrawerToggle() {
|
||||||
|
return mActionBarDrawerToggle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DrawerLayout getDrawerLayout() {
|
||||||
|
return mDrawerLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNavigationDrawerItemSelected(int position, Webcam webcam) {
|
||||||
|
selectItem(position, webcam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateAdapter(WebcamAdapter adapter) {
|
||||||
|
adapter.setNavigationDrawerCallbacks(this);
|
||||||
|
mDrawerList.setAdapter(adapter);
|
||||||
|
// selectItem(mCurrentSelectedPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users of this fragment must call this method to set up the navigation drawer interactions.
|
||||||
|
*
|
||||||
|
* @param fragmentId The android:id of this fragment in its activity's layout.
|
||||||
|
* @param drawerLayout The DrawerLayout containing this fragment's UI.
|
||||||
|
* @param toolbar The Toolbar of the activity.
|
||||||
|
*/
|
||||||
|
public void setup(int fragmentId, DrawerLayout drawerLayout, Toolbar toolbar) {
|
||||||
|
mFragmentContainerView = getActivity().findViewById(fragmentId);
|
||||||
|
mDrawerLayout = drawerLayout;
|
||||||
|
|
||||||
|
mDrawerLayout.setStatusBarBackgroundColor(ContextCompat.getColor(getActivity(), R.color.primary));
|
||||||
|
|
||||||
|
mActionBarDrawerToggle = new ActionBarDrawerToggle(getActivity(), mDrawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
|
||||||
|
@Override
|
||||||
|
public void onDrawerClosed(View drawerView) {
|
||||||
|
super.onDrawerClosed(drawerView);
|
||||||
|
if (!isAdded()) return;
|
||||||
|
|
||||||
|
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDrawerOpened(View drawerView) {
|
||||||
|
super.onDrawerOpened(drawerView);
|
||||||
|
if (!isAdded()) return;
|
||||||
|
if (!mUserLearnedDrawer) {
|
||||||
|
mUserLearnedDrawer = true;
|
||||||
|
SharedPreferences sp = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(getActivity());
|
||||||
|
sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
|
||||||
|
}
|
||||||
|
getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
|
||||||
|
// per the navigation drawer design guidelines.
|
||||||
|
if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
|
||||||
|
mDrawerLayout.openDrawer(mFragmentContainerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Defer code dependent on restoration of previous instance state.
|
||||||
|
mDrawerLayout.post(mActionBarDrawerToggle::syncState);
|
||||||
|
|
||||||
|
mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
|
||||||
|
//selectItem(mCurrentSelectedPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectItem(int position, Webcam webcam) {
|
||||||
|
mCurrentSelectedPosition = position;
|
||||||
|
if (mDrawerLayout != null) {
|
||||||
|
mDrawerLayout.closeDrawer(mFragmentContainerView);
|
||||||
|
}
|
||||||
|
if (mCallbacks != null) {
|
||||||
|
mCallbacks.onNavigationDrawerItemSelected(position, webcam);
|
||||||
|
}
|
||||||
|
((WebcamAdapter) mDrawerList.getAdapter()).selectPosition(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openDrawer() {
|
||||||
|
mDrawerLayout.openDrawer(mFragmentContainerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeDrawer() {
|
||||||
|
mDrawerLayout.closeDrawer(mFragmentContainerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
try {
|
||||||
|
mCallbacks = (NavigationDrawerCallbacks) context;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
throw new ClassCastException("Activity must implement NavigationDrawerCallbacks.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetach() {
|
||||||
|
super.onDetach();
|
||||||
|
mCallbacks = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
// Forward the new configuration the drawer toggle component.
|
||||||
|
mActionBarDrawerToggle.onConfigurationChanged(newConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void configureNavHeader() {
|
||||||
|
MaterialProgressBar progressBar = (MaterialProgressBar) mFragmentContainerView.findViewById(R.id.progressBar);
|
||||||
|
mFragmentContainerView.findViewById(R.id.updateWebcams).setOnClickListener(v -> {
|
||||||
|
new WebcamListLoader(getActivity(), this, progressBar).execute(WebcamListLoader.UPDATE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getGoogleDrawer() {
|
||||||
|
return mFragmentContainerView.findViewById(R.id.googleDrawer);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by poliveira on 24/10/2014.
|
||||||
|
*/
|
||||||
|
public class NavigationItem {
|
||||||
|
private String mText;
|
||||||
|
private Drawable mDrawable;
|
||||||
|
|
||||||
|
public NavigationItem(String text, Drawable drawable) {
|
||||||
|
mText = text;
|
||||||
|
mDrawable = drawable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return mText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
mText = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getDrawable() {
|
||||||
|
return mDrawable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDrawable(Drawable drawable) {
|
||||||
|
mDrawable = drawable;
|
||||||
|
}
|
||||||
|
}
|
34
app/src/main/java/com/annimon/webcamviewer/Webcam.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
public class Webcam {
|
||||||
|
|
||||||
|
private final String name, url;
|
||||||
|
private final int updateInterval;
|
||||||
|
|
||||||
|
public Webcam(String name, String url) {
|
||||||
|
this(name, url, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Webcam(String name, String url, int updateInterval) {
|
||||||
|
this.name = name;
|
||||||
|
this.url = url;
|
||||||
|
this.updateInterval = updateInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUpdateInterval() {
|
||||||
|
return updateInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s: %s", name, url);
|
||||||
|
}
|
||||||
|
}
|
101
app/src/main/java/com/annimon/webcamviewer/WebcamAdapter.java
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.bignerdranch.expandablerecyclerview.Adapter.ExpandableRecyclerAdapter;
|
||||||
|
import com.bignerdranch.expandablerecyclerview.Model.ParentListItem;
|
||||||
|
import com.bignerdranch.expandablerecyclerview.ViewHolder.ChildViewHolder;
|
||||||
|
import com.bignerdranch.expandablerecyclerview.ViewHolder.ParentViewHolder;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WebcamAdapter extends ExpandableRecyclerAdapter<WebcamAdapter.WebcamGroupViewHolder, WebcamAdapter.WebcamViewHolder> {
|
||||||
|
|
||||||
|
private LayoutInflater mInflater;
|
||||||
|
private NavigationDrawerCallbacks mNavigationDrawerCallbacks;
|
||||||
|
private View mSelectedView;
|
||||||
|
private int mSelectedPosition;
|
||||||
|
|
||||||
|
public WebcamAdapter(Context context, List<WebcamGroup> data) {
|
||||||
|
super(data);
|
||||||
|
this.mInflater = LayoutInflater.from(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NavigationDrawerCallbacks getNavigationDrawerCallbacks() {
|
||||||
|
return mNavigationDrawerCallbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNavigationDrawerCallbacks(NavigationDrawerCallbacks navigationDrawerCallbacks) {
|
||||||
|
mNavigationDrawerCallbacks = navigationDrawerCallbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectPosition(int position) {
|
||||||
|
mSelectedPosition = position;
|
||||||
|
notifyItemChanged(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebcamGroupViewHolder onCreateParentViewHolder(ViewGroup parent) {
|
||||||
|
final View view = mInflater.inflate(R.layout.drawer_group, parent, false);
|
||||||
|
return new WebcamGroupViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebcamViewHolder onCreateChildViewHolder(ViewGroup parent) {
|
||||||
|
final View view = mInflater.inflate(R.layout.drawer_row, parent, false);
|
||||||
|
final WebcamViewHolder viewHolder = new WebcamViewHolder(view);
|
||||||
|
|
||||||
|
viewHolder.mNameTextView.setClickable(true);
|
||||||
|
viewHolder.mNameTextView.setOnClickListener(v -> {
|
||||||
|
if (mSelectedView != null) {
|
||||||
|
mSelectedView.setSelected(false);
|
||||||
|
}
|
||||||
|
final int adapterPosition = viewHolder.getAdapterPosition();
|
||||||
|
mSelectedPosition = adapterPosition;
|
||||||
|
v.setSelected(true);
|
||||||
|
mSelectedView = v;
|
||||||
|
if (mNavigationDrawerCallbacks != null) {
|
||||||
|
mNavigationDrawerCallbacks.onNavigationDrawerItemSelected(
|
||||||
|
adapterPosition,
|
||||||
|
(Webcam) getListItem(adapterPosition)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// viewHolder.mNameTextView.setBackgroundResource(R.drawable.row_selector);
|
||||||
|
return viewHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindParentViewHolder(WebcamGroupViewHolder webcamGroupViewHolder, int i, ParentListItem parentListItem) {
|
||||||
|
final WebcamGroup webcamGroup = (WebcamGroup) parentListItem;
|
||||||
|
webcamGroupViewHolder.mGroupNameTextView.setText(webcamGroup.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindChildViewHolder(WebcamViewHolder webcamViewHolder, int i, Object childListItem) {
|
||||||
|
final Webcam webcam = (Webcam) childListItem;
|
||||||
|
webcamViewHolder.mNameTextView.setText(webcam.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class WebcamGroupViewHolder extends ParentViewHolder {
|
||||||
|
public TextView mGroupNameTextView;
|
||||||
|
|
||||||
|
public WebcamGroupViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
mGroupNameTextView = (TextView) itemView.findViewById(R.id.item_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WebcamViewHolder extends ChildViewHolder {
|
||||||
|
public TextView mNameTextView;
|
||||||
|
|
||||||
|
public WebcamViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
mNameTextView = (TextView) itemView.findViewById(R.id.item_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
app/src/main/java/com/annimon/webcamviewer/WebcamGroup.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
import com.annimon.stream.Collectors;
|
||||||
|
import com.annimon.stream.Stream;
|
||||||
|
import com.bignerdranch.expandablerecyclerview.Model.ParentListItem;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WebcamGroup implements ParentListItem {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final boolean enabled;
|
||||||
|
private final List<Webcam> webcams;
|
||||||
|
private List<Object> mChildrenList;
|
||||||
|
|
||||||
|
public WebcamGroup(String name, boolean enabled, List<Webcam> webcams) {
|
||||||
|
this.name = name;
|
||||||
|
this.enabled = enabled;
|
||||||
|
this.webcams = webcams;
|
||||||
|
mChildrenList = Stream.of(webcams).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Webcam> getWebcams() {
|
||||||
|
return webcams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s, %s", name, webcams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<?> getChildItemList() {
|
||||||
|
return webcams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInitiallyExpanded() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
130
app/src/main/java/com/annimon/webcamviewer/WebcamListLoader.java
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import com.annimon.stream.Exceptional;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WebcamListLoader extends AsyncTask<Integer, Void, List<WebcamGroup>> {
|
||||||
|
|
||||||
|
private static final String WEBCAM_LIST_URL = "http://projects.annimon.com/projects/webcam-urls.json";
|
||||||
|
private static final String WEBCAM_LIST_FILENAME = "webcam-urls.json";
|
||||||
|
|
||||||
|
public static final int NORMAL = 0, UPDATE = 1;
|
||||||
|
|
||||||
|
private final Context mContext;
|
||||||
|
private final NavigationDrawerFragment mNavigationDrawerFragment;
|
||||||
|
private final ProgressBar mProgressBar;
|
||||||
|
|
||||||
|
public WebcamListLoader(Context context, NavigationDrawerFragment fragment) {
|
||||||
|
this(context, fragment, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebcamListLoader(Context context, NavigationDrawerFragment fragment, ProgressBar progressbar) {
|
||||||
|
this.mContext = context;
|
||||||
|
this.mNavigationDrawerFragment = fragment;
|
||||||
|
this.mProgressBar = progressbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
if (mProgressBar != null) {
|
||||||
|
mProgressBar.setIndeterminate(true);
|
||||||
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<WebcamGroup> doInBackground(Integer... params) {
|
||||||
|
return Exceptional.of(() -> {
|
||||||
|
final File file = mContext.getFileStreamPath(WEBCAM_LIST_FILENAME);
|
||||||
|
ExceptionHandler.log(WEBCAM_LIST_FILENAME + " exists: " + file.exists());
|
||||||
|
final String jsonRaw;
|
||||||
|
if (params[0] == NORMAL && file.exists()) {
|
||||||
|
// Load from internal storage
|
||||||
|
jsonRaw = loadFile(file);
|
||||||
|
} else {
|
||||||
|
// Retrieve from web
|
||||||
|
jsonRaw = loadUrl(WEBCAM_LIST_URL);
|
||||||
|
}
|
||||||
|
ExceptionHandler.log("JSONRAW length: " + jsonRaw.length());
|
||||||
|
|
||||||
|
final List<WebcamGroup> webcamGroups = new ArrayList<>();
|
||||||
|
final JSONArray groups = new JSONObject(jsonRaw).getJSONArray("groups");
|
||||||
|
final int length = groups.length();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
final JSONObject group = groups.getJSONObject(i);
|
||||||
|
final String groupName = group.getString("name");
|
||||||
|
final boolean isGroupEnabled = group.optBoolean("enabled", true);
|
||||||
|
if (!isGroupEnabled) continue;
|
||||||
|
|
||||||
|
final JSONArray urls = group.getJSONArray("urls");
|
||||||
|
final int urlsLength = urls.length();
|
||||||
|
final List<Webcam> webcams = new ArrayList<>(urlsLength);
|
||||||
|
for (int j = 0; j < urlsLength; j++) {
|
||||||
|
final JSONObject url = urls.getJSONObject(j);
|
||||||
|
webcams.add(new Webcam(url.getString("name"), url.getString("url")));
|
||||||
|
}
|
||||||
|
|
||||||
|
webcamGroups.add(new WebcamGroup(groupName, isGroupEnabled, webcams));
|
||||||
|
}
|
||||||
|
|
||||||
|
ExceptionHandler.log("Json parsed successfully");
|
||||||
|
ExceptionHandler.log("Got " + webcamGroups.size() + " groups");
|
||||||
|
|
||||||
|
try (final OutputStream os = new FileOutputStream(file);
|
||||||
|
final OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8")) {
|
||||||
|
osw.write(jsonRaw);
|
||||||
|
osw.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ExceptionHandler.log("Successfully wrote to internal file");
|
||||||
|
|
||||||
|
return webcamGroups;
|
||||||
|
}).ifException(e -> ExceptionHandler.log("WebcamListLoader: " + e.getMessage(), e))
|
||||||
|
.getOrElse(new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String loadUrl(String url) throws IOException {
|
||||||
|
final OkHttpClient client = new OkHttpClient();
|
||||||
|
final Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.build();
|
||||||
|
final Response response = client.newCall(request).execute();
|
||||||
|
return response.body().string();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String loadFile(File file) throws IOException {
|
||||||
|
try (final InputStream is = new FileInputStream(file);
|
||||||
|
final InputStreamReader isr = new InputStreamReader(is, "UTF-8");
|
||||||
|
final BufferedReader reader = new BufferedReader(isr)) {
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
while ( (line = reader.readLine()) != null ) {
|
||||||
|
sb.append(line);
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(List<WebcamGroup> webcams) {
|
||||||
|
super.onPostExecute(webcams);
|
||||||
|
if (mProgressBar != null) {
|
||||||
|
mProgressBar.setVisibility(View.INVISIBLE);
|
||||||
|
mProgressBar.setIndeterminate(false);
|
||||||
|
}
|
||||||
|
mNavigationDrawerFragment.updateAdapter(new WebcamAdapter(mContext, webcams));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
package com.annimon.webcamviewer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import com.blundell.tut.LoaderImageView;
|
||||||
|
|
||||||
|
public class WebcamViewerFragment extends Fragment {
|
||||||
|
|
||||||
|
private static final String ARG_URL = "url";
|
||||||
|
|
||||||
|
private String imageUrl;
|
||||||
|
private LoaderImageView contentImage;
|
||||||
|
|
||||||
|
private boolean autoUpdate;
|
||||||
|
private Timer timer;
|
||||||
|
|
||||||
|
public static WebcamViewerFragment newInstance(Webcam webcam) {
|
||||||
|
final WebcamViewerFragment instance = new WebcamViewerFragment();
|
||||||
|
final Bundle args = new Bundle();
|
||||||
|
args.putString(ARG_URL, webcam.getUrl());
|
||||||
|
instance.setArguments(args);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WebcamViewerFragment() {
|
||||||
|
autoUpdate = false;
|
||||||
|
timer = new Timer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
contentImage = new LoaderImageView(getActivity(), (String) null);
|
||||||
|
imageUrl = getArguments().getString(ARG_URL);
|
||||||
|
update();
|
||||||
|
return contentImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_auto_update:
|
||||||
|
autoUpdate = !autoUpdate;
|
||||||
|
autoUpdate();
|
||||||
|
break;
|
||||||
|
case R.id.menu_update:
|
||||||
|
update();
|
||||||
|
break;
|
||||||
|
case R.id.menu_save:
|
||||||
|
try {
|
||||||
|
save("image" + File.separator + "Донецк");
|
||||||
|
Toast.makeText(getActivity(), "Сохранено", Toast.LENGTH_SHORT).show();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case R.id.menu_videos:
|
||||||
|
final String camimg = "/camimg/cam";
|
||||||
|
final int start = imageUrl.indexOf(camimg) + camimg.length();
|
||||||
|
String camId = imageUrl.substring(start, imageUrl.indexOf("-5.jpg"));
|
||||||
|
Intent intent = new Intent(getActivity(), VideoGetActivity.class);
|
||||||
|
intent.putExtra("camera_id", Integer.parseInt(camId));
|
||||||
|
startActivity(intent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
contentImage.post(() -> contentImage.setImageDrawable(imageUrl));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void autoUpdate() {
|
||||||
|
TimerTask task = new TimerTask() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (autoUpdate) {
|
||||||
|
timer.schedule(task, 500, 100);
|
||||||
|
contentImage.setQuickMode(true);
|
||||||
|
} else {
|
||||||
|
timer.cancel();
|
||||||
|
timer = new Timer();
|
||||||
|
contentImage.setQuickMode(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save(String path) throws IOException {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
|
||||||
|
String fullPath = Environment.getExternalStorageDirectory() +
|
||||||
|
File.separator + path +
|
||||||
|
File.separator + sdf.format(new Date()) + ".jpg";
|
||||||
|
|
||||||
|
try (OutputStream out = new FileOutputStream(new File(fullPath))) {
|
||||||
|
Bitmap bitmap = ((BitmapDrawable) contentImage.getDrawable()).getBitmap();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 85, out);
|
||||||
|
out.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
214
app/src/main/java/com/blundell/tut/LoaderImageView.java
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
package com.blundell.tut;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Handler.Callback;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import com.annimon.webcamviewer.R;
|
||||||
|
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free for anyone to use, just say thanks and share :-)
|
||||||
|
* @author Blundell
|
||||||
|
*/
|
||||||
|
public final class LoaderImageView extends FrameLayout {
|
||||||
|
|
||||||
|
private static final int COMPLETE = 0;
|
||||||
|
private static final int FAILED = 1;
|
||||||
|
private static final int PROGRESS = 2;
|
||||||
|
|
||||||
|
private Drawable mDrawable;
|
||||||
|
private MaterialProgressBar mProgressBar;
|
||||||
|
private ImageView mImage;
|
||||||
|
private boolean mQuickMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used when creating the view in XML
|
||||||
|
* To have an image load in XML use the tag 'image="http://developer.android.com/images/dialog_buttons.png"'
|
||||||
|
* Replacing the url with your desired image
|
||||||
|
* Once you have instantiated the XML view you can call
|
||||||
|
* setImageDrawable(url) to change the image
|
||||||
|
* @param context
|
||||||
|
* @param attrSet
|
||||||
|
*/
|
||||||
|
public LoaderImageView(final Context context, final AttributeSet attrSet) {
|
||||||
|
super(context, attrSet);
|
||||||
|
final String url = attrSet.getAttributeValue(null, "image");
|
||||||
|
instantiate(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used when creating the view programmatically
|
||||||
|
* Once you have instantiated the view you can call
|
||||||
|
* setImageDrawable(url) to change the image
|
||||||
|
* @param context the Activity context
|
||||||
|
* @param imageUrl the Image URL you wish to load
|
||||||
|
*/
|
||||||
|
public LoaderImageView(final Context context, final String imageUrl) {
|
||||||
|
super(context);
|
||||||
|
instantiate(imageUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used when creating the view programmatically
|
||||||
|
* Once you have instantiated the view you can call
|
||||||
|
* setImageDrawable(url) to change the image
|
||||||
|
*/
|
||||||
|
public LoaderImageView(final Context context) {
|
||||||
|
super(context);
|
||||||
|
instantiate(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First time loading of the LoaderImageView
|
||||||
|
* Sets up the LayoutParams of the view, you can change these to
|
||||||
|
* get the required effects you want
|
||||||
|
*/
|
||||||
|
private void instantiate(final String imageUrl) {
|
||||||
|
mQuickMode = false;
|
||||||
|
|
||||||
|
mImage = new ImageView(getContext());
|
||||||
|
mImage.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
|
mProgressBar = new MaterialProgressBar(getContext());
|
||||||
|
mProgressBar.setLayoutParams(new LayoutParams(
|
||||||
|
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.CENTER));
|
||||||
|
mProgressBar.setProgress(0);
|
||||||
|
mProgressBar.setVisibility(GONE);
|
||||||
|
|
||||||
|
addView(mImage);
|
||||||
|
addView(mProgressBar);
|
||||||
|
|
||||||
|
if (imageUrl != null) {
|
||||||
|
setImageDrawable(imageUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set's the view's drawable, this uses the internet to retrieve the image
|
||||||
|
* don't forget to add the correct permissions to your manifest
|
||||||
|
* @param imageUrl the url of the image you wish to load
|
||||||
|
*/
|
||||||
|
public void setImageDrawable(final String imageUrl) {
|
||||||
|
// mDrawable = null;
|
||||||
|
if (!mQuickMode) {
|
||||||
|
mProgressBar.setVisibility(VISIBLE);
|
||||||
|
mProgressBar.setProgress(0);
|
||||||
|
mProgressBar.setIndeterminate(true);
|
||||||
|
}
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
mDrawable = getDrawableFromUrl(imageUrl);
|
||||||
|
imageLoadedHandler.sendEmptyMessage(COMPLETE);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
imageLoadedHandler.sendEmptyMessage(FAILED);
|
||||||
|
} catch (IOException e) {
|
||||||
|
imageLoadedHandler.sendEmptyMessage(FAILED);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getDrawable() {
|
||||||
|
return mImage.getDrawable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isQuickMode() {
|
||||||
|
return mQuickMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuickMode(boolean quickMode) {
|
||||||
|
this.mQuickMode = quickMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback that is received once the image has been downloaded
|
||||||
|
*/
|
||||||
|
private final Handler imageLoadedHandler = new Handler(new Callback() {
|
||||||
|
@Override
|
||||||
|
public boolean handleMessage(Message msg) {
|
||||||
|
switch (msg.what) {
|
||||||
|
case COMPLETE:
|
||||||
|
mImage.setImageDrawable(mDrawable);
|
||||||
|
mProgressBar.setVisibility(GONE);
|
||||||
|
break;
|
||||||
|
case PROGRESS:
|
||||||
|
mProgressBar.setIndeterminate(false);
|
||||||
|
mProgressBar.setProgress(msg.arg1);
|
||||||
|
break;
|
||||||
|
case FAILED:
|
||||||
|
default:
|
||||||
|
// Could change image here to a 'failed' image
|
||||||
|
// otherwise will just keep on spinning
|
||||||
|
mImage.setImageResource(R.drawable.no_image);
|
||||||
|
mProgressBar.setIndeterminate(false);
|
||||||
|
mProgressBar.setVisibility(GONE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass in an image url to get a drawable object
|
||||||
|
* @return a drawable object
|
||||||
|
* @throws IOException
|
||||||
|
* @throws MalformedURLException
|
||||||
|
*/
|
||||||
|
private Drawable getDrawableFromUrl(final String imageUrl) throws IOException, MalformedURLException {
|
||||||
|
final URL url = new URL(imageUrl);
|
||||||
|
final URLConnection conection = url.openConnection();
|
||||||
|
conection.connect();
|
||||||
|
// this will be useful so that you can show a typical 0-100% progress bar
|
||||||
|
int lenghtOfFile = conection.getContentLength();
|
||||||
|
if (lenghtOfFile <= 0 || mQuickMode) {
|
||||||
|
// try to load by system call
|
||||||
|
return Drawable.createFromStream((InputStream) url.getContent(), "name");
|
||||||
|
}
|
||||||
|
|
||||||
|
// download the file
|
||||||
|
final InputStream input = new BufferedInputStream(url.openStream(), 8192);
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream(lenghtOfFile);
|
||||||
|
final byte[] buffer = new byte[4096];
|
||||||
|
long total = 0;
|
||||||
|
int count;
|
||||||
|
while ((count = input.read(buffer)) != -1) {
|
||||||
|
total += count;
|
||||||
|
// publishing the progress....
|
||||||
|
imageLoadedHandler.obtainMessage(PROGRESS, (int) ((total * 360) / lenghtOfFile), 0)
|
||||||
|
.sendToTarget();
|
||||||
|
// writing data
|
||||||
|
output.write(buffer, 0, count);
|
||||||
|
}
|
||||||
|
// flushing output
|
||||||
|
output.flush();
|
||||||
|
// closing streams
|
||||||
|
output.close();
|
||||||
|
input.close();
|
||||||
|
|
||||||
|
byte[] data = output.toByteArray();
|
||||||
|
output = null;
|
||||||
|
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||||
|
data = null;
|
||||||
|
return new BitmapDrawable(getContext().getResources(), bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
BIN
app/src/main/res/drawable-hdpi/ic_menu_check.png
Normal file
After Width: | Height: | Size: 212 B |
BIN
app/src/main/res/drawable-hdpi/ic_refresh_grey600_24dp.png
Normal file
After Width: | Height: | Size: 840 B |
BIN
app/src/main/res/drawable-hdpi/no_image.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/drawable-mdpi/ic_menu_check.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
app/src/main/res/drawable-mdpi/ic_refresh_grey600_24dp.png
Normal file
After Width: | Height: | Size: 578 B |
BIN
app/src/main/res/drawable-xhdpi/ic_menu_check.png
Normal file
After Width: | Height: | Size: 232 B |
BIN
app/src/main/res/drawable-xhdpi/ic_refresh_grey600_24dp.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_menu_check.png
Normal file
After Width: | Height: | Size: 329 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_refresh_grey600_24dp.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_refresh_grey600_24dp.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
5
app/src/main/res/drawable/row_selector.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_selected="true" android:drawable="@drawable/selected_gray"/>
|
||||||
|
<item android:state_pressed="true" android:drawable="@drawable/pressed_gray"/>
|
||||||
|
</selector>
|
BIN
app/src/main/res/drawable/wallpaper.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
38
app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/root"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/toolbar_actionbar"
|
||||||
|
layout="@layout/toolbar_default"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<android.support.v4.widget.DrawerLayout
|
||||||
|
android:id="@+id/drawer"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_below="@+id/toolbar_actionbar">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<!-- android:layout_marginTop="?android:attr/actionBarSize"-->
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/fragment_drawer"
|
||||||
|
android:name="com.annimon.webcamviewer.NavigationDrawerFragment"
|
||||||
|
android:layout_width="@dimen/navigation_drawer_width"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
app:layout="@layout/fragment_navigation_drawer"/>
|
||||||
|
</android.support.v4.widget.DrawerLayout>
|
||||||
|
</RelativeLayout>
|
15
app/src/main/res/layout/drawer_group.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_width="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/item_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:drawablePadding="16dp"
|
||||||
|
android:paddingLeft="4dp"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textColor="@color/accent"/>
|
||||||
|
</LinearLayout>
|
14
app/src/main/res/layout/drawer_row.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_width="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/item_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:drawablePadding="16dp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textColor="@color/primary_text"/>
|
||||||
|
</LinearLayout>
|
56
app/src/main/res/layout/fragment_navigation_drawer.xml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:id="@+id/googleDrawer"
|
||||||
|
android:background="@android:color/white">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:background="@drawable/wallpaper"
|
||||||
|
android:id="@+id/navigationHeader"
|
||||||
|
android:paddingTop="6dp"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/updateWebcams"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:drawableLeft="@drawable/ic_refresh_grey600_24dp"
|
||||||
|
android:text="@string/update"
|
||||||
|
android:background="@null" />
|
||||||
|
|
||||||
|
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:visibility="invisible"
|
||||||
|
android:layout_below="@+id/updateWebcams"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:indeterminate="true"
|
||||||
|
app:mpb_progressStyle="horizontal"
|
||||||
|
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:background="#1f000000"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:id="@+id/separator"
|
||||||
|
android:layout_below="@+id/navigationHeader"
|
||||||
|
android:layout_marginBottom="8dp"/>
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
|
android:id="@+id/drawerList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/drawer_background"
|
||||||
|
android:layout_below="@+id/separator"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
7
app/src/main/res/layout/toolbar_default.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
style="@style/ToolBarStyle"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:minHeight="@dimen/abc_action_bar_default_height_material"/>
|
4
app/src/main/res/menu/main.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/action_settings"
|
||||||
|
android:title="@string/action_settings"/>
|
||||||
|
</menu>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 813 B |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
28
app/src/main/res/values-v21/styles.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/primary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/primary_dark</item>
|
||||||
|
<item name="colorAccent">@color/accent</item>
|
||||||
|
<item name="android:textColorPrimary">@color/primary_text</item>
|
||||||
|
<item name="android:navigationBarColor">@color/navigation_color</item>
|
||||||
|
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
|
||||||
|
|
||||||
|
|
||||||
|
<item name="android:windowBackground">@color/window_background</item>
|
||||||
|
<item name="android:windowContentTransitions">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
|
||||||
|
<item name="spinBars">true</item>
|
||||||
|
<item name="color">@android:color/white</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="ToolBarStyle" parent="">
|
||||||
|
<item name="android:elevation">@dimen/toolbar_elevation</item>
|
||||||
|
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||||
|
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
21
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Check Android Theme colors for color reference:
|
||||||
|
https://developer.android.com/training/material/images/ThemeColors.png
|
||||||
|
|
||||||
|
Refer also to Color palette for the UI colors you should use:
|
||||||
|
http://www.google.com/design/spec/style/color.html#color-ui-color-palette
|
||||||
|
-->
|
||||||
|
|
||||||
|
<color name="primary">#03A9F4</color>
|
||||||
|
<color name="primary_dark">#0288D1</color>
|
||||||
|
<color name="accent">#FF5722</color>
|
||||||
|
<color name="drawer_background">#FFF</color>
|
||||||
|
<color name="window_background">#FFF</color>
|
||||||
|
<color name="primary_text">#212121</color>
|
||||||
|
<color name="navigation_color">#000</color>
|
||||||
|
|
||||||
|
<drawable name="pressed_gray">#0c000000</drawable>
|
||||||
|
<drawable name="selected_gray">#2c000000</drawable>
|
||||||
|
</resources>
|
12
app/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||||
|
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||||
|
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||||
|
|
||||||
|
<!-- Per the design guidelines, navigation drawers should be between 240dp and 320dp:
|
||||||
|
https://developer.android.com/design/patterns/navigation-drawer.html -->
|
||||||
|
<dimen name="navigation_drawer_width">240dp</dimen>
|
||||||
|
<dimen name="toolbar_elevation">4dp</dimen>
|
||||||
|
<dimen name="navheader_height">70dp</dimen>
|
||||||
|
<dimen name="md_keylines">16dp</dimen>
|
||||||
|
</resources>
|
7
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">WebcamViewer</string>
|
||||||
|
<string name="drawer_open">Menu opened</string>
|
||||||
|
<string name="drawer_close">Menu closed</string>
|
||||||
|
<string name="action_settings">Settings</string>
|
||||||
|
<string name="update">Update</string>
|
||||||
|
</resources>
|
28
app/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<resources>
|
||||||
|
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
<item name="colorPrimary">@color/primary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/primary_dark</item>
|
||||||
|
<item name="colorAccent">@color/accent</item>
|
||||||
|
<item name="android:textColorPrimary">@color/primary_text</item>
|
||||||
|
<item name="android:navigationBarColor">@color/navigation_color</item>
|
||||||
|
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
|
||||||
|
|
||||||
|
|
||||||
|
<item name="android:windowBackground">@color/window_background</item>
|
||||||
|
<item name="android:windowContentTransitions">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
|
||||||
|
<item name="spinBars">true</item>
|
||||||
|
<item name="color">@android:color/white</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="ToolBarStyle" parent="">
|
||||||
|
<item name="android:elevation">@dimen/toolbar_elevation</item>
|
||||||
|
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||||
|
<item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
19
build.gradle
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
18
gradle.properties
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||||
|
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||||
|
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#Wed Apr 10 15:27:10 PDT 2013
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
164
gradlew
vendored
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn ( ) {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die ( ) {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||||
|
if $cygwin ; then
|
||||||
|
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >&-
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >&-
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin, switch paths to Windows format before running java
|
||||||
|
if $cygwin ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
|
function splitJvmOpts() {
|
||||||
|
JVM_OPTS=("$@")
|
||||||
|
}
|
||||||
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
90
gradlew.bat
vendored
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windowz variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
goto execute
|
||||||
|
|
||||||
|
:4NT_args
|
||||||
|
@rem Get arguments from the 4NT Shell from JP Software
|
||||||
|
set CMD_LINE_ARGS=%$
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
|||||||
|
include ':app'
|