Search in sources :

Example 6 with BaseActivity

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);
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) UriDerivativeLoader(dev.dworks.apps.anexplorer.loader.UriDerivativeLoader) Loader(android.content.Loader) RootsCache(dev.dworks.apps.anexplorer.misc.RootsCache) State(dev.dworks.apps.anexplorer.BaseActivity.State) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) ArrayList(java.util.ArrayList) List(java.util.List) DocumentStack(dev.dworks.apps.anexplorer.model.DocumentStack)

Example 7 with BaseActivity

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();
    }
}
Also used : State(dev.dworks.apps.anexplorer.BaseActivity.State) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) Point(android.graphics.Point) Point(android.graphics.Point)

Example 8 with BaseActivity

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);
}
Also used : ContentValues(android.content.ContentValues) Bundle(android.os.Bundle) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) Uri(android.net.Uri) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Example 9 with BaseActivity

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);
}
Also used : Bundle(android.os.Bundle) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) Intent(android.content.Intent) DocumentInfo.getCursorString(dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)

Example 10 with BaseActivity

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;
                }
            }
        }
    }
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity)

Aggregations

BaseActivity (dev.dworks.apps.anexplorer.BaseActivity)13 Bundle (android.os.Bundle)6 Context (android.content.Context)5 State (dev.dworks.apps.anexplorer.BaseActivity.State)4 DialogInterface (android.content.DialogInterface)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 Intent (android.content.Intent)2 Loader (android.content.Loader)2 AlertDialog (android.support.v7.app.AlertDialog)2 LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 RootsCache (dev.dworks.apps.anexplorer.misc.RootsCache)2 DocumentInfo (dev.dworks.apps.anexplorer.model.DocumentInfo)2 DocumentInfo.getCursorString (dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)2 RootInfo (dev.dworks.apps.anexplorer.model.RootInfo)2 NetworkConnection (dev.dworks.apps.anexplorer.network.NetworkConnection)2 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 Point (android.graphics.Point)1 Uri (android.net.Uri)1