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);
}
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);
}
};
}
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);
}
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;
}
}
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();
}
Aggregations