use of de.baumann.browser.View.Adapter_Record in project browser by scoute-dich.
the class BrowserActivity method showEditDialog.
private void showEditDialog(final Adapter_Record adapterRecord, List<Record> recordList, int location) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View dialogView = View.inflate(BrowserActivity.this, R.layout.dialog_edit, null);
final Record record = recordList.get(location);
final EditText editText = dialogView.findViewById(R.id.dialog_edit);
editText.setHint(R.string.dialog_title_hint);
editText.setText(record.getTitle());
editText.setSelection(record.getTitle().length());
builder.setView(dialogView);
builder.setTitle(R.string.menu_edit);
builder.setPositiveButton(R.string.app_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String text = editText.getText().toString().trim();
if (text.isEmpty()) {
NinjaToast.show(BrowserActivity.this, getString(R.string.toast_input_empty));
}
RecordAction action = new RecordAction(BrowserActivity.this);
action.open(true);
record.setTitle(text);
action.updateBookmark(record);
action.close();
adapterRecord.notifyDataSetChanged();
hideSoftInput(editText);
}
});
builder.setNegativeButton(R.string.app_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
hideSoftInput(editText);
}
});
AlertDialog dialog = builder.create();
dialog.show();
showSoftInput(editText);
}
use of de.baumann.browser.View.Adapter_Record in project browser by scoute-dich.
the class BrowserActivity method showListMenu.
private void showListMenu(final Adapter_Record adapterRecord, final List<Record> recordList, final int location) {
final Record record = recordList.get(location);
bottomSheetDialog = new BottomSheetDialog(BrowserActivity.this);
View dialogView = View.inflate(BrowserActivity.this, R.layout.dialog_menu_context, null);
ninjaRelativeLayout = (NinjaRelativeLayout) currentAlbumController;
tv2_menu_newTab = dialogView.findViewById(R.id.tv2_menu_newTab);
tv2_menu_newTab.setVisibility(View.VISIBLE);
tv2_menu_newTab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addAlbum(getString(R.string.album_untitled), record.getURL(), false, null);
NinjaToast.show(BrowserActivity.this, getString(R.string.toast_new_tab_successful));
bottomSheetDialog.cancel();
}
});
tv2_menu_newTab_open = dialogView.findViewById(R.id.tv2_menu_newTab_open);
tv2_menu_newTab_open.setVisibility(View.VISIBLE);
tv2_menu_newTab_open.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pinAlbums(record.getURL());
bottomSheetDialog.cancel();
}
});
tv2_menu_delete = dialogView.findViewById(R.id.tv2_menu_delete);
tv2_menu_delete.setVisibility(View.VISIBLE);
tv2_menu_delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bottomSheetDialog.cancel();
bottomSheetDialog = new BottomSheetDialog(BrowserActivity.this);
View dialogView = View.inflate(BrowserActivity.this, R.layout.dialog_action, null);
TextView textView = dialogView.findViewById(R.id.dialog_text);
textView.setText(R.string.toast_titleConfirm_delete);
Button action_ok = dialogView.findViewById(R.id.action_ok);
action_ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
RecordAction action = new RecordAction(BrowserActivity.this);
action.open(true);
if (currentAlbumController.getFlag() == BrowserUnit.FLAG_BOOKMARKS) {
action.deleteBookmark(record);
} else if (currentAlbumController.getFlag() == BrowserUnit.FLAG_HISTORY) {
action.deleteHistory(record);
}
action.close();
recordList.remove(location);
adapterRecord.notifyDataSetChanged();
updateBookmarks();
updateAutoComplete();
bottomSheetDialog.cancel();
NinjaToast.show(BrowserActivity.this, getString(R.string.toast_delete_successful));
}
});
Button action_cancel = dialogView.findViewById(R.id.action_cancel);
action_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
bottomSheetDialog.cancel();
}
});
bottomSheetDialog.setContentView(dialogView);
bottomSheetDialog.show();
}
});
tv2_menu_edit = dialogView.findViewById(R.id.tv2_menu_edit);
if (ninjaRelativeLayout.getFlag() != BrowserUnit.FLAG_HISTORY) {
tv2_menu_edit.setVisibility(View.VISIBLE);
tv2_menu_edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bottomSheetDialog.cancel();
showEditDialog(adapterRecord, recordList, location);
}
});
}
bottomSheetDialog.setContentView(dialogView);
bottomSheetDialog.show();
}
use of de.baumann.browser.View.Adapter_Record in project browser by scoute-dich.
the class BrowserActivity method initBHList.
private void initBHList(final NinjaRelativeLayout layout) {
RecordAction action = new RecordAction(BrowserActivity.this);
action.open(false);
final List<Record> list;
if (layout.getFlag() == BrowserUnit.FLAG_BOOKMARKS) {
list = action.listBookmarks();
Collections.sort(list, new Comparator<Record>() {
@Override
public int compare(Record first, Record second) {
return first.getTitle().compareTo(second.getTitle());
}
});
} else if (layout.getFlag() == BrowserUnit.FLAG_HISTORY) {
list = action.listHistory();
} else {
list = new ArrayList<>();
}
action.close();
listView = layout.findViewById(R.id.home_list);
final Adapter_Record adapter = new Adapter_Record(BrowserActivity.this, list);
listView.setAdapter(adapter);
adapter.notifyDataSetChanged();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
updateAlbum(list.get(position).getURL());
}
});
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
showListMenu(adapter, list, position);
return true;
}
});
}
Aggregations