use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.
the class RecentsCreateFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Context context = getActivity();
mAdapter = new DocumentStackAdapter();
mListView.setAdapter(mAdapter);
final RootsCache roots = DocumentsApplication.getRootsCache(context);
final State state = ((BaseActivity) getActivity()).getDisplayState();
mCallbacks = new LoaderCallbacks<List<DocumentStack>>() {
@Override
public Loader<List<DocumentStack>> onCreateLoader(int id, Bundle args) {
return new RecentsCreateLoader(context, roots, state);
}
@Override
public void onLoadFinished(Loader<List<DocumentStack>> loader, List<DocumentStack> data) {
mAdapter.swapStacks(data);
if (isResumed()) {
setListShown(true);
} else {
setListShownNoAnimation(true);
}
// When launched into empty recents, show drawer
if (mAdapter.isEmpty() && !state.stackTouched) {
((BaseActivity) context).setRootsDrawerOpen(true);
}
}
@Override
public void onLoaderReset(Loader<List<DocumentStack>> loader) {
mAdapter.swapStacks(null);
}
};
setListAdapter(mAdapter);
setListShown(false);
getLoaderManager().restartLoader(LOADER_RECENTS, getArguments(), mCallbacks);
}
use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.
the class DirectoryFragment method updateDisplayState.
private void updateDisplayState() {
final State state = getDisplayState(this);
mDefaultColor = SettingsActivity.getPrimaryColor(getActivity());
int accentColor = SettingsActivity.getAccentColor();
if (mLastMode == state.derivedMode && mLastSortOrder == state.derivedSortOrder && mLastShowSize == state.showSize && mLastShowFolderSize == state.showFolderSize && mLastShowThumbnail == state.showThumbnail && mLastShowHiddenFiles == state.showHiddenFiles && (mLastShowColor != 0 && mLastShowColor == mDefaultColor) && (mLastShowAccentColor != 0 && mLastShowAccentColor == accentColor))
return;
boolean refreshData = mLastShowHiddenFiles != state.showHiddenFiles;
mLastMode = state.derivedMode;
mLastSortOrder = state.derivedSortOrder;
mLastShowSize = state.showSize;
mLastShowFolderSize = state.showFolderSize;
mLastShowThumbnail = state.showThumbnail;
mLastShowHiddenFiles = state.showHiddenFiles;
mLastShowColor = mDefaultColor;
mProgressBar.setColor(mLastShowColor);
mListView.setVisibility(state.derivedMode == MODE_LIST ? View.VISIBLE : View.GONE);
mGridView.setVisibility(state.derivedMode == MODE_GRID ? View.VISIBLE : View.GONE);
final int choiceMode;
if (state.allowMultiple) {
choiceMode = ListView.CHOICE_MODE_MULTIPLE_MODAL;
} else {
choiceMode = ListView.CHOICE_MODE_NONE;
}
final int thumbSize;
if (state.derivedMode == MODE_GRID) {
thumbSize = getResources().getDimensionPixelSize(R.dimen.grid_width);
mListView.setAdapter(null);
mListView.setChoiceMode(ListView.CHOICE_MODE_NONE);
mGridView.setAdapter(mAdapter);
mGridView.setColumnWidth(thumbSize);
mGridView.setNumColumns(GridView.AUTO_FIT);
mGridView.setChoiceMode(choiceMode);
mCurrentView = mGridView;
} else if (state.derivedMode == MODE_LIST) {
thumbSize = getResources().getDimensionPixelSize(R.dimen.icon_size);
mGridView.setAdapter(null);
mGridView.setChoiceMode(ListView.CHOICE_MODE_NONE);
mListView.setAdapter(mAdapter);
mListView.setChoiceMode(choiceMode);
mCurrentView = mListView;
} else {
throw new IllegalStateException("Unknown state " + state.derivedMode);
}
((BaseActivity) getActivity()).upadateActionItems(mCurrentView);
mThumbSize = new Point(thumbSize, thumbSize);
if (refreshData) {
onUserSortOrderChanged();
}
}
use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.
the class DirectoryFragment method bookmarkDocument.
private void bookmarkDocument(DocumentInfo doc) {
DocumentInfo document = doc;
ContentValues contentValues = new ContentValues();
contentValues.put(ExplorerProvider.BookmarkColumns.PATH, document.path);
contentValues.put(ExplorerProvider.BookmarkColumns.TITLE, document.displayName);
contentValues.put(ExplorerProvider.BookmarkColumns.ROOT_ID, document.displayName);
Uri uri = getActivity().getContentResolver().insert(ExplorerProvider.buildBookmark(), contentValues);
if (null != uri) {
((BaseActivity) getActivity()).showInfo("Bookmark added");
RootsCache.updateRoots(getActivity(), ExternalStorageProvider.AUTHORITY);
}
Bundle params = new Bundle();
AnalyticsManager.logEvent("bookmarked", root, params);
}
use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.
the class DirectoryFragment method openDocument.
private void openDocument(DocumentInfo doc) {
Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage(AppsProvider.getPackageForDocId(doc.documentId));
if (intent != null) {
if (Utils.isIntentAvailable(getActivity(), intent)) {
getActivity().startActivity(intent);
}
} else {
((BaseActivity) getActivity()).showError(R.string.unable_to_open_app);
}
Bundle params = new Bundle();
String type = IconUtils.getTypeNameFromMimeType(doc.mimeType);
params.putString(FILE_TYPE, type);
AnalyticsManager.logEvent("open" + "_" + type, params);
}
use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.
the class RootsFragment method onCurrentRootChanged.
public void onCurrentRootChanged() {
if (mAdapter == null || mList == null)
return;
final RootInfo root = ((BaseActivity) getActivity()).getCurrentRoot();
for (int i = 0; i < mAdapter.getGroupCount(); i++) {
for (int j = 0; j < mAdapter.getChildrenCount(i); j++) {
final Object item = mAdapter.getChild(i, j);
if (item instanceof RootItem) {
final RootInfo testRoot = ((RootItem) item).root;
if (Objects.equal(testRoot, root)) {
try {
long id = ExpandableListView.getPackedPositionForChild(i, j);
int index = mList.getFlatListPosition(id);
// mList.setSelection(index);
mList.setItemChecked(index, true);
} catch (Exception e) {
CrashReportingManager.logException(e);
}
return;
}
}
}
}
}
Aggregations