use of dev.dworks.apps.anexplorer.network.NetworkConnection in project AnExplorer by 1hakr.
the class ServerFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setRetainInstance(true);
root = getArguments().getParcelable(EXTRA_ROOT);
NetworkConnection connection = NetworkConnection.fromRootInfo(getActivity(), root);
path.setText(connection.getPath());
username.setText(connection.getUserName());
password.setText(connection.getPassword());
}
use of dev.dworks.apps.anexplorer.network.NetworkConnection in project AnExplorer by 1hakr.
the class ConnectionsAdapter method getDocumentView.
private View getDocumentView(int position, View convertView, ViewGroup parent) {
final Context context = parent.getContext();
if (convertView == null) {
final LayoutInflater inflater = LayoutInflater.from(context);
convertView = inflater.inflate(R.layout.item_connection_list, parent, false);
}
final Cursor cursor = getItem(position);
NetworkConnection networkConnection = NetworkConnection.fromConnectionsCursor(cursor);
final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
final View iconMimeBackground = convertView.findViewById(R.id.icon_mime_background);
final TextView title = (TextView) convertView.findViewById(android.R.id.title);
final ImageView icon1 = (ImageView) convertView.findViewById(android.R.id.icon1);
final TextView summary = (TextView) convertView.findViewById(android.R.id.summary);
final View popupButton = convertView.findViewById(R.id.button_popup);
popupButton.setVisibility(isTelevision() ? View.INVISIBLE : View.VISIBLE);
popupButton.setOnClickListener(mListener);
title.setText(networkConnection.getName());
summary.setText(networkConnection.getSummary());
iconMimeBackground.setVisibility(View.VISIBLE);
iconMimeBackground.setBackgroundColor(IconColorUtils.loadSchmeColor(context, networkConnection.getType()));
iconMime.setImageDrawable(IconUtils.loadSchemeIcon(context, networkConnection.type));
// ContextCompat.getDrawable(context, R.drawable.ic_connection_network));
return convertView;
}
use of dev.dworks.apps.anexplorer.network.NetworkConnection 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