use of com.owncloud.android.ui.fragment.GalleryFragment in project android by nextcloud.
the class DrawerActivity method onNavigationItemClicked.
private void onNavigationItemClicked(final MenuItem menuItem) {
setDrawerMenuItemChecked(menuItem.getItemId());
int itemId = menuItem.getItemId();
if (itemId == R.id.nav_all_files) {
if (this instanceof FileDisplayActivity && !(((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) && !(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) {
showFiles(false);
((FileDisplayActivity) this).browseToRoot();
EventBus.getDefault().post(new ChangeMenuEvent());
} else {
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setAction(FileDisplayActivity.ALL_FILES);
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
startActivity(intent);
}
} else if (itemId == R.id.nav_favorites) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.FAVORITE_SEARCH), menuItem.getItemId());
} else if (itemId == R.id.nav_gallery) {
startPhotoSearch(menuItem);
} else if (itemId == R.id.nav_on_device) {
EventBus.getDefault().post(new ChangeMenuEvent());
showFiles(true);
} else if (itemId == R.id.nav_uploads) {
startActivity(UploadListActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
} else if (itemId == R.id.nav_trashbin) {
startActivity(TrashbinActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
} else if (itemId == R.id.nav_activity) {
startActivity(ActivitiesActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP);
} else if (itemId == R.id.nav_notifications) {
startActivity(NotificationsActivity.class);
} else if (itemId == R.id.nav_settings) {
startActivity(SettingsActivity.class);
} else if (itemId == R.id.nav_community) {
startActivity(CommunityActivity.class);
} else if (itemId == R.id.nav_logout) {
mCheckedMenuItem = -1;
menuItem.setChecked(false);
final Optional<User> optionalUser = getUser();
if (optionalUser.isPresent()) {
UserInfoActivity.openAccountRemovalConfirmationDialog(optionalUser.get(), getSupportFragmentManager());
}
} else if (itemId == R.id.nav_shared) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER), menuItem.getItemId());
} else if (itemId == R.id.nav_recently_modified) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH), menuItem.getItemId());
} else {
if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK && menuItem.getItemId() <= MENU_ITEM_EXTERNAL_LINK + 100) {
// external link clicked
externalLinkClicked(menuItem);
} else {
Log_OC.w(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle());
}
}
}
use of com.owncloud.android.ui.fragment.GalleryFragment in project android by nextcloud.
the class FileDisplayActivity method onNewIntent.
// Is called with the flag FLAG_ACTIVITY_SINGLE_TOP and set the new file and intent
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (ACTION_DETAILS.equalsIgnoreCase(intent.getAction())) {
OCFile file = intent.getParcelableExtra(EXTRA_FILE);
setFile(file);
setIntent(intent);
setFile(intent.getParcelableExtra(EXTRA_FILE));
showDetails(file);
} else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
handleOpenFileViaIntent(intent);
} else if (RESTART.equals(intent.getAction())) {
finish();
startActivity(intent);
} else // Verify the action and get the query
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
setIntent(intent);
SearchEvent searchEvent = intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT);
if (searchEvent != null) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH.equals(searchEvent.getSearchType())) {
Log_OC.d(this, "Switch to photo search fragment");
GalleryFragment photoFragment = new GalleryFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
photoFragment.setArguments(bundle);
setLeftFragment(photoFragment);
} else {
Log_OC.d(this, "Switch to oc file search fragment");
OCFileListFragment photoFragment = new OCFileListFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
photoFragment.setArguments(bundle);
setLeftFragment(photoFragment);
}
}
} else if (ALL_FILES.equals(intent.getAction())) {
Log_OC.d(this, "Switch to oc file fragment");
setLeftFragment(new OCFileListFragment());
}
}
use of com.owncloud.android.ui.fragment.GalleryFragment in project android by nextcloud.
the class FileDisplayActivity method onResume.
@Override
protected void onResume() {
Log_OC.v(TAG, "onResume() start");
super.onResume();
// Instead of onPostCreate, starting the loading in onResume for children fragments
Fragment leftFragment = getLeftFragment();
// Listen for sync messages
if (!(leftFragment instanceof OCFileListFragment) || !((OCFileListFragment) leftFragment).isSearchFragment()) {
IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
mSyncBroadcastReceiver = new SyncBroadcastReceiver();
localBroadcastManager.registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
}
if (!(leftFragment instanceof OCFileListFragment)) {
if (leftFragment instanceof FileFragment) {
super.updateActionBarTitleAndHomeButton(((FileFragment) leftFragment).getFile());
}
return;
}
OCFileListFragment ocFileListFragment = (OCFileListFragment) leftFragment;
ocFileListFragment.setLoading(mSyncInProgress);
syncAndUpdateFolder(false);
OCFile startFile = null;
if (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) != null) {
startFile = getIntent().getParcelableExtra(EXTRA_FILE);
setFile(startFile);
}
// refresh list of files
if (searchView != null && !TextUtils.isEmpty(searchQuery)) {
searchView.setQuery(searchQuery, false);
} else if (!ocFileListFragment.isSearchFragment() && startFile == null) {
updateListOfFilesFragment(false);
ocFileListFragment.registerFabListener();
} else {
ocFileListFragment.listDirectory(startFile, false, false);
updateActionBarTitleAndHomeButton(startFile);
}
// Listen for upload messages
IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage());
mUploadFinishReceiver = new UploadFinishReceiver();
localBroadcastManager.registerReceiver(mUploadFinishReceiver, uploadIntentFilter);
// Listen for download messages
IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.getDownloadAddedMessage());
downloadIntentFilter.addAction(FileDownloader.getDownloadFinishMessage());
mDownloadFinishReceiver = new DownloadFinishReceiver();
localBroadcastManager.registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
// setup drawer
menuItemId = getIntent().getIntExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
if (menuItemId == -1) {
if (MainApp.isOnlyOnDevice()) {
setDrawerMenuItemChecked(R.id.nav_on_device);
setupToolbar();
} else {
setDrawerMenuItemChecked(R.id.nav_all_files);
setupHomeSearchToolbarWithSortAndListButtons();
}
} else {
if (menuItemId == R.id.nav_all_files) {
setupHomeSearchToolbarWithSortAndListButtons();
} else {
setupToolbar();
}
setDrawerMenuItemChecked(menuItemId);
}
if (ocFileListFragment instanceof GalleryFragment) {
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_gallery));
}
Log_OC.v(TAG, "onResume() end");
}
use of com.owncloud.android.ui.fragment.GalleryFragment in project android by nextcloud.
the class FileDisplayActivity method onMessageEvent.
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(final SearchEvent event) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.getSearchType()) {
Log_OC.d(this, "Switch to photo search fragment");
setLeftFragment(new GalleryFragment());
}
}
use of com.owncloud.android.ui.fragment.GalleryFragment in project android by nextcloud.
the class GallerySearchTask method onPostExecute.
@Override
protected void onPostExecute(GallerySearchTask.Result result) {
if (photoFragmentWeakReference.get() != null) {
GalleryFragment photoFragment = photoFragmentWeakReference.get();
photoFragment.setLoading(false);
photoFragment.searchCompleted(result.emptySearch, result.lastTimestamp);
if (!result.success) {
photoFragment.setEmptyListMessage(SearchType.GALLERY_SEARCH);
}
}
}
Aggregations