Commit 3d889c18 authored by Markus's avatar Markus

init

parent 0b75cfda
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
MediaDBViewer
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.8" />
<option name="gradleJvm" value="1.7" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/MediaDBViewer.iml" filepath="$PROJECT_DIR$/MediaDBViewer.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.markus.mediadbviewer"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/markus/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 *;
#}
package com.example.markus.mediadbviewer;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.markus.mediadbviewer">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package com.example.markus.mediadbviewer;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.util.Log;
import java.io.File;
import java.net.URL;
import java.net.URLConnection;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.util.Arrays;
class CoverDownloader extends AsyncTask<String, String, String> {
private String coverType = "";
private String quality = "";
private String[] validCoverTypes = new String[]{"Filme", "Serien", "Staffeln"};
private String[] validQualities = new String[]{"high", "low"};
private String rootDomain = "http://mediadb.ddns.net/cover/"; // später über Einstellungen
public CoverDownloader(String coverType, String quality) {
if (Arrays.asList(validCoverTypes).contains(coverType)) {
this.coverType = coverType;
} else {
Log.d("DEBUG","CoverDownloader: invalid cover type " + coverType);
}
if (Arrays.asList(validQualities).contains(quality)) {
this.quality = quality;
} else {
Log.d("DEBUG","CoverDownloader: invalid quality " + quality);
}
}
public void setCoverType(String coverType) {
if (Arrays.asList(validCoverTypes).contains(coverType)) {
this.coverType = coverType;
} else {
Log.d("DEBUG","CoverDownloader: invalid cover type " + coverType);
}
}
public void setQuality (String quality) {
if (Arrays.asList(validQualities).contains(quality)) {
this.quality = quality;
} else {
Log.d("DEBUG","CoverDownloader: invalid quality " + quality);
}
}
@Override
protected void onPreExecute() {
super.onPreExecute();
//showDialog();
}
@Override
protected String doInBackground(String[] keys) {
String downloadFolder;
String downloadUrl;
// erstelle URL und Downloadpfad
if (this.coverType.equals("Filme") && keys[0].length() == 7) {
if (this.quality.equals("low")) {
downloadFolder = MainActivity.rootCoverFolder + this.coverType + "/" + this.quality + "/";
downloadUrl = rootDomain + this.coverType + "/" + this.quality + "/";
} else if (this.quality.equals("high")) {
downloadFolder = MainActivity.rootCoverFolder + this.coverType + "/" + this.quality + "/";
downloadUrl = rootDomain + this.coverType + "/" + this.quality + "/";
} else {
Log.d("DEBUG", "CoverDownloader: invalid quality " + this.quality + " for cover type " + this.coverType);
return null;
}
} else if (this.coverType.equals("Serien")) {
if (this.quality.equals("low")) {
downloadFolder = MainActivity.rootCoverFolder + this.coverType + "/" + this.quality + "/";
downloadUrl = rootDomain + this.coverType + "/" + this.quality + "/";
} else {
Log.d("DEBUG", "CoverDownloader: invalid quality " + this.quality + " for cover type " + this.coverType);
return null;
}
} else if (this.coverType.equals("Staffeln")) {
if (this.quality.equals("low")) {
downloadFolder = MainActivity.rootCoverFolder + this.coverType + "/" + this.quality + "/";
downloadUrl = rootDomain + this.coverType + "/" + this.quality + "/";
} else if (this.quality.equals("high")) {
downloadFolder = MainActivity.rootCoverFolder + this.coverType + "/" + this.quality + "/";
downloadUrl = rootDomain + this.coverType + "/" + this.quality + "/";
} else {
Log.d("DEBUG", "CoverDownloader: invalid quality " + this.quality + " for cover type " + this.coverType);
return null;
}
} else {
Log.d("DEBUG", "CoverDownloader: could not download for " + this.quality + " with key " + keys[0]);
return null;
}
File downloadFolderFile = new File(downloadFolder);
// erstelle downloadFolder
if (!downloadFolderFile.exists()) {
downloadFolderFile.mkdirs();
}
// lösche alle Dateien im Ordner
File[] files = downloadFolderFile.listFiles();
if (files != null) {
for(File f: files) {
f.delete();
}
}
// downloade alle cover
int count;
for (String key : keys) {
try {
URL url = new URL(downloadUrl + key + ".jpg");
URLConnection connection = url.openConnection();
connection.connect();
// getting file length
int lenghtOfFile = connection.getContentLength();
// input stream to read file - with 8k buffer
InputStream input = new BufferedInputStream(url.openStream(), 8192);
// Output stream to write file
OutputStream output = new FileOutputStream(downloadFolder + key + ".jpg");
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
// publishing the progress....
// After this onProgressUpdate will be called
// writing data to file
output.write(data, 0, count);
}
// flushing output
output.flush();
// closing streams
output.close();
input.close();
} catch (Exception e) {
Log.d("FehlerDownload",e.getMessage());
}
// ruft onProgressUpdate() auf
//publishProgress(String.valueOf((int) ((((float) filesProcessed)/totalFiles)*100.)));
MainActivity.progressDialog.setProgress(MainActivity.progressDialog.getProgress() + 1);
}
return null;
}
@Override
protected void onPostExecute(String link_url) {
if (MainActivity.progressDialog.getProgress() / MainActivity.progressDialog.getMax() > 0.99) {
MainActivity.progressDialog.dismiss();
}
}
}
package com.example.markus.mediadbviewer;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
class DrawerListAdapter extends BaseAdapter {
ArrayList<NavigationbarIcon> mNavItems;
Context mContext;
public DrawerListAdapter(Context context, ArrayList<NavigationbarIcon> navItems) {
mContext = context;
mNavItems = navItems;
}
@Override
public int getCount() {
return mNavItems.size();
}
@Override
public Object getItem(int position) {
return mNavItems.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.drawer_item, null);
}
else {
view = convertView;
}
TextView titleView = (TextView) view.findViewById(R.id.title);
TextView subtitleView = (TextView) view.findViewById(R.id.subTitle);
ImageView iconView = (ImageView) view.findViewById(R.id.icon);
titleView.setText( mNavItems.get(position).mTitle );
subtitleView.setText( mNavItems.get(position).mSubtitle );
iconView.setImageResource(mNavItems.get(position).mIcon);
return view;
}
}
\ No newline at end of file
package com.example.markus.mediadbviewer;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewManager;
import android.widget.ArrayAdapter;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class EpisodeArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private ArrayList<MediaObject> episodeList = new ArrayList<MediaObject>();
public EpisodeArrayAdapter (Context context, List episodeList) {
super(context, -1, episodeList);
this.episodeList = (ArrayList<MediaObject>) episodeList;
this.context = context;
}
private void setValues(ViewHolder holder, int position) {
// setzt imdbID für ViewHolder
holder.season_nr = this.episodeList.get(position).season_nr;
holder.episodenumber = this.episodeList.get(position).episodenumber;
// Setze Texte des Views
holder.firstLine.setText(String.valueOf(this.episodeList.get(position).episodenumber) + ") " + this.episodeList.get(position).name);
//holder.secondLine.setText("Rating: " + this.seriesList.get(position).finished);
// setze checked Bild
if (episodeList.get(position).checked.equals("1")) {
holder.checkedImage.setImageResource(R.drawable.correct);
} else if (episodeList.get(position).checked.equals("0")) {
holder.checkedImage.setImageResource(R.drawable.wrong);
} else {
holder.checkedImage.setImageDrawable(null);
}
// setzte view count, existiert nicht
//holder.viewCount.setText(String.valueOf(this.episodeList.get(position).views));
}
// iteriert über jedes Element des String-Arrays (position) ist Array-Index
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //hole den LayoutInflater
convertView = inflater.inflate(R.layout.list_element, null);//inflate Element
// erstelle ViewHolder, setze Klassenvariablen und füge ihn dem View hinzu
holder = new ViewHolder();
convertView.setTag(holder);
holder.firstLine = (TextView) convertView.findViewById(R.id.firstLine);
holder.secondLine = (TextView) convertView.findViewById(R.id.secondLine);
holder.checkedImage = (ImageView) convertView.findViewById(R.id.checkedImage);
holder.viewCount = (TextView) convertView.findViewById(R.id.viewCount);
holder.cover = (ImageView) convertView.findViewById(R.id.cover);
// entferne Cover view
((ViewManager) holder.cover.getParent()).removeView(holder.cover);
//entferne second line
((ViewManager) holder.secondLine.getParent()).removeView(holder.secondLine);
// führe Funktion zum Anpassen des Views aus
setValues(holder, position);
// setze onClickListener ... ändert sich nie, deshalb nur beim Initialisieren
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewHolder holder = (ViewHolder) v.getTag();
FragmentManager fragmentManager = ((Activity) context).getFragmentManager();
EpisodeDetailedFragment episodeDetailedFragment = new EpisodeDetailedFragment();
episodeDetailedFragment.setSeason_nr(holder.season_nr);
episodeDetailedFragment.setEpisodenumber(holder.episodenumber);
fragmentManager.beginTransaction().replace(R.id.mainContent, episodeDetailedFragment).addToBackStack("episodeDetailedFragment").commit();
}
});
} else {
holder = (ViewHolder) convertView.getTag();
setValues(holder, position);
}
return convertView;
}
private class ViewHolder {
public TextView firstLine;
public TextView secondLine;
public ImageView checkedImage;
public ImageView cover;
public TextView viewCount;
public int season_nr;
public int episodenumber;
}
}
\ No newline at end of file
package com.example.markus.mediadbviewer;
import android.app.ListFragment;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import java.io.File;
import java.util.ArrayList;
public class EpisodeListFragment extends ListFragment {
private String coverFolder = MainActivity.rootCoverFolder + "Staffeln/high/";
private ArrayList<MediaObject> episodeList = new ArrayList<MediaObject>();
private int season_nr;
public void setSeason_nr(int season_nr) {
this.season_nr = season_nr;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View fragment = inflater.inflate(R.layout.episode_list_fragment, container, false); //wendet layout an
final ListView episodeListView = (ListView) fragment.findViewById(android.R.id.list); //hole Referenz auf ListView
// setze Cover vor ListView
ImageView cover = (ImageView) fragment.findViewById(R.id.seasonCover);
if (new File(this.coverFolder + this.season_nr + ".jpg").exists()) {
cover.setImageDrawable(Drawable.createFromPath(this.coverFolder + this.season_nr + ".jpg"));
} else {
cover.setImageResource(R.drawable.android);
}
// hole Daten für episodeListView
SeriesQueryFactory episodeQueryFactory = new SeriesQueryFactory("Episoden");
updateEpisodeListView(episodeQueryFactory, episodeListView);
return fragment;
}
private void updateEpisodeListView (SeriesQueryFactory episodeQueryFactory, ListView listView) {
// notwendige Spalten für ListView können zentral hier geändert werden
episodeQueryFactory.addColumns(new String[]{"episodenumber", "name", "series_nr", "season_nr", "checked"});
episodeQueryFactory.addConditions(new String[]{"season_nr=" + this.season_nr});
JSONParser parser = new JSONParser();
try {
parser.execute(new String[]{episodeQueryFactory.getUrl()}).get();
} catch (Exception e) {
}
this.episodeList = parser.getMediaList();
// setzen des ArrayAdapters
EpisodeArrayAdapter episodeArrayAdapter = new EpisodeArrayAdapter(getActivity(), this.episodeList);
listView.setAdapter(episodeArrayAdapter);
}
@Override
public void onResume() {
super.onResume();
getActivity().setTitle("Episoden (" + this.episodeList.size() + ")");
}
}
package com.example.markus.mediadbviewer;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.app.Fragment;
public class HomeFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
getActivity().setTitle("Home");
View fragment = inflater.inflate(R.layout.home_fragment, container, false); //wendet layout an
return fragment;
}
@Override
public void onResume() {
super.onResume();
getActivity().setTitle("Home");
}
}
package com.example.markus.mediadbviewer;
import android.os.AsyncTask;
import android.util.JsonReader;
import android.util.JsonToken;
import android.util.Log;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;
class JSONParser extends AsyncTask<String, String, String> {
private ArrayList<MediaObject> mediaList;
public ArrayList<MediaObject> getMediaList() {
return this.mediaList;
}
@Override
protected String doInBackground(String[] links) {
try {
URL url = new URL(links[0]);
URLConnection connection = url.openConnection();
connection.connect();
InputStream stream = connection.getInputStream();
InputStreamReader isReader = new InputStreamReader(stream);
JsonReader jsonReader = new JsonReader(isReader);
this.mediaList = readJsonStream(stream);
} catch (Exception e) {
Log.d("Exceptions", e.getClass().getName());
}
return null;
}
public ArrayList<MediaObject> readJsonStream(InputStream in) throws IOException {
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
ArrayList<MediaObject> list = new ArrayList();
try {
reader.beginObject(); //startet das root Object, welches mit { beginnt
for (int i=0; i<3; i++) { //überspringt die ersten 4 Attribute, da uninteressant
Log.d("JSON", reader.nextName()); // nextName muss aufgerufen werden !!!
reader.skipValue();
}
if (reader.nextName().equals("Antwort")) {
reader.beginObject();
if (reader.nextName().equals("Spalten")) {
reader.skipValue();
}
}
list = readMessagesArray(reader);
} catch (Exception e) {
Log.d("JSONFehler", e.getMessage());
} finally {
reader.close();
}
return list;
}
public ArrayList<MediaObject> readMessagesArray(JsonReader reader) throws IOException {
ArrayList<MediaObject> media = new ArrayList();
if (reader.nextName().equals("Data")) {
}
reader.beginArray();
while (reader.hasNext()) {
media.add(readMessage(reader));
}
reader.endArray();
reader.endObject();
reader.endObject();
return media;
}
public MediaObject readMessage(JsonReader reader) throws IOException {
MediaObject mediaObject = new MediaObject();
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
//Log.d("JSON", name);
if (name.equals("imdbID")) {
mediaObject.imdbID = reader.nextString();
} else if (name.equals("name")) {
mediaObject.name = reader.nextString();
} else if (name.equals("year")) {
mediaObject.year = reader.nextInt();
} else if (name.equals("size")) {
mediaObject.size = reader.nextLong();
} else if (name.equals("Size")) {
mediaObject.Size = reader.nextLong();
} else if (name.equals("md5")) {
mediaObject.md5 = reader.nextString();
} else if (name.equals("3d")) {
mediaObject.dimensions = reader.nextString();
} else if (name.equals("vcodec")) {
mediaObject.vcodec = reader.nextString();
} else if (name.equals("duration")) {
mediaObject.duration = reader.nextInt();
} else if (name.equals("Duration")) {
mediaObject.Duration = reader.nextInt();
} else if (name.equals("totalbitrate")) {
mediaObject.totalbitrate = reader.nextInt();
} else if (name.equals("resolution")) {
mediaObject.resolution = reader.nextString();
} else if (name.equals("width")) {
mediaObject.width = reader.nextInt();
} else if (name.equals("height")) {
mediaObject.height = reader.nextInt();
} else if (name.equals("acodecger")) {
mediaObject.acodecger = reader.nextString();
} else if (name.equals("abitrateger")) {
mediaObject.abitrateger = reader.nextInt();
} else if (name.equals("channelsger")) {
mediaObject.channelsger = reader.nextInt();
} else if (name.equals("acodeceng")) {
try {
mediaObject.acodeceng = reader.nextString();
} catch (Exception e){
mediaObject.acodeceng = "";
}
} else if (name.equals("abitrateeng")) {
try {
mediaObject.abitrateeng = Integer.valueOf(reader.nextString());
} catch (Exception e) {
mediaObject.abitrateeng = 0;
}
} else if (name.equals("channelseng")) {
try {
mediaObject.channelseng = Integer.valueOf(reader.nextString());
} catch (Exception e) {
mediaObject.channelseng = 0;
}
} else if (name.equals("hdd")) {
mediaObject.hdd = reader.nextInt();
} else if (name.equals("rating")) {
mediaObject.rating = reader.nextDouble();
} else if (name.equals("checked")) {
mediaObject.checked = reader.nextString();
} else if (name.equals("Checked")) {
mediaObject.Checked = reader.nextString();
} else if (name.equals("views")) {
mediaObject.views = reader.nextInt();
} else if (name.equals("Views")) {
mediaObject.Views = reader.nextDouble();
} else if (name.equals("comment")) {
mediaObject.comment = reader.nextString();
} else if (name.equals("added")) {
mediaObject.added = reader.nextString();
} else if (name.equals("lastView")) {
mediaObject.lastView = reader.nextString();
} else if (name.equals("Schauspieler")) {
reader.beginArray();
while (reader.hasNext()) {
try {
mediaObject.schauspieler.add(reader.nextString());
} catch (Exception e) {
Log.d("FIND", "Hallo");
}
}
reader.endArray();
} else if (name.equals("Genre") && reader.peek() != JsonToken.NULL) {
reader.beginArray();
while (reader.hasNext()) {
mediaObject.Genre.add(reader.nextString());
}
reader.endArray();
} else if (name.equals("series_nr")) {
mediaObject.series_nr = reader.nextInt();
} else if (name.equals("season_nr")) {
mediaObject.season_nr = reader.nextInt();
} else if (name.equals("season")) {
mediaObject.season = reader.nextInt();
} else if (name.equals("source")) {
mediaObject.source = reader.nextString();
} else if (name.equals("sound")) {
mediaObject.sound = reader.nextString();
} else if (name.equals("finished")) {
mediaObject.finished = reader.nextInt();
} else if (name.equals("episodenumber")) {
mediaObject.episodenumber = reader.nextInt();
} else {
Log.d("JSON", "Skipped: " + name);
reader.skipValue();
}
}
reader.endObject();
return mediaObject;
}
}
package com.example.markus.mediadbviewer;
import java.util.ArrayList;
/**
* Created by markus on 12.01.16.
*/
public class MediaObject {
// allgemeine Attribute
public String name; //Bsp.: Hangover 1
public long size; // immer in Byte
public String md5; // Prüfsumme der jeweiligen Datei
public String vcodec; //entspricht dem Container (z.B. mkv)
public int duration; //Laufzeit in Sekunden
public int totalbitrate; //durchschnittliche Bitrate der Datei (Audio + Video)
public String resolution; //Werte: 1080p, 720p, SD
public int width; //Videobreite in Pixeln
public int height; //Videohöhe in Pixeln
public String acodecger; //Audiocodec der deutschen Tonspur
public int abitrateger; //Bitrate der deutschen Tonspur
public int channelsger; //Anzahl Kanäle der deutschen Tonspur
public String acodeceng; //Audiocodec der englischen Tonspur; Null, wenn nicht vorhanden
public int abitrateeng; //Bitrate der englischen Tonspur; Null, wenn nicht vorhanden
public int channelseng; //Anzahl Kanäle der englischen Tonspur; Null, wenn nicht vorhanden
public int hdd; //Festplatte auf der sich die Datei befindet
public String checked; //Indikator, ob der Film bereits auf Fehler überprüft wurde
public int views; //Anzahl gesehen
public String comment; //Kommentar
public String added; //Datum, an dem der Filme hinzugefügt wurde
public String lastView; //Datum, an dem der Film das letzte mal gesehen wurde
// filmspezifische Attribute
public ArrayList<String> Genre = new ArrayList<String>(); // Genres des Films
public ArrayList<String> schauspieler = new ArrayList<String>(); // Schauspieler des Films
public String imdbID; //Bsp.: 0123456 (immer 7 Zahlen)
public int year; //Bsp.: 2015
public String dimensions; //entspricht Spalte 3d in der Datenbank
public double rating; //IMDB-Rating des Films
// serienspezifische Attribute
public int series_nr; // Primärschlüssel für Serien
public int season; // Staffel-Nummer
public String sound; // Ton: z.B. 2.0 oder 5.1
public String source; // Quelle der Staffel
public int season_nr; // Primärschlüssel für Staffeln
public int finished; // Information, ob eine Serie abgeschlossen ist
public int episodenumber; // Nummer einer Episode
public double Views; // abstrakt: AVG(Episoden.views)
public String Checked; // abstrakt: AVG(Episoden.checked)
public long Size; // abstrakt: SUM(Episoden.size)
public long Duration; // abstrakt; SUM(Episoden.duration)
}
package com.example.markus.mediadbviewer;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
import org.w3c.dom.Text;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class MovieArrayAdapter extends ArrayAdapter<String> {
private String coverFolder = MainActivity.rootCoverFolder + "Filme/low/";
private final Context context;
private ArrayList<MediaObject> movieList = new ArrayList<MediaObject>();
public MovieArrayAdapter(Context context, List movieList) {
super(context, -1, movieList);
this.movieList = (ArrayList<MediaObject>) movieList;
this.context = context;
}
private void setValues(ViewHolder holder, int position) {
// setzt imdbID für ViewHolder
holder.imdbID = this.movieList.get(position).imdbID;
holder.dimensions = this.movieList.get(position).dimensions;
// Setze Texte des Views
holder.firstLine.setText(this.movieList.get(position).name + " (" + this.movieList.get(position).year + ")");
holder.secondLine.setText("Rating: " + this.movieList.get(position).rating);
holder.thirdLine.setText("Laufzeit: " + this.movieList.get(position).duration/60 + " Min");
File cover = new File(this.coverFolder + movieList.get(position).imdbID + ".jpg");
File fallbackCover = new File(this.coverFolder + "0000000.jpg");
Bitmap fallbackCoverBitmap = BitmapFactory.decodeFile(fallbackCover.getAbsolutePath());
//Bearbeite Bild des Layouts
if (cover.exists()) {
Bitmap coverBitmap = BitmapFactory.decodeFile(cover.getAbsolutePath());
holder.cover.setImageBitmap(coverBitmap);
} else if (fallbackCover.exists()) {
holder.cover.setImageBitmap(fallbackCoverBitmap);
} else {
holder.cover.setImageResource(R.drawable.android);
}
// verstecke oder aktiviere 3D Logo
if (this.movieList.get(position).dimensions.length() == 0) {
holder.dimensionsLogo.setImageDrawable(null);
} else {
holder.dimensionsLogo.setImageResource(R.drawable.logo3d);
}
// setze checked Bild
if (this.movieList.get(position).checked.equals("1")) {
holder.checkedImage.setImageResource(R.drawable.correct);
} else if (this.movieList.get(position).checked.equals("0")) {
holder.checkedImage.setImageResource(R.drawable.wrong);
} else {
holder.checkedImage.setImageDrawable(null);
}
// setzte view count
holder.viewCount.setText(String.valueOf(this.movieList.get(position).views));
}
// iteriert über jedes Element des String-Arrays (position) ist Array-Index
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //hole den LayoutInflater
convertView = inflater.inflate(R.layout.list_element, null);//inflate Element
// erstelle ViewHolder, setze Klassenvariablen und füge ihn dem View hinzu
holder = new ViewHolder();
convertView.setTag(holder);
holder.firstLine = (TextView) convertView.findViewById(R.id.firstLine);
holder.secondLine = (TextView) convertView.findViewById(R.id.secondLine);
holder.thirdLine = (TextView) convertView.findViewById(R.id.thirdLine);
holder.cover = (ImageView) convertView.findViewById(R.id.cover);
holder.dimensionsLogo = (ImageView) convertView.findViewById(R.id.movie3dLogo);
holder.checkedImage = (ImageView) convertView.findViewById(R.id.checkedImage);
holder.viewCount = (TextView) convertView.findViewById(R.id.viewCount);
// führe Funktion zum Anpassen des Views aus
setValues(holder, position);
// setze onClickListener ... ändert sich nie, deshalb nur beim Initialisieren
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewHolder holder = (ViewHolder) v.getTag();
FragmentManager fragmentManager = ((Activity) context).getFragmentManager();
MovieDetailedFragment movieDetailedFragment = new MovieDetailedFragment();
movieDetailedFragment.setImdbID(holder.imdbID);
if (holder.dimensions.length() == 0) {
movieDetailedFragment.setDimensions(0);
} else {
movieDetailedFragment.setDimensions(1);
}
fragmentManager.beginTransaction().replace(R.id.mainContent, movieDetailedFragment).addToBackStack("movieDetailsFragment").commit();
}
});
} else {
holder = (ViewHolder) convertView.getTag();
setValues(holder, position);
}
return convertView;
}
private class ViewHolder {
public TextView firstLine;
public TextView secondLine;
public TextView thirdLine;
public ImageView cover;
public ImageView dimensionsLogo;
public ImageView checkedImage;
public TextView viewCount;
public String imdbID; // wird gebraucht, damit bei onClick event die imdbID ausgelesen werden kann
public String dimensions; // wird gebraucht, damit bei onClick event die imdbID ausgelesen werden kann
}
}
package com.example.markus.mediadbviewer;
import android.util.Log;
import java.util.Arrays;
public class MovieQueryFactory {
private String url=""; // finale URL
private String rootURL = "http://mediadb.ivaya.de/api.php"; // später aus Einstellungen
private String apiKey = "0123456789"; // später aus Einstellungen
private String[] validColumns = new String[]{"imdbID", "name", "year", "size", "md5", "3d", "vcodec", "duration", "totalbitrate", "resolution",
"width", "height", "acodecger", "abitrateger", "channelsger", "acodeceng", "abitrateeng", "channelseng", "hdd", "rating",
"checked", "views", "comment", "added", "lastView", "Genre", "Schauspieler"};
private String[] validConditions = new String[]{"Anzahl", "imdbID", "Suche", "3d", "Genre", "Schauspieler"};
private String[] validGenres = new String[]{"Action", "Adventure", "Animation", "Biography", "Comedy", "Crime", "Documentary", "Drama", "Family",
"Fantasy", "History", "Horror", "Music", "Musical", "Mystery", "Romance", "Sci-Fi", "Short", "Sport", "Thriller", "War", "Western"};
private String[] validDirections = new String[]{"ASC", "DESC", "asc", "desc", "Asc", "Desc"};
private String columns = "";
private String conditions = "";
private String order = "";
public MovieQueryFactory() {
this.url += this.rootURL;
this.url += "?key=";
this.url += this.apiKey;
this.url += "&action=GetDataList";
this.url += "&Tabelle=Filme";
}
// prüft Spalten und füge sie hinzu
public void addColumns(String[] columns) {
for (String column : columns) {
if (Arrays.asList(this.validColumns).contains(column)) {
if (this.columns.length() == 0) {
this.columns += column;
} else {
this.columns += ",";
this.columns += column;
}
} else {
Log.d("DEBUG", "MovieQueryFactory: unknown column " + column);
}
}
}
// füge Bedingungen zu Abfrage hinzu
// werden wie folgt angegeben: imdbID=1234567
public void addConditions(String[] conditions) {
for (String condition : conditions) {
/*
if (Arrays.asList(this.validConditions).contains(condition.split("=")[0])) {
if (condition.split("=").length == 2) {
if (condition.split("=")[0]=="3d") {
if ((Integer.valueOf(condition.split("=")[1]) != 1) && (Integer.valueOf(condition.split("=")[1]) != 1)) {
Log.d("DEBUG", "MovieQueryFactory: wrong value " + condition.split("=")[1] + "for 3d filter");
} else {
this.conditions += "&" + condition;
}
} else {
this.conditions += "&" + condition;
}
} else {
Log.d("DEBUG", "MovieQueryFactory: no value assigned to condition " + condition);
}
} else {
Log.d("DEBUG", "MovieQueryFactory: unknown condition " + condition);
}
*/
this.conditions += "&" + condition;
}
}
// füge Sortierung zur Abfrage hinzu
public void setOrder(String column, String direction) {
if (this.order.length() == 0) {
if (Arrays.asList(this.validColumns).contains(column)) {
if (Arrays.asList(this.validDirections).contains(direction)) {
this.order += "&Sortierung=" + column + "%20" + direction;
} else {
Log.d("DEBUG", "MovieQueryFactory: invalid direction '" + direction + "'for ordering ");
}
} else {
Log.d("DEBUG", "MovieQueryFactory: invalid column " + column + " for ordering");
}
} else {
Log.d("DEBUG", "MovieQueryFactory: order clause already set - ignoring " + column + " " + direction);
}
}
// erstelle URL
public String getUrl () {
// füge Spalten zur URL hinzu
if (this.columns.length() != 0) {
this.url += "&Spalten=";
this.url += this.columns;
}
// füge Bedingungen zur URL hinzu
if (this.conditions.length() != 0) {
this.url += this.conditions;
}
// füge Sortierung zur URL hinzu
if (this.order.length() != 0) {
this.url += this.order;
}
Log.d("INFO", "MovieQueryFactory: build URL " + url);
return this.url;
}
}
package com.example.markus.mediadbviewer;
import android.view.View;
/**
* Created by markus on 13.01.16.
*/
public class MovieViewOnClickListener implements View.OnClickListener {
public void onClick(View v) {
}
}
package com.example.markus.mediadbviewer;
class NavigationbarIcon {
String mTitle;
String mSubtitle;
int mIcon;
public NavigationbarIcon(String title, String subtitle, int icon) {
mTitle = title;
mSubtitle = subtitle;
mIcon = icon;
}
}
\ No newline at end of file
package com.example.markus.mediadbviewer;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.TextView;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class SeasonArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private ArrayList<MediaObject> seasonList = new ArrayList<MediaObject>();
private String coverFolderSeasons = MainActivity.rootCoverFolder + "Staffeln/low/";
private String coverFolderSeries = MainActivity.rootCoverFolder + "Serien/low/";
public SeasonArrayAdapter (Context context, List seasonList) {
super(context, -1, seasonList);
this.seasonList = (ArrayList<MediaObject>) seasonList;
this.context = context;
}
private void setValues(ViewHolder holder, int position) {
// setzt season_nr für ViewHolder
holder.season_nr = this.seasonList.get(position).season_nr;
// Setze Texte des Views
holder.firstLine.setText("Staffel " + this.seasonList.get(position).season + " (" + this.seasonList.get(position).resolution + ") (" + this.seasonList.get(position).sound + ") (" + this.seasonList.get(position).source + ")");
holder.secondLine.setText("Größe: " + String.valueOf(Math.round(this.seasonList.get(position).Size/Math.pow(1024,3)*100)/100.) + " GB");
holder.thirdLine.setText("Laufzeit: " + String.valueOf(this.seasonList.get(position).Duration/60) + " Min");
if (new File(this.coverFolderSeasons + this.seasonList.get(position).season_nr + ".jpg").exists()) {
holder.cover.setImageDrawable(Drawable.createFromPath(this.coverFolderSeasons + this.seasonList.get(position).season_nr + ".jpg"));
} else if (new File(this.coverFolderSeries + this.seasonList.get(position).series_nr + ".jpg").exists()) {
holder.cover.setImageDrawable(Drawable.createFromPath(this.coverFolderSeries + this.seasonList.get(position).series_nr + ".jpg"));
} else {
holder.cover.setImageResource(R.drawable.android);
}
// setze checked Bild
if (this.seasonList.get(position).Checked.equals("1.0000")) {
holder.checkedImage.setImageResource(R.drawable.correct); // alles ganz
} else if (this.seasonList.get(position).Checked.equals("0.0000")) {
holder.checkedImage.setImageResource(R.drawable.wrong); // alles defekt
} else if (this.seasonList.get(position).Checked.length() == 0) {
holder.checkedImage.setImageDrawable(null); // noch nicht geprüft
} else {
holder.checkedImage.setImageResource(R.drawable.yellowdot); // teilweise defekt
}
// setzte view count
holder.viewCount.setText(String.valueOf(Math.round(this.seasonList.get(position).Views*100)/100.));
}
// iteriert über jedes Element des String-Arrays (position) ist Array-Index
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //hole den LayoutInflater
convertView = inflater.inflate(R.layout.list_element, null);//inflate Element
// erstelle ViewHolder, setze Klassenvariablen und füge ihn dem View hinzu
holder = new ViewHolder();
convertView.setTag(holder);
holder.firstLine = (TextView) convertView.findViewById(R.id.firstLine);
holder.secondLine = (TextView) convertView.findViewById(R.id.secondLine);
holder.thirdLine = (TextView) convertView.findViewById(R.id.thirdLine);
holder.cover = (ImageView) convertView.findViewById(R.id.cover);
holder.checkedImage = (ImageView) convertView.findViewById(R.id.checkedImage);
holder.viewCount = (TextView) convertView.findViewById(R.id.viewCount);
// führe Funktion zum Anpassen des Views aus
setValues(holder, position);
// setze onClickListener ... ändert sich nie, deshalb nur beim Initialisieren
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewHolder holder = (ViewHolder) v.getTag();
FragmentManager fragmentManager = ((Activity) context).getFragmentManager();
EpisodeListFragment episodeListFragment = new EpisodeListFragment();
episodeListFragment.setSeason_nr(holder.season_nr);
fragmentManager.beginTransaction().replace(R.id.mainContent, episodeListFragment).addToBackStack("episodeListFragment").commit();
}
});
} else {
holder = (ViewHolder) convertView.getTag();
setValues(holder, position);
}
return convertView;
}
private class ViewHolder {
public TextView firstLine;
public TextView secondLine;
public TextView thirdLine;
public ImageView cover;
public ImageView checkedImage;
public TextView viewCount;
public int season_nr;
}
}
\ No newline at end of file
package com.example.markus.mediadbviewer;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import java.util.ArrayList;
public class SeasonListFragment extends ListFragment {
private ArrayList<MediaObject> seasonList = new ArrayList<MediaObject>();
private int series_nr;
public void setSeries_nr(int series_nr) {
this.series_nr = series_nr;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View fragment = inflater.inflate(R.layout.list_fragment, container, false); //wendet layout an
final ListView seasonListView = (ListView) fragment.findViewById(android.R.id.list); //hole Referenz auf ListView
// hole Daten für seasonListView
SeriesQueryFactory seasonQueryFactory = new SeriesQueryFactory("Staffeln");
updateSeasonListView(seasonQueryFactory, seasonListView);
return fragment;
}
private void updateSeasonListView (SeriesQueryFactory seasonQueryFactory, ListView listView) {
// notwendige Spalten für ListView können zentral hier geändert werden
seasonQueryFactory.addColumns(new String[]{"season", "resolution", "sound", "source", "season_nr", "series_nr", "checked", "Statistik"});
seasonQueryFactory.addConditions(new String[]{"series_nr=" + this.series_nr});
seasonQueryFactory.setOrder("season", "ASC");
JSONParser parser = new JSONParser();
try {
parser.execute(new String[]{seasonQueryFactory.getUrl()}).get();
} catch (Exception e) {
}
this.seasonList = parser.getMediaList();
// setzen des ArrayAdapters
SeasonArrayAdapter seasonArrayAdapter = new SeasonArrayAdapter(getActivity(), this.seasonList);
listView.setAdapter(seasonArrayAdapter);
}
@Override
public void onResume() {
super.onResume();
getActivity().setTitle("Staffeln (" + this.seasonList.size() + ")");
}
}
package com.example.markus.mediadbviewer;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class SeriesArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private ArrayList<MediaObject> seriesList = new ArrayList<MediaObject>();
private String coverFolder = MainActivity.rootCoverFolder + "Serien/low/";
public SeriesArrayAdapter (Context context, List seriesList) {
super(context, -1, seriesList);
this.seriesList = (ArrayList<MediaObject>) seriesList;
this.context = context;
}
private void setValues(ViewHolder holder, int position) {
// setzt imdbID für ViewHolder
holder.series_nr = this.seriesList.get(position).series_nr;
// Setze Texte des Views
holder.firstLine.setText(this.seriesList.get(position).name);
holder.secondLine.setText("Größe: " + String.valueOf(Math.round(this.seriesList.get(position).Size/Math.pow(1024,3)*100)/100.) + " GB");
holder.thirdLine.setText("Laufzeit: " + String.valueOf(this.seriesList.get(position).Duration/60) + " Min");
if (new File(this.coverFolder + this.seriesList.get(position).series_nr + ".jpg").exists()) {
holder.cover.setImageDrawable(Drawable.createFromPath(this.coverFolder + this.seriesList.get(position).series_nr + ".jpg"));
} else {
holder.cover.setImageResource(R.drawable.android);
Log.d("INFO", this.coverFolder + this.seriesList.get(position).series_nr + ".jpg" + " does not exist");
}
// setze checked Bild
if (this.seriesList.get(position).Checked.equals("1.0000")) {
holder.checkedImage.setImageResource(R.drawable.correct); // alles ganz
} else if (this.seriesList.get(position).Checked.equals("0.0000")) {
holder.checkedImage.setImageResource(R.drawable.wrong); // alles defekt
} else if (this.seriesList.get(position).Checked.length() == 0) {
holder.checkedImage.setImageDrawable(null); // noch nicht geprüft
} else {
holder.checkedImage.setImageResource(R.drawable.yellowdot); // teilweise defekt
}
// setzte view count
holder.viewCount.setText(String.valueOf(Math.round(this.seriesList.get(position).Views*100)/100.));
}
// iteriert über jedes Element des String-Arrays (position) ist Array-Index
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //hole den LayoutInflater
convertView = inflater.inflate(R.layout.list_element, null);//inflate Element
// erstelle ViewHolder, setze Klassenvariablen und füge ihn dem View hinzu
holder = new ViewHolder();
convertView.setTag(holder);
holder.firstLine = (TextView) convertView.findViewById(R.id.firstLine);
holder.secondLine = (TextView) convertView.findViewById(R.id.secondLine);
holder.thirdLine = (TextView) convertView.findViewById(R.id.thirdLine);
holder.viewCount = (TextView) convertView.findViewById(R.id.viewCount);
holder.cover = (ImageView) convertView.findViewById(R.id.cover);
holder.checkedImage = (ImageView) convertView.findViewById(R.id.checkedImage);
// führe Funktion zum Anpassen des Views aus
setValues(holder, position);
// setze onClickListener ... ändert sich nie, deshalb nur beim Initialisieren
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewHolder holder = (ViewHolder) v.getTag();
FragmentManager fragmentManager = ((Activity) context).getFragmentManager();
SeasonListFragment seasonListFragment = new SeasonListFragment();
seasonListFragment.setSeries_nr(holder.series_nr);
fragmentManager.beginTransaction().replace(R.id.mainContent, seasonListFragment).addToBackStack("seasonFragment").commit();
}
});
} else {
holder = (ViewHolder) convertView.getTag();
setValues(holder, position);
}
return convertView;
}
private class ViewHolder {
public TextView firstLine;
public TextView secondLine;
public TextView thirdLine;
public TextView viewCount;
public ImageView checkedImage;
public ImageView cover;
public int series_nr;
}
}
package com.example.markus.mediadbviewer;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import java.util.ArrayList;
public class SeriesListFragment extends ListFragment {
private ArrayList<MediaObject> seriesList = new ArrayList<MediaObject>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View fragment = inflater.inflate(R.layout.list_fragment, container, false); //wendet layout an
final ListView seriesListView = (ListView) fragment.findViewById(android.R.id.list); //hole Referenz auf ListView
// hole Daten für seriesListView
SeriesQueryFactory seriesQueryFactory = new SeriesQueryFactory("Serien");
updateSeriesListView(seriesQueryFactory, seriesListView);
return fragment;
}
private void updateSeriesListView (SeriesQueryFactory seriesQueryFactory, ListView listView) {
// notwendige Spalten für ListView können zentral hier geändert werden
seriesQueryFactory.addColumns(new String[]{"name", "finished", "series_nr", "Statistik"});
seriesQueryFactory.setOrder("name", "ASC");
JSONParser parser = new JSONParser();
try {
parser.execute(new String[]{seriesQueryFactory.getUrl()}).get();
} catch (Exception e) {
}
this.seriesList = parser.getMediaList();
// setzen des ArrayAdapters
SeriesArrayAdapter seriesArrayAdapter = new SeriesArrayAdapter(getActivity(), this.seriesList);
listView.setAdapter(seriesArrayAdapter);
}
@Override
public void onResume() {
super.onResume();
getActivity().setTitle("Serien (" + this.seriesList.size() + ")");
}
}
package com.example.markus.mediadbviewer;
import android.util.Log;
import java.util.Arrays;
public class SeriesQueryFactory {
private String url=""; // finale URL
private String rootURL = "http://mediadb.ivaya.de/api.php"; // später aus Einstellungen
private String apiKey = "0123456789"; // später aus Einstellungen
private String table = "";
private String columns = "";
private String conditions = "";
private String order = "";
private String[] validTables = new String[]{"Serien", "Staffeln", "Episoden"};
private String[] validColumnsSerien = new String[]{"name", "finished", "series_nr", "Statistik"};
private String[] validColumnsStaffeln = new String[]{"season", "resolution", "sound", "source", "checked", "comment", "series_nr", "season_nr", "Statistik"};
private String[] validColumnsEpisoden = new String[]{"episodenumber", "name", "size", "duration", "md5", "vcodec", "width", "height", "totalbitrate", "acodecger",
"abitrateger", "channelsger", "acodeceng", "abitrateeng", "channelseng", "hdd", "comment", "checked", "added", "season_nr", "series_nr"};
private String[] validConditionsStaffeln = new String[]{"series_nr", "season_nr"};
private String[] validConditionsEpisoden = new String[]{"season_nr", "episodenumber"};
// erstelle Objekt und setze Tabelle, falls gültig
public SeriesQueryFactory(String table) {
if (Arrays.asList(this.validTables).contains(table)) {
this.table = table;
} else {
Log.d("DEBUG", "invalid table " + table);
}
this.url += this.rootURL;
this.url += "?key=";
this.url += this.apiKey;
this.url += "&action=GetDataList";
}
// füge Spalten zur Abfrage hinzu
public void addColumns (String[] columns) {
for (String column : columns) {
if (this.table.length() != 0) {
if ((this.table.equals("Serien") && Arrays.asList(this.validColumnsSerien).contains(column)) || (this.table.equals("Staffeln") && Arrays.asList(this.validColumnsStaffeln).contains(column)) || (this.table.equals("Episoden") && Arrays.asList(this.validColumnsEpisoden).contains(column))) {
if (this.columns.length() == 0) {
this.columns += column;
} else {
this.columns += ",";
this.columns += column;
}
} else {
Log.d("DEBUG", "SeriesQueryFactory: invalid column " + column + " for table " + this.table);
}
} else {
Log.d("DEBUG", "SeriesQueryFactory: cant set column " + column + " - no table selected");
}
}
}
// füge Bedingungen zur Abfrage hinzu
public void addConditions (String[] conditions) {
for (String condition : conditions) {
if (this.table.length() != 0) {
if ((this.table.equals("Staffeln") && Arrays.asList(validConditionsStaffeln).contains(condition.split("=")[0])) || (this.table.equals("Episoden") && Arrays.asList(validConditionsEpisoden).contains(condition.split("=")[0]))) {
this.conditions += "&" + condition;
} else {
Log.d("DEBUG", "SeriesQueryFactory: invalid condition " + condition + " for table " + this.table);
}
} else {
Log.d("DEBUG", "SeriesQueryFactory: cant set condition " + condition + " - no table selected");
}
}
}
// setze Sortierreihenfolge ... noch zu implementieren !!!
public void setOrder (String order, String direction) {
if (this.table.length() != 0) {
this.order = "&Sortierung=" + order + "%20" + direction;
}
}
// erstelle URL
public String getUrl () {
if (this.table.length() != 0) {
// füge Tabelle zur URL hinzu
this.url += "&Tabelle=" + this.table;
// füge Spalten zur URL hinzu
if (this.columns.length() != 0) {
this.url += "&Spalten=";
this.url += this.columns;
}
// füge Bedingungen zur URL hinzu
if (this.conditions.length() != 0) {
this.url += this.conditions;
}
// füge Sortierung zur URL hinzu
if (this.order.length() != 0) {
this.url += this.order;
}
Log.d("INFO", "SeriesQueryFactory: build URL " + url);
return this.url;
} else {
Log.d("DEBUG", "SeriesQueryFactory: error building url, no table set");
return "";
}
}
}
package com.example.markus.mediadbviewer;
import android.os.AsyncTask;
import android.util.Log;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class TableUpdater extends AsyncTask<String, String, String> {
private String rootURL = "http://mediadb.ivaya.de/api.php?key=0123456789&action=SetData"; // über Einstellungen
private String conditions = "";
private StringBuffer response = new StringBuffer();
public String getResponse() {
return this.response.toString();
}
@Override
protected String doInBackground(String[] links) {
try {
URL url = new URL(this.rootURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
//connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
// Send post request
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.writeBytes(this.conditions);
out.flush();
out.close();
//int responseCode = connection.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
} catch (Exception e) {
Log.d("Exception", e.getMessage());
}
return this.response.toString();
}
}
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/listCover"/>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/movieDetailedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Attribute vim LinearLayout müssen exakt so gesetzt werden, damit die ScrollView funktioniert-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/movieTitleDetailed"
android:textSize="30sp"
android:textAlignment="center"
android:textStyle="bold"
android:textColor="#000000"
android:paddingTop="6sp"
android:paddingBottom="6sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ImageView
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/detailedCover"/>
<TableLayout
android:id="@+id/movieTable"
android:paddingTop="10sp"
android:paddingBottom="10sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingBottom="10dp">
<ImageView
android:id="@+id/icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="@drawable/android"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginRight="20dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:gravity="center_vertical"
android:textColor="#000"
android:text="Line 1"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/icon"
android:layout_toEndOf="@+id/icon" />
<TextView android:id="@+id/subTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Line 2"
android:layout_toRightOf="@+id/icon"
android:layout_below="@+id/title"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/seasonCover"/>
<!-- ListFrame setzt diese ID voraus-->
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/downloadButton"
android:onClick="downloadCover"
android:text="Aktualisiere Cover"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
\ No newline at end of file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/movieListElementLayout"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:padding="1dip" >
<!-- alle Infoelemente -->
<LinearLayout
android:id="@+id/infoElement"
android:layout_width="27dp"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView android:id="@+id/viewCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="4dp"/>
<ImageView
android:id="@+id/checkedImage"
android:paddingLeft="1dp"
android:layout_width="match_parent"
android:layout_height="15sp"/>
</LinearLayout>
<ImageView
android:id="@+id/cover"
android:layout_width="60dp"
android:layout_height="90dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:layout_toRightOf="@id/infoElement"/>
<LinearLayout
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="10dp">
<TextView
android:id="@+id/firstLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:gravity="center_vertical"
android:textColor="#000"
android:text="Line 1"
android:textStyle="bold"
android:layout_centerVertical="true"/>
<TextView android:id="@+id/secondLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/thirdLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="30dp"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- PLatzhalter, damit 3D Logo unten rechts erscheint-->
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<ImageView
android:id="@+id/movie3dLogo"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listFragmentLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- ListFrame setzt diese ID voraus-->
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
/>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="2mm"
android:paddingRight="2mm"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/firstColumnDetailed"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
android:layout_gravity="start"
android:textStyle="bold"
android:textSize="18sp"
android:text="Kein Text"/>
<!-- layout_weight ermöglicht Umbruch der Daten im TextView-->
<TextView
android:id="@+id/secondColumnDetailed"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_width="0dp"
android:paddingLeft="10sp"
android:textSize="18sp"
android:text="Kein Text"/>
</TableRow>
\ No newline at end of file
<menu 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"
tools:context="com.example.markus.mediadbviewer.MainActivity">
<!--
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />-->
<item
android:id="@+id/action_search"
android:icon="@android:drawable/ic_menu_search"
android:visible="false"
app:showAsAction="always"
android:title="Search"/>
</menu>
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="red">#FF0000</color>
<color name="green">#00FF00</color>
<color name="filterBar">#DDDDDD</color>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="list_height">120dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
<resources>
<string name="app_name">MediaDB Viewer</string>
<string name="action_settings">Settings</string>
<string name="hello_blank_fragment">Hello Fragment</string>
<string name="title_activity_movie_list">MovieListActivity</string>
<string name="navigation_drawer_open">Öffnen</string>
<string name="navigation_drawer_close">Schließen</string>
<string name="movieSearchFieldHint">Suchkriterium</string>
<string name="movieActorSearchFieldHint">Schauspieler</string>
<string name="movieSortText">Sortierung</string>
<string name="movieFilterButtonText">Anwenden</string>
<string name="movie3DText">3D</string>
<string name="movieGenreText">Genre</string>
<string name="movieLanguageText">Sprache</string>
<string name="movieAcodecgerText">Audiocodec Ger</string>
<string name="movieAcodecengText">Audiocodec Eng</string>
<string name="movieVcodecText">Video Container</string>
<string name="movieResolutionText">Auflösung</string>
<string name="movieChannelsgerText">Audiokanäle Ger</string>
<string name="movieChannelsengText">Audiokanäle Eng</string>
<string name="movieHddText">Festplatte</string>
<string name="movieCheckedText">Geprüft</string>
<string name="movieYearFilterHeaderHidden">Erscheinungsjahr [einblenden]</string>
<string name="yearFilterHeaderShown">Erscheinungsjahr [ausblenden]</string>
<string name="alternative">ODER</string>
<string name="movieYearAbsoluteText">Jahr = </string>
<string name="movieYearAbsoluteHint">z.B.: 2015</string>
<string name="movieYearLowerBoundHint">z.B.: 2010</string>
<string name="movieYearUpperBoundHint">z.B.: 2014</string>
<string name="movieYearRangeText"> &lt;= Jahr &lt;= </string>
<string name="movieSizeFilterHeaderHidden">Größe [einblenden]</string>
<string name="movieSizeFilterHeaderShown">Größe [ausblenden]</string>
<string name="movieSizeLowerBoundHint">z.B.: 5.01 [GB]</string>
<string name="movieSizeUpperBoundHint">z.B.: 8.99 [GB]</string>
<string name="movieSizeRangeText"> &lt;= Größe &lt;= </string>
<string-array name="directionSpinner">
<item>auf</item>
<item>ab</item>
</string-array>
<string-array name="categorySpinner">
<item>Name</item>
<item>Jahr</item>
<item>Laufzeit</item>
<item>Rating</item>
<item>Hinzugefügt</item>
<item>Größe</item>
<item>Views</item>
<item>Gesehen</item>
</string-array>
<string-array name="dimensionsSpinner">
<item>beliebig</item>
<item>3D</item>
<item>nicht 3D</item>
</string-array>
<string-array name="genreSpinner">
<item>beliebig</item>
<item>Action</item>
<item>Adventure</item>
<item>Animation</item>
<item>Biography</item>
<item>Comedy</item>
<item>Crime</item>
<item>Documentary</item>
<item>Drama</item>
<item>Family</item>
<item>Fantasy</item>
<item>History</item>
<item>Horror</item>
<item>Music</item>
<item>Musical</item>
<item>Mystery</item>
<item>Romance</item>
<item>Sci-Fi</item>
<item>Short</item>
<item>Sport</item>
<item>Thriller</item>
<item>War</item>
<item>Western</item>
</string-array>
<string-array name="languageSpiiner">
<item>beliebig</item>
<item>Englisch</item>
<item>nur Deutsch</item>
</string-array>
<string-array name="acodecSpinner">
<item>beliebig</item>
<item>"AC-3"</item>
<item>"DTS"</item>
<item>"MPEG Audio</item>
<item>"Vorbis"</item>
</string-array>
<string-array name="vcodecSpinner">
<item>beliebig</item>
<item>AVI</item>
<item>DivX</item>
<item>Flash Video</item>
<item>mkv</item>
<item>MPEG-4</item>
<item>MPEG-PS</item>
</string-array>
<string-array name="resolutionSpinner">
<item>beliebig</item>
<item>SD</item>
<item>720p</item>
<item>1080p</item>
</string-array>
<string-array name="channelsSpinner">
<item>beliebig</item>
<item>1</item>
<item>2</item>
<item>6</item>
<item>8</item>
</string-array>
<string-array name="hddSpinner">
<item>beliebig</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
</string-array>
<string-array name="checkedSpinner">
<item>beliebig</item>
<item>nicht geprüft</item>
<item>fehlerfrei</item>
<item>fehlerhaft</item>
</string-array>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
package com.example.markus.mediadbviewer;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// 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.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# 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
\ No newline at end of file
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
#!/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
# 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\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
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"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# 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 "$@"
@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
include ':app'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment