use of de.baumann.browser.View.DialogAdapter in project browser by scoute-dich.
the class HolderActivity method showHolderDialog.
private void showHolderDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(new NinjaContextWrapper(this));
builder.setCancelable(true);
@SuppressLint("InflateParams") NinjaRelativeLayout linearLayout = (NinjaRelativeLayout) getLayoutInflater().inflate(R.layout.main_home, null, false);
builder.setView(linearLayout);
String[] strings = getResources().getStringArray(R.array.holder_menu);
List<String> list = new ArrayList<>();
list.addAll(Arrays.asList(strings));
ListView listView = linearLayout.findViewById(R.id.home_list);
DialogAdapter adapter = new DialogAdapter(this, list);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
final AlertDialog dialog = builder.create();
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
HolderActivity.this.finish();
}
});
dialog.show();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position) {
case 0:
Intent toActivity = new Intent(HolderActivity.this, BrowserActivity.class);
toActivity.putExtra(IntentUnit.OPEN, first.getURL());
startActivity(toActivity);
break;
case 1:
BrowserUnit.copyURL(HolderActivity.this, first.getURL());
break;
case 2:
IntentUnit.share(HolderActivity.this, first.getTitle(), first.getURL());
break;
default:
break;
}
dialog.hide();
dialog.dismiss();
finish();
}
});
}
Aggregations