use of android.widget.AdapterView.OnItemClickListener in project android_packages_apps_OmniGears by omnirom.
the class AppSelectListPreference method onBindDialogView.
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
final ListView list = (ListView) view.findViewById(R.id.applist);
list.setAdapter(mAdapter);
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
PackageItem info = (PackageItem) parent.getItemAtPosition(position);
mValue = info.mValue;
if (shouldPersist()) {
persistString(mValue);
}
mTitle = info.mTitle;
mAppIconDrawable = null;
mAppIconResourceId = 0;
if (info.mComponentName != null) {
mAppIconDrawable = resolveAppIcon(info);
} else {
mAppIconResourceId = info.mAppIconResourceId;
}
updatePreferenceViews();
callChangeListener(mValue);
getDialog().dismiss();
}
});
}
use of android.widget.AdapterView.OnItemClickListener in project opacclient by opacapp.
the class OpacActivity method selectaccount.
public void selectaccount() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
// Get the layout inflater
LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.dialog_simple_list, null);
ListView lv = (ListView) view.findViewById(R.id.lvBibs);
AccountDataSource data = new AccountDataSource(this);
final List<Account> accounts = data.getAllAccounts();
AccountListAdapter adapter = new AccountListAdapter(this, accounts);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
app.setAccount(accounts.get(position).getId());
adialog.dismiss();
((AccountSelectedListener) fragment).accountSelected(accounts.get(position));
}
});
builder.setTitle(R.string.account_select).setView(view).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
adialog.cancel();
}
}).setNeutralButton(R.string.accounts_edit, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
Intent intent = new Intent(OpacActivity.this, AccountListActivity.class);
startActivity(intent);
}
});
adialog = builder.create();
adialog.show();
}
use of android.widget.AdapterView.OnItemClickListener in project LibreraReader by foobnix.
the class PrefDialogs method selectFileDialog.
public static void selectFileDialog(final Context a, List<String> browseexts, File path, final com.foobnix.android.utils.ResultResponse<String> onChoose) {
final BrowserAdapter adapter = new BrowserAdapter(a, new ExtFilter(browseexts));
if (path.isFile()) {
String absolutePath = path.getAbsolutePath();
String filePath = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator));
adapter.setCurrentDirectory(new File(filePath));
} else {
adapter.setCurrentDirectory(path);
}
final AlertDialog.Builder builder = new AlertDialog.Builder(a);
builder.setTitle(R.string.choose_);
final EditText text = new EditText(a);
text.setText(path.getName());
int p = Dips.dpToPx(5);
text.setPadding(p, p, p, p);
text.setSingleLine();
text.setEllipsize(TruncateAt.END);
text.setEnabled(true);
final TextView pathText = new TextView(a);
pathText.setText(path.getPath());
pathText.setPadding(p, p, p, p);
pathText.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
pathText.setTextSize(16);
pathText.setSingleLine();
pathText.setEllipsize(TruncateAt.END);
final ListView list = new ListView(a);
list.setMinimumHeight(1000);
list.setMinimumWidth(600);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final File file = new File(adapter.getItem(position).getPath());
if (file.isDirectory()) {
adapter.setCurrentDirectory(file);
pathText.setText(file.getPath());
list.setSelection(0);
} else {
text.setText(file.getName());
}
}
});
LinearLayout inflate = (LinearLayout) LayoutInflater.from(a).inflate(R.layout.frame_layout, null, false);
list.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
pathText.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0f));
inflate.addView(pathText);
inflate.addView(list);
inflate.addView(text);
builder.setView(inflate);
builder.setPositiveButton(R.string.select, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
}
});
final AlertDialog dialog = builder.create();
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = text.getText().toString();
if (name == null || name.trim().length() == 0) {
Toast.makeText(a, "Invalid File name", Toast.LENGTH_SHORT).show();
return;
}
File toFile = new File(adapter.getCurrentDirectory(), name);
onChoose.onResultRecive(toFile.getAbsolutePath());
dialog.dismiss();
}
});
}
use of android.widget.AdapterView.OnItemClickListener in project LibreraReader by foobnix.
the class DragingDialogs method addBookmarks.
public static void addBookmarks(final FrameLayout anchor, final DocumentController controller, final Runnable onRefeshUI) {
final List<AppBookmark> objects = new ArrayList<AppBookmark>();
final BookmarksAdapter bookmarksAdapter = new BookmarksAdapter(anchor.getContext(), objects, true);
final View.OnClickListener onAdd = new View.OnClickListener() {
@Override
public void onClick(final View v) {
ListBoxHelper.showAddDialog(controller, objects, bookmarksAdapter, "");
}
};
final OnItemClickListener onItem = new OnItemClickListener() {
@Override
public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) {
final AppBookmark appBookmark = objects.get(position);
int page = PageUrl.realToFake(appBookmark.getPage());
if (page != controller.getCurentPageFirst1()) {
final Integer offsetY = Integer.valueOf((int) controller.getOffsetY());
LOG.d("onItemClick: Bookmark", offsetY);
controller.getLinkHistory().clear();
controller.getLinkHistory().add(offsetY);
}
controller.onGoToPage(page);
onRefeshUI.run();
}
};
final OnItemLongClickListener onBooksLong = new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(final AdapterView<?> parent, final View view, final int position, final long id) {
ListBoxHelper.showEditDeleteDialog(objects.get(position), controller, bookmarksAdapter, objects);
return true;
}
};
new DragingPopup(R.string.bookmarks, anchor, 300, 400) {
@Override
public View getContentView(final LayoutInflater inflater) {
View a = inflater.inflate(R.layout.dialog_bookmarks, null, false);
final ListView contentList = (ListView) a.findViewById(R.id.contentList);
contentList.setDivider(new ColorDrawable(Color.TRANSPARENT));
contentList.setVerticalScrollBarEnabled(false);
contentList.setAdapter(bookmarksAdapter);
contentList.setOnItemClickListener(onItem);
contentList.setOnItemLongClickListener(onBooksLong);
a.findViewById(R.id.addBookmark).setOnClickListener(onAdd);
final View.OnClickListener onAddPAge = new View.OnClickListener() {
@Override
public void onClick(final View v) {
int page = PageUrl.fakeToReal(controller.getCurentPageFirst1());
for (AppBookmark all : objects) {
if (all.getPage() == page) {
Toast.makeText(controller.getActivity(), R.string.bookmark_for_this_page_already_exists, Toast.LENGTH_LONG).show();
return;
}
}
final AppBookmark bookmark = new AppBookmark(controller.getCurrentBook().getPath(), controller.getString(R.string.fast_bookmark), page, controller.getTitle());
AppSharedPreferences.get().addBookMark(bookmark);
objects.clear();
objects.addAll(AppSharedPreferences.get().getBookmarksByBook(controller.getCurrentBook()));
bookmarksAdapter.notifyDataSetChanged();
closeDialog();
String TEXT = controller.getString(R.string.fast_bookmark) + " " + TxtUtils.LONG_DASH + " " + controller.getString(R.string.page) + " " + page + "";
Toast.makeText(controller.getActivity(), TEXT, Toast.LENGTH_SHORT).show();
}
};
a.findViewById(R.id.addPageBookmark).setOnClickListener(onAddPAge);
objects.clear();
objects.addAll(AppSharedPreferences.get().getBookmarksByBook(controller.getCurrentBook()));
bookmarksAdapter.notifyDataSetChanged();
return a;
}
}.show("addBookmarks", false, true);
}
use of android.widget.AdapterView.OnItemClickListener in project LibreraReader by foobnix.
the class DragingDialogs method searchMenu.
public static void searchMenu(final FrameLayout anchor, final DocumentController controller, final String text) {
DragingPopup dialog = new DragingPopup(R.string.search, anchor, 250, 150) {
@Override
public View getContentView(LayoutInflater inflater) {
final View view = inflater.inflate(R.layout.search_dialog, null, false);
final EditText searchEdit = (EditText) view.findViewById(R.id.edit1);
searchEdit.setText(text);
final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar1);
final TextView searchingMsg = (TextView) view.findViewById(R.id.searching);
final GridView gridView = (GridView) view.findViewById(R.id.grid1);
gridView.setColumnWidth(Dips.dpToPx(80));
final BaseItemLayoutAdapter<Integer> adapter = new BaseItemLayoutAdapter<Integer>(anchor.getContext(), android.R.layout.simple_spinner_dropdown_item) {
@Override
public void populateView(View inflate, int arg1, Integer page) {
final TextView text = Views.text(inflate, android.R.id.text1, TxtUtils.deltaPage(page + 1, 0));
text.setGravity(Gravity.CENTER);
text.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
}
@Override
public long getItemId(int position) {
return getItem(position) + 1;
}
};
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
controller.onGoToPage((int) id);
}
});
ImageView onClear = (ImageView) view.findViewById(R.id.imageClear);
onClear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
boolean isRun = TempHolder.isSeaching;
TempHolder.isSeaching = false;
if (!isRun) {
searchEdit.setText("");
controller.clearSelectedText();
searchingMsg.setVisibility(View.GONE);
adapter.getItems().clear();
adapter.notifyDataSetChanged();
}
}
});
final View onSearch = view.findViewById(R.id.onSearch);
TintUtil.setTintBg(onSearch);
EditTextHelper.enableKeyboardSearch(searchEdit, new Runnable() {
@Override
public void run() {
onSearch.performClick();
}
});
if (TxtUtils.isNotEmpty(text)) {
onSearch.postDelayed(new Runnable() {
@Override
public void run() {
onSearch.performClick();
}
}, 250);
}
final String searchingString = anchor.getContext().getString(R.string.searching_please_wait_);
final int count = controller.getPageCount();
final Handler hMessage = new Handler() {
@Override
public void handleMessage(android.os.Message msg) {
int pageNumber = msg.what;
LOG.d("Receive page", pageNumber);
progressBar.setVisibility(View.GONE);
gridView.setVisibility(View.VISIBLE);
if (pageNumber < -1) {
searchingMsg.setVisibility(View.VISIBLE);
searchingMsg.setText(searchingString + " " + Math.abs(pageNumber) + "/" + count);
return;
}
if (pageNumber == -1) {
if (adapter.getItems().size() == 0) {
searchingMsg.setVisibility(View.VISIBLE);
searchingMsg.setText(R.string.msg_no_text_found);
} else {
searchingMsg.setVisibility(View.GONE);
}
}
if (pageNumber == Integer.MAX_VALUE) {
adapter.notifyDataSetChanged();
return;
}
if (pageNumber >= 0) {
pageNumber = PageUrl.realToFake(pageNumber);
searchingMsg.setVisibility(View.VISIBLE);
adapter.getItems().add(pageNumber);
adapter.notifyDataSetChanged();
}
}
};
onSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (TempHolder.isSeaching) {
return;
}
String searchString = searchEdit.getText().toString().trim();
if (searchString.length() < 2) {
return;
}
TempHolder.isSeaching = true;
searchingMsg.setText(R.string.searching_please_wait_);
searchingMsg.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
gridView.setVisibility(View.GONE);
adapter.getItems().clear();
adapter.notifyDataSetChanged();
Keyboards.close(searchEdit);
hMessage.removeCallbacksAndMessages(null);
controller.doSearch(searchString, new ResultResponse<Integer>() {
@Override
public boolean onResultRecive(final Integer pageNumber) {
hMessage.sendEmptyMessage(pageNumber);
return false;
}
});
}
});
return view;
}
};
dialog.setOnCloseListener(new Runnable() {
@Override
public void run() {
TempHolder.isSeaching = false;
}
});
dialog.show("searchMenu");
}
Aggregations