List of usage examples for android.widget TextView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.todoroo.astrid.activity.TaskEditFragment.java
private void setupBeastModeButton() { TextView beastMode = (TextView) getView().findViewById(R.id.edit_beast_mode); TypedValue tv = new TypedValue(); Theme theme = getActivity().getTheme(); theme.resolveAttribute(R.attr.asTextColor, tv, false); int color = tv.data & 0x00ffffff; color = color + 0x7f000000;/*from w w w .j av a2 s . c o m*/ beastMode.setTextColor(color); beastMode.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), BeastModePreferences.class); intent.setAction(AstridApiConstants.ACTION_SETTINGS); startActivityForResult(intent, REQUEST_CODE_BEAST_MODE); } }); }
From source file:maimeng.yodian.app.client.android.chat.adapter.MessageAdapter.java
private void setRobotMenuMessageLayout(LinearLayout parentView, JSONArray jsonArr) { try {// www . ja va2 s. c o m parentView.removeAllViews(); for (int i = 0; i < jsonArr.length(); i++) { final String itemStr = jsonArr.getString(i); final TextView textView = new TextView(context); textView.setText(itemStr); textView.setTextSize(15); try { textView.setTextColor(context.getResources().getColor(R.color.menu_msg_text_color)); } catch (Exception e) { e.printStackTrace(); } textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((ChatActivity) context).sendText(itemStr); } }); LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); llLp.bottomMargin = DensityUtil.dip2px(context, 3); llLp.topMargin = DensityUtil.dip2px(context, 3); parentView.addView(textView, llLp); } } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.prey.activities.CheckPasswordActivity.java
@Override protected void onResume() { super.onResume(); bindPasswordControls();//from www . j a v a 2 s . c o m TextView device_ready_h2_text = (TextView) findViewById(R.id.device_ready_h2_text); final TextView textForgotPassword = (TextView) findViewById(R.id.link_forgot_password); Button password_btn_login = (Button) findViewById(R.id.password_btn_login); EditText password_pass_txt = (EditText) findViewById(R.id.password_pass_txt); TextView textView1 = (TextView) findViewById(R.id.textView1); TextView textView2 = (TextView) findViewById(R.id.textView2); Typeface titilliumWebRegular = Typeface.createFromAsset(getAssets(), "fonts/Titillium_Web/TitilliumWeb-Regular.ttf"); Typeface titilliumWebBold = Typeface.createFromAsset(getAssets(), "fonts/Titillium_Web/TitilliumWeb-Bold.ttf"); Typeface magdacleanmonoRegular = Typeface.createFromAsset(getAssets(), "fonts/MagdaClean/magdacleanmono-regular.ttf"); textView1.setTypeface(magdacleanmonoRegular); textView2.setTypeface(magdacleanmonoRegular); device_ready_h2_text.setTypeface(titilliumWebRegular); textForgotPassword.setTypeface(titilliumWebBold); password_btn_login.setTypeface(titilliumWebBold); password_pass_txt.setTypeface(magdacleanmonoRegular); try { textForgotPassword.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl(); Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url)); startActivity(browserIntent); } catch (Exception e) { } } }); } catch (Exception e) { } TextView textView5_1 = (TextView) findViewById(R.id.textView5_1); TextView textView5_2 = (TextView) findViewById(R.id.textView5_2); textView5_1.setTypeface(magdacleanmonoRegular); textView5_2.setTypeface(titilliumWebBold); TextView textViewUninstall = (TextView) findViewById(R.id.textViewUninstall); LinearLayout linearLayoutTour = (LinearLayout) findViewById(R.id.linearLayoutTour); textViewUninstall.setTypeface(titilliumWebBold); if (PreyConfig.getPreyConfig(getApplication()).getProtectTour()) { linearLayoutTour.setVisibility(View.GONE); textViewUninstall.setVisibility(View.VISIBLE); textViewUninstall.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = PreyConfig.getPreyConfig(getApplication()).getPreyUninstallUrl(); Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url)); startActivity(browserIntent); finish(); } }); } else { linearLayoutTour.setVisibility(View.VISIBLE); textViewUninstall.setVisibility(View.GONE); try { linearLayoutTour.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), TourActivity1.class); Bundle b = new Bundle(); b.putInt("id", 1); intent.putExtras(b); startActivity(intent); finish(); } }); } catch (Exception e) { } } boolean showLocation = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean canAccessFineLocation = PreyPermission.canAccessFineLocation(this); boolean canAccessCoarseLocation = PreyPermission.canAccessCoarseLocation(this); boolean canAccessCamera = PreyPermission.canAccessCamera(this); boolean canAccessReadPhoneState = PreyPermission.canAccessReadPhoneState(this); boolean canAccessReadExternalStorage = PreyPermission.canAccessReadExternalStorage(this); if (!canAccessFineLocation || !canAccessCoarseLocation || !canAccessCamera || !canAccessReadPhoneState || !canAccessReadExternalStorage) { AlertDialog.Builder builder = new AlertDialog.Builder(this); final FrameLayout frameView = new FrameLayout(this); builder.setView(frameView); final AlertDialog alertDialog = builder.create(); LayoutInflater inflater = alertDialog.getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.warning, frameView); TextView warning_title = (TextView) dialoglayout.findViewById(R.id.warning_title); TextView warning_body = (TextView) dialoglayout.findViewById(R.id.warning_body); warning_title.setTypeface(magdacleanmonoRegular); warning_body.setTypeface(titilliumWebBold); Button button_ok = (Button) dialoglayout.findViewById(R.id.button_ok); Button button_close = (Button) dialoglayout.findViewById(R.id.button_close); button_ok.setTypeface(titilliumWebBold); button_close.setTypeface(titilliumWebBold); final Activity thisActivity = this; button_ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PreyLogger.d("askForPermission"); askForPermission(); alertDialog.dismiss(); } }); button_close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PreyLogger.d("close ask"); alertDialog.dismiss(); } }); alertDialog.show(); showLocation = false; } else { showLocation = true; } } else { showLocation = true; } if (showLocation) { LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); boolean isGpsEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean isNetworkEnabled = mlocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (isGpsEnabled || isNetworkEnabled) { PreyLogger.d("isGpsEnabled || isNetworkEnabled"); } else { PreyLogger.d("no gps ni red"); AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog alertDialog = builder.create(); TextView textview = new TextView(this); textview.setText(getString(R.string.location_settings)); textview.setMaxLines(10); textview.setTextSize(18F); textview.setPadding(20, 0, 20, 20); textview.setTextColor(Color.BLACK); builder.setView(textview); builder.setPositiveButton(getString(R.string.go_to_settings), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { dialoginterface.dismiss(); Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, 0); return; } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { dialoginterface.dismiss(); } }); builder.create().show(); } } }
From source file:com.sdspikes.fireworks.FireworksActivity.java
private TextView makeAttributeTextView(final int rank, final GameState.CardColor color) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); int oneButtonWidth = mDiscardWidthR2 / 10; int marginWidth = oneButtonWidth / 10; params.setMargins(marginWidth, 5, marginWidth, 5); params.width = oneButtonWidth - marginWidth * 2; params.height = params.width;//w w w. java 2s .c o m TextView textView = new TextView(this); textView.setLayoutParams(params); textView.setText(String.valueOf(rank)); if (rank == -1) textView.setText(" "); textView.setGravity(Gravity.CENTER); textView.setBackgroundResource(HandFragment.cardColorToBGColor.get(color)); textView.setTextColor(getResources().getColor(HandFragment.cardColorToTextColor(color))); textView.setVisibility(View.VISIBLE); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "clicked on an attribute button: " + GameState.Card.cardColorToString(color) + " " + rank); List<GameState.Card> hand = mTurnData.state.hands.get(mRecipientPlayer).hand; List<Integer> locations = new ArrayList<Integer>(); String info = ""; if (rank == -1) { info = GameState.Card.cardColorToString(color); for (int i = 0; i < hand.size(); i++) { if (hand.get(i).color == color) locations.add(i); } } else { info = HandFragment.rankToString(rank); for (int i = 0; i < hand.size(); i++) { if (hand.get(i).rank == rank) locations.add(i); } } if (locations.size() == 0) { Toast.makeText(FireworksActivity.this, mIdToName.get(mRecipientPlayer) + " does not have any " + info, Toast.LENGTH_SHORT); } else { int[] positions = new int[locations.size()]; for (int i = 0; i < positions.length; i++) { // Make the positions 1-indexed positions[i] = locations.get(i) + 1; } LogItem item = new InfoLogItem(mMyId, mRecipientPlayer, info, positions); actionLog.add(item.toString()); mTurnData.state.hintsRemaining--; mTurnData.state.currentPlayerId = mTurnData.state.hands .get(mTurnData.state.currentPlayerId).nextPlayerId; togglePlayOptionsVisible(PlayOptions.turnMessage); broadcastGameInfo(item.getJSONObject()); updateAllPlayers(mTurnData.getJSONObject()); mRecipientPlayer = null; } } }); return textView; }
From source file:com.xpple.jahoqy.adapter.MessageAdapter.java
/** * ???//from www . j a v 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.openerp.addons.messages.MessageDetail.java
/** * Sets the up list view.//w w w . jav a 2 s . c om * * @param list * the new up list view */ private boolean setupListView(final List<OEListViewRows> list) { // Handling List View controls and keys String[] from = new String[] { "image", "email_from|name", "email_from|email", "body", "date", "partners", "starred", "vote_nb" }; int[] to = new int[] { R.id.imgUserPicture, R.id.txvMessageAuthor, R.id.txvAuthorEmail, R.id.webViewMessageBody, R.id.txvTime, R.id.txvTo, R.id.imgBtnStar, R.id.txvmessageVotenb }; // Creating instance for listAdapter listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_detail_listview_items, list, from, to, db); listAdapter.toHTML("body", true); listAdapter.addImageColumn("image"); // listAdapter.layoutBackgroundColor("parent_id", // Color.parseColor("#aaaaaa"), Color.parseColor("#0099cc")); listAdapter.cleanDate("date", scope.User().getTimezone(), "MMM dd, yyyy, hh:mm a"); listAdapter.addViewListener(new OEListViewOnCreateListener() { @Override public View listViewOnCreateListener(final int position, View row_view, OEListViewRows row_data) { final int message_id = row_data.getRow_id(); final HashMap<String, Object> row_values = row_data.getRow_data(); /* handling vote control */ final TextView txvVote = (TextView) row_view.findViewById(R.id.txvmessageVotenb); final int vote_nb = Integer.parseInt(row_data.getRow_data().get("vote_nb").toString()); if (vote_nb == 0) { txvVote.setText(""); } final boolean hasVoted = Boolean.parseBoolean(row_data.getRow_data().get("has_voted").toString()); if (!hasVoted) { txvVote.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.ic_thumbs_up_unselected_dark_tablet), null, null, null); // txvVote.setBackgroundResource(R.drawable.vote_background_selector_gray); } else { // txvVote.setBackgroundResource(R.drawable.vote_background_selector_blue); txvVote.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.ic_thumbs_up_selected_dark_tablet), null, null, null); } txvVote.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { MessageVoteToggle voteToggle = new MessageVoteToggle(message_id, vote_nb, hasVoted); String newVote = ""; boolean btnvoted = false; if (hasVoted) { newVote = (vote_nb - 1) + ""; row_values.put("has_voted", "false"); } else { btnvoted = true; newVote = (vote_nb + 1) + ""; row_values.put("has_voted", "true"); } row_values.put("vote_nb", newVote); listAdapter.updateRow(position, new OEListViewRows(message_id, row_values)); voteToggle.execute((Void) null); txvVote.setText(newVote); if (!btnvoted) { txvVote.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.ic_thumbs_up_unselected_dark_tablet), null, null, null); // txvVote.setBackgroundResource(R.drawable.vote_background_selector_gray); } else { // txvVote.setBackgroundResource(R.drawable.vote_background_selector_blue); txvVote.setCompoundDrawablesWithIntrinsicBounds( getResources().getDrawable(R.drawable.ic_thumbs_up_selected_dark_tablet), null, null, null); } } }); /* handling attachments */ List<OEListViewRows> attachments = getAttachmentsOfMessage(row_data.getRow_id() + ""); int index = 0; if (attachments.size() > 0) { LayoutInflater vi = (LayoutInflater) scope.context().getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View insertPoint = row_view.findViewById(R.id.gridAttachments); ((ViewGroup) insertPoint).removeAllViews(); for (OEListViewRows row : attachments) { View v = vi.inflate(R.layout.fragment_message_detail_attachment_grid_item, null, true); TextView txvAttachmentName = (TextView) v.findViewById(R.id.txvFileName); txvAttachmentName.setText(row.getRow_data().get("name").toString()); TextView txvAttachmentSize = (TextView) v.findViewById(R.id.txvFileSize); long fileSize = Long.parseLong(row.getRow_data().get("file_size").toString()); String file_size = OEFileSizeHelper.readableFileSize(fileSize); txvAttachmentSize.setText((file_size.equals("0")) ? " " : file_size); TextView txvAttachmentId = (TextView) v.findViewById(R.id.txvAttachmentId); txvAttachmentId.setText(String.valueOf(row.getRow_id())); ((ViewGroup) insertPoint).addView(v, index, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); v.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int attachment_id = Integer.parseInt( ((TextView) v.findViewById(R.id.txvAttachmentId)).getText().toString()); OEBinaryDownloadHelper binaryDownload = new OEBinaryDownloadHelper(); binaryDownload.downloadBinary(attachment_id, db); } }); index++; } } else { row_view.findViewById(R.id.layoutMessageAttachments).setVisibility(View.GONE); } OEContactView oe_contactView = (OEContactView) row_view.findViewById(R.id.imgUserPicture); int partner_id = Integer.parseInt(row_data.getRow_data().get("partner_id").toString()); oe_contactView.assignPartnerId(partner_id); return row_view; } }); listAdapter.setItemClickListener(R.id.imgBtnReply, new ControlClickEventListener() { @Override public OEListViewRows controlClicked(int position, OEListViewRows row, View view) { Intent composeIntent = new Intent(scope.context(), MessageComposeActivty.class); composeIntent.putExtra("message_id", message_id); composeIntent.putExtra("send_reply", true); startActivityForResult(composeIntent, MESSAGE_REPLY); return null; } }); // Setting callback handler for boolean field value change. listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred, R.drawable.ic_action_unstarred, updateStarred); GridView lstview = (GridView) rootView.findViewById(R.id.lstMessageDetail); // Providing adapter to listview lstview.setAdapter(listAdapter); return true; }
From source file:com.yi4all.rupics.ImageDetailActivity.java
private void initBtn() { topBarPanel = findViewById(R.id.image_top_bar); topBarPanel.setVisibility(View.GONE); popMenuPanel = findViewById(R.id.image_pop_menu); TextView tv = (TextView) findViewById(R.id.image_title_txt); tv.setText(issue.getCategory().getName() + "-" + issue.getName()); ImageView back = (ImageView) findViewById(R.id.image_back_btn); back.setOnClickListener(new OnClickListener() { @Override/*from ww w .ja v a 2 s.co m*/ public void onClick(View v) { finish(); } }); ImageView pop = (ImageView) findViewById(R.id.image_pop_btn); pop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (popMenuPanel.getVisibility() == View.VISIBLE) { popMenuPanel.setVisibility(View.GONE); } else { popMenuPanel.setVisibility(View.VISIBLE); } } }); // final TextView wallpaperBtn = (TextView) findViewById(R.id.wallpaperBtn); final TextView slideshowBtn = (TextView) findViewById(R.id.slideshowBtn); final TextView shareBtn = (TextView) findViewById(R.id.shareBtn); final TextView downloadBtn = (TextView) findViewById(R.id.downloadBtn); // wallpaperBtn.setOnClickListener(new OnClickListener() { // public void onClick(View v) { // String img = imgList.get(imageSequence).getUrl(); // String path = Utils.convertUrl2Path(ImageDetailActivity.this, img); // if (path != null && new File(path).exists()) { // try { // ImageDetailActivity.this.setWallpaper(BitmapFactory.decodeFile(path)); // } catch (IOException e) { // e.printStackTrace(); // } // } else { // // give a tip to user // Utils.toastMsg(ImageDetailActivity.this, R.string.noImageWallpaper); // } // Utils.toastMsg(ImageDetailActivity.this, R.string.setWallpaperSuccess); // } // }); slideshowBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { isSlideshow = !isSlideshow; if (isSlideshow) { startSlideShow(); topBarPanel.setVisibility(View.GONE); popMenuPanel.setVisibility(View.GONE); slideshowBtn.setText(R.string.slideshow_pause); } else { topBarPanel.setVisibility(View.VISIBLE); slideshowBtn.setText(R.string.slideshow); } } }); shareBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Intent intent = createShareIntent(); byte[] bytes = getCurrentImage(); if (bytes == null) { Utils.toastMsg(ImageDetailActivity.this, R.string.noImageShare); } else { // ImageDetailActivity.this.startActivity(intent); popMenuPanel.setVisibility(View.GONE); UMServiceFactory.shareTo(ImageDetailActivity.this, getString(R.string.shareImageMmsBody), bytes); } } }); downloadBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (getService().sureLimitation()) { popMenuPanel.setVisibility(View.GONE); final ProgressDialog pd = ProgressDialog.show(ImageDetailActivity.this, getString(R.string.waitTitle), getString(R.string.downloadAllImage), false, false); final Handler handler = new Handler() { int current = 0; int total = imgList.size(); int size = 0; @Override public void handleMessage(Message msg) { current++; pd.setMessage(getString(R.string.downloadAllImage) + current + "/" + total); if (msg.arg2 > 0) { size += msg.arg2; } if (current >= total) { if (size > 0) { getService().addUserConsumedKbytes(size); } pd.dismiss(); } } }; new Thread(new Runnable() { @Override public void run() { for (ImageModel im : imgList) { String imgUrl = im.getUrl(); String path = Utils.convertUrl2Path(ImageDetailActivity.this, imgUrl); util.runSaveUrl(path, imgUrl, handler); } } }).start(); } } }); }
From source file:com.easemob.chatui.adapter.MessageAdapter.java
/** * ???// w w w . 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", 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
/** * ???/*from www .j av a 2s . 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.google.samples.apps.iosched.ui.SessionDetailActivity.java
private void tryRenderTags() { if (mTagMetadata == null || mTagsString == null) { return;/*from w w w . j a va 2s . c om*/ } if (TextUtils.isEmpty(mTagsString)) { mTagsContainer.setVisibility(View.GONE); } else { mTagsContainer.setVisibility(View.VISIBLE); mTags.removeAllViews(); LayoutInflater inflater = LayoutInflater.from(this); String[] tagIds = mTagsString.split(","); List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>(); for (String tagId : tagIds) { if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) { continue; } TagMetadata.Tag tag = mTagMetadata.getTag(tagId); if (tag == null) { continue; } tags.add(tag); } if (tags.size() == 0) { mTagsContainer.setVisibility(View.GONE); return; } Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR); for (final TagMetadata.Tag tag : tags) { TextView chipView = (TextView) inflater.inflate(R.layout.include_session_tag_chip, mTags, false); chipView.setText(tag.getName()); if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) { ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape()); colorDrawable.setIntrinsicWidth(mTagColorDotSize); colorDrawable.setIntrinsicHeight(mTagColorDotSize); colorDrawable.getPaint().setStyle(Paint.Style.FILL); chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null); colorDrawable.getPaint().setColor(tag.getColor()); } chipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); // TODO: better encapsulation Intent intent = new Intent(SessionDetailActivity.this, BrowseSessionsActivity.class) .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId()) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } }); mTags.addView(chipView); } } }