diff --git a/Atarashii/res/layout/record_igf_gridview.xml b/Atarashii/res/layout/record_igf_gridview.xml index b224a64b..f62deed1 100644 --- a/Atarashii/res/layout/record_igf_gridview.xml +++ b/Atarashii/res/layout/record_igf_gridview.xml @@ -7,8 +7,7 @@ android:id="@+id/coverImage" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:scaleType="centerCrop" - android:src="@drawable/transpanel" /> + android:scaleType="centerCrop" /> \ No newline at end of file diff --git a/Atarashii/res/layout/record_igf_listview.xml b/Atarashii/res/layout/record_igf_listview.xml index b88d6595..d4373340 100644 --- a/Atarashii/res/layout/record_igf_listview.xml +++ b/Atarashii/res/layout/record_igf_listview.xml @@ -7,8 +7,7 @@ android:id="@+id/coverImage" android:layout_width="fill_parent" android:layout_height="fill_parent" - android:scaleType="centerCrop" - android:src="@drawable/transpanel" /> + android:scaleType="centerCrop" /> diff --git a/Atarashii/src/net/somethingdreadful/MAL/Home.java b/Atarashii/src/net/somethingdreadful/MAL/Home.java index 334a58fb..b2d5e4e3 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Home.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Home.java @@ -268,7 +268,8 @@ public boolean onPrepareOptionsMenu(Menu menu) { } private void setChecked(MenuItem item) { - item.setChecked(true); + if (item != null) + item.setChecked(true); } private void myListChanged() { diff --git a/Atarashii/src/net/somethingdreadful/MAL/Theme.java b/Atarashii/src/net/somethingdreadful/MAL/Theme.java index 7e909242..80d928c6 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Theme.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Theme.java @@ -103,8 +103,12 @@ public static boolean isPortrait() { * Changes the language to the preferred one. */ private void setLanguage() { - Resources res = getBaseContext().getResources(); - res.updateConfiguration(config, res.getDisplayMetrics()); + try { + Resources res = getBaseContext().getResources(); + res.updateConfiguration(config, res.getDisplayMetrics()); + } catch (Exception e) { + Theme.logTaskCrash("Theme", "setLanguage", e); + } } /** diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/UserList.java b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/UserList.java index 44113592..bf6f1d91 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/UserList.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/UserList.java @@ -132,13 +132,18 @@ private ArrayList con net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Anime anime = new net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Anime(); anime.setId(detail.getAnime().getId()); anime.setTitle(detail.getAnime().getTitleRomaji()); - anime.setImageUrl(detail.getAnime().getImageUrlLge()); anime.setType(detail.getAnime().getType()); + anime.setImageUrl(detail.getAnime().getImageUrlLge()); + anime.setPopularity(detail.getAnime().getPopularity()); + anime.setStatus(detail.getAnime().getAiringStatus()); + anime.setAverageScore(detail.getAnime().getAverageScore()); + anime.setEpisodes(detail.getAnime().getTotalEpisodes()); + anime.setWatchedStatus(detail.getListStatus()); + anime.setScore(detail.getScoreraw()); anime.setPriority(detail.getPriorty()); anime.setRewatching(detail.getRewatched()); anime.setNotes(detail.getNotes()); - anime.setScore(detail.getScoreraw()); anime.setWatchedEpisodes(detail.getEpisodesWatched()); newList.add(anime); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseManager.java b/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseManager.java index 872936c2..8c7aa34f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseManager.java +++ b/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseManager.java @@ -35,11 +35,17 @@ public void saveAnime(Anime anime) { cv.put("airingTime", anime.getAiring().getTime()); cv.put("nextEpisode", anime.getAiring().getNextEpisode()); } - if (anime.getWatchedStatus() != null) { // AniList does not provide this in the details + + // The app is offline + if (anime.getWatchedStatus() != null) { cv.put("watchedStatus", anime.getWatchedStatus()); cv.put("watchedEpisodes", anime.getWatchedEpisodes()); } + + // AniList does not provide this in the details if (AccountService.isMAL()) { + cv.put("watchedStatus", anime.getWatchedStatus()); + cv.put("watchedEpisodes", anime.getWatchedEpisodes()); cv.put("watchingStart", anime.getWatchingStart()); cv.put("watchingEnd", anime.getWatchingEnd()); cv.put("fansubGroup", anime.getFansubGroup()); @@ -101,6 +107,15 @@ private void saveAnimeList(Anime anime) { cv.put("score", anime.getScore()); cv.put("watchedStatus", anime.getWatchedStatus()); + // AniList details only + if (!AccountService.isMAL()) { + cv.put("popularity", anime.getPopularity()); + cv.put("averageScore", anime.getAverageScore()); + cv.put("priority", anime.getPriority()); + cv.put("rewatching", anime.getRewatching()); + cv.put("notes", anime.getNotes()); + } + try { db.beginTransaction(); Query.newQuery(db).updateRecord(DatabaseTest.TABLE_ANIME, cv, anime.getId()); @@ -117,11 +132,15 @@ public void saveManga(Manga manga) { ContentValues cv = listDetails(manga); cv.put("chapters", manga.getChapters()); cv.put("volumes", manga.getVolumes()); - if (manga.getReadStatus() != null) { // AniList does not provide this in the details + + // The app is offline + if (manga.getReadStatus() != null) { cv.put("readStatus", manga.getReadStatus()); cv.put("chaptersRead", manga.getChaptersRead()); cv.put("volumesRead", manga.getVolumesRead()); } + + // AniList does not provide this in the details if (AccountService.isMAL()) { cv.put("readingStart", manga.getReadingStart()); cv.put("readingEnd", manga.getReadingEnd()); @@ -197,15 +216,19 @@ private ContentValues listDetails(GenericRecord record) { cv.put("status", record.getStatus()); cv.put("startDate", record.getStartDate()); cv.put("endDate", record.getEndDate()); - cv.put("score", record.getScore()); - cv.put("priority", record.getPriority()); + + // MyAnimeList details only + if (AccountService.isMAL()) { + cv.put("score", record.getScore()); + cv.put("priority", record.getPriority()); + cv.put("averageScoreCount", record.getAverageScoreCount()); + cv.put("rank", record.getRank()); + cv.put("notes", record.getNotes()); + cv.put("favoritedCount", record.getFavoritedCount()); + } cv.put("classification", record.getClassification()); cv.put("averageScore", record.getAverageScore()); - cv.put("averageScoreCount", record.getAverageScoreCount()); cv.put("popularity", record.getPopularity()); - cv.put("rank", record.getRank()); - cv.put("notes", record.getNotes()); - cv.put("favoritedCount", record.getFavoritedCount()); cv.put("dirty", record.getDirty() != null ? new Gson().toJson(record.getDirty()) : null); cv.put("createFlag", record.getCreateFlag()); cv.put("deleteFlag", record.getDeleteFlag()); @@ -281,7 +304,7 @@ public ArrayList getAnimeList(String ListType) { cursor = query.OrderBy(1, "title").run(); break; case "rewatching": // rewatching/rereading - cursor = query.whereEqGr("rewatchCount", "1").andEquals("watchedStatus", "watching").OrderBy(1, "title").run(); + cursor = query.whereEqGr("rewatchCount", "1").andOrEquals("watchedStatus", "watching", "rewatching", "true").OrderBy(1, "title").run(); break; default: // normal lists cursor = query.where("watchedStatus", ListType).OrderBy(1, "title").run(); diff --git a/Atarashii/src/net/somethingdreadful/MAL/database/Query.java b/Atarashii/src/net/somethingdreadful/MAL/database/Query.java index 1f72e75f..dde1ba16 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/database/Query.java +++ b/Atarashii/src/net/somethingdreadful/MAL/database/Query.java @@ -56,6 +56,11 @@ public Query andEquals(String column1, String value) { return this; } + public Query andOrEquals(String column1, String value1, String column2, String value2) { + queryString += " AND (" + column1 + " = '" + value1 + "' OR " + column2 + " = '" + value2 + "')"; + return this; + } + public Query OrderBy(int type, String column) { switch (type) { case 1: // Name diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/NetworkTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/NetworkTask.java index 92b7f35b..4d785acb 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/NetworkTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/NetworkTask.java @@ -112,6 +112,9 @@ protected Object doInBackground(String... params) { if (AccountService.isMAL()) mManager.verifyAuthentication(); + mManager.cleanDirtyAnimeRecords(); + mManager.cleanDirtyMangaRecords(); + taskResult = isAnimeTask() ? mManager.downloadAndStoreAnimeList(params[0]) : mManager.downloadAndStoreMangaList(params[0]); if (taskResult != null && params.length == 2) taskResult = isAnimeTask() ? mManager.getAnimeListFromDB(params[1]) : mManager.getMangaListFromDB(params[1]); diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/WriteDetailTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/WriteDetailTask.java index 374af411..f4763635 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/WriteDetailTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/WriteDetailTask.java @@ -43,7 +43,7 @@ protected Boolean doInBackground(GenericRecord... gr) { boolean error = false; MALManager manager = new MALManager(context); - if (!AccountService.isMAL()) + if (!AccountService.isMAL() && MALApi.isNetworkAvailable(context)) manager.verifyAuthentication(); try { diff --git a/build.gradle b/build.gradle index 4729b612..e8059400 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.0.0-beta4' + classpath 'com.android.tools.build:gradle:2.0.0-beta5' } }