Search in sources :

Example 6 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class Utils method getAppsBackupFile.

public static File getAppsBackupFile(Context context) {
    final RootInfo root = DocumentsApplication.getRootsCache(context).getPrimaryRoot();
    File rootFile = (null != root) ? new File(root.path) : Environment.getExternalStorageDirectory();
    return new File(rootFile, DIRECTORY_APPBACKUP);
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) File(java.io.File)

Example 7 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class HomeFragment method showShortcuts.

private void showShortcuts() {
    ArrayList<RootInfo> data = roots.getShortcutsInfo();
    mShortcutsAdapter = new ShortcutsAdapter(getActivity(), data);
    mShortcutsAdapter.setOnItemClickListener(new ShortcutsAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(ShortcutsAdapter.ViewHolder item, int position) {
            openRoot(mShortcutsAdapter.getItem(position));
        }
    });
    mShortcutsRecycler.setAdapter(mShortcutsAdapter);
}
Also used : ShortcutsAdapter(dev.dworks.apps.anexplorer.adapter.ShortcutsAdapter) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo)

Example 8 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class HomeFragment method showMemory.

private void showMemory(long currentAvailableBytes) {
    final RootInfo processRoot = roots.getProcessRoot();
    if (null != processRoot) {
        memoryStats.setVisibility(View.VISIBLE);
        memoryStats.setInfo(processRoot);
        memoryStats.setAction(R.drawable.ic_clean, new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                new OperationTask(processRoot).execute();
                Bundle params = new Bundle();
                AnalyticsManager.logEvent("process_clean", params);
            }
        });
        memoryStats.setCardListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                openRoot(processRoot);
            }
        });
        if (currentAvailableBytes != 0) {
            long availableBytes = processRoot.availableBytes - currentAvailableBytes;
            String summaryText = availableBytes <= 0 ? "Already cleaned up!" : getActivity().getString(R.string.root_available_bytes, Formatter.formatFileSize(getActivity(), availableBytes));
            ((DocumentsActivity) getActivity()).showInfo(summaryText);
        }
        processTimer = new Timer();
        animateProgress(memoryStats, processTimer, processRoot);
    }
}
Also used : DocumentsActivity(dev.dworks.apps.anexplorer.DocumentsActivity) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) Timer(java.util.Timer) Bundle(android.os.Bundle) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 9 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class HomeFragment method showRecents.

private void showRecents() {
    final RootInfo root = roots.getRecentsRoot();
    recents.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            openRoot(root);
        }
    });
    mRecentsAdapter = new RecentsAdapter(getActivity(), null);
    mRecentsAdapter.setOnItemClickListener(new RecentsAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(RecentsAdapter.ViewHolder item, int position) {
            openDocument(item.mDocumentInfo);
        }
    });
    mRecentsRecycler.setAdapter(mRecentsAdapter);
    LinearSnapHelper helper = new LinearSnapHelper();
    helper.attachToRecyclerView(mRecentsRecycler);
    final BaseActivity.State state = getDisplayState(this);
    mCallbacks = new LoaderManager.LoaderCallbacks<DirectoryResult>() {

        @Override
        public Loader<DirectoryResult> onCreateLoader(int id, Bundle args) {
            final RootsCache roots = DocumentsApplication.getRootsCache(getActivity());
            return new RecentLoader(getActivity(), roots, state);
        }

        @Override
        public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) {
            if (!isAdded())
                return;
            if (null == result.cursor || (null != result.cursor && result.cursor.getCount() == 0)) {
                recents_container.setVisibility(View.GONE);
            } else {
                // recents_container.setVisibility(View.VISIBLE);
                mRecentsAdapter.swapCursor(new LimitCursorWrapper(result.cursor, MAX_RECENT_COUNT));
            }
        }

        @Override
        public void onLoaderReset(Loader<DirectoryResult> loader) {
            mRecentsAdapter.swapCursor(null);
        }
    };
    getLoaderManager().restartLoader(mLoaderId, null, mCallbacks);
}
Also used : Bundle(android.os.Bundle) LinearSnapHelper(android.support.v7.widget.LinearSnapHelper) RecentLoader(dev.dworks.apps.anexplorer.loader.RecentLoader) Loader(android.content.Loader) LimitCursorWrapper(dev.dworks.apps.anexplorer.cursor.LimitCursorWrapper) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) RecentsAdapter(dev.dworks.apps.anexplorer.adapter.RecentsAdapter) LoaderManager(android.app.LoaderManager) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) RootsCache(dev.dworks.apps.anexplorer.misc.RootsCache) DirectoryResult(dev.dworks.apps.anexplorer.model.DirectoryResult) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) RecentLoader(dev.dworks.apps.anexplorer.loader.RecentLoader)

Example 10 with RootInfo

use of dev.dworks.apps.anexplorer.model.RootInfo in project AnExplorer by 1hakr.

the class DocumentsActivity method again.

@Override
public void again() {
    if (Utils.hasMarshmallow()) {
        RootsCache.updateRoots(this, ExternalStorageProvider.AUTHORITY);
        mRoots = DocumentsApplication.getRootsCache(this);
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {

            @Override
            public void run() {
                mRoots.updateAsync();
                final RootInfo root = getCurrentRoot();
                if (root.isHome()) {
                    HomeFragment homeFragment = HomeFragment.get(getFragmentManager());
                    if (null != homeFragment) {
                        homeFragment.reloadData();
                    }
                }
            }
        }, 500);
    }
}
Also used : RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) Handler(android.os.Handler) HomeFragment(dev.dworks.apps.anexplorer.fragment.HomeFragment)

Aggregations

RootInfo (dev.dworks.apps.anexplorer.model.RootInfo)26 Bundle (android.os.Bundle)5 View (android.view.View)5 TextView (android.widget.TextView)5 DocumentInfo (dev.dworks.apps.anexplorer.model.DocumentInfo)5 ArrayList (java.util.ArrayList)5 FragmentManager (android.app.FragmentManager)4 Uri (android.net.Uri)4 RecyclerView (android.support.v7.widget.RecyclerView)4 Intent (android.content.Intent)3 BaseActivity (dev.dworks.apps.anexplorer.BaseActivity)3 Timer (java.util.Timer)3 TargetApi (android.annotation.TargetApi)2 Context (android.content.Context)2 Loader (android.content.Loader)2 Cursor (android.database.Cursor)2 MenuItem (android.view.MenuItem)2 State (dev.dworks.apps.anexplorer.BaseActivity.State)2 RootsFragment (dev.dworks.apps.anexplorer.fragment.RootsFragment)2 SaveFragment (dev.dworks.apps.anexplorer.fragment.SaveFragment)2