public static final String TAG = PreviewImageActivity.class.getSimpleName();
public static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW";
+ private static final String KEY_WAITING_FOR_BINDER = "WAITING_FOR_BINDER";
private OCFile mFile;
private OCFile mParentFolder;
private ServiceConnection mDownloadConnection, mUploadConnection = null;
private FileUploaderBinder mUploaderBinder = null;
private OCFile mWaitingToPreview = null;
+
+ private boolean mRequestWaitingForBinder;
@Override
mParentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
}
- mWaitingToPreview = null;
if (savedInstanceState != null) {
mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(KEY_WAITING_TO_PREVIEW);
+ mRequestWaitingForBinder = savedInstanceState.getBoolean(KEY_WAITING_FOR_BINDER);
+ } else {
+ mWaitingToPreview = null;
+ mRequestWaitingForBinder = false;
}
createViewPager();
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(KEY_WAITING_TO_PREVIEW, mWaitingToPreview);
+ outState.putBoolean(KEY_WAITING_FOR_BINDER, mRequestWaitingForBinder);
}
if (component.equals(new ComponentName(PreviewImageActivity.this, FileDownloader.class))) {
Log.d(TAG, "Download service connected");
mDownloaderBinder = (FileDownloaderBinder) service;
+ if (mRequestWaitingForBinder) {
+ if (mWaitingToPreview != null) {
+ requestForDownload();
+ }
+ mRequestWaitingForBinder = false;
+ }
} else if (component.equals(new ComponentName(PreviewImageActivity.this, FileUploader.class))) {
Log.d(TAG, "Upload service connected");
private void requestForDownload() {
Log.e(TAG, "REQUEST FOR DOWNLOAD : " + mWaitingToPreview.getFileName());
- if (!mDownloaderBinder.isDownloading(mAccount, mWaitingToPreview)) {
+ if (mDownloaderBinder == null) {
+ mRequestWaitingForBinder = true;
+
+ } else if (!mDownloaderBinder.isDownloading(mAccount, mWaitingToPreview)) {
Intent i = new Intent(this, FileDownloader.class);
i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
i.putExtra(FileDownloader.EXTRA_FILE, mWaitingToPreview);
startService(i);
}
+ mViewPager.invalidate();
}
@Override
Log.e(TAG, "BEFORE NOTIFY DATA SET CHANGED");
mPreviewImagePagerAdapter.notifyDataSetChanged();
Log.e(TAG, "AFTER NOTIFY DATA SET CHANGED");
- //Log.e(TAG, "BEFORE INVALIDATE");
- //mViewPager.postInvalidate();
- //Log.e(TAG, "AFTER INVALIDATE");
}
}
}
} else {
mWaitingToPreview = currentFile;
requestForDownload();
- mViewPager.invalidate();
}
}