List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.npi.muzeiflickr.ui.activities.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); CalligraphyConfig.initDefault(""); setContentView(R.layout.settings_activity); final SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); final SharedPreferences.Editor editor = settings.edit(); //Find views//from w w w . j a v a 2 s . c o m Switch wifiOnly = (Switch) findViewById(R.id.wifi_only); mRefreshRate = (TextView) findViewById(R.id.refresh_rate); ImageView aboutShortcut = (ImageView) findViewById(R.id.about); mRequestList = (DragSortListView) findViewById(R.id.content_list); mUndoContainer = (RelativeLayout) findViewById(R.id.undo_container); mLastDeletedItemText = (TextView) findViewById(R.id.last_deleted_item); TextView mLastDeletedUndo = (TextView) findViewById(R.id.last_deleted_undo); List<RequestData> items = new ArrayList<RequestData>(); items.addAll(Search.listAll(Search.class)); items.addAll(User.listAll(User.class)); items.addAll(Tag.listAll(Tag.class)); items.addAll(FGroup.listAll(FGroup.class)); mRequestAdapter = new RequestAdapter(this, items); final View footerView = getLayoutInflater().inflate(R.layout.list_footer, null); mRequestList.addFooterView(footerView); mRequestList.setAdapter(mRequestAdapter); mRequestList.setRemoveListener(onRemove); populateFooter(footerView); //Wifi status and setting wifiOnly.setChecked(settings.getBoolean(PreferenceKeys.WIFI_ONLY, false)); wifiOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { editor.putBoolean(PreferenceKeys.WIFI_ONLY, isChecked); editor.commit(); } }); //Other settings population int refreshRate = settings.getInt(PreferenceKeys.REFRESH_TIME, FlickrSource.DEFAULT_REFRESH_TIME); mRefreshRate.setText(Utils.convertDurationtoString(refreshRate)); mRefreshRate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { HHmsPickerBuilder hpb = new HHmsPickerBuilder().setFragmentManager(getSupportFragmentManager()) .setStyleResId(R.style.MyCustomBetterPickerTheme); hpb.show(); } }); aboutShortcut.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AboutActivity.launchActivity(SettingsActivity.this); } }); mLastDeletedUndo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mLastDeletedItem instanceof User) { User user = ((User) mLastDeletedItem); user.setId(null); user.save(); } else if (mLastDeletedItem instanceof Search) { Search search = ((Search) mLastDeletedItem); search.setId(null); search.save(); } mRequestAdapter.add(mLastDeletedItem); mRequestAdapter.notifyDataSetChanged(); mUndoContainer.setVisibility(View.GONE); } }); }
From source file:nya.miku.wishmaster.http.cloudflare.CloudflareUIHandler.java
/** * ?-? Cloudflare.//from www.jav a 2 s .com * * @param e ? {@link CloudflareException} * @param chan * @param activity ?, ? ( ? ? ), * ? ? WebView ? Anti DDOS ? javascript. * ??? ? UI ({@link Activity#runOnUiThread(Runnable)}) * @param cfTask ?? * @param callback ? {@link Callback} */ static void handleCloudflare(final CloudflareException e, final HttpChanModule chan, final Activity activity, final CancellableTask cfTask, final InteractiveException.Callback callback) { if (cfTask.isCancelled()) return; if (!e.isRecaptcha()) { // ? anti DDOS if (!CloudflareChecker.getInstance().isAvaibleAntiDDOS()) { //? ? ?? , ? ? ? // ?, ? ChanModule, // ? ? () cloudflare ? ? // ? ? ? ? ? CloudflareChecker while (!CloudflareChecker.getInstance().isAvaibleAntiDDOS()) Thread.yield(); if (!cfTask.isCancelled()) activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); return; } Cookie cfCookie = CloudflareChecker.getInstance().checkAntiDDOS(e, chan.getHttpClient(), cfTask, activity); if (cfCookie != null) { chan.saveCookie(cfCookie); if (!cfTask.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); } } else if (!cfTask.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onError(activity.getString(R.string.error_cloudflare_antiddos)); } }); } } else { // ? final Recaptcha recaptcha; try { recaptcha = CloudflareChecker.getInstance().getRecaptcha(e, chan.getHttpClient(), cfTask); } catch (RecaptchaException recaptchaException) { if (!cfTask.isCancelled()) activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onError(activity.getString(R.string.error_cloudflare_get_captcha)); } }); return; } if (!cfTask.isCancelled()) activity.runOnUiThread(new Runnable() { @SuppressLint("InflateParams") @Override public void run() { Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? new ContextThemeWrapper(activity, R.style.Neutron_Medium) : activity; View view = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_cloudflare_captcha, null); ImageView captchaView = (ImageView) view.findViewById(R.id.dialog_captcha_view); final EditText captchaField = (EditText) view.findViewById(R.id.dialog_captcha_field); captchaView.setImageBitmap(recaptcha.bitmap); DialogInterface.OnClickListener process = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (cfTask.isCancelled()) return; PriorityThreadFactory.LOW_PRIORITY_FACTORY.newThread(new Runnable() { @Override public void run() { String answer = captchaField.getText().toString(); Cookie cfCookie = CloudflareChecker.getInstance().checkRecaptcha(e, (ExtendedHttpClient) chan.getHttpClient(), cfTask, recaptcha.challenge, answer); if (cfCookie != null) { chan.saveCookie(cfCookie); if (!cfTask.isCancelled()) { activity.runOnUiThread(new Runnable() { @Override public void run() { callback.onSuccess(); } }); } } else { // (?, , ) handleCloudflare(e, chan, activity, cfTask, callback); } } }).start(); } }; DialogInterface.OnCancelListener onCancel = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { callback.onError(activity.getString(R.string.error_cloudflare_cancelled)); } }; if (cfTask.isCancelled()) return; final AlertDialog recaptchaDialog = new AlertDialog.Builder(dialogContext).setView(view) .setPositiveButton(R.string.dialog_cloudflare_captcha_check, process) .setOnCancelListener(onCancel).create(); recaptchaDialog.getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); recaptchaDialog.setCanceledOnTouchOutside(false); recaptchaDialog.show(); captchaView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { recaptchaDialog.dismiss(); if (cfTask.isCancelled()) return; PriorityThreadFactory.LOW_PRIORITY_FACTORY.newThread(new Runnable() { @Override public void run() { handleCloudflare(e, chan, activity, cfTask, callback); } }).start(); } }); } }); } }
From source file:org.akvo.caddisfly.sensor.colorimetry.strip.instructions.InstructionActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_instruction); final PageIndicatorView pageIndicatorView = (PageIndicatorView) findViewById(R.id.pager_indicator); final ImageView imagePageLeft = (ImageView) findViewById(R.id.image_pageLeft); final ImageView imagePageRight = (ImageView) findViewById(R.id.image_pageRight); StripTest.Brand brand = (new StripTest()).getBrand(getIntent().getStringExtra(Constant.UUID)); setTitle(brand.getName());//from w w w .j a va 2 s.c o m JSONArray instructions = brand.getInstructions(); if (instructions != null) { for (int i = 0; i < instructions.length(); i++) { try { Object item = instructions.getJSONObject(i).get("text"); JSONArray jsonArray; if (item instanceof JSONArray) { jsonArray = (JSONArray) item; } else { String text = (String) item; jsonArray = new JSONArray(); jsonArray.put(text); } fragments.add(InstructionDetailFragment.newInstance(jsonArray, instructions.getJSONObject(i).has("png") ? instructions.getJSONObject(i).getString("png") : "")); } catch (JSONException e) { Timber.e(e); } } pageIndicatorView.setPageCount(instructions.length()); } mViewPager = (ViewPager) findViewById(R.id.pager); final PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(pagerAdapter); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { pageIndicatorView.setActiveIndex(position); if (position < 1) { imagePageLeft.setVisibility(View.INVISIBLE); } else { imagePageLeft.setVisibility(View.VISIBLE); } if (position > pagerAdapter.getCount() - 2) { imagePageRight.setVisibility(View.INVISIBLE); } else { imagePageRight.setVisibility(View.VISIBLE); } } @Override public void onPageScrollStateChanged(int state) { } }); imagePageLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(Math.max(0, mViewPager.getCurrentItem() - 1)); } }); imagePageRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(Math.min(fragments.size() - 1, mViewPager.getCurrentItem() + 1)); } }); if (pagerAdapter.getCount() < 2) { imagePageLeft.setVisibility(View.GONE); imagePageRight.setVisibility(View.GONE); } }
From source file:com.Candy.sizer.CandySizer.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final ImageView delButton = (ImageView) getView().findViewById(R.id.btn_delete); final ImageView profileButton = (ImageView) getView().findViewById(R.id.btn_profile); if (delButton == null) { return;/*from w w w. j a v a2s.co m*/ } // create arraylist of apps not to be removed final ArrayList<String> safetyList = new ArrayList<String>(); safetyList.add("BackupRestoreConfirmation.apk"); safetyList.add("CertInstaller.apk"); safetyList.add("Contacts.apk"); safetyList.add("ContactsProvider.apk"); safetyList.add("DefaultContainerService.apk"); safetyList.add("DownloadProvider.apk"); safetyList.add("DrmProvider.apk"); safetyList.add("MediaProvider.apk"); safetyList.add("Mms.apk"); safetyList.add("PackageInstaller.apk"); safetyList.add("Phone.apk"); safetyList.add("Settings.apk"); safetyList.add("SettingsProvider.apk"); safetyList.add("CandyOTA.apk"); safetyList.add("Superuser.apk"); safetyList.add("SystemUI.apk"); safetyList.add("TelephonyProvider.apk"); // create arraylist from /system/app content File system = new File(systemPath); String[] sysappArray = system.list(); mSysApp = new ArrayList<String>(Arrays.asList(sysappArray)); // remove "apps not to be removed" from list and sort list mSysApp.removeAll(safetyList); Collections.sort(mSysApp); // populate listview via arrayadapter adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_multiple_choice, mSysApp); final ListView lv = (ListView) getView().findViewById(R.string.listsystem); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); lv.setAdapter(adapter); // longclick an entry lv.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int arg2, long arg3) { // create deletion dialog String item = lv.getAdapter().getItem(arg2).toString(); showDialog(DELETE_DIALOG, item, adapter, 0); return false; } }); // click button delete delButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // check which items are selected String item = null; int itemCounter = 0; SparseBooleanArray checked = lv.getCheckedItemPositions(); for (int i = lv.getCount() - 1; i > 0; i--) { if (checked.get(i)) { item = mSysApp.get(i); itemCounter++; } } if (item == null) { toast(getResources().getString(R.string.sizer_message_noselect)); return; } else { showDialog(DELETE_MULTIPLE_DIALOG, item, adapter, itemCounter); } } }); // click button profile profileButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // call select dialog selectDialog(mSysApp, adapter); } }); }
From source file:com.example.conallcurran.quick_click.English_Infants.java
private void zoomImageFromThumb(final View thumbView, int imageResId) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel();//from ww w . j av a 2 s. co m } final ImageView expandedImageView = (ImageView) findViewById(R.id.expanded_image); expandedImageView.setImageResource(imageResId); final Rect startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); thumbView.getGlobalVisibleRect(startBounds); findViewById(R.id.container).getGlobalVisibleRect(finalBounds, globalOffset); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); float startScale; if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { // Extend start bounds vertically startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } thumbView.setAlpha(0f); expandedImageView.setVisibility(View.VISIBLE); expandedImageView.setPivotX(0f); expandedImageView.setPivotY(0f); AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left, finalBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top, finalBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale, 1f)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale, 1f)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; final float startScaleFinal = startScale; expandedImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } // Animate the four positioning/sizing properties in parallel, back to their // original values. AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(expandedImageView, View.X, startBounds.left)) .with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal)) .with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal)); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } @Override public void onAnimationCancel(Animator animation) { thumbView.setAlpha(1f); expandedImageView.setVisibility(View.GONE); mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; } }); }
From source file:de.baumann.quitsmoking.fragments.FragmentNotes.java
private void setNotesList() { ArrayList<HashMap<String, String>> mapList = new ArrayList<>(); try {/* ww w . ja v a2 s .c o m*/ Database_Notes db = new Database_Notes(getActivity()); ArrayList<String[]> bookmarkList = new ArrayList<>(); db.getBookmarks(bookmarkList, getActivity()); if (bookmarkList.size() == 0) { db.loadInitialData(); db.getBookmarks(bookmarkList, getActivity()); } db.close(); for (String[] strAry : bookmarkList) { HashMap<String, String> map = new HashMap<>(); map.put("seqno", strAry[0]); map.put("title", strAry[1]); map.put("cont", strAry[2]); map.put("icon", strAry[3]); map.put("attachment", strAry[4]); map.put("createDate", strAry[5]); mapList.add(map); } SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), mapList, R.layout.list_item_notes, new String[] { "title", "cont", "createDate" }, new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }) { @Override public View getView(final int position, View convertView, ViewGroup parent) { @SuppressWarnings("unchecked") HashMap<String, String> map = (HashMap<String, String>) listView.getItemAtPosition(position); final String title = map.get("title"); final String cont = map.get("cont"); final String seqnoStr = map.get("seqno"); final String icon = map.get("icon"); final String attachment = map.get("attachment"); final String create = map.get("createDate"); View v = super.getView(position, convertView, parent); ImageView i = (ImageView) v.findViewById(R.id.icon_notes); ImageView i2 = (ImageView) v.findViewById(R.id.att_notes); switch (icon) { case "1": i.setImageResource(R.drawable.emoticon_neutral); break; case "2": i.setImageResource(R.drawable.emoticon_happy); break; case "3": i.setImageResource(R.drawable.emoticon_sad); break; case "4": i.setImageResource(R.drawable.emoticon); break; case "5": i.setImageResource(R.drawable.emoticon_cool); break; case "6": i.setImageResource(R.drawable.emoticon_dead); break; case "7": i.setImageResource(R.drawable.emoticon_excited); break; case "8": i.setImageResource(R.drawable.emoticon_tongue); break; case "9": i.setImageResource(R.drawable.emoticon_devil); break; } switch (attachment) { case "": i2.setVisibility(View.GONE); break; default: i2.setVisibility(View.VISIBLE); break; } File file = new File(attachment); if (!file.exists()) { i2.setVisibility(View.GONE); } i.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final FragmentNotes.Item[] items = { new FragmentNotes.Item(getString(R.string.text_tit_1), R.drawable.emoticon_neutral), new FragmentNotes.Item(getString(R.string.text_tit_2), R.drawable.emoticon_happy), new FragmentNotes.Item(getString(R.string.text_tit_3), R.drawable.emoticon_sad), new FragmentNotes.Item(getString(R.string.text_tit_4), R.drawable.emoticon), new FragmentNotes.Item(getString(R.string.text_tit_5), R.drawable.emoticon_cool), new FragmentNotes.Item(getString(R.string.text_tit_6), R.drawable.emoticon_dead), new FragmentNotes.Item(getString(R.string.text_tit_7), R.drawable.emoticon_excited), new FragmentNotes.Item(getString(R.string.text_tit_8), R.drawable.emoticon_tongue), new FragmentNotes.Item(getString(R.string.text_tit_9), R.drawable.emoticon_devil) }; ListAdapter adapter = new ArrayAdapter<FragmentNotes.Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, items) { @NonNull public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Use super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setTextSize(18); tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); //Add margin between image and text (support various screen densities) int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; new AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.goal_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { changeIcon(seqnoStr, title, cont, "1", attachment, create); } else if (item == 1) { changeIcon(seqnoStr, title, cont, "2", attachment, create); } else if (item == 2) { changeIcon(seqnoStr, title, cont, "3", attachment, create); } else if (item == 3) { changeIcon(seqnoStr, title, cont, "4", attachment, create); } else if (item == 4) { changeIcon(seqnoStr, title, cont, "5", attachment, create); } else if (item == 5) { changeIcon(seqnoStr, title, cont, "6", attachment, create); } else if (item == 6) { changeIcon(seqnoStr, title, cont, "7", attachment, create); } else if (item == 7) { changeIcon(seqnoStr, title, cont, "8", attachment, create); } else if (item == 8) { changeIcon(seqnoStr, title, cont, "9", attachment, create); } else if (item == 9) { changeIcon(seqnoStr, title, cont, "10", attachment, create); } } }).show(); } }); i2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { openAtt(attachment); } }); return v; } }; listView.setAdapter(simpleAdapter); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } }
From source file:com.yek.keyboard.anysoftkeyboard.AnySoftKeyboard.java
@Override public void setCandidatesView(@NonNull View view) { super.setCandidatesView(view); mCandidatesParent = view.getParent() instanceof View ? (View) view.getParent() : null; mCandidateView = (CandidateView) view.findViewById(R.id.candidates); mCandidateView.setService(this); setCandidatesViewShown(false);/*from w w w .j a v a 2 s .c o m*/ final KeyboardTheme theme = KeyboardThemeFactory.getCurrentKeyboardTheme(getApplicationContext()); final TypedArray a = theme.getPackageContext().obtainStyledAttributes(null, R.styleable.AnyKeyboardViewTheme, 0, theme.getThemeResId()); int closeTextColor = ContextCompat.getColor(this, R.color.candidate_other); float fontSizePixel = getResources().getDimensionPixelSize(R.dimen.candidate_font_height); Drawable suggestionCloseDrawable = null; try { closeTextColor = a.getColor(R.styleable.AnyKeyboardViewTheme_suggestionOthersTextColor, closeTextColor); fontSizePixel = a.getDimension(R.styleable.AnyKeyboardViewTheme_suggestionTextSize, fontSizePixel); suggestionCloseDrawable = a.getDrawable(R.styleable.AnyKeyboardViewTheme_suggestionCloseImage); } catch (Exception e) { e.printStackTrace(); } a.recycle(); // mCandidateCloseText = (TextView) view.findViewById(R.id.close_suggestions_strip_text); ImageView closeIcon = (ImageView) view.findViewById(R.id.close_suggestions_strip_icon); if (suggestionCloseDrawable != null) closeIcon.setImageDrawable(suggestionCloseDrawable); closeIcon.setOnClickListener(new OnClickListener() { // two seconds is enough. private final static long DOUBLE_TAP_TIMEOUT = 2 * 1000 - 50; public void onClick(View v) { //mKeyboardHandler.removeMessages(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT); // mCandidateCloseText.setVisibility(View.VISIBLE); // mCandidateCloseText.startAnimation(AnimationUtils.loadAnimation(getApplicationContext(), R.anim.close_candidates_hint_in)); //mKeyboardHandler.sendMessageDelayed(mKeyboardHandler.obtainMessage(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT), DOUBLE_TAP_TIMEOUT); onFunctionKey(KeyCodes.VOICE_INPUT, null, 0, null, true); } }); /* mCandidateCloseText.setTextColor(closeTextColor); mCandidateCloseText.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSizePixel); mCandidateCloseText.setOnClickListener(new OnClickListener() { public void onClick(View v) { mKeyboardHandler.removeMessages(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT); mCandidateCloseText.setVisibility(View.GONE); abortCorrectionAndResetPredictionState(true); } });*/ }
From source file:com.nerderylabs.android.nerdalert.ui.fragment.MainFragment.java
private void initializeNametag() { final EditText nameEditText = (EditText) view.findViewById(R.id.my_name); final EditText taglineEditText = (EditText) view.findViewById(R.id.my_tagline); final ImageView photoImageView = (ImageView) view.findViewById(R.id.my_photo); // restore state nameEditText.setText(myInfo.getName()); taglineEditText.setText(myInfo.getTagline()); if (myInfo.getBitmap() != null) { photoImageView.setImageDrawable(new BitmapDrawable(getResources(), myInfo.getBitmap())); } else {//from w w w .j av a 2 s . c o m Drawable photo = ContextCompat.getDrawable(getContext(), R.drawable.ic_contact_photo); DrawableCompat.setTint(photo, ContextCompat.getColor(getContext(), R.color.color_nametag)); photoImageView.setImageDrawable(photo); } // listen for focus change View.OnFocusChangeListener focusListener = new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { persistNametagValues((TextView) v); } } }; // listen for the done key EditText.OnEditorActionListener doneListener = new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { persistNametagValues(v); } return false; } }; // open profile contact card when user's photo is tapped ImageView.OnClickListener imageClickListener = new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_EDIT); intent.setDataAndType(ContactsContract.Profile.CONTENT_URI, ContactsContract.Contacts.CONTENT_ITEM_TYPE); // In Android 4.0 (API version 14) and later, a problem in the contacts app causes // incorrect navigation.To work around this problem in Android 4.0.3 (API version // 15) and later, add the extended data key finishActivityOnSaveCompleted to the // intent, with a value of true. intent.putExtra("finishActivityOnSaveCompleted", true); startActivity(intent); } }; nameEditText.setOnEditorActionListener(doneListener); taglineEditText.setOnEditorActionListener(doneListener); nameEditText.setOnFocusChangeListener(focusListener); taglineEditText.setOnFocusChangeListener(focusListener); photoImageView.setOnClickListener(imageClickListener); }
From source file:im.neon.adapters.VectorMessagesAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); if (null != view) { view.setBackgroundColor(Color.TRANSPARENT); }//from w ww . j ava2 s.co m ImageView e2eIconView = (ImageView) view.findViewById(R.id.message_adapter_e2e_icon); View senderMargin = view.findViewById(R.id.e2e_sender_margin); View senderNameView = view.findViewById(R.id.messagesAdapter_sender); // GA issue if (position >= getCount()) { return view; } MessageRow row = getItem(position); final Event event = row.getEvent(); if (mE2eIconByEventId.containsKey(event.eventId)) { senderMargin.setVisibility(senderNameView.getVisibility()); e2eIconView.setVisibility(View.VISIBLE); e2eIconView.setImageResource(mE2eIconByEventId.get(event.eventId)); int type = getItemViewType(position); if ((type == ROW_TYPE_IMAGE) || (type == ROW_TYPE_VIDEO)) { View bodyLayoutView = view.findViewById(org.matrix.androidsdk.R.id.messagesAdapter_body_layout); ViewGroup.MarginLayoutParams bodyLayout = (ViewGroup.MarginLayoutParams) bodyLayoutView .getLayoutParams(); ViewGroup.MarginLayoutParams e2eIconViewLayout = (ViewGroup.MarginLayoutParams) e2eIconView .getLayoutParams(); e2eIconViewLayout.setMargins(bodyLayout.leftMargin, e2eIconViewLayout.topMargin, e2eIconViewLayout.rightMargin, e2eIconViewLayout.bottomMargin); bodyLayout.setMargins(4, bodyLayout.topMargin, bodyLayout.rightMargin, bodyLayout.bottomMargin); e2eIconView.setLayoutParams(e2eIconViewLayout); bodyLayoutView.setLayoutParams(bodyLayout); } e2eIconView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != mVectorMessagesAdapterEventsListener) { mVectorMessagesAdapterEventsListener.onE2eIconClick(event, mE2eDeviceByEventId.get(event.eventId)); } } }); } else { e2eIconView.setVisibility(View.GONE); senderMargin.setVisibility(View.GONE); } return view; }
From source file:com.anysoftkeyboard.AnySoftKeyboard.java
@Override public void setCandidatesView(@NonNull View view) { super.setCandidatesView(view); mCandidatesParent = view.getParent() instanceof View ? (View) view.getParent() : null; mCandidateView = (CandidateView) view.findViewById(R.id.candidates); mCandidateView.setService(this); setCandidatesViewShown(false);// ww w . j a v a 2s. co m final KeyboardTheme theme = KeyboardThemeFactory.getCurrentKeyboardTheme(getApplicationContext()); final TypedArray a = theme.getPackageContext().obtainStyledAttributes(null, R.styleable.AnyKeyboardViewTheme, 0, theme.getThemeResId()); int closeTextColor = ContextCompat.getColor(this, R.color.candidate_other); float fontSizePixel = getResources().getDimensionPixelSize(R.dimen.candidate_font_height); Drawable suggestionCloseDrawable = null; try { closeTextColor = a.getColor(R.styleable.AnyKeyboardViewTheme_suggestionOthersTextColor, closeTextColor); fontSizePixel = a.getDimension(R.styleable.AnyKeyboardViewTheme_suggestionTextSize, fontSizePixel); suggestionCloseDrawable = a.getDrawable(R.styleable.AnyKeyboardViewTheme_suggestionCloseImage); } catch (Exception e) { e.printStackTrace(); } a.recycle(); mCandidateCloseText = (TextView) view.findViewById(R.id.close_suggestions_strip_text); ImageView closeIcon = (ImageView) view.findViewById(R.id.close_suggestions_strip_icon); if (suggestionCloseDrawable != null) closeIcon.setImageDrawable(suggestionCloseDrawable); closeIcon.setOnClickListener(new OnClickListener() { // two seconds is enough. private static final long DOUBLE_TAP_TIMEOUT = 2 * 1000 - 50; public void onClick(View v) { mKeyboardHandler.removeMessages(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT); mCandidateCloseText.setVisibility(View.VISIBLE); mCandidateCloseText.startAnimation( AnimationUtils.loadAnimation(getApplicationContext(), R.anim.close_candidates_hint_in)); mKeyboardHandler.sendMessageDelayed( mKeyboardHandler.obtainMessage(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT), DOUBLE_TAP_TIMEOUT); } }); mCandidateCloseText.setTextColor(closeTextColor); mCandidateCloseText.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSizePixel); mCandidateCloseText.setOnClickListener(new OnClickListener() { public void onClick(View v) { mKeyboardHandler.removeMessages(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT); mCandidateCloseText.setVisibility(View.GONE); abortCorrectionAndResetPredictionState(true); } }); }