use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.
the class RootsFragment method onResume.
@Override
public void onResume() {
super.onResume();
final Context context = getActivity();
final State state = ((BaseActivity) context).getDisplayState();
state.showAdvanced = state.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(context);
state.rootMode = SettingsActivity.getRootMode(getActivity());
if (state.action == ACTION_BROWSE) {
mList.setOnItemLongClickListener(mItemLongClickListener);
} else {
mList.setOnItemLongClickListener(null);
mList.setLongClickable(false);
}
getLoaderManager().restartLoader(2, null, mCallbacks);
}
use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.
the class SaveFragment method onClick.
@Override
public void onClick(View v) {
final BaseActivity activity = BaseActivity.get(SaveFragment.this);
switch(v.getId()) {
case android.R.id.button1:
if (mReplaceTarget != null) {
activity.onSaveRequested(mReplaceTarget);
} else {
final String mimeType = getArguments().getString(EXTRA_MIME_TYPE);
final String displayName = mDisplayName.getText().toString();
String extension = FileUtils.getExtFromFilename(displayName);
activity.onSaveRequested(TextUtils.isEmpty(extension) ? mimeType : extension, displayName);
}
break;
case android.R.id.button2:
getActivity().getFragmentManager().beginTransaction().remove(this).commit();
break;
}
}
use of dev.dworks.apps.anexplorer.BaseActivity in project AnExplorer by 1hakr.
the class CreateConnectionFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = getActivity().getLayoutInflater();
final View view = dialogInflater.inflate(R.layout.dialog_create_connection, null, false);
name = (AppCompatEditText) view.findViewById(R.id.name);
host = (AppCompatEditText) view.findViewById(R.id.host);
port = (AppCompatEditText) view.findViewById(R.id.port);
path = (AppCompatEditText) view.findViewById(R.id.path);
hostContainer = view.findViewById(R.id.hostContainer);
pathContainer = view.findViewById(R.id.pathContainer);
username = (AppCompatEditText) view.findViewById(R.id.username);
usernameContainer = view.findViewById(R.id.usernameContainer);
password = (AppCompatEditText) view.findViewById(R.id.password);
passwordContainer = view.findViewById(R.id.passwordContainer);
scheme = (AppCompatSpinner) view.findViewById(R.id.scheme);
anonymous = (AppCompatCheckBox) view.findViewById(R.id.anonymous);
anonymous.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
usernameContainer.setVisibility(b ? View.GONE : View.VISIBLE);
passwordContainer.setVisibility(b ? View.GONE : View.VISIBLE);
}
});
if (connection_id != 0) {
NetworkConnection connection = NetworkConnection.fromConnectionId(getActivity(), connection_id);
ArrayAdapter myAdap = (ArrayAdapter) scheme.getAdapter();
int spinnerPosition = myAdap.getPosition(connection.getScheme().toUpperCase());
scheme.setSelection(spinnerPosition);
name.setText(connection.getName());
host.setText(connection.getHost());
port.setText(Integer.toString(connection.getPort()));
path.setText(connection.getPath());
username.setText(connection.getUserName());
password.setText(connection.getPassword());
anonymous.setChecked(connection.isAnonymousLogin());
if (SERVER.equals(connection.getType())) {
hostContainer.setVisibility(View.GONE);
pathContainer.setVisibility(View.VISIBLE);
}
}
builder.setTitle((connection_id == 0 ? "New" : "Edit") + " Connection");
builder.setView(view);
builder.setPositiveButton(connection_id == 0 ? "ADD" : "SAVE", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final BaseActivity activity = (BaseActivity) getActivity();
NetworkConnection networkConnection = getNetworkConnection();
if (validate(networkConnection)) {
new CreateConnectionTask(activity, networkConnection).executeOnExecutor(ProviderExecutor.forAuthority(ExplorerProvider.AUTHORITY));
}
}
});
builder.setNegativeButton(android.R.string.cancel, null);
return builder.create();
}
Aggregations