diff --git a/.gitignore b/.gitignore
index 9a8c230..1254948 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,4 +56,7 @@ crashlytics-build.properties
com_crashlytics_export_strings.xml
# Fabric
-fabric.properties
\ No newline at end of file
+fabric.properties
+
+# Keystore
+keystore.properties
\ No newline at end of file
diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
deleted file mode 100644
index 719bb8b..0000000
--- a/.idea/codeStyleSettings.xml
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
deleted file mode 100644
index 96cc43e..0000000
--- a/.idea/compiler.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
deleted file mode 100644
index 7ac24c7..0000000
--- a/.idea/gradle.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 5d19981..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 54b7b3f..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460..0000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index e3f632e..316dbc6 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,8 +1,37 @@
+def VERSION_MAJOR = 1
+def VERSION_MINOR = 5
+def VERSION_PATCH = 1
+def VERSION_BUILD = 1
+def VERSION_CODE = VERSION_MAJOR * 10000 + VERSION_MINOR * 1000 + VERSION_PATCH * 100 + VERSION_BUILD
+def logging = true
+
apply plugin: 'com.android.application'
+def keystorePropertiesFile = rootProject.file("keystore.properties")
+def keystoreProperties = new Properties()
+keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
+
+
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
+
+ //distinguish apk file name between different versions and builds
+ applicationVariants.all { variant ->
+ variant.outputs.each { output ->
+ output.outputFile = new File(
+ output.outputFile.parent,
+ "$project.name-$variant.name-$variant.versionName-${variant.versionName}.apk")
+ }
+ }
+ signingConfigs {
+ release {
+ keyAlias keystoreProperties['keyAlias']
+ keyPassword keystoreProperties['keyPassword']
+ storeFile file(keystoreProperties['storeFile'])
+ storePassword keystoreProperties['storePassword']
+ }
+ }
defaultConfig {
applicationId "cz.muni.fi.pv256.movio2.uco_422678"
minSdkVersion 17
@@ -10,12 +39,39 @@ android {
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ //leave only the necessary resources in the apk
+ resConfigs "sk", "en"
+
+ versionCode VERSION_CODE
+ versionName "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
+ debug {
+ versionNameSuffix ".${VERSION_BUILD}-${VERSION_CODE}"
+ buildConfigField "boolean", "REPORT_CRASHES", "false"
+ }
+ }
+ productFlavors {
+ primary {
+ logging=true
+ resValue "string", "app_name", "Movio2"
+ }
+ secondary {
+ logging=false
+ applicationIdSuffix ".secondary"
+ resValue "string", "app_name", "Movio2(secret flavor)"
+ }
+ }
+ sourceSets.primary{
+ res.srcDirs = ['res', 'src/main/res']
+ }
+ sourceSets.secondary{
+ res.srcDirs = ['res', 'src/secondary/res']
}
}
@@ -26,7 +82,15 @@ dependencies {
})
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
+ compile 'com.android.support:design:26.+'
+ compile 'com.squareup.okhttp3:okhttp:3.9.1'
+ compile 'com.google.code.gson:gson:2.8.2'
+ compile 'com.squareup.picasso:picasso:2.5.2'
+ compile 'com.squareup.retrofit2:retrofit:2.3.0'
+ compile 'com.squareup.retrofit2:converter-gson:2.3.0'
+ compile 'joda-time:joda-time:2.9.9'
testCompile 'junit:junit:4.12'
+ compile "com.android.support:support-core-utils:26.1.0"
}
allprojects {
diff --git a/app/src/androidTest/java/cz/muni/fi/pv256/movio2/MovieManagerTest.java b/app/src/androidTest/java/cz/muni/fi/pv256/movio2/MovieManagerTest.java
new file mode 100644
index 0000000..bfd8285
--- /dev/null
+++ b/app/src/androidTest/java/cz/muni/fi/pv256/movio2/MovieManagerTest.java
@@ -0,0 +1,49 @@
+package cz.muni.fi.pv256.movio2;
+
+import android.test.AndroidTestCase;
+import android.util.Log;
+import java.util.ArrayList;
+
+import cz.muni.fi.pv256.movio2.uco_422678.Movie;
+import cz.muni.fi.pv256.movio2.uco_422678.MovieContract;
+import cz.muni.fi.pv256.movio2.uco_422678.MovieDBHelper;
+import cz.muni.fi.pv256.movio2.uco_422678.MovieManagerImpl;
+
+/**
+ * Created by BranislavSmik on 1/11/2018.
+ */
+
+public class MovieManagerTest extends AndroidTestCase {
+ private static final String TAG = MovieManagerImpl.class.getSimpleName();
+
+ private MovieManagerImpl mManager;
+
+ @Override
+ protected void setUp() throws Exception {
+ mManager = new MovieManagerImpl((new MovieDBHelper(mContext)).getWritableDatabase());
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ mContext.getContentResolver().delete(
+ MovieContract.MovieEntry.CONTENT_URI,
+ null,
+ null
+ );
+ }
+
+ public void testAddMovie() throws Exception {
+ Movie expected = createMovie("testTitle", 1500260033l, "test-cover", "test-backdrop", 5.3f , "description of the test");
+ mManager.createMovie(expected);
+ ArrayList saved = (ArrayList)mManager.getSavedMovies();
+
+ Log.d(TAG, saved.get(0).toString());
+ assertTrue(saved.size() == 1);
+ assertEquals(expected, saved.get(0));
+ }
+
+ private Movie createMovie(String title, Long release, String cover, String backdrop, float rating, String overview) {
+ Movie m = new Movie(123l, release, cover, backdrop, title, overview, rating);
+ return m;
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 0199761..e7a35c1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,6 +1,14 @@
+ package="cz.muni.fi.pv256.movio2">
+
+
+
+
+
+
+
+
-
+ android:theme="@style/SecondTheme"
+ android:name=".App">
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/cz/muni/fi/pv256/movio2/App.java b/app/src/main/java/cz/muni/fi/pv256/movio2/App.java
index 0c93b1c..a34aa74 100644
--- a/app/src/main/java/cz/muni/fi/pv256/movio2/App.java
+++ b/app/src/main/java/cz/muni/fi/pv256/movio2/App.java
@@ -17,6 +17,7 @@ public void onCreate() {
}
}
+
private void initStrictMode() {
StrictMode.ThreadPolicy.Builder tpb = new StrictMode.ThreadPolicy.Builder()
.detectAll()
diff --git a/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/AbstractDataLoader.java b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/AbstractDataLoader.java
new file mode 100644
index 0000000..bf7eb07
--- /dev/null
+++ b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/AbstractDataLoader.java
@@ -0,0 +1,106 @@
+package cz.muni.fi.pv256.movio2.uco_422678;
+
+import java.util.List;
+import android.content.Context;
+import android.support.v4.content.AsyncTaskLoader;
+
+/**
+ * Created by BranislavSmik on 12/13/2017.
+ */
+
+public abstract class AbstractDataLoader> extends
+ AsyncTaskLoader {
+ protected E mLastDataList = null;
+ protected abstract E buildList();
+ public AbstractDataLoader(Context context) {
+ super(context);
+ }
+ /**
+ * Runs on a worker thread, loading in our data. Delegates the real work to
+ * concrete subclass' buildList() method.
+ */
+ @Override
+ public E loadInBackground() {
+ return buildList();
+ }
+ /**
+ * Runs on the UI thread, routing the results from the background thread to
+ * whatever is using the dataList.
+ */
+ @Override
+ public void deliverResult(E dataList) {
+ if (isReset()) {
+ // An async query came in while the loader is stopped
+ emptyDataList(dataList);
+ return;
+ }
+ E oldDataList = mLastDataList;
+ mLastDataList = dataList;
+ if (isStarted()) {
+ super.deliverResult(dataList);
+ }
+ if (oldDataList != null && oldDataList != dataList
+ && oldDataList.size() > 0) {
+ emptyDataList(oldDataList);
+ }
+ }
+ /**
+ * Starts an asynchronous load of the list data. When the result is ready
+ * the callbacks will be called on the UI thread. If a previous load has
+ * been completed and is still valid the result may be passed to the
+ * callbacks immediately.
+ *
+ * Must be called from the UI thread.
+ */
+ @Override
+ protected void onStartLoading() {
+ if (mLastDataList != null) {
+ deliverResult(mLastDataList);
+ }
+ if (takeContentChanged() || mLastDataList == null
+ || mLastDataList.size() == 0) {
+ forceLoad();
+ }
+ }
+ /**
+ * Must be called from the UI thread, triggered by a call to stopLoading().
+ */
+ @Override
+ protected void onStopLoading() {
+ // Attempt to cancel the current load task if possible.
+ cancelLoad();
+ }
+ /**
+ * Must be called from the UI thread, triggered by a call to cancel(). Here,
+ * we make sure our Cursor is closed, if it still exists and is not already
+ * closed.
+ */
+ @Override
+ public void onCanceled(E dataList) {
+ if (dataList != null && dataList.size() > 0) {
+ emptyDataList(dataList);
+ }
+ }
+ /**
+ * Must be called from the UI thread, triggered by a call to reset(). Here,
+ * we make sure our Cursor is closed, if it still exists and is not already
+ * closed.
+ */
+ @Override
+ protected void onReset() {
+ super.onReset();
+ // Ensure the loader is stopped
+ onStopLoading();
+ if (mLastDataList != null && mLastDataList.size() > 0) {
+ emptyDataList(mLastDataList);
+ }
+ mLastDataList = null;
+ }
+ protected void emptyDataList(E dataList) {
+ if (dataList != null && dataList.size() > 0) {
+ for (int i = 0; i < dataList.size(); i++) {
+ dataList.remove(i);
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/Constants.java b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/Constants.java
new file mode 100644
index 0000000..aa198a2
--- /dev/null
+++ b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/Constants.java
@@ -0,0 +1,15 @@
+package cz.muni.fi.pv256.movio2.uco_422678;
+
+/**
+ * Created by BranislavSmik on 11/26/2017.
+ */
+
+public class Constants {
+ public static final String APIKEYv3 = "80606f918fbd89549fcbb4a0e2782925";
+ public static final String APIKEYv4 = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI4MDYwNmY5MThmYmQ4OTU0OWZjYmI0YTBlMjc4MjkyNSIsInN1YiI6IjU5ZDU0NDg4YzNhMzY4NDU3MjAxYmFjYiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.KCTMoy6eS9chRIUFdGV0KYy6d7Ebx2seEtHL4mrEzHg";
+
+ public static final String QUERY_PARAM_INTHEATRES = "&primary_release_date.gte=2018-01-01&primary_release_date.lte=2018-01-31"; //Just MVP solution
+ public static final String QUERY_PARAM_DRAMA = "&with_genres=18&sort_by=popularity.desc";
+ public static final String URL = "http://api.themoviedb.org/";
+ public static final String PATH = "3/discover/movie?api_key=";
+}
\ No newline at end of file
diff --git a/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/ContentChangingTask.java b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/ContentChangingTask.java
new file mode 100644
index 0000000..4be19c4
--- /dev/null
+++ b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/ContentChangingTask.java
@@ -0,0 +1,22 @@
+package cz.muni.fi.pv256.movio2.uco_422678;
+
+import android.os.AsyncTask;
+import android.support.v4.content.Loader;
+
+
+/**
+ * Created by BranislavSmik on 12/13/2017.
+ */
+abstract class ContentChangingTask extends
+ AsyncTask {
+ private Loader> loader=null;
+
+ ContentChangingTask(Loader> loader) {
+ this.loader=loader;
+ }
+
+ @Override
+ protected void onPostExecute(T3 param) {
+ loader.onContentChanged();
+ }
+}
diff --git a/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/DetailFragment.java b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/DetailFragment.java
new file mode 100644
index 0000000..28b4c60
--- /dev/null
+++ b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/DetailFragment.java
@@ -0,0 +1,106 @@
+package cz.muni.fi.pv256.movio2.uco_422678;
+
+import android.database.sqlite.SQLiteDatabase;
+import java.text.SimpleDateFormat;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.design.widget.FloatingActionButton;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import android.widget.ImageView;
+import android.content.Context;
+import android.widget.Toast;
+
+import cz.muni.fi.pv256.movio2.R;
+import com.squareup.picasso.Picasso;
+
+
+/**
+ * Created by BranislavSmik on 10/19/2017.
+ */
+
+public class DetailFragment extends Fragment {
+ public static final String TAG = DetailFragment.class.getSimpleName();
+ private static final String ARGS_MOVIE = "args_movie";
+ public static final String DATE_FORMAT = "dd.MM.yyyy";
+
+ private Context mContext;
+ private Movie mMovie;
+
+ private SQLiteDatabase mDatabase;
+ private MovieManagerImpl mFilmManager;
+ private MovieDBHelper mDbHelper;
+
+ public static DetailFragment newInstance(Movie movie) {
+ DetailFragment fragment = new DetailFragment();
+ Bundle args = new Bundle();
+ args.putParcelable(ARGS_MOVIE, movie);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mContext = getActivity();
+ Bundle args = getArguments();
+ if (args != null) {
+ mMovie = args.getParcelable(ARGS_MOVIE);
+ }
+
+ mDbHelper = new MovieDBHelper(getActivity());
+ mDatabase = mDbHelper.getWritableDatabase();
+ mFilmManager = new MovieManagerImpl(mDatabase);
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_detail, container, false);
+
+ TextView titleTextView = (TextView) view.findViewById(R.id.movie_title);
+ TextView ratingTextView = (TextView) view.findViewById(R.id.movie_rating);
+ TextView descriptionTextView = (TextView) view.findViewById(R.id.movie_description);
+ TextView releaseDateTextView = (TextView) view.findViewById(R.id.movie_release);
+ ImageView movieImage = (ImageView) view.findViewById(R.id.movie_image);
+
+ final FloatingActionButton floatingActionButton = (FloatingActionButton) view.findViewById(R.id.float_but);
+ floatingActionButton.setImageResource(R.drawable.plus);
+
+ if (mFilmManager.containsMovie(mMovie.getId())) {
+ floatingActionButton.setImageResource(R.drawable.minus);
+ }
+
+ floatingActionButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mFilmManager.containsMovie(mMovie.getId())) {
+ mFilmManager.deleteMovie(mMovie);
+ Toast.makeText(getActivity(), mMovie.getTitle() + " removed from favorites.", Toast.LENGTH_LONG).show();
+ floatingActionButton.setImageResource(R.drawable.plus);
+ } else {
+ mFilmManager.createMovie(mMovie);
+ Toast.makeText(getActivity(), mMovie.getTitle() + " added to favorites.", Toast.LENGTH_LONG).show();
+ floatingActionButton.setImageResource(R.drawable.minus);
+ }
+
+ }
+ });
+
+ if (mMovie != null) {
+ titleTextView.setText(mMovie.getTitle());
+ ratingTextView.setText(Float.toString(mMovie.getPopularity()));
+ descriptionTextView.setText(mMovie.getOverview());
+ Picasso.with(mContext).load("https://image.tmdb.org/t/p/w500/" + mMovie.getBackdrop()).into(movieImage);
+
+ SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
+ releaseDateTextView.setText(dateFormat.format(mMovie.getRealeaseDate()));
+ }
+
+ return view;
+ }
+
+}
diff --git a/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/DownloadService.java b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/DownloadService.java
new file mode 100644
index 0000000..7819a5c
--- /dev/null
+++ b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/DownloadService.java
@@ -0,0 +1,157 @@
+package cz.muni.fi.pv256.movio2.uco_422678;
+
+import android.app.IntentService;
+import android.app.PendingIntent;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.support.annotation.Nullable;
+import android.support.v4.content.LocalBroadcastManager;
+import android.support.v4.app.NotificationCompat;
+import android.content.Intent;
+import android.content.Context;
+import android.util.MalformedJsonException;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Build;
+
+import cz.muni.fi.pv256.movio2.R;
+import retrofit2.Call;
+import retrofit2.Retrofit;
+import retrofit2.converter.gson.GsonConverterFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+/**
+ * Created by BranislavSmik on 12/1/2017.
+ */
+
+public class DownloadService extends IntentService {
+ public static final String ACTION_NEW = "download_new_movies";
+ public static final String ACTION_DRAMA = "download_drama_movies";
+ public static final String ACTION = "download_action";
+ public static final String ERROR = "download_error";
+ public static final String ERROR_PARSE = "parsing_error";
+ public static final String ERROR_CONN = "connection_error";
+ public static final String RESPONSE = "response";
+ public static final String INTENT = "DonwloadService";
+ public static final String CHANNEL = "download_notify";
+
+ private MovieAPI APIservice;
+
+ public DownloadService() {
+ super(DownloadService.class.getSimpleName());
+ }
+
+ public DownloadService(String name) {
+ super(name);
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ APIservice = getMovieAPI();
+ }
+
+ @Override
+ protected void onHandleIntent(Intent intent) {
+ String action = intent.getAction();
+ downloadingNotification();
+
+ try {
+ if(action == ACTION_NEW) {
+ Call requestNew = APIservice.getMovieList(Constants.QUERY_PARAM_INTHEATRES);
+ MovieList newMovies = requestNew.execute().body();
+ broadcastMovieList(new ArrayList(newMovies.getResults()), action);
+
+ } else if(action == ACTION_DRAMA) {
+ Call requestDrama = APIservice.getMovieList(Constants.QUERY_PARAM_DRAMA);
+ MovieList dramaMovies = requestDrama.execute().body();
+ broadcastMovieList(new ArrayList(dramaMovies.getResults()), action);
+ }
+ } catch (MalformedJsonException e) {
+ broadcastMovieListError(ERROR_PARSE);
+ e.printStackTrace();
+ return;
+ } catch (IOException e) {
+ broadcastMovieListError(ERROR_CONN);
+ e.printStackTrace();
+ return;
+ }
+
+ downloadingEndNotification();
+ }
+
+ private void broadcastMovieList(ArrayList movieList, String action) {
+ Intent broadcastIntent = new Intent(INTENT);
+ broadcastIntent.putExtra(ACTION, action);
+ broadcastIntent.putExtra(RESPONSE, movieList);
+ LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent);
+ }
+
+ private void broadcastMovieListError(String error) {
+ Intent broadcastIntent = new Intent(INTENT);
+ broadcastIntent.putExtra(ERROR, error);
+ downloadingErrorNotification(error);
+ LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent);
+ }
+
+ private MovieAPI getMovieAPI() {
+ MovieAPI sMovieAPI;
+
+ Retrofit retrofit = new Retrofit.Builder()
+ .baseUrl(Constants.URL)
+ .addConverterFactory(GsonConverterFactory.create())
+ .build();
+
+ sMovieAPI= retrofit.create(MovieAPI.class);
+
+ return sMovieAPI;
+ }
+
+ public void downloadingErrorNotification(String error) {
+ Notification.Builder n = prepareNotification();
+
+ if(error == ERROR_CONN) {
+ n.setContentText(getResources().getText(R.string.no_data_warning)).setSmallIcon(R.mipmap.ic_download);
+ } else if(error == ERROR_PARSE) {
+ n.setContentText(getResources().getText(R.string.parse_error)).setSmallIcon(R.mipmap.ic_download);
+ }
+
+ NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ notificationManager.notify(0, n.build()); //0 udává číslo notifikace. Na některých zařízeních nefunguje jinačí int než 0.
+ }
+
+ private void downloadingNotification() {
+ Notification.Builder n = prepareNotification();
+ n.setContentText("Downloading movies").setSmallIcon(R.mipmap.ic_download);
+
+ NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ notificationManager.notify(0, n.build()); //0 udává číslo notifikace. Na některých zařízeních nefunguje jinačí int než 0.
+ }
+
+ private void downloadingEndNotification() {
+ Notification.Builder n = prepareNotification();
+ n.setContentText("Movies downloaded successfully").setSmallIcon(R.mipmap.ic_download);
+
+ NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ notificationManager.notify(0, n.build()); //0 udává číslo notifikace. Na některých zařízeních nefunguje jinačí int než 0.
+ }
+
+ private Notification.Builder prepareNotification() {
+ Intent intent = new Intent(this, MovieListFragment.class);
+ PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ Notification.Builder n;
+ if (Build.VERSION.SDK_INT < 26) {
+ n = new Notification.Builder(this);
+ }
+ else {
+ n = new Notification.Builder(this, CHANNEL);
+ }
+ n.setContentTitle(getResources().getString(R.string.app_name))
+ .setContentIntent(pIntent)
+ .setAutoCancel(true).build();
+ return n;
+ }
+}
diff --git a/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/MainActivity.java b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/MainActivity.java
new file mode 100644
index 0000000..82fc910
--- /dev/null
+++ b/app/src/main/java/cz/muni/fi/pv256/movio2/uco_422678/MainActivity.java
@@ -0,0 +1,118 @@
+package cz.muni.fi.pv256.movio2.uco_422678;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v7.widget.SwitchCompat;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.CompoundButton;
+
+import cz.muni.fi.pv256.movio2.R;
+import cz.muni.fi.pv256.movio2.uco_422678.sync.UpdaterSyncAdapter;
+
+public class MainActivity extends AppCompatActivity implements MovieListFragment.OnMovieSelectListener {
+ //private RecyclerView mRecyclerView;
+ //private RecyclerView.Adapter mAdapter;
+ //private RecyclerView.LayoutManager mLayoutManager;
+ //private static final String PREFSTRING = "currentTheme";
+ //protected static ArrayList