use of android.widget.AdapterView.OnItemClickListener in project instructure-android by instructure.
the class RecipientEditTextView method showAddress.
private void showAddress(final DrawableRecipientChip currentChip, final ListPopupWindow popup) {
if (!mAttachedToWindow) {
return;
}
int line = getLayout().getLineForOffset(getChipStart(currentChip));
int bottomOffset = calculateOffsetFromBottomToTop(line);
// Align the alternates popup with the left side of the View,
// regardless of the position of the chip tapped.
popup.setAnchorView(this);
popup.setVerticalOffset(bottomOffset);
popup.setAdapter(createSingleAddressAdapter(currentChip));
popup.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
unselectChip(currentChip);
popup.dismiss();
}
});
popup.show();
ListView listView = popup.getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
unselectChip(currentChip);
popup.dismiss();
}
});
listView.setItemChecked(0, true);
}
use of android.widget.AdapterView.OnItemClickListener in project RxTools by vondear.
the class RxPopupSingleView method initUI.
/**
* 初始化弹窗列表
*/
private void initUI() {
mListView = (ListView) getContentView().findViewById(R.id.title_list);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int index, long arg3) {
// 点击子类项后,弹窗消失
dismiss();
if (mItemOnClickListener != null)
mItemOnClickListener.onItemClick(mActionItems.get(index), index);
}
});
}
use of android.widget.AdapterView.OnItemClickListener in project android_packages_apps_crDroidSettings by crdroidandroid.
the class SlimRecentsBlacklist method onCreateDialog.
@Override
public Dialog onCreateDialog(int dialogId) {
switch(dialogId) {
case DIALOG_BLACKLIST_APPS:
{
Dialog dialog;
AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
final ListView list = new ListView(getActivity());
list.setAdapter(mPackageAdapter);
alertDialog.setTitle(R.string.profile_choose_app);
alertDialog.setView(list);
dialog = alertDialog.create();
list.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Add empty application definition, the user will be able to edit it later
PackageItem info = (PackageItem) parent.getItemAtPosition(position);
addCustomApplicationPref(info.packageName, mBlacklistPackages);
dialog.cancel();
}
});
return dialog;
}
}
return super.onCreateDialog(dialogId);
}
use of android.widget.AdapterView.OnItemClickListener in project android_packages_apps_crDroidSettings by crdroidandroid.
the class IconPickerActivity method getIconPackDialog.
private Dialog getIconPackDialog(Context context) {
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View view = inflater.inflate(R.layout.dialog_iconpack, null);
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final IconPackageAdapter adapter = new IconPackageAdapter(this);
final ListView listView = (ListView) view.findViewById(R.id.iconpack_list);
final Dialog dialog;
adapter.load();
dialog = builder.setTitle(getString(R.string.icon_pack_picker_dialog_title)).setView(view).setOnCancelListener(this).setNegativeButton(android.R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onCancel(dialog);
}
}).create();
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ResolveInfo info = adapter.getItem(position);
String packageName = info.activityInfo.packageName;
Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.crdroid.settings.fragments.navbar.IconPackGridActivity");
intent.putExtra("icon_package_name", packageName);
dialog.dismiss();
startActivityForResult(intent, ICON_PACK_ICON_RESULT);
}
});
return dialog;
}
use of android.widget.AdapterView.OnItemClickListener in project instructure-android by instructure.
the class SubmissionDetailsFragment method setupListeners.
private void setupListeners() {
if (addSubmission != null) {
addSubmission.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Open Submission view, "Go To Discussion" or "Go To Quiz"
if (// Allow the user to go to the discussion.
assignment.getDiscussionTopicHeader() != null && assignment.getDiscussionTopicHeader().getId() > 0 && assignment.getCourseId() > 0) {
String url = DiscussionTopic.getDiscussionURL(ApiPrefs.getProtocol(), ApiPrefs.getDomain(), assignment.getCourseId(), assignment.getDiscussionTopicHeader().getId());
if (!RouterUtils.canRouteInternally(getActivity(), url, ApiPrefs.getDomain(), true)) {
Intent intent = new Intent(getActivity(), InternalWebViewActivity.class);
getActivity().startActivity(intent);
}
} else if (assignment.getQuizId() > 0) {
String url = getQuizURL(getActivity(), assignment.getCourseId(), assignment.getQuizId());
if (!RouterUtils.canRouteInternally(getActivity(), url, ApiPrefs.getDomain(), true)) {
Intent intent = new Intent(getActivity(), InternalWebViewActivity.class);
getActivity().startActivity(intent);
}
} else if (assignment.getTurnInType() == Assignment.TURN_IN_TYPE.EXTERNAL_TOOL) {
// TODO stream doesn't pass the LTI url. Grab it now if we need it
String authenticationURL = assignment.getUrl();
if (authenticationURL == null || authenticationURL.equalsIgnoreCase("null")) {
// get the assignment
AssignmentManager.getAssignment(assignment.getId(), course.getId(), true, canvasCallbackAssignment);
return;
} else {
SubmissionManager.getLtiFromAuthenticationUrl(assignment.getUrl(), canvasCallbackLTITool, true);
}
} else {
if (!APIHelper.hasNetworkConnection()) {
Toast.makeText(getContext(), getContext().getString(R.string.notAvailableOffline), Toast.LENGTH_SHORT).show();
return;
}
// open add submission view
// start it for xml so we can update the results if we need to. Need to call it on the parent fragment
// and it will call onActivityResult in the current child fragment.
Navigation navigation = getNavigation();
if (navigation != null) {
Bundle bundle = AddSubmissionFragment.createBundle((Course) getCanvasContext(), assignment, isOnlineTextAllowed, isUrlEntryAllowed, isFileEntryAllowed, isMediaRecording);
navigation.addFragment(FragUtils.getFrag(AddSubmissionFragment.class, bundle));
}
}
}
});
}
// Handle pressing of the send button.
if (submitComment != null) {
submitComment.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// try to submit the comment
if (!APIHelper.hasNetworkConnection()) {
Toast.makeText(getContext(), getContext().getString(R.string.notAvailableOffline), Toast.LENGTH_SHORT).show();
return;
}
sendMessage(assignment.getId());
}
});
mediaComment.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
ListView listView = new ListView(getActivity());
AttachmentAdapter adapter = new AttachmentAdapter(getActivity(), android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.discussion_attachments));
listView.setAdapter(adapter);
listView.setDivider(null);
listView.setPadding((int) Utils.dpToPx(getActivity(), 10), (int) Utils.dpToPx(getActivity(), 10), (int) Utils.dpToPx(getActivity(), 10), (int) Utils.dpToPx(getActivity(), 16));
final AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.commentUpload).setView(listView).create();
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position) {
case 0:
// Use File Upload Dialog
showUploadFileDialog();
dialog.dismiss();
break;
case 1:
if (message.getText().toString().trim().length() != 0 || attachmentIds.size() > 0) {
Toast.makeText(getContext(), R.string.unableToUploadMediaComment, Toast.LENGTH_SHORT).show();
} else {
// Use Notorious
Intent intent = NotoriousMediaUploadPicker.createIntentForSubmissionComment(getContext(), assignment);
assignmentFragment.get().startActivityForResult(intent, RequestCodes.NOTORIOUS_REQUEST);
dialog.dismiss();
}
break;
default:
break;
}
}
});
dialog.show();
}
});
}
// Handle if they hit the send button in landscape mode.
message.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
// Try to send the message.
if (actionId == EditorInfo.IME_ACTION_SEND) {
sendMessage(assignment.getId());
// Hide keyboard
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(message.getWindowToken(), 0);
return true;
}
return false;
}
});
if (listView != null) {
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
Submission submission = (Submission) adapter.getAdapter().getItem(position);
// it has the details that we need
if (submission.getSubmissionComments().size() == 0) {
if (submission.getSubmissionType().equals("online_upload") || submission.getSubmissionType().equals("media_recording")) {
if (submission.getAttachments().size() == 1) {
// makes more sense to open the file since they should already have it on their device
if (submission.getAttachments().get(0).getContentType().contains("pdf")) {
startActivity(StudentSubmissionActivity.createIntent(getActivity(), course, assignment, new GradeableStudentSubmission(new StudentAssignee(ApiPrefs.getUser(), ApiPrefs.getUser().getId(), ApiPrefs.getUser().getName()), null, false)));
} else {
openMedia(submission.getAttachments().get(0).getContentType(), submission.getAttachments().get(0).getUrl(), submission.getAttachments().get(0).getFilename());
}
} else if (submission.getMediaComment() != null) {
MediaComment mediaComment = submission.getMediaComment();
openMedia(mediaComment.getContentType(), mediaComment.getUrl(), mediaComment.get_fileName());
} else {
// show a list dialog of the files to download.
showFileList(submission.getAttachments());
}
} else if (submission.getSubmissionType().equals("online_text_entry")) {
Navigation navigation = getNavigation();
if (navigation != null) {
Bundle bundle = InternalWebviewFragment.Companion.createBundleHTML(getCanvasContext(), submission.getBody());
navigation.addFragment(FragUtils.getFrag(InternalWebviewFragment.class, bundle));
}
} else if (submission.getSubmissionType().equals("online_url")) {
// Take the user to viewing the online url submission. If the image hasn't processed yet they'll see a toast and it
// will match what the web does - show the url and say it might be different from when they submitted.
Navigation navigation = getNavigation();
if (navigation != null) {
Bundle bundle = SubmissionViewOnlineURLFragment.createBundle(getCanvasContext(), submission);
navigation.addFragment(FragUtils.getFrag(SubmissionViewOnlineURLFragment.class, bundle));
}
if (submission.getAttachments().size() == 0) {
// the server hasn't processed the image for the submitted url yet, show a crouton and reload
showToast(R.string.itemStillProcessing);
loadData(assignment.getId(), false, false);
}
}
}
}
});
}
addComment.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (!APIHelper.hasNetworkConnection()) {
Toast.makeText(getContext(), getContext().getString(R.string.notAvailableOffline), Toast.LENGTH_SHORT).show();
return;
}
// Only show the header if it hasn't been added prior.
if (listView.getHeaderViewsCount() == 1) {
listView.addHeaderView(composeHeaderView, null, false);
}
// add the compose header (the comment box)
composeHeaderView.setVisibility(View.VISIBLE);
}
});
}
Aggregations