Skip to content

Commit

Permalink
feat: add maker for sqlite-database-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacksgong committed Dec 16, 2017
1 parent 8899395 commit cba5dcf
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@

/**
* Persist data to SQLite database.
*
* You can valid this database implementation through:
* <p>
* class MyApplication extends Application {
* ...
* public void onCreate() {
* ...
* FileDownloader.setupOnApplicationOnCreate(this)
* .database(SqliteDatabaseImpl.createMaker())
* ...
* .commit();
* ...
* }
* ...
* }
*
*/
public class SqliteDatabaseImpl implements FileDownloadDatabase {

Expand All @@ -43,6 +59,9 @@ public class SqliteDatabaseImpl implements FileDownloadDatabase {
public static final String TABLE_NAME = "filedownloader";
public static final String CONNECTION_TABLE_NAME = "filedownloaderConnection";

public static Maker createMaker() {
return new Maker();
}

public SqliteDatabaseImpl() {
SqliteDatabaseOpenHelper openHelper = new SqliteDatabaseOpenHelper(
Expand Down Expand Up @@ -398,4 +417,12 @@ private static FileDownloadModel createFromCursor(Cursor c) {

return model;
}

public static class Maker implements FileDownloadHelper.DatabaseCustomMaker {

@Override
public FileDownloadDatabase customMake() {
return new SqliteDatabaseImpl();
}
}
}

0 comments on commit cba5dcf

Please sign in to comment.