List of usage examples for android.widget TextView setOnLongClickListener
public void setOnLongClickListener(@Nullable OnLongClickListener l)
From source file:org.svij.taskwarriorapp.activities.TaskAddActivity.java
public void onCreate(Bundle savedInstanceState) { setTheme(android.R.style.Theme_Holo_Light_DarkActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_task_add); final TextView tvDueDate = (TextView) findViewById(R.id.tvDueDate); tvDueDate.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a 2s .c o m public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); CalendarDatePickerDialog calendarDatePickerDialog = CalendarDatePickerDialog.newInstance( TaskAddActivity.this, Calendar.getInstance().get(Calendar.YEAR), Calendar.getInstance().get(Calendar.MONTH), Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); calendarDatePickerDialog.show(fm, "fragment_date_picker"); } }); final TextView tvDueTime = (TextView) findViewById(R.id.tvDueTime); tvDueTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); RadialTimePickerDialog timePickerDialog = RadialTimePickerDialog.newInstance(TaskAddActivity.this, Calendar.getInstance().get(Calendar.HOUR_OF_DAY), Calendar.getInstance().get(Calendar.MINUTE), android.text.format.DateFormat.is24HourFormat(TaskAddActivity.this)); timePickerDialog.show(fm, "fragment_time_picker_name"); } }); tvDueDate.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (TextUtils.isEmpty(tvDueTime.getText().toString())) { timestamp = 0; } else { cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR)); cal.set(Calendar.MONTH, Calendar.getInstance().get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); timestamp = cal.getTimeInMillis(); } tvDueDate.setText(""); return true; } }); tvDueTime.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (TextUtils.isEmpty(tvDueDate.getText().toString())) { timestamp = 0; } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); timestamp = cal.getTimeInMillis(); } tvDueTime.setText(""); return true; } }); TaskDatabase dataSource = new TaskDatabase(this); ArrayList<String> projects = dataSource.getProjects(); projects.removeAll(Collections.singleton(null)); final AutoCompleteTextView actvProject = (AutoCompleteTextView) findViewById(R.id.actvProject); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, projects.toArray(new String[projects.size()])); actvProject.setAdapter(adapter); actvProject.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { actvProject.showDropDown(); return false; } }); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { taskID = extras.getString("taskID"); if (taskID != null) { data = new TaskDatabase(this); Task task = data.getTask(UUID.fromString(taskID)); TextView etTaskAdd = (TextView) findViewById(R.id.etTaskAdd); Spinner spPriority = (Spinner) findViewById(R.id.spPriority); etTaskAdd.setText(task.getDescription()); if (task.getDue() != null && task.getDue().getTime() != 0) { tvDueDate.setText(DateFormat.getDateInstance(DateFormat.SHORT).format(task.getDue())); if (!DateFormat.getTimeInstance().format(task.getDue()).equals("00:00:00")) { tvDueTime.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(task.getDue())); } cal.setTime(task.getDue()); timestamp = cal.getTimeInMillis(); } actvProject.setText(task.getProject()); Log.i("PriorityID", ":" + task.getPriorityID()); spPriority.setSelection(task.getPriorityID()); if (task.getTags() != null) { TextView etTags = (TextView) findViewById(R.id.etTags); String tagString = ""; for (String s : task.getTags()) { tagString += s + " "; } etTags.setText(tagString.trim()); } } else { String action = intent.getAction(); if ((action.equalsIgnoreCase(Intent.ACTION_SEND) || action.equalsIgnoreCase("com.google.android.gm.action.AUTO_SEND")) && intent.hasExtra(Intent.EXTRA_TEXT)) { String s = intent.getStringExtra(Intent.EXTRA_TEXT); TextView etTaskAdd = (TextView) findViewById(R.id.etTaskAdd); etTaskAdd.setText(s); addingTaskFromOtherApp = true; } } } }
From source file:com.xpple.jahoqy.adapter.MessageAdapter.java
/** * ???// www. jav a2 s . c o m * * @param message * @param holder * @param position * @param convertView */ private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { TextView locationView = ((TextView) convertView.findViewById(R.id.tv_location)); LocationMessageBody locBody = (LocationMessageBody) message.getBody(); locationView.setText(locBody.getAddress()); LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude()); locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress())); locationView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", Type.LOCATION.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return false; } }); if (message.direct == Direct.RECEIVE) { return; } // deal with send message switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); break; default: sendMsgInBackground(message, holder); } }
From source file:com.easemob.chatui.adapter.MessageAdapter.java
/** * ???/* www .j a va2s . c om*/ * * @param message * @param holder * @param position * @param convertView */ private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { TextView locationView = ((TextView) convertView.findViewById(R.id.tv_location)); LocationMessageBody locBody = (LocationMessageBody) message.getBody(); locationView.setText(locBody.getAddress()); LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude()); locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress())); locationView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", EMMessage.Type.LOCATION.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return false; } }); if (message.direct == Direct.RECEIVE) { return; } // deal with send message switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); break; default: sendMsgInBackground(message, holder); } }
From source file:cn.ucai.superwechat.adapter.MessageAdapter.java
/** * ???/* w w w. j a va 2 s . com*/ * * @param message * @param holder * @param position * @param convertView */ private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { TextView locationView = ((TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_location)); LocationMessageBody locBody = (LocationMessageBody) message.getBody(); locationView.setText(locBody.getAddress()); LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude()); locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress())); locationView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", EMMessage.Type.LOCATION.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return false; } }); if (message.direct == EMMessage.Direct.RECEIVE) { return; } // deal with send message switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); break; default: sendMsgInBackground(message, holder); } }
From source file:com.shengtao.chat.chatUI.adapter.MessageAdapter.java
/** * ???/*ww w . ja v a 2 s. c om*/ * * @param message * @param holder * @param position * @param convertView */ private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { TextView locationView = ((TextView) convertView.findViewById(id.tv_location)); LocationMessageBody locBody = (LocationMessageBody) message.getBody(); locationView.setText(locBody.getAddress()); LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude()); locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress())); locationView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", Type.LOCATION.ordinal()), ChatActivity.REQUEST_CODE_CONTEXT_MENU); return false; } }); if (message.direct == Direct.RECEIVE) { return; } // deal with send message switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); break; default: sendMsgInBackground(message, holder); } }
From source file:com.com.easemob.chatuidemo.adapter.MessageAdapter.java
/** * ???//from w ww . jav a 2 s . c o m * * @param message * @param holder * @param position * @param convertView */ private void handleLocationMessage(final EMMessage message, final ViewHolder holder, final int position, View convertView) { TextView locationView = ((TextView) convertView.findViewById(R.id.tv_location)); LocationMessageBody locBody = (LocationMessageBody) message.getBody(); locationView.setText(locBody.getAddress()); LatLng loc = new LatLng(locBody.getLatitude(), locBody.getLongitude()); locationView.setOnClickListener(new MapClickListener(loc, locBody.getAddress())); locationView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { activity.startActivityForResult((new Intent(activity, ContextMenu.class)) .putExtra("position", position).putExtra("type", EMMessage.Type.LOCATION.ordinal()), ChatMessage.REQUEST_CODE_CONTEXT_MENU); return false; } }); if (message.direct == EMMessage.Direct.RECEIVE) { return; } // deal with send message switch (message.status) { case SUCCESS: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.GONE); break; case FAIL: holder.pb.setVisibility(View.GONE); holder.staus_iv.setVisibility(View.VISIBLE); break; case INPROGRESS: holder.pb.setVisibility(View.VISIBLE); break; default: sendMsgInBackground(message, holder); } }
From source file:com.hippo.ehviewer.ui.scene.GalleryDetailScene.java
@SuppressWarnings("deprecation") private void bindTags(GalleryTagGroup[] tagGroups) { Context context = getContext2(); LayoutInflater inflater = getLayoutInflater2(); Resources resources = getResources2(); if (null == context || null == inflater || null == resources || null == mTags || null == mNoTags) { return;/*w ww . ja v a2 s . com*/ } mTags.removeViews(1, mTags.getChildCount() - 1); if (tagGroups == null || tagGroups.length == 0) { mNoTags.setVisibility(View.VISIBLE); return; } else { mNoTags.setVisibility(View.GONE); } int colorTag = resources.getColor(R.color.colorPrimary); int colorName = resources.getColor(R.color.purple_a400); for (GalleryTagGroup tg : tagGroups) { LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.gallery_tag_group, mTags, false); ll.setOrientation(LinearLayout.HORIZONTAL); mTags.addView(ll); TextView tgName = (TextView) inflater.inflate(R.layout.item_gallery_tag, ll, false); ll.addView(tgName); tgName.setText(tg.groupName); tgName.setBackgroundDrawable(new RoundSideRectDrawable(colorName)); AutoWrapLayout awl = new AutoWrapLayout(context); ll.addView(awl, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); for (int j = 0, z = tg.size(); j < z; j++) { TextView tag = (TextView) inflater.inflate(R.layout.item_gallery_tag, awl, false); awl.addView(tag); String tagStr = tg.getTagAt(j); tag.setText(tagStr); tag.setBackgroundDrawable(new RoundSideRectDrawable(colorTag)); tag.setTag(R.id.tag, tg.groupName + ":" + tagStr); tag.setOnClickListener(this); tag.setOnLongClickListener(this); } } }
From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java
/** * As the name means./*from w ww . ja v a 2 s . c om*/ */ private void buildAddressBar(final Uri path) { if (path == null) return; mViewAddressBar.removeAllViews(); new LoadingDialog<Void, Cursor, Void>(getActivity(), false) { LinearLayout.LayoutParams lpBtnLoc; LinearLayout.LayoutParams lpDivider; LayoutInflater inflater = getLayoutInflater(null); final int dim = getResources().getDimensionPixelSize(R.dimen.afc_5dp); int count = 0; @Override protected void onPreExecute() { super.onPreExecute(); lpBtnLoc = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lpBtnLoc.gravity = Gravity.CENTER; }// onPreExecute() @Override protected Void doInBackground(Void... params) { Cursor cursor = getActivity().getContentResolver().query(path, null, null, null, null); while (cursor != null) { if (cursor.moveToFirst()) { publishProgress(cursor); cursor.close(); } else break; /* * Process the parent directory. */ Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(BaseFile.COLUMN_URI))); cursor = getActivity().getContentResolver() .query(BaseFile.genContentUriApi(uri.getAuthority()).buildUpon() .appendPath(BaseFile.CMD_GET_PARENT) .appendQueryParameter(BaseFile.PARAM_SOURCE, uri.getLastPathSegment()).build(), null, null, null, null); } // while return null; }// doInBackground() @Override protected void onProgressUpdate(Cursor... progress) { /* * Add divider. */ if (mViewAddressBar.getChildCount() > 0) { View divider = inflater.inflate(R.layout.afc_view_locations_divider, null); if (lpDivider == null) { lpDivider = new LinearLayout.LayoutParams(dim, dim); lpDivider.gravity = Gravity.CENTER; lpDivider.setMargins(dim, dim, dim, dim); } mViewAddressBar.addView(divider, 0, lpDivider); } Uri lastUri = Uri.parse(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_URI))); TextView btnLoc = (TextView) inflater.inflate(R.layout.afc_button_location, null); String name = BaseFileProviderUtils.getFileName(progress[0]); btnLoc.setText(TextUtils.isEmpty(name) ? getString(R.string.afc_root) : name); btnLoc.setTag(lastUri); btnLoc.setOnClickListener(mBtnLocationOnClickListener); btnLoc.setOnLongClickListener(mBtnLocationOnLongClickListener); mViewAddressBar.addView(btnLoc, 0, lpBtnLoc); if (count++ == 0) { Rect r = new Rect(); btnLoc.getPaint().getTextBounds(name, 0, name.length(), r); if (r.width() >= getResources().getDimensionPixelSize(R.dimen.afc_button_location_max_width) - btnLoc.getPaddingLeft() - btnLoc.getPaddingRight()) { mTextFullDirName .setText(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_NAME))); mTextFullDirName.setVisibility(View.VISIBLE); } else mTextFullDirName.setVisibility(View.GONE); } // if }// onProgressUpdate() @Override protected void onPostExecute(Void result) { super.onPostExecute(result); /* * Sometimes without delay time, it doesn't work... */ mViewLocationsContainer.postDelayed(new Runnable() { public void run() { mViewLocationsContainer.fullScroll(HorizontalScrollView.FOCUS_RIGHT); }// run() }, DisplayPrefs.DELAY_TIME_FOR_VERY_SHORT_ANIMATION); }// onPostExecute() }.execute(); }
From source file:com.haibison.android.anhuu.FragmentFiles.java
/** * As the name means.//from w w w . ja va 2 s . c om */ private void buildAddressBar(final Uri path) { if (path == null) return; mViewAddressBar.removeAllViews(); new LoadingDialog<Void, Cursor, Void>(getActivity(), false) { LinearLayout.LayoutParams lpBtnLoc; LinearLayout.LayoutParams lpDivider; LayoutInflater inflater = getLayoutInflater(null); final int dim = getResources().getDimensionPixelSize(R.dimen.anhuu_f5be488d_5dp); int count = 0; @Override protected void onPreExecute() { super.onPreExecute(); lpBtnLoc = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lpBtnLoc.gravity = Gravity.CENTER; }// onPreExecute() @Override protected Void doInBackground(Void... params) { Cursor cursor = getActivity().getContentResolver().query(path, null, null, null, null); while (cursor != null) { if (cursor.moveToFirst()) { publishProgress(cursor); cursor.close(); } else break; /* * Process the parent directory. */ Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(BaseFile.COLUMN_URI))); cursor = getActivity().getContentResolver() .query(BaseFile.genContentUriApi(uri.getAuthority()).buildUpon() .appendPath(BaseFile.CMD_GET_PARENT) .appendQueryParameter(BaseFile.PARAM_SOURCE, uri.getLastPathSegment()).build(), null, null, null, null); } // while return null; }// doInBackground() @Override protected void onProgressUpdate(Cursor... progress) { /* * Add divider. */ if (mViewAddressBar.getChildCount() > 0) { View divider = inflater.inflate(R.layout.anhuu_f5be488d_view_locations_divider, null); if (lpDivider == null) { lpDivider = new LinearLayout.LayoutParams(dim, dim); lpDivider.gravity = Gravity.CENTER; lpDivider.setMargins(dim, dim, dim, dim); } mViewAddressBar.addView(divider, 0, lpDivider); } Uri lastUri = Uri.parse(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_URI))); TextView btnLoc = (TextView) inflater.inflate(R.layout.anhuu_f5be488d_button_location, null); String name = BaseFileProviderUtils.getFileName(progress[0]); btnLoc.setText(TextUtils.isEmpty(name) ? getString(R.string.anhuu_f5be488d_root) : name); btnLoc.setTag(lastUri); btnLoc.setOnClickListener(mBtnLocationOnClickListener); btnLoc.setOnLongClickListener(mBtnLocationOnLongClickListener); mViewAddressBar.addView(btnLoc, 0, lpBtnLoc); if (count++ == 0) { Rect r = new Rect(); btnLoc.getPaint().getTextBounds(name, 0, name.length(), r); if (r.width() >= getResources() .getDimensionPixelSize(R.dimen.anhuu_f5be488d_button_location_max_width) - btnLoc.getPaddingLeft() - btnLoc.getPaddingRight()) { mTextFullDirName .setText(progress[0].getString(progress[0].getColumnIndex(BaseFile.COLUMN_NAME))); mTextFullDirName.setVisibility(View.VISIBLE); } else mTextFullDirName.setVisibility(View.GONE); } // if }// onProgressUpdate() @Override protected void onPostExecute(Void result) { super.onPostExecute(result); /* * Sometimes without delay time, it doesn't work... */ mViewLocationsContainer.postDelayed(new Runnable() { public void run() { mViewLocationsContainer.fullScroll(HorizontalScrollView.FOCUS_RIGHT); }// run() }, Display.DELAY_TIME_FOR_VERY_SHORT_ANIMATION); }// onPostExecute() }.execute(); }
From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java
public void attachOnLongTouchPower(final TextView view) { view.setOnLongClickListener(new OnLongClickListener() { @Override/*from w w w. j a v a 2 s. c om*/ public boolean onLongClick(View v) { view.setText("0.0"); powerMin = 0.0; powerMax = 0.0; power_show_type = 1; powerType.setText("live"); return false; } }); }