-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce more android arch component
- Loading branch information
Cameron Mace
committed
Nov 30, 2017
1 parent
6a9c916
commit c2058f5
Showing
31 changed files
with
711 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...n-places/schemas/com.mapbox.plugins.places.autocomplete.data.SearchHistoryDatabase/1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 1, | ||
"identityHash": "6785f3a8f4d6195ea76771bea75e1fd5", | ||
"entities": [ | ||
{ | ||
"tableName": "searchhistory", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`placeId` TEXT NOT NULL, `carmen_feature` TEXT, PRIMARY KEY(`placeId`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "placeId", | ||
"columnName": "placeId", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "carmenFeature", | ||
"columnName": "carmen_feature", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
} | ||
], | ||
"primaryKey": { | ||
"columnNames": [ | ||
"placeId" | ||
], | ||
"autoGenerate": false | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
} | ||
], | ||
"setupQueries": [ | ||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", | ||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"6785f3a8f4d6195ea76771bea75e1fd5\")" | ||
] | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...n-places/schemas/com.mapbox.plugins.places.autocomplete.data.SearchHistoryDatabase/2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"formatVersion": 1, | ||
"database": { | ||
"version": 2, | ||
"identityHash": "6785f3a8f4d6195ea76771bea75e1fd5", | ||
"entities": [ | ||
{ | ||
"tableName": "searchhistory", | ||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`placeId` TEXT NOT NULL, `carmen_feature` TEXT, PRIMARY KEY(`placeId`))", | ||
"fields": [ | ||
{ | ||
"fieldPath": "placeId", | ||
"columnName": "placeId", | ||
"affinity": "TEXT", | ||
"notNull": true | ||
}, | ||
{ | ||
"fieldPath": "carmenFeature", | ||
"columnName": "carmen_feature", | ||
"affinity": "TEXT", | ||
"notNull": false | ||
} | ||
], | ||
"primaryKey": { | ||
"columnNames": [ | ||
"placeId" | ||
], | ||
"autoGenerate": false | ||
}, | ||
"indices": [], | ||
"foreignKeys": [] | ||
} | ||
], | ||
"setupQueries": [ | ||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", | ||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"6785f3a8f4d6195ea76771bea75e1fd5\")" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
plugin-places/src/main/java/com/mapbox/plugins/places/autocomplete/DataRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.mapbox.plugins.places.autocomplete; | ||
|
||
import android.arch.lifecycle.LiveData; | ||
import android.arch.lifecycle.MediatorLiveData; | ||
import android.arch.lifecycle.Observer; | ||
import android.support.annotation.Nullable; | ||
|
||
import com.mapbox.plugins.places.autocomplete.data.SearchHistoryDatabase; | ||
import com.mapbox.plugins.places.autocomplete.data.entity.SearchHistoryEntity; | ||
|
||
import java.util.List; | ||
|
||
public class DataRepository { | ||
|
||
private static DataRepository instance; | ||
|
||
private final SearchHistoryDatabase database; | ||
private MediatorLiveData<List<SearchHistoryEntity>> observableSearchHistory; | ||
|
||
private DataRepository(final SearchHistoryDatabase database) { | ||
this.database = database; | ||
observableSearchHistory = new MediatorLiveData<>(); | ||
|
||
observableSearchHistory.addSource(database.searchHistoryDao().getAll(), | ||
new Observer<List<SearchHistoryEntity>>() { | ||
@Override | ||
public void onChanged(@Nullable List<SearchHistoryEntity> searchHistoryEntities) { | ||
if (database.getDatabaseCreated().getValue() != null) { | ||
observableSearchHistory.postValue(searchHistoryEntities); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public static DataRepository getInstance(final SearchHistoryDatabase database) { | ||
if (instance == null) { | ||
instance = new DataRepository(database); | ||
} | ||
return instance; | ||
} | ||
|
||
public LiveData<List<SearchHistoryEntity>> getSearchHistory() { | ||
return observableSearchHistory; | ||
} | ||
|
||
public void addSearchHistoryEntity(SearchHistoryEntity searchHistory) { | ||
SearchHistoryDatabase.insertData(database, searchHistory); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
...-places/src/main/java/com/mapbox/plugins/places/autocomplete/OnCardItemClickListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.