use of com.bedrock.padder.adapter.PresetStoreAdapter in project Tapad by berict.
the class PresetStoreActivity method setAdapter.
private void setAdapter() {
Log.d(TAG, "setAdapter");
// attach the adapter to the layout
if (new File(metadataLocation).exists()) {
// metadata file exists
String metadata = fileHelper.getStringFromFile(metadataLocation);
if (isFirebaseMetadataUpdated(activity)) {
// updated, download new one
downloadMetadata();
} else {
Log.d(TAG, "Attached adapter");
// offline or not updated, continue
Gson gson = new Gson();
FirebaseMetadata firebaseMetadata = gson.fromJson(metadata, FirebaseMetadata.class);
if (firebaseMetadata == null || firebaseMetadata.getPresets() == null || firebaseMetadata.getVersionCode() == null) {
// corrupted metadata, download again
downloadMetadata();
} else {
// attach adapter while its not null
presetStoreAdapter = new PresetStoreAdapter(firebaseMetadata, R.layout.adapter_preset_store, activity);
window.getRecyclerView(R.id.layout_preset_store_recyclerview, activity).setAdapter(presetStoreAdapter);
}
setLoadingFinished(true);
}
} else {
downloadMetadata();
}
}
Aggregations