Skip to content

Commit

Permalink
Merge pull request #163 from virxkane/cr3.2.46-fixes2
Browse files Browse the repository at this point in the history
Fixed a NullPointer exception in the code related to Google Drive sync.
  • Loading branch information
buggins authored Sep 4, 2020
2 parents e9b4e6e + c3477a7 commit 3ff61c2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions android/src/org/coolreader/CoolReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,27 +324,29 @@ public void onSyncStarted(Synchronizer.SyncDirection direction) {

@Override
public void OnSyncProgress(Synchronizer.SyncDirection direction, int current, int total) {
runInReader(() -> {
log.v("sync progress: current=" + current + "; total=" + total);
if (null != mReaderView) {
int total_ = total;
log.v("sync progress: current=" + current + "; total=" + total);
if (current > total_)
total_ = current;
mReaderView.showCloudSyncProgress(10000 * current / total_);
});
};
}

@Override
public void onSyncCompleted(Synchronizer.SyncDirection direction) {
log.d("Google Drive SyncTo successfully completed");
showToast(R.string.googledrive_sync_completed);
// Hide sync indicator
runInReader(() -> mReaderView.hideSyncProgress());
if (null != mReaderView)
mReaderView.hideSyncProgress();
}

@Override
public void onSyncError(Synchronizer.SyncDirection direction, String errorString) {
// Hide sync indicator
runInReader(() -> mReaderView.hideSyncProgress());
if (null != mReaderView)
mReaderView.hideSyncProgress();
if (null != errorString)
showToast(R.string.googledrive_sync_failed_with, errorString);
else
Expand All @@ -354,7 +356,8 @@ public void onSyncError(Synchronizer.SyncDirection direction, String errorString
@Override
public void onAborted(Synchronizer.SyncDirection direction) {
// Hide sync indicator
runInReader(() -> mReaderView.hideSyncProgress());
if (null != mReaderView)
mReaderView.hideSyncProgress();
showToast(R.string.googledrive_sync_aborted);
}

Expand Down

0 comments on commit 3ff61c2

Please sign in to comment.