diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java b/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java index c675962e1..0b475f9e2 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/DatabaseHelper.java @@ -24,8 +24,8 @@ import eu.kanade.mangafeed.data.database.models.Manga; import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLiteDeleteResolver; import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLitePutResolver; import eu.kanade.mangafeed.data.database.resolvers.MangaWithUnreadGetResolver; -import eu.kanade.mangafeed.data.database.tables.ChaptersTable; -import eu.kanade.mangafeed.data.database.tables.MangasTable; +import eu.kanade.mangafeed.data.database.tables.ChapterTable; +import eu.kanade.mangafeed.data.database.tables.MangaTable; import eu.kanade.mangafeed.util.ChapterRecognition; import eu.kanade.mangafeed.util.PostResult; import rx.Observable; @@ -57,20 +57,20 @@ public class DatabaseHelper { "SELECT %1$s.*, COUNT(C.%4$s) AS %5$s FROM %1$s LEFT JOIN " + "(SELECT %4$s FROM %2$s WHERE %6$s = 0) AS C ON %3$s = C.%4$s " + "WHERE %7$s = 1 GROUP BY %3$s", - MangasTable.TABLE, - ChaptersTable.TABLE, - MangasTable.TABLE + "." + MangasTable.COLUMN_ID, - ChaptersTable.COLUMN_MANGA_ID, - MangasTable.COLUMN_UNREAD, - ChaptersTable.COLUMN_READ, - MangasTable.COLUMN_FAVORITE + MangaTable.TABLE, + ChapterTable.TABLE, + MangaTable.TABLE + "." + MangaTable.COLUMN_ID, + ChapterTable.COLUMN_MANGA_ID, + MangaTable.COLUMN_UNREAD, + ChapterTable.COLUMN_READ, + MangaTable.COLUMN_FAVORITE ); public PreparedGetListOfObjects getMangas() { return db.get() .listOfObjects(Manga.class) .withQuery(Query.builder() - .table(MangasTable.TABLE) + .table(MangaTable.TABLE) .build()) .prepare(); } @@ -80,7 +80,7 @@ public class DatabaseHelper { .listOfObjects(Manga.class) .withQuery(RawQuery.builder() .query(favoriteMangasWithUnreadQuery) - .observesTables(MangasTable.TABLE, ChaptersTable.TABLE) + .observesTables(MangaTable.TABLE, ChapterTable.TABLE) .build()) .prepare(); } @@ -89,8 +89,8 @@ public class DatabaseHelper { return db.get() .listOfObjects(Manga.class) .withQuery(Query.builder() - .table(MangasTable.TABLE) - .where(MangasTable.COLUMN_FAVORITE + "=?") + .table(MangaTable.TABLE) + .where(MangaTable.COLUMN_FAVORITE + "=?") .whereArgs(1) .build()) .prepare(); @@ -100,8 +100,8 @@ public class DatabaseHelper { return db.get() .listOfObjects(Manga.class) .withQuery(Query.builder() - .table(MangasTable.TABLE) - .where(MangasTable.COLUMN_URL + "=?") + .table(MangaTable.TABLE) + .where(MangaTable.COLUMN_URL + "=?") .whereArgs(url) .build()) .prepare(); @@ -111,8 +111,8 @@ public class DatabaseHelper { return db.get() .listOfObjects(Manga.class) .withQuery(Query.builder() - .table(MangasTable.TABLE) - .where(MangasTable.COLUMN_ID + "=?") + .table(MangaTable.TABLE) + .where(MangaTable.COLUMN_ID + "=?") .whereArgs(id) .build()) .prepare(); @@ -149,8 +149,8 @@ public class DatabaseHelper { return db.get() .listOfObjects(Chapter.class) .withQuery(Query.builder() - .table(ChaptersTable.TABLE) - .where(ChaptersTable.COLUMN_MANGA_ID + "=?") + .table(ChapterTable.TABLE) + .where(ChapterTable.COLUMN_MANGA_ID + "=?") .whereArgs(manga.id) .build()) .prepare(); @@ -158,15 +158,15 @@ public class DatabaseHelper { public PreparedGetListOfObjects getChapters(long manga_id, boolean sortAToZ, boolean onlyUnread) { Query.CompleteBuilder query = Query.builder() - .table(ChaptersTable.TABLE) + .table(ChapterTable.TABLE) - .orderBy(ChaptersTable.COLUMN_CHAPTER_NUMBER + (sortAToZ ? " ASC" : " DESC")); + .orderBy(ChapterTable.COLUMN_CHAPTER_NUMBER + (sortAToZ ? " ASC" : " DESC")); if (onlyUnread) { - query = query.where(ChaptersTable.COLUMN_MANGA_ID + "=? AND " + ChaptersTable.COLUMN_READ + "=?") + query = query.where(ChapterTable.COLUMN_MANGA_ID + "=? AND " + ChapterTable.COLUMN_READ + "=?") .whereArgs(manga_id, 0); } else { - query = query.where(ChaptersTable.COLUMN_MANGA_ID + "=?") + query = query.where(ChapterTable.COLUMN_MANGA_ID + "=?") .whereArgs(manga_id); } @@ -180,12 +180,12 @@ public class DatabaseHelper { return db.get() .listOfObjects(Chapter.class) .withQuery(Query.builder() - .table(ChaptersTable.TABLE) - .where(ChaptersTable.COLUMN_MANGA_ID + "=? AND " + - ChaptersTable.COLUMN_CHAPTER_NUMBER + ">? AND " + - ChaptersTable.COLUMN_CHAPTER_NUMBER + "<=?") + .table(ChapterTable.TABLE) + .where(ChapterTable.COLUMN_MANGA_ID + "=? AND " + + ChapterTable.COLUMN_CHAPTER_NUMBER + ">? AND " + + ChapterTable.COLUMN_CHAPTER_NUMBER + "<=?") .whereArgs(chapter.manga_id, chapter.chapter_number, chapter.chapter_number + 1) - .orderBy(ChaptersTable.COLUMN_CHAPTER_NUMBER) + .orderBy(ChapterTable.COLUMN_CHAPTER_NUMBER) .limit(1) .build()) .prepare(); @@ -195,12 +195,12 @@ public class DatabaseHelper { return db.get() .listOfObjects(Chapter.class) .withQuery(Query.builder() - .table(ChaptersTable.TABLE) - .where(ChaptersTable.COLUMN_MANGA_ID + "=? AND " + - ChaptersTable.COLUMN_CHAPTER_NUMBER + "=?") + .table(ChapterTable.TABLE) + .where(ChapterTable.COLUMN_MANGA_ID + "=? AND " + + ChapterTable.COLUMN_CHAPTER_NUMBER + "=?") .whereArgs(chapter.manga_id, chapter.chapter_number, chapter.chapter_number - 1) - .orderBy(ChaptersTable.COLUMN_CHAPTER_NUMBER + " DESC") + .orderBy(ChapterTable.COLUMN_CHAPTER_NUMBER + " DESC") .limit(1) .build()) .prepare(); diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/DbOpenHelper.java b/app/src/main/java/eu/kanade/mangafeed/data/database/DbOpenHelper.java index 65b0cdd17..bfebf5ed8 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/DbOpenHelper.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/DbOpenHelper.java @@ -5,8 +5,8 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.support.annotation.NonNull; -import eu.kanade.mangafeed.data.database.tables.ChaptersTable; -import eu.kanade.mangafeed.data.database.tables.MangasTable; +import eu.kanade.mangafeed.data.database.tables.ChapterTable; +import eu.kanade.mangafeed.data.database.tables.MangaTable; public class DbOpenHelper extends SQLiteOpenHelper { @@ -19,8 +19,8 @@ public class DbOpenHelper extends SQLiteOpenHelper { @Override public void onCreate(@NonNull SQLiteDatabase db) { - db.execSQL(MangasTable.getCreateTableQuery()); - db.execSQL(ChaptersTable.getCreateTableQuery()); + db.execSQL(MangaTable.getCreateTableQuery()); + db.execSQL(ChapterTable.getCreateTableQuery()); } @Override diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/models/Chapter.java b/app/src/main/java/eu/kanade/mangafeed/data/database/models/Chapter.java index a4e03f465..a89855557 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/models/Chapter.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/models/Chapter.java @@ -3,36 +3,36 @@ package eu.kanade.mangafeed.data.database.models; import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; -import eu.kanade.mangafeed.data.database.tables.ChaptersTable; +import eu.kanade.mangafeed.data.database.tables.ChapterTable; -@StorIOSQLiteType(table = ChaptersTable.TABLE) +@StorIOSQLiteType(table = ChapterTable.TABLE) public class Chapter { - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_ID, key = true) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_ID, key = true) public Long id; - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_MANGA_ID) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_MANGA_ID) public Long manga_id; - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_URL) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_URL) public String url; - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_NAME) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_NAME) public String name; - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_READ) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_READ) public boolean read; - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_LAST_PAGE_READ) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_LAST_PAGE_READ) public int last_page_read; - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_DATE_FETCH) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_DATE_FETCH) public long date_fetch; - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_DATE_UPLOAD) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_DATE_UPLOAD) public long date_upload; - @StorIOSQLiteColumn(name = ChaptersTable.COLUMN_CHAPTER_NUMBER) + @StorIOSQLiteColumn(name = ChapterTable.COLUMN_CHAPTER_NUMBER) public float chapter_number; public int downloaded; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/models/Manga.java b/app/src/main/java/eu/kanade/mangafeed/data/database/models/Manga.java index 86ab30332..c51eeba1e 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/models/Manga.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/models/Manga.java @@ -3,54 +3,54 @@ package eu.kanade.mangafeed.data.database.models; import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteColumn; import com.pushtorefresh.storio.sqlite.annotations.StorIOSQLiteType; -import eu.kanade.mangafeed.data.database.tables.MangasTable; +import eu.kanade.mangafeed.data.database.tables.MangaTable; -@StorIOSQLiteType(table = MangasTable.TABLE) +@StorIOSQLiteType(table = MangaTable.TABLE) public class Manga { - @StorIOSQLiteColumn(name = MangasTable.COLUMN_ID, key = true) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_ID, key = true) public Long id; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_SOURCE) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_SOURCE) public int source; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_URL) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_URL) public String url; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_ARTIST) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_ARTIST) public String artist; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_AUTHOR) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_AUTHOR) public String author; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_DESCRIPTION) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_DESCRIPTION) public String description; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_GENRE) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_GENRE) public String genre; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_TITLE) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_TITLE) public String title; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_STATUS) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_STATUS) public String status; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_THUMBNAIL_URL) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_THUMBNAIL_URL) public String thumbnail_url; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_FAVORITE) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_FAVORITE) public boolean favorite; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_LAST_UPDATE) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_LAST_UPDATE) public long last_update; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_INITIALIZED) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_INITIALIZED) public boolean initialized; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_VIEWER) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_VIEWER) public int viewer; - @StorIOSQLiteColumn(name = MangasTable.COLUMN_CHAPTER_ORDER) + @StorIOSQLiteColumn(name = MangaTable.COLUMN_CHAPTER_ORDER) public int chapter_order; public int unread; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/resolvers/MangaWithUnreadGetResolver.java b/app/src/main/java/eu/kanade/mangafeed/data/database/resolvers/MangaWithUnreadGetResolver.java index a5a2f91a6..e438513e7 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/resolvers/MangaWithUnreadGetResolver.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/resolvers/MangaWithUnreadGetResolver.java @@ -5,15 +5,14 @@ import android.support.annotation.NonNull; import eu.kanade.mangafeed.data.database.models.Manga; import eu.kanade.mangafeed.data.database.models.MangaStorIOSQLiteGetResolver; -import eu.kanade.mangafeed.data.database.tables.MangasTable; - +import eu.kanade.mangafeed.data.database.tables.MangaTable; public class MangaWithUnreadGetResolver extends MangaStorIOSQLiteGetResolver { @Override public Manga mapFromCursor(@NonNull Cursor cursor) { Manga manga = super.mapFromCursor(cursor); - int unreadColumn = cursor.getColumnIndex(MangasTable.COLUMN_UNREAD); + int unreadColumn = cursor.getColumnIndex(MangaTable.COLUMN_UNREAD); if (unreadColumn != -1) manga.unread = cursor.getInt(unreadColumn); return manga; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/tables/CategoriesTable.java b/app/src/main/java/eu/kanade/mangafeed/data/database/tables/CategoryTable.java similarity index 80% rename from app/src/main/java/eu/kanade/mangafeed/data/database/tables/CategoriesTable.java rename to app/src/main/java/eu/kanade/mangafeed/data/database/tables/CategoryTable.java index bc56409e6..2134a8ac9 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/tables/CategoriesTable.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/tables/CategoryTable.java @@ -2,10 +2,7 @@ package eu.kanade.mangafeed.data.database.tables; import android.support.annotation.NonNull; -/** - * Created by len on 23/09/2015. - */ -public class CategoriesTable { +public class CategoryTable { @NonNull public static final String TABLE = "categories"; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/tables/ChaptersTable.java b/app/src/main/java/eu/kanade/mangafeed/data/database/tables/ChapterTable.java similarity index 94% rename from app/src/main/java/eu/kanade/mangafeed/data/database/tables/ChaptersTable.java rename to app/src/main/java/eu/kanade/mangafeed/data/database/tables/ChapterTable.java index 548e6b874..e5337564e 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/tables/ChaptersTable.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/tables/ChapterTable.java @@ -2,7 +2,7 @@ package eu.kanade.mangafeed.data.database.tables; import android.support.annotation.NonNull; -public class ChaptersTable { +public class ChapterTable { @NonNull public static final String TABLE = "chapters"; @@ -46,7 +46,7 @@ public class ChaptersTable { + COLUMN_CHAPTER_NUMBER + " FLOAT NOT NULL, " + COLUMN_DATE_FETCH + " LONG NOT NULL, " + COLUMN_DATE_UPLOAD + " LONG NOT NULL, " - + "FOREIGN KEY(" + COLUMN_MANGA_ID + ") REFERENCES " + MangasTable.TABLE + "(" + MangasTable.COLUMN_ID + ") " + + "FOREIGN KEY(" + COLUMN_MANGA_ID + ") REFERENCES " + MangaTable.TABLE + "(" + MangaTable.COLUMN_ID + ") " + "ON DELETE CASCADE" + ");" + "CREATE INDEX " + TABLE + "_" + COLUMN_MANGA_ID + "_index ON " + TABLE + "(" + COLUMN_MANGA_ID + ");"; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangasCategoriesTable.java b/app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangaCategoryTable.java similarity index 80% rename from app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangasCategoriesTable.java rename to app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangaCategoryTable.java index 4799710f4..173ebbd54 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangasCategoriesTable.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangaCategoryTable.java @@ -2,10 +2,7 @@ package eu.kanade.mangafeed.data.database.tables; import android.support.annotation.NonNull; -/** - * Created by len on 23/09/2015. - */ -public class MangasCategoriesTable { +public class MangaCategoryTable { @NonNull public static final String TABLE = "mangas_categories"; diff --git a/app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangasTable.java b/app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangaTable.java similarity index 97% rename from app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangasTable.java rename to app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangaTable.java index 57a1b6445..df6a7f2fe 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangasTable.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/database/tables/MangaTable.java @@ -2,7 +2,7 @@ package eu.kanade.mangafeed.data.database.tables; import android.support.annotation.NonNull; -public class MangasTable { +public class MangaTable { @NonNull public static final String TABLE = "mangas"; @@ -56,7 +56,7 @@ public class MangasTable { public static final String COLUMN_UNREAD = "unread"; // This is just class with Meta Data, we don't need instances - private MangasTable() { + private MangaTable() { throw new IllegalStateException("No instances please"); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CatalogueFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CatalogueFragment.java index 856d65419..46fdbc915 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CatalogueFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CatalogueFragment.java @@ -176,7 +176,7 @@ public class CatalogueFragment extends BaseRxFragment { if(v == null) return null; - return (ImageView) v.findViewById(R.id.catalogue_thumbnail); + return (ImageView) v.findViewById(R.id.thumbnail); } public void updateImage(Manga manga) { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersHolder.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersHolder.java index aab73a0a1..1a2859730 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersHolder.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersHolder.java @@ -7,10 +7,6 @@ import android.view.View; import android.widget.ImageView; import android.widget.TextView; -import java.text.DateFormat; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -67,7 +63,7 @@ public class ChaptersHolder extends RecyclerView.ViewHolder implements else if (chapter.downloaded == Chapter.NOT_DOWNLOADED) download_icon.setImageResource(R.drawable.ic_file_download_black_36dp); - date.setText(sdf.format(new Date(chapter.date_fetch))); + date.setText(sdf.format(new Date(chapter.date_upload))); toggleActivation(); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/info/MangaInfoFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/info/MangaInfoFragment.java index 063bcd903..e73f35c0a 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/info/MangaInfoFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/info/MangaInfoFragment.java @@ -1,7 +1,6 @@ package eu.kanade.mangafeed.ui.manga.info; import android.os.Bundle; -import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; diff --git a/app/src/main/res/layout/fragment_manga_chapters.xml b/app/src/main/res/layout/fragment_manga_chapters.xml index 56e6162c8..0f0b7cad0 100644 --- a/app/src/main/res/layout/fragment_manga_chapters.xml +++ b/app/src/main/res/layout/fragment_manga_chapters.xml @@ -10,7 +10,7 @@ android:id="@+id/swipe_refresh" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_above="@id/appbar_bottom" + android:layout_above="@+id/appbar_bottom" android:orientation="vertical">