Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Merge pull request #481 from ratan12/Update
Browse files Browse the repository at this point in the history
Fixes for 2.2.3
  • Loading branch information
ratan12 committed Feb 28, 2016
2 parents 20e2a0c + a2c0d9e commit 8c57e4e
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 20 deletions.
3 changes: 1 addition & 2 deletions Atarashii/res/layout/record_igf_gridview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<include layout="@layout/record_igf_panel" />
</FrameLayout>
3 changes: 1 addition & 2 deletions Atarashii/res/layout/record_igf_listview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<include layout="@layout/record_igf_panel" />

Expand Down
3 changes: 2 additions & 1 deletion Atarashii/src/net/somethingdreadful/MAL/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 6 additions & 2 deletions Atarashii/src/net/somethingdreadful/MAL/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,18 @@ private ArrayList<net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Anime> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -281,7 +304,7 @@ public ArrayList<Anime> 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();
Expand Down
5 changes: 5 additions & 0 deletions Atarashii/src/net/somethingdreadful/MAL/database/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down

0 comments on commit 8c57e4e

Please sign in to comment.