Search in sources :

Example 1 with BaseActivity

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

the class DirectoryFragment method infoDocument.

private void infoDocument(DocumentInfo doc) {
    final BaseActivity activity = (BaseActivity) getActivity();
    activity.setInfoDrawerOpen(true);
    if (activity.isShowAsDialog()) {
        DetailFragment.showAsDialog(activity.getSupportFragmentManager(), doc);
    } else {
        DetailFragment.show(activity.getSupportFragmentManager(), doc);
    }
    Bundle params = new Bundle();
    String type = IconUtils.getTypeNameFromMimeType(doc.mimeType);
    params.putString(FILE_TYPE, type);
    AnalyticsManager.logEvent("details", params);
}
Also used : Bundle(android.os.Bundle) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) DocumentInfo.getCursorString(dev.dworks.apps.anexplorer.model.DocumentInfo.getCursorString)

Example 2 with BaseActivity

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

the class RootsFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (null != savedInstanceState) {
        group_size = savedInstanceState.getInt(GROUP_SIZE, 0);
        expandedIds = (ArrayList<Long>) savedInstanceState.getSerializable(GROUP_IDS);
    }
    final Context context = getActivity();
    final RootsCache roots = DocumentsApplication.getRootsCache(context);
    final State state = ((BaseActivity) context).getDisplayState();
    mCallbacks = new LoaderCallbacks<Collection<RootInfo>>() {

        @Override
        public Loader<Collection<RootInfo>> onCreateLoader(int id, Bundle args) {
            return new RootsLoader(context, roots, state);
        }

        @Override
        public void onLoadFinished(Loader<Collection<RootInfo>> loader, Collection<RootInfo> result) {
            if (!isAdded())
                return;
            final Intent includeApps = getArguments().getParcelable(EXTRA_INCLUDE_APPS);
            if (mAdapter == null) {
                mAdapter = new RootsExpandableAdapter(context, result, includeApps);
                Parcelable state = mList.onSaveInstanceState();
                mList.setAdapter(mAdapter);
                mList.onRestoreInstanceState(state);
            } else {
                mAdapter.setData(result);
            }
            int groupCount = mAdapter.getGroupCount();
            if (group_size != 0 && group_size == groupCount) {
                if (expandedIds != null) {
                    restoreExpandedState(expandedIds);
                }
            } else {
                group_size = groupCount;
                for (int i = 0; i < group_size; i++) {
                    mList.expandGroup(i);
                }
                expandedIds = getExpandedIds();
                mList.setOnGroupExpandListener(mOnGroupExpandListener);
                mList.setOnGroupCollapseListener(mOnGroupCollapseListener);
            }
        }

        @Override
        public void onLoaderReset(Loader<Collection<RootInfo>> loader) {
            mAdapter = null;
            mList.setAdapter((RootsExpandableAdapter) null);
        }
    };
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Loader(android.content.Loader) RootsLoader(dev.dworks.apps.anexplorer.loader.RootsLoader) Intent(android.content.Intent) Parcelable(android.os.Parcelable) RootsLoader(dev.dworks.apps.anexplorer.loader.RootsLoader) RootsCache(dev.dworks.apps.anexplorer.misc.RootsCache) RootInfo(dev.dworks.apps.anexplorer.model.RootInfo) State(dev.dworks.apps.anexplorer.BaseActivity.State) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) RootsExpandableAdapter(dev.dworks.apps.anexplorer.adapter.RootsExpandableAdapter) Collection(java.util.Collection)

Example 3 with BaseActivity

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

the class HomeFragment method openDocument.

private void openDocument(DocumentInfo doc) {
    ((BaseActivity) getActivity()).onDocumentPicked(doc);
    Bundle params = new Bundle();
    String type = IconUtils.getTypeNameFromMimeType(doc.mimeType);
    params.putString(FILE_TYPE, type);
    AnalyticsManager.logEvent("open_image_recent", params);
}
Also used : Bundle(android.os.Bundle) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity)

Example 4 with BaseActivity

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

the class ConnectionsFragment method onPopupMenuItemClick.

public boolean onPopupMenuItemClick(MenuItem item, int position) {
    final Cursor cursor = mAdapter.getItem(position);
    int connection_id = getCursorInt(cursor, BaseColumns._ID);
    NetworkConnection networkConnection = NetworkConnection.fromConnectionsCursor(cursor);
    final int id = item.getItemId();
    switch(id) {
        case R.id.menu_edit:
            editConnection(connection_id);
            return true;
        case R.id.menu_delete:
            if (!networkConnection.type.equals(SERVER)) {
                deleteConnection(connection_id);
            } else {
                ((BaseActivity) getActivity()).showSnackBar("Default server connection can't be deleted", Snackbar.LENGTH_SHORT);
            }
            return true;
        default:
            return false;
    }
}
Also used : NetworkConnection(dev.dworks.apps.anexplorer.network.NetworkConnection) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) Cursor(android.database.Cursor)

Example 5 with BaseActivity

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

the class CreateDirectoryFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
    final View view = dialogInflater.inflate(R.layout.dialog_create_dir, null, false);
    final EditText text1 = (EditText) view.findViewById(android.R.id.text1);
    Utils.tintWidget(text1);
    builder.setTitle(R.string.menu_create_dir);
    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String displayName = text1.getText().toString();
            final BaseActivity activity = (BaseActivity) getActivity();
            final DocumentInfo cwd = activity.getCurrentDirectory();
            if (TextUtils.isEmpty(displayName)) {
                activity.showError(R.string.create_error);
                return;
            }
            new CreateDirectoryTask(activity, cwd, displayName).executeOnExecutor(ProviderExecutor.forAuthority(cwd.authority));
        }
    });
    builder.setNegativeButton(android.R.string.cancel, null);
    return builder.create();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) View(android.view.View) LayoutInflater(android.view.LayoutInflater) BaseActivity(dev.dworks.apps.anexplorer.BaseActivity) OnClickListener(android.content.DialogInterface.OnClickListener) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

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