use of com.baker.abaker.ABakerApp in project baker-android by bakerframework.
the class MagazineThumb method setBookJson.
public void setBookJson(BookJson bookJson) {
this.book = bookJson;
if (null != this.book) {
GindActivity activity = (GindActivity) this.getContext();
activity.viewMagazine(this.book);
} else {
Toast.makeText(this.getContext(), "The book.json was not found!", Toast.LENGTH_LONG).show();
}
if (this.previewLoaded) {
this.previewLoaded = false;
findViewById(R.id.download_container).setVisibility(View.VISIBLE);
findViewById(R.id.txtProgress).setVisibility(View.GONE);
}
// Here we register the OPEN ISSUE event on Google Analytics
if (this.activity.getResources().getBoolean(R.bool.ga_enable) && this.activity.getResources().getBoolean(R.bool.ga_register_issue_read_event)) {
((ABakerApp) this.activity.getApplication()).sendEvent(this.activity.getString(R.string.issues_category), this.activity.getString(R.string.issue_open), this.magazine.getName());
}
}
use of com.baker.abaker.ABakerApp in project baker-android by bakerframework.
the class MagazineThumb method postExecute.
/**
* As an instance of GindMandator, this class should implement a method postExecute
* to be executed when one of the tasks is done.
*
* @param taskId the id of the task that ended.
* @param results the results values.
*/
@Override
public void postExecute(final int taskId, String... results) {
//Hide progress
findViewById(R.id.txtProgress).setVisibility(View.GONE);
findViewById(R.id.progress_ui).setVisibility(View.GONE);
//TODO: Handle failures.
switch(taskId) {
case MAGAZINE_DOWNLOAD_TASK:
this.packDownloader = null;
//When the download task ended successfully we will start unzipping the file.
Log.d(this.getClass().getName(), "DownloaderTask result: " + results[0]);
if (results[0].equals("SUCCESS")) {
// Here we register the DOWNLOAD ISSUE event on Google Analytics
if (this.activity.getResources().getBoolean(R.bool.ga_enable) && this.activity.getResources().getBoolean(R.bool.ga_register_issue_download_event)) {
((ABakerApp) this.activity.getApplication()).sendEvent(this.activity.getString(R.string.issues_category), this.activity.getString(R.string.issue_download), this.magazine.getName());
}
startUnzip(results[1], this.magazine.getName());
} else if (results[0].equals("ERROR")) {
this.resetUI();
}
break;
case THUMB_DOWNLOAD_TASK:
//If the thumbnail download ended successfully we will render the cover.
if (results[0].equals("SUCCESS")) {
Log.d(this.getClass().getName(), "Cover download for " + this.magazine.getName() + " finished.");
this.renderCover();
thumbnailDownloaderHandler.sendEmptyMessage(1);
}
break;
case UNZIP_MAGAZINE_TASK:
//If the Unzip tasks ended successfully we will update the UI to let the user
//start reading the issue.
this.unzipperTask = null;
if (results[0].equals("SUCCESS")) {
this.enableReadArchiveActions();
this.sendDownloadReport();
} else {
this.resetUI();
Toast.makeText(this.getContext(), "Could not extract the package. Possibly corrupted.", Toast.LENGTH_LONG).show();
}
break;
case MAGAZINE_DELETE_TASK:
//the user download the issue again.
if (results[0].equals("SUCCESS")) {
// Here we register the DELETE ISSUE event on Google Analytics
if (this.activity.getResources().getBoolean(R.bool.ga_enable) && this.activity.getResources().getBoolean(R.bool.ga_register_issue_delete_event)) {
((ABakerApp) this.activity.getApplication()).sendEvent(this.activity.getString(R.string.issues_category), this.activity.getString(R.string.issue_delete), this.magazine.getName());
}
this.enableDownloadAction();
}
break;
case POST_DOWNLOAD_TASK:
if (!results[0].equals("ERROR")) {
}
break;
case BOOK_JSON_PARSE_TASK:
try {
BookJson bookJson = new BookJson();
final String magazineName = results[0];
final String rawJson = results[1];
bookJson.setMagazineName(magazineName);
bookJson.fromJson(rawJson);
setBookJson(bookJson);
} catch (JSONException ex) {
Log.e(this.getClass().getName(), "Error parsing the book.json", ex);
} catch (ParseException ex) {
Log.e(this.getClass().getName(), "Error parsing the book.json", ex);
}
break;
case CHECK_INTERNET_TASK:
if (results[0].equals("TRUE")) {
if (TASK == TASKS_AFTER_CHECK_INTERNET.DOWNLOAD_ISSUE) {
this.startPackageDownload();
} else {
this.readOnline();
}
} else {
if (TASK == TASKS_AFTER_CHECK_INTERNET.DOWNLOAD_ISSUE) {
Log.e(this.getClass().toString(), "No Internet access to download the issue.");
Toast.makeText(this.getContext(), this.getContext().getString(R.string.cannot_download_issue), Toast.LENGTH_LONG).show();
} else {
Log.e(this.getClass().toString(), "Cannot view issue online. No internet access.");
Toast.makeText(this.getContext(), this.getContext().getString(R.string.cannot_view_online), Toast.LENGTH_LONG).show();
}
}
break;
}
}
Aggregations