List of usage examples for android.widget TextView setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); mService = getTweetingsApplication().getServiceInterface(); mResolver = getContentResolver();//w w w.j av a2s . c o m super.onCreate(savedInstanceState); setContentView(R.layout.compose); mActionBar = getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); mUploadProvider = mPreferences.getString(PREFERENCE_KEY_IMAGE_UPLOADER, null); final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras(); final long account_id = bundle != null ? bundle.getLong(INTENT_KEY_ACCOUNT_ID) : -1; mAccountIds = bundle != null ? bundle.getLongArray(INTENT_KEY_IDS) : null; mInReplyToStatusId = bundle != null ? bundle.getLong(INTENT_KEY_IN_REPLY_TO_ID) : -1; mInReplyToScreenName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME) : null; mInReplyToName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_NAME) : null; mInReplyToText = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_TWEET) : null; mIsImageAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_IMAGE_ATTACHED) : false; mIsPhotoAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_PHOTO_ATTACHED) : false; mImageUri = bundle != null ? (Uri) bundle.getParcelable(INTENT_KEY_IMAGE_URI) : null; final String[] mentions = bundle != null ? bundle.getStringArray(INTENT_KEY_MENTIONS) : null; final String account_username = getAccountUsername(this, account_id); int text_selection_start = -1; mIsBuffer = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_BUFFER, false) : false; if (mInReplyToStatusId > 0) { if (bundle != null && bundle.getString(INTENT_KEY_TEXT) != null && (mentions == null || mentions.length < 1)) { mText = bundle.getString(INTENT_KEY_TEXT); } else if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); text_selection_start = mText.indexOf(' ') + 1; } mIsQuote = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_QUOTE, false) : false; final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); final String name = display_name ? mInReplyToName : mInReplyToScreenName; if (name != null) { setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to, name)); } if (mAccountIds == null || mAccountIds.length == 0) { mAccountIds = new long[] { account_id }; } TextView replyText = (TextView) findViewById(R.id.reply_text); if (!isNullOrEmpty(mInReplyToText)) { replyText.setVisibility(View.VISIBLE); replyText.setText(mInReplyToText); } else { replyText.setVisibility(View.GONE); } } else { if (mentions != null) { final StringBuilder builder = new StringBuilder(); for (final String mention : mentions) { if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) { builder.append('@' + account_username + ' '); } else if (!mention.equalsIgnoreCase(account_username)) { builder.append('@' + mention + ' '); } } mText = builder.toString(); } if (mAccountIds == null || mAccountIds.length == 0) { final long[] ids_in_prefs = ArrayUtils .fromString(mPreferences.getString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, null), ','); final long[] activated_ids = getActivatedAccountIds(this); final long[] intersection = ArrayUtils.intersection(ids_in_prefs, activated_ids); mAccountIds = intersection.length > 0 ? intersection : activated_ids; } final String action = getIntent().getAction(); if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { setTitle(R.string.share); final Bundle extras = getIntent().getExtras(); if (extras != null) { if (mText == null) { final CharSequence extra_subject = extras.getCharSequence(Intent.EXTRA_SUBJECT); final CharSequence extra_text = extras.getCharSequence(Intent.EXTRA_TEXT); mText = getShareStatus(this, parseString(extra_subject), parseString(extra_text)); } else { mText = bundle.getString(INTENT_KEY_TEXT); } if (mImageUri == null) { final Uri extra_stream = extras.getParcelable(Intent.EXTRA_STREAM); final String content_type = getIntent().getType(); if (extra_stream != null && content_type != null && content_type.startsWith("image/")) { final String real_path = getImagePathFromUri(this, extra_stream); final File file = real_path != null ? new File(real_path) : null; if (file != null && file.exists()) { mImageUri = Uri.fromFile(file); mIsImageAttached = true; mIsPhotoAttached = false; } else { mImageUri = null; mIsImageAttached = false; } } } } } else if (bundle != null) { if (bundle.getString(INTENT_KEY_TEXT) != null) { mText = bundle.getString(INTENT_KEY_TEXT); } } } final File image_file = mImageUri != null && "file".equals(mImageUri.getScheme()) ? new File(mImageUri.getPath()) : null; final boolean image_file_valid = image_file != null && image_file.exists(); mImageThumbnailPreview.setVisibility(image_file_valid ? View.VISIBLE : View.GONE); if (image_file_valid) { reloadAttachedImageThumbnail(image_file); } mImageThumbnailPreview.setOnClickListener(this); mImageThumbnailPreview.setOnLongClickListener(this); mMenuBar.setOnMenuItemClickListener(this); mMenuBar.inflate(R.menu.menu_compose); mMenuBar.show(); if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) { mEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); mEditText.setMovementMethod(ArrowKeyMovementMethod.getInstance()); mEditText.setImeOptions(EditorInfo.IME_ACTION_GO); mEditText.setOnEditorActionListener(this); } mEditText.addTextChangedListener(this); if (mText != null) { mEditText.setText(mText); if (mIsQuote) { mEditText.setSelection(0); } else if (text_selection_start != -1 && text_selection_start < mEditText.length() && mEditText.length() > 0) { mEditText.setSelection(text_selection_start, mEditText.length() - 1); } else if (mEditText.length() > 0) { mEditText.setSelection(mEditText.length()); } } invalidateSupportOptionsMenu(); setMenu(); if (mColorIndicator != null) { mColorIndicator.setOrientation(ColorView.VERTICAL); mColorIndicator.setColor(getAccountColors(this, mAccountIds)); } mContentModified = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_CONTENT_MODIFIED) : false; mIsPossiblySensitive = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE) : false; }
From source file:android.support.v7.preference.Preference.java
/** * Binds the created View to the data for this Preference. * <p>// w w w . j a v a2s .co m * This is a good place to grab references to custom Views in the layout and * set properties on them. * <p> * Make sure to call through to the superclass's implementation. * * @param holder The ViewHolder that provides references to the views to fill in. These views * will be recycled, so you should not hold a reference to them after this method * returns. */ public void onBindViewHolder(PreferenceViewHolder holder) { holder.itemView.setOnClickListener(mClickListener); holder.itemView.setId(mViewId); final TextView titleView = (TextView) holder.findViewById(android.R.id.title); if (titleView != null) { final CharSequence title = getTitle(); if (!TextUtils.isEmpty(title)) { titleView.setText(title); titleView.setVisibility(View.VISIBLE); } else { titleView.setVisibility(View.GONE); } } final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary); if (summaryView != null) { final CharSequence summary = getSummary(); if (!TextUtils.isEmpty(summary)) { summaryView.setText(summary); summaryView.setVisibility(View.VISIBLE); } else { summaryView.setVisibility(View.GONE); } } final ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon); if (imageView != null) { if (mIconResId != 0 || mIcon != null) { if (mIcon == null) { mIcon = ContextCompat.getDrawable(getContext(), mIconResId); } if (mIcon != null) { imageView.setImageDrawable(mIcon); } } imageView.setVisibility(mIcon != null ? View.VISIBLE : View.GONE); } View imageFrame = holder.findViewById(R.id.icon_frame); if (imageFrame == null) { imageFrame = holder.findViewById(AndroidResources.ANDROID_R_ICON_FRAME); } if (imageFrame != null) { imageFrame.setVisibility(mIcon != null ? View.VISIBLE : View.GONE); } if (mShouldDisableView) { setEnabledStateOnViews(holder.itemView, isEnabled()); } else { setEnabledStateOnViews(holder.itemView, true); } final boolean selectable = isSelectable(); holder.itemView.setFocusable(selectable); holder.itemView.setClickable(selectable); holder.setDividerAllowedAbove(selectable); holder.setDividerAllowedBelow(selectable); }
From source file:cn.hbm.superwechat.adapter.MessageAdapter.java
@SuppressLint("NewApi") public View getView(final int position, View convertView, ViewGroup parent) { final EMMessage message = getItem(position); ChatType chatType = message.getChatType(); final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = createViewByMessage(message, position); if (message.getType() == EMMessage.Type.IMAGE) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.iv_sendPicture)); holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.percentage); holder.pb = (ProgressBar) convertView.findViewById(R.id.progressBar); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { }/* w w w . j av a 2s . c o m*/ } else if (message.getType() == EMMessage.Type.TXT) { try { holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); // holder.tv = (TextView) convertView.findViewById(R.id.tv_chatcontent); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); holder.tvTitle = (TextView) convertView.findViewById(R.id.tvTitle); holder.tvList = (LinearLayout) convertView.findViewById(R.id.ll_layout); } catch (Exception e) { } // ??? if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) || message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) { holder.iv = (ImageView) convertView.findViewById(R.id.iv_call_icon); holder.tv = (TextView) convertView.findViewById(R.id.tv_chatcontent); } } else if (message.getType() == EMMessage.Type.VOICE) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.iv_voice)); holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.tv_length); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); holder.iv_read_status = (ImageView) convertView.findViewById(R.id.iv_unread_voice); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.LOCATION) { try { holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.tv_location); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.VIDEO) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.chatting_content_iv)); holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.percentage); holder.pb = (ProgressBar) convertView.findViewById(R.id.progressBar); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.size = (TextView) convertView.findViewById(R.id.chatting_size_iv); holder.timeLength = (TextView) convertView.findViewById(R.id.chatting_length_iv); holder.playBtn = (ImageView) convertView.findViewById(R.id.chatting_status_btn); holder.container_status_btn = (LinearLayout) convertView .findViewById(R.id.container_status_btn); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.FILE) { try { holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv_file_name = (TextView) convertView.findViewById(R.id.tv_file_name); holder.tv_file_size = (TextView) convertView.findViewById(R.id.tv_file_size); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_file_download_state = (TextView) convertView.findViewById(R.id.tv_file_state); holder.ll_container = (LinearLayout) convertView.findViewById(R.id.ll_file_container); // holder.tv = (TextView) convertView.findViewById(R.id.percentage); } catch (Exception e) { } try { holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // ?????? if ((chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == EMMessage.Direct.RECEIVE) { //demousername?nick // UserUtils.setUserNick(message.getFrom(), holder.tv_usernick); Log.i("main", "1"); UserUtils.setGroupUserNick(username, message.getFrom(), holder.tv_usernick); } if (message.direct == EMMessage.Direct.SEND) { UserUtils.setCurrentUserNick(holder.tv_usernick); } // ??????textview if (!(chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == EMMessage.Direct.SEND) { holder.tv_ack = (TextView) convertView.findViewById(R.id.tv_ack); holder.tv_delivered = (TextView) convertView.findViewById(R.id.tv_delivered); if (holder.tv_ack != null) { if (message.isAcked) { if (holder.tv_delivered != null) { holder.tv_delivered.setVisibility(View.INVISIBLE); } holder.tv_ack.setVisibility(View.VISIBLE); } else { holder.tv_ack.setVisibility(View.INVISIBLE); // check and display msg delivered ack status if (holder.tv_delivered != null) { if (message.isDelivered) { holder.tv_delivered.setVisibility(View.VISIBLE); } else { holder.tv_delivered.setVisibility(View.INVISIBLE); } } } } } else { // ??group messgae,chatroom message?? if ((message.getType() == Type.TXT || message.getType() == Type.LOCATION) && !message.isAcked && chatType != ChatType.GroupChat && chatType != ChatType.ChatRoom) { // ?? if (!message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false)) { try { EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId()); // ?? message.isAcked = true; } catch (Exception e) { e.printStackTrace(); } } } } //? setUserAvatar(message, holder.iv_avatar); switch (message.getType()) { // ??typeitem case IMAGE: // handleImageMessage(message, holder, position, convertView); break; case TXT: // if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) || message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) // ? handleCallMessage(message, holder, position); else if (((DemoHXSDKHelper) HXSDKHelper.getInstance()).isRobotMenuMessage(message)) //?? handleRobotMenuMessage(message, holder, position); else handleTextMessage(message, holder, position); break; case LOCATION: // ? handleLocationMessage(message, holder, position, convertView); break; case VOICE: // handleVoiceMessage(message, holder, position, convertView); break; case VIDEO: // handleVideoMessage(message, holder, position, convertView); break; case FILE: // handleFileMessage(message, holder, position, convertView); break; default: // not supported } if (message.direct == EMMessage.Direct.SEND) { View statusView = convertView.findViewById(R.id.msg_status); // ?? statusView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ???alertdialog Intent intent = new Intent(activity, AlertDialog.class); intent.putExtra("msg", activity.getString(R.string.confirm_resend)); intent.putExtra("title", activity.getString(R.string.resend)); intent.putExtra("cancel", true); intent.putExtra("position", position); if (message.getType() == EMMessage.Type.TXT) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_TEXT); else if (message.getType() == EMMessage.Type.VOICE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VOICE); else if (message.getType() == EMMessage.Type.IMAGE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_PICTURE); else if (message.getType() == EMMessage.Type.LOCATION) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_LOCATION); else if (message.getType() == EMMessage.Type.FILE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_FILE); else if (message.getType() == EMMessage.Type.VIDEO) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VIDEO); } }); } else { final String st = context.getResources().getString(R.string.Into_the_blacklist); if (!((ChatActivity) activity).isRobot && chatType != ChatType.ChatRoom) { // ???? holder.iv_avatar.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent = new Intent(activity, AlertDialog.class); intent.putExtra("msg", st); intent.putExtra("cancel", true); intent.putExtra("position", position); activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_ADD_TO_BLACKLIST); return true; } }); } } TextView timestamp = (TextView) convertView.findViewById(R.id.timestamp); if (position == 0) { timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime()))); timestamp.setVisibility(View.VISIBLE); } else { // ??? EMMessage prevMessage = getItem(position - 1); if (prevMessage != null && DateUtils.isCloseEnough(message.getMsgTime(), prevMessage.getMsgTime())) { timestamp.setVisibility(View.GONE); } else { timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime()))); timestamp.setVisibility(View.VISIBLE); } } return convertView; }
From source file:com.qubittech.feelknit.app.MainActivity.java
@Override protected void onNavItemSelected(int id) { switch (id) { case 101:/*from ww w . jav a 2s . c om*/ ShowProfileFragment(ApplicationHelper.getAvatar(getApplicationContext())); break; case 102: ShowCurrentFeelingsFragment(); break; case 103: StartUserFeelingsFragment(); break; case 104: showCommentsFeelingsFragment(); break; case 105: ShowRelatedFeelingFragment(); break; case 106: final Dialog d = new Dialog(this, R.style.CustomDialogTheme); d.setContentView(R.layout.custom_dialog); d.show(); TextView version = (TextView) d.findViewById(R.id.versionTextView); TextView saripaar = (TextView) d.findViewById(R.id.saripaar); TextView licenseLink = (TextView) d.findViewById(R.id.licenseLink); final TextView license = (TextView) d.findViewById(R.id.license); saripaar.setText(Html.fromHtml("<u>android-saripaar</u>")); licenseLink.setText(Html.fromHtml("(<u>license</u>)")); saripaar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uriUrl = Uri.parse("https://github.com/ragunathjawahar/android-saripaar"); Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); startActivity(launchBrowser); } }); license.setText("Copyright 2012 - 2015 Mobs and Geeks\n\n" + "Licensed under the Apache License, Version 2.0 (the \"License\");\n" + "you may not use this file except in compliance with the License.\n" + "You may obtain a copy of the License at\n" + "\n" + " http://www.apache.org/licenses/LICENSE-2.0\n" + "\n" + "Unless required by applicable law or agreed to in writing, software\n" + "distributed under the License is distributed on an \"AS IS\" BASIS,\n" + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + "See the License for the specific language governing permissions and\n" + "limitations under the License."); licenseLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { license.setVisibility(license.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE); } }); try { version.setText(getApplicationContext().getPackageManager() .getPackageInfo(getApplicationContext().getPackageName(), 0).versionName); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } TextView close_btn = (TextView) d.findViewById(R.id.okButton); close_btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { d.dismiss(); } }); } }
From source file:cn.ucai.fulicenter.adapter.MessageAdapter.java
@SuppressLint("NewApi") public View getView(final int position, View convertView, ViewGroup parent) { final EMMessage message = getItem(position); ChatType chatType = message.getChatType(); final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = createViewByMessage(message, position); if (message.getType() == EMMessage.Type.IMAGE) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.iv_sendPicture)); holder.iv_avatar = (NetworkImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.percentage); holder.pb = (ProgressBar) convertView.findViewById(R.id.progressBar); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { }/*w w w.ja va 2 s . com*/ } else if (message.getType() == EMMessage.Type.TXT) { try { holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.iv_avatar = (NetworkImageView) convertView.findViewById(R.id.iv_userhead); // holder.tv = (TextView) convertView.findViewById(R.id.tv_chatcontent); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); holder.tvTitle = (TextView) convertView.findViewById(R.id.tvTitle); holder.tvList = (LinearLayout) convertView.findViewById(R.id.ll_layout); } catch (Exception e) { } // ??? if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) || message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) { holder.iv = (ImageView) convertView.findViewById(R.id.iv_call_icon); holder.tv = (TextView) convertView.findViewById(R.id.tv_chatcontent); } } else if (message.getType() == EMMessage.Type.VOICE) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.iv_voice)); holder.iv_avatar = (NetworkImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.tv_length); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); holder.iv_read_status = (ImageView) convertView.findViewById(R.id.iv_unread_voice); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.LOCATION) { try { holder.iv_avatar = (NetworkImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.tv_location); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.VIDEO) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.chatting_content_iv)); holder.iv_avatar = (NetworkImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.percentage); holder.pb = (ProgressBar) convertView.findViewById(R.id.progressBar); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.size = (TextView) convertView.findViewById(R.id.chatting_size_iv); holder.timeLength = (TextView) convertView.findViewById(R.id.chatting_length_iv); holder.playBtn = (ImageView) convertView.findViewById(R.id.chatting_status_btn); holder.container_status_btn = (LinearLayout) convertView .findViewById(R.id.container_status_btn); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.FILE) { try { holder.iv_avatar = (NetworkImageView) convertView.findViewById(R.id.iv_userhead); holder.tv_file_name = (TextView) convertView.findViewById(R.id.tv_file_name); holder.tv_file_size = (TextView) convertView.findViewById(R.id.tv_file_size); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_file_download_state = (TextView) convertView.findViewById(R.id.tv_file_state); holder.ll_container = (LinearLayout) convertView.findViewById(R.id.ll_file_container); // holder.tv = (TextView) convertView.findViewById(R.id.percentage); } catch (Exception e) { } try { holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // ?????? if ((chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == EMMessage.Direct.RECEIVE) { //demousername?nick UserUtils.setUserNick(message.getFrom(), holder.tv_usernick); UserUtils.setUserBeanNick(message.getFrom(), holder.tv_usernick); //UserUtils.setGroupMembersNick(username, message.getFrom(), holder.tv_usernick); } if (message.direct == EMMessage.Direct.SEND) { UserUtils.setCurrentUserNick(holder.tv_usernick); UserUtils.setCurrentUserBeanNick(holder.tv_usernick); } // ??????textview if (!(chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == EMMessage.Direct.SEND) { holder.tv_ack = (TextView) convertView.findViewById(R.id.tv_ack); holder.tv_delivered = (TextView) convertView.findViewById(R.id.tv_delivered); if (holder.tv_ack != null) { if (message.isAcked) { if (holder.tv_delivered != null) { holder.tv_delivered.setVisibility(View.INVISIBLE); } holder.tv_ack.setVisibility(View.VISIBLE); } else { holder.tv_ack.setVisibility(View.INVISIBLE); // check and display msg delivered ack status if (holder.tv_delivered != null) { if (message.isDelivered) { holder.tv_delivered.setVisibility(View.VISIBLE); } else { holder.tv_delivered.setVisibility(View.INVISIBLE); } } } } } else { // ??group messgae,chatroom message?? if ((message.getType() == Type.TXT || message.getType() == Type.LOCATION) && !message.isAcked && chatType != ChatType.GroupChat && chatType != ChatType.ChatRoom) { // ?? if (!message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false)) { try { EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId()); // ?? message.isAcked = true; } catch (Exception e) { e.printStackTrace(); } } } } //? setUserAvatar(message, holder.iv_avatar); switch (message.getType()) { // ??typeitem case IMAGE: // handleImageMessage(message, holder, position, convertView); break; case TXT: // if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) || message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) // ? handleCallMessage(message, holder, position); else if (((DemoHXSDKHelper) HXSDKHelper.getInstance()).isRobotMenuMessage(message)) //?? handleRobotMenuMessage(message, holder, position); else handleTextMessage(message, holder, position); break; case LOCATION: // ? handleLocationMessage(message, holder, position, convertView); break; case VOICE: // handleVoiceMessage(message, holder, position, convertView); break; case VIDEO: // handleVideoMessage(message, holder, position, convertView); break; case FILE: // handleFileMessage(message, holder, position, convertView); break; default: // not supported } if (message.direct == EMMessage.Direct.SEND) { View statusView = convertView.findViewById(R.id.msg_status); // ?? statusView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ???alertdialog Intent intent = new Intent(activity, AlertDialog.class); intent.putExtra("msg", activity.getString(R.string.confirm_resend)); intent.putExtra("title", activity.getString(R.string.resend)); intent.putExtra("cancel", true); intent.putExtra("position", position); if (message.getType() == EMMessage.Type.TXT) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_TEXT); else if (message.getType() == EMMessage.Type.VOICE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VOICE); else if (message.getType() == EMMessage.Type.IMAGE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_PICTURE); else if (message.getType() == EMMessage.Type.LOCATION) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_LOCATION); else if (message.getType() == EMMessage.Type.FILE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_FILE); else if (message.getType() == EMMessage.Type.VIDEO) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VIDEO); } }); } else { final String st = context.getResources().getString(R.string.Into_the_blacklist); if (!((ChatActivity) activity).isRobot && chatType != ChatType.ChatRoom) { // ???? holder.iv_avatar.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent = new Intent(activity, AlertDialog.class); intent.putExtra("msg", st); intent.putExtra("cancel", true); intent.putExtra("position", position); activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_ADD_TO_BLACKLIST); return true; } }); } } TextView timestamp = (TextView) convertView.findViewById(R.id.timestamp); if (position == 0) { timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime()))); timestamp.setVisibility(View.VISIBLE); } else { // ??? EMMessage prevMessage = getItem(position - 1); if (prevMessage != null && DateUtils.isCloseEnough(message.getMsgTime(), prevMessage.getMsgTime())) { timestamp.setVisibility(View.GONE); } else { timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime()))); timestamp.setVisibility(View.VISIBLE); } } return convertView; }
From source file:br.edu.ifpb.breath.slidingtabs.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from ww w . j a v a 2s.c om*/ TextView tabTitleView = null; ImageView tabIconView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); tabIconView = (ImageView) tabView.findViewById(mTabViewImageViewId); } if (tabView == null && !mUseIcons) { tabView = createDefaultTabView(getContext(), 0); tabView.setAlpha(i == 0 ? 1.0f : 0.25f); } if (tabView == null && mUseIcons) { tabView = createDefaultTabView(getContext(), 1); tabView.setAlpha(i == 0 ? 1.0f : 0.25f); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; tabTitleView.setAlpha(i == 0 ? 1.0f : 0.25f); } if (tabIconView == null && ImageView.class.isInstance(tabView)) { tabIconView = (ImageView) tabView; tabIconView.setAlpha(i == 0 ? 1.0f : 0.25f); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } if (mUseIcons) { tabIconView.setVisibility(View.VISIBLE); if (tabTitleView != null) tabTitleView.setVisibility(View.GONE); if (mIcons.containsKey(i)) tabIconView.setImageDrawable(mIcons.get(i)); } else { tabTitleView.setVisibility(View.VISIBLE); if (tabIconView != null) tabIconView.setVisibility(View.GONE); tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextColor(mTextColor); } tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.easemob.chatuidemo.adapter.MessageAdapter.java
@SuppressLint("NewApi") public View getView(final int position, View convertView, ViewGroup parent) { final EMMessage message = getItem(position); ChatType chatType = message.getChatType(); final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = createViewByMessage(message, position); if (message.getType() == EMMessage.Type.IMAGE) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.iv_sendPicture)); holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.percentage); holder.pb = (ProgressBar) convertView.findViewById(R.id.progressBar); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { }//from w w w.ja va 2 s.c o m } else if (message.getType() == EMMessage.Type.TXT) { try { holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); // holder.tv = (TextView) convertView.findViewById(R.id.tv_chatcontent); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); holder.tvTitle = (TextView) convertView.findViewById(R.id.tvTitle); holder.tvList = (LinearLayout) convertView.findViewById(R.id.ll_layout); } catch (Exception e) { } // ??? if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) || message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) { holder.iv = (ImageView) convertView.findViewById(R.id.iv_call_icon); holder.tv = (TextView) convertView.findViewById(R.id.tv_chatcontent); } } else if (message.getType() == EMMessage.Type.VOICE) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.iv_voice)); holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.tv_length); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); holder.iv_read_status = (ImageView) convertView.findViewById(R.id.iv_unread_voice); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.LOCATION) { try { holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.tv_location); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.VIDEO) { try { holder.iv = ((ImageView) convertView.findViewById(R.id.chatting_content_iv)); holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(R.id.percentage); holder.pb = (ProgressBar) convertView.findViewById(R.id.progressBar); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.size = (TextView) convertView.findViewById(R.id.chatting_size_iv); holder.timeLength = (TextView) convertView.findViewById(R.id.chatting_length_iv); holder.playBtn = (ImageView) convertView.findViewById(R.id.chatting_status_btn); holder.container_status_btn = (LinearLayout) convertView .findViewById(R.id.container_status_btn); holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.FILE) { try { holder.iv_avatar = (ImageView) convertView.findViewById(R.id.iv_userhead); holder.tv_file_name = (TextView) convertView.findViewById(R.id.tv_file_name); holder.tv_file_size = (TextView) convertView.findViewById(R.id.tv_file_size); holder.pb = (ProgressBar) convertView.findViewById(R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(R.id.msg_status); holder.tv_file_download_state = (TextView) convertView.findViewById(R.id.tv_file_state); holder.ll_container = (LinearLayout) convertView.findViewById(R.id.ll_file_container); // holder.tv = (TextView) convertView.findViewById(R.id.percentage); } catch (Exception e) { } try { holder.tv_usernick = (TextView) convertView.findViewById(R.id.tv_userid); } catch (Exception e) { } } convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // ?????? if ((chatType == ChatType.GroupChat || chatType == chatType.ChatRoom) && message.direct == EMMessage.Direct.RECEIVE) { //demousername?nick holder.tv_usernick.setText(message.getFrom()); } // ??????textview if (!(chatType == ChatType.GroupChat || chatType == chatType.ChatRoom) && message.direct == EMMessage.Direct.SEND) { holder.tv_ack = (TextView) convertView.findViewById(R.id.tv_ack); holder.tv_delivered = (TextView) convertView.findViewById(R.id.tv_delivered); if (holder.tv_ack != null) { if (message.isAcked) { if (holder.tv_delivered != null) { holder.tv_delivered.setVisibility(View.INVISIBLE); } holder.tv_ack.setVisibility(View.VISIBLE); } else { holder.tv_ack.setVisibility(View.INVISIBLE); // check and display msg delivered ack status if (holder.tv_delivered != null) { if (message.isDelivered) { holder.tv_delivered.setVisibility(View.VISIBLE); } else { holder.tv_delivered.setVisibility(View.INVISIBLE); } } } } } else { // ??group messgae,chatroom message?? if ((message.getType() == Type.TXT || message.getType() == Type.LOCATION) && !message.isAcked && chatType != ChatType.GroupChat && chatType != ChatType.ChatRoom) { // ?? if (!message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false)) { try { EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId()); // ?? message.isAcked = true; } catch (Exception e) { e.printStackTrace(); } } } } //? //setUserAvatar(message, holder.iv_avatar); holder.iv_avatar.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { context.startActivity( new Intent(context, Activity_boshu_FriMsg.class).putExtra("userId", username)); } }); setAvater(context, message, holder.iv_avatar); switch (message.getType()) { // ??typeitem case IMAGE: // handleImageMessage(message, holder, position, convertView); break; case TXT: // if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) || message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) // ? handleCallMessage(message, holder, position); else if (((DemoHXSDKHelper) HXSDKHelper.getInstance()).isRobotMenuMessage(message)) //?? handleRobotMenuMessage(message, holder, position); else handleTextMessage(message, holder, position); break; case LOCATION: // ? handleLocationMessage(message, holder, position, convertView); break; case VOICE: // handleVoiceMessage(message, holder, position, convertView); break; case VIDEO: // handleVideoMessage(message, holder, position, convertView); break; case FILE: // handleFileMessage(message, holder, position, convertView); break; default: // not supported } if (message.direct == EMMessage.Direct.SEND) { View statusView = convertView.findViewById(R.id.msg_status); // ?? statusView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ???alertdialog Intent intent = new Intent(activity, AlertDialog.class); intent.putExtra("msg", activity.getString(R.string.confirm_resend)); intent.putExtra("title", activity.getString(R.string.resend)); intent.putExtra("cancel", true); intent.putExtra("position", position); if (message.getType() == EMMessage.Type.TXT) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_TEXT); else if (message.getType() == EMMessage.Type.VOICE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VOICE); else if (message.getType() == EMMessage.Type.IMAGE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_PICTURE); else if (message.getType() == EMMessage.Type.LOCATION) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_LOCATION); else if (message.getType() == EMMessage.Type.FILE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_FILE); else if (message.getType() == EMMessage.Type.VIDEO) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VIDEO); } }); } else { final String st = context.getResources().getString(R.string.Into_the_blacklist); if (!((ChatActivity) activity).isRobot && chatType != ChatType.ChatRoom) { // ???? holder.iv_avatar.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent = new Intent(activity, AlertDialog.class); intent.putExtra("msg", st); intent.putExtra("cancel", true); intent.putExtra("position", position); activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_ADD_TO_BLACKLIST); return true; } }); } } TextView timestamp = (TextView) convertView.findViewById(R.id.timestamp); if (position == 0) { timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime()))); timestamp.setVisibility(View.VISIBLE); } else { // ??? EMMessage prevMessage = getItem(position - 1); if (prevMessage != null && DateUtils.isCloseEnough(message.getMsgTime(), prevMessage.getMsgTime())) { timestamp.setVisibility(View.GONE); } else { timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime()))); timestamp.setVisibility(View.VISIBLE); } } return convertView; }
From source file:cm.aptoide.pt.ManageRepo.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { LayoutInflater li = LayoutInflater.from(this); switch (item.getItemId()) { case ADD_REPO: View view = li.inflate(R.layout.addrepo, null); final TextView sec_msg = (TextView) view.findViewById(R.id.sec_msg); final TextView sec_msg2 = (TextView) view.findViewById(R.id.sec_msg2); final EditText sec_user = (EditText) view.findViewById(R.id.sec_user); final EditText sec_pwd = (EditText) view.findViewById(R.id.sec_pwd); final CheckBox sec = (CheckBox) view.findViewById(R.id.secure_chk); sec.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sec_user.setEnabled(true); sec_pwd.setEnabled(true); } else { sec_user.setEnabled(false); sec_pwd.setEnabled(false); }//from w w w .ja v a 2 s . c o m } }); Builder p = new AlertDialog.Builder(this).setView(view); alrt = p.create(); alrt.setIcon(android.R.drawable.ic_menu_add); alrt.setTitle("Add new repository"); alrt.setButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Message msg = new Message(); EditText uri = (EditText) alrt.findViewById(R.id.edit_uri); String uri_str = uri.getText().toString(); sec_msg.setVisibility(View.GONE); sec_msg2.setVisibility(View.GONE); if (sec.isChecked()) { String user = sec_user.getText().toString(); String pwd = sec_pwd.getText().toString(); int result = checkServer(uri_str, user, pwd); if (result == 200) { msg.obj = 0; db.addServer(uri_str); db.addLogin(user, pwd, uri_str); change = true; redraw(); } else if (result == 401) { sec_msg2.setText("Login is wrong"); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; } else { sec_msg.setText("Can't connect to server"); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; } } else { int result = checkServer(uri_str, null, null); if (result == 200) { msg.obj = 0; db.addServer(uri_str); change = true; redraw(); } else if (result == 401) { sec_msg2.setText("Login required"); sec_msg2.setVisibility(View.VISIBLE); msg.obj = 1; } else { sec_msg.setText("Can't connect to server"); sec_msg.setVisibility(View.VISIBLE); msg.obj = 1; } } new_repo.sendMessage(msg); } }); alrt.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alrt.dismiss(); } }); alrt.show(); break; case REM_REPO: final Vector<String> rem_lst = new Vector<String>(); CharSequence[] b = new CharSequence[server_lst.size()]; for (int i = 0; i < server_lst.size(); i++) { b[i] = server_lst.get(i).uri; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Chose repository to remove"); builder.setIcon(android.R.drawable.ic_menu_close_clear_cancel); builder.setMultiChoiceItems(b, null, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { if (isChecked) { rem_lst.addElement(server_lst.get(whichButton).uri); } else { rem_lst.removeElement(server_lst.get(whichButton).uri); } } }); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { db.removeServer(rem_lst); change = true; redraw(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); AlertDialog alert = builder.create(); alert.show(); break; case EDIT_REPO: CharSequence[] b2 = new CharSequence[server_lst.size()]; for (int i = 0; i < server_lst.size(); i++) { b2[i] = server_lst.get(i).uri; } AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle("Chose repository to edit"); builder2.setIcon(android.R.drawable.ic_menu_edit); builder2.setSingleChoiceItems(b2, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { updt_repo = server_lst.get(which).uri; } }); builder2.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { editRepo(updt_repo); return; } }); builder2.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); alert2 = builder2.create(); alert2.show(); break; } return super.onMenuItemSelected(featureId, item); }
From source file:cn.ucai.superwechat.adapter.MessageAdapter.java
@SuppressLint("NewApi") public View getView(final int position, View convertView, ViewGroup parent) { final EMMessage message = getItem(position); ChatType chatType = message.getChatType(); final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = createViewByMessage(message, position); if (message.getType() == EMMessage.Type.IMAGE) { try { holder.iv = ((ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_sendPicture)); holder.iv_avatar = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.percentage); holder.pb = (ProgressBar) convertView.findViewById(cn.ucai.superwechat.R.id.progressBar); holder.staus_iv = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_userid); } catch (Exception e) { }//from w w w .ja va 2 s . c om } else if (message.getType() == EMMessage.Type.TXT) { try { holder.pb = (ProgressBar) convertView.findViewById(cn.ucai.superwechat.R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.msg_status); holder.iv_avatar = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_userhead); // holder.tv = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_chatcontent); holder.tv_usernick = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_userid); holder.tvTitle = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tvTitle); holder.tvList = (LinearLayout) convertView.findViewById(cn.ucai.superwechat.R.id.ll_layout); } catch (Exception e) { } // ??? if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) || message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) { holder.iv = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_call_icon); holder.tv = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_chatcontent); } } else if (message.getType() == EMMessage.Type.VOICE) { try { holder.iv = ((ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_voice)); holder.iv_avatar = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_length); holder.pb = (ProgressBar) convertView.findViewById(cn.ucai.superwechat.R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_userid); holder.iv_read_status = (ImageView) convertView .findViewById(cn.ucai.superwechat.R.id.iv_unread_voice); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.LOCATION) { try { holder.iv_avatar = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_location); holder.pb = (ProgressBar) convertView.findViewById(cn.ucai.superwechat.R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.msg_status); holder.tv_usernick = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_userid); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.VIDEO) { try { holder.iv = ((ImageView) convertView .findViewById(cn.ucai.superwechat.R.id.chatting_content_iv)); holder.iv_avatar = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_userhead); holder.tv = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.percentage); holder.pb = (ProgressBar) convertView.findViewById(cn.ucai.superwechat.R.id.progressBar); holder.staus_iv = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.msg_status); holder.size = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.chatting_size_iv); holder.timeLength = (TextView) convertView .findViewById(cn.ucai.superwechat.R.id.chatting_length_iv); holder.playBtn = (ImageView) convertView .findViewById(cn.ucai.superwechat.R.id.chatting_status_btn); holder.container_status_btn = (LinearLayout) convertView .findViewById(cn.ucai.superwechat.R.id.container_status_btn); holder.tv_usernick = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_userid); } catch (Exception e) { } } else if (message.getType() == EMMessage.Type.FILE) { try { holder.iv_avatar = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.iv_userhead); holder.tv_file_name = (TextView) convertView .findViewById(cn.ucai.superwechat.R.id.tv_file_name); holder.tv_file_size = (TextView) convertView .findViewById(cn.ucai.superwechat.R.id.tv_file_size); holder.pb = (ProgressBar) convertView.findViewById(cn.ucai.superwechat.R.id.pb_sending); holder.staus_iv = (ImageView) convertView.findViewById(cn.ucai.superwechat.R.id.msg_status); holder.tv_file_download_state = (TextView) convertView .findViewById(cn.ucai.superwechat.R.id.tv_file_state); holder.ll_container = (LinearLayout) convertView .findViewById(cn.ucai.superwechat.R.id.ll_file_container); // holder.tv = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.percentage); } catch (Exception e) { } try { holder.tv_usernick = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_userid); } catch (Exception e) { } } convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } // ?????? if ((chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == EMMessage.Direct.RECEIVE) { //demousername?nick //UserUtils.setAppUserNick(message.getFrom(), holder.tv_usernick); UserUtils.setAppMemberNick(username, message.getFrom(), holder.tv_usernick); } if (message.direct == EMMessage.Direct.SEND) { UserUtils.setCurrentUserNick(holder.tv_usernick); } // ??????textview if (!(chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == EMMessage.Direct.SEND) { holder.tv_ack = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_ack); holder.tv_delivered = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.tv_delivered); if (holder.tv_ack != null) { if (message.isAcked) { if (holder.tv_delivered != null) { holder.tv_delivered.setVisibility(View.INVISIBLE); } holder.tv_ack.setVisibility(View.VISIBLE); } else { holder.tv_ack.setVisibility(View.INVISIBLE); // check and display msg delivered ack status if (holder.tv_delivered != null) { if (message.isDelivered) { holder.tv_delivered.setVisibility(View.VISIBLE); } else { holder.tv_delivered.setVisibility(View.INVISIBLE); } } } } } else { // ??group messgae,chatroom message?? if ((message.getType() == Type.TXT || message.getType() == Type.LOCATION) && !message.isAcked && chatType != ChatType.GroupChat && chatType != ChatType.ChatRoom) { // ?? if (!message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false)) { try { EMChatManager.getInstance().ackMessageRead(message.getFrom(), message.getMsgId()); // ?? message.isAcked = true; } catch (Exception e) { e.printStackTrace(); } } } } //? setUserAvatar(message, holder.iv_avatar); switch (message.getType()) { // ??typeitem case IMAGE: // handleImageMessage(message, holder, position, convertView); break; case TXT: // if (message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VOICE_CALL, false) || message.getBooleanAttribute(Constant.MESSAGE_ATTR_IS_VIDEO_CALL, false)) // ? handleCallMessage(message, holder, position); else if (((DemoHXSDKHelper) HXSDKHelper.getInstance()).isRobotMenuMessage(message)) //?? handleRobotMenuMessage(message, holder, position); else handleTextMessage(message, holder, position); break; case LOCATION: // ? handleLocationMessage(message, holder, position, convertView); break; case VOICE: // handleVoiceMessage(message, holder, position, convertView); break; case VIDEO: // handleVideoMessage(message, holder, position, convertView); break; case FILE: // handleFileMessage(message, holder, position, convertView); break; default: // not supported } if (message.direct == EMMessage.Direct.SEND) { View statusView = convertView.findViewById(cn.ucai.superwechat.R.id.msg_status); // ?? statusView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ???alertdialog Intent intent = new Intent(activity, AlertDialog.class); intent.putExtra("msg", activity.getString(cn.ucai.superwechat.R.string.confirm_resend)); intent.putExtra("title", activity.getString(cn.ucai.superwechat.R.string.resend)); intent.putExtra("cancel", true); intent.putExtra("position", position); if (message.getType() == EMMessage.Type.TXT) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_TEXT); else if (message.getType() == EMMessage.Type.VOICE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VOICE); else if (message.getType() == EMMessage.Type.IMAGE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_PICTURE); else if (message.getType() == EMMessage.Type.LOCATION) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_LOCATION); else if (message.getType() == EMMessage.Type.FILE) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_FILE); else if (message.getType() == EMMessage.Type.VIDEO) activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VIDEO); } }); } else { final String st = context.getResources().getString(cn.ucai.superwechat.R.string.Into_the_blacklist); if (!((ChatActivity) activity).isRobot && chatType != ChatType.ChatRoom) { // ???? holder.iv_avatar.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent = new Intent(activity, AlertDialog.class); intent.putExtra("msg", st); intent.putExtra("cancel", true); intent.putExtra("position", position); activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_ADD_TO_BLACKLIST); return true; } }); } } TextView timestamp = (TextView) convertView.findViewById(cn.ucai.superwechat.R.id.timestamp); if (position == 0) { timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime()))); timestamp.setVisibility(View.VISIBLE); } else { // ??? EMMessage prevMessage = getItem(position - 1); if (prevMessage != null && DateUtils.isCloseEnough(message.getMsgTime(), prevMessage.getMsgTime())) { timestamp.setVisibility(View.GONE); } else { timestamp.setText(DateUtils.getTimestampString(new Date(message.getMsgTime()))); timestamp.setVisibility(View.VISIBLE); } } return convertView; }
From source file:com.RSMSA.policeApp.OffenceReportForm.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_report_offence); sharedpreferences = getSharedPreferences(MyPREF, Context.MODE_PRIVATE); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*w w w . ja v a 2 s . c om*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setTranslucentStatus(true); } SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); ColorDrawable colorDrawable = new ColorDrawable(getResources().getColor(R.color.blue_900)); tintManager.setTintDrawable(colorDrawable); RelativeLayout inputs = (RelativeLayout) findViewById(R.id.inputs); plateNumberEdit = (EditText) findViewById(R.id.plate_number_edit_text); licenceNumberEdit = (EditText) findViewById(R.id.licence_number_edit_text); final Bundle bundle = getIntent().getExtras(); namePassed = bundle.getString("name"); dLicense = bundle.getString("licence_number"); plateNumberObtained = bundle.getString("plate_number"); driverUid = bundle.getString("driverUid"); vehicleUid = bundle.getString("vehicleUid"); try { invalidLicence = bundle.getString("invalidLicence"); expiredInsuarance = bundle.getString("expiredInsuarance"); } catch (NullPointerException e) { } if (dLicense.equals("") || dLicense == null) { licenceNumberEdit.setVisibility(View.VISIBLE); } else if (plateNumberObtained.equals("") || plateNumberObtained == null) { plateNumberEdit.setVisibility(View.VISIBLE); } submit = (TextView) findViewById(R.id.submit_text); plateNo = (TextView) findViewById(R.id.plate_no_); chargesAcceptance = (TextView) findViewById(R.id.charges_acceptance); chargesAcceptance.setTypeface(MainOffence.Roboto_Regular); offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed_title); offensesCommittedTextview.setTypeface(MainOffence.Roboto_BoldCondensed); ChargesAcceptanceTitle = (TextView) findViewById(R.id.charges_acceptance_title); paymentMethodTitle = (TextView) findViewById(R.id.payment_method_title); PaymentTitle = (TextView) findViewById(R.id.payment_title); ChargesAcceptanceTitle.setTypeface(MainOffence.Roboto_BoldCondensed); paymentMethodTitle.setTypeface(MainOffence.Roboto_BoldCondensed); PaymentTitle.setTypeface(MainOffence.Roboto_BoldCondensed); offencesCostTitle = (TextView) findViewById(R.id.offences_cost_title); offencesCostTitle.setTypeface(MainOffence.Roboto_BoldCondensed); submitText = (TextView) findViewById(R.id.submit_text); license = (TextView) findViewById(R.id.license); license.setText(dLicense); report = (RelativeLayout) findViewById(R.id.report); summary = (RelativeLayout) findViewById(R.id.summary); submit_layout = (RelativeLayout) findViewById(R.id.submit_layout); submit_layout1 = (RelativeLayout) findViewById(R.id.submit_layout1); submit_layout1.setVisibility(View.GONE); progressBar = (ProgressBar) findViewById(R.id.pbar_report); TextView driverName = (TextView) findViewById(R.id.driver_name); driverName.setTypeface(MainOffence.Roboto_BoldCondensed); TextView plateNumberTitle = (TextView) findViewById(R.id.plate_no_title_); plateNumberTitle.setTypeface(MainOffence.Roboto_BoldCondensed); TextView driverLicense = (TextView) findViewById(R.id.driver_license); driverLicense.setTypeface(MainOffence.Roboto_BoldCondensed); RelativeLayout OffenseType = (RelativeLayout) findViewById(R.id.offense_type); OffenseType.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(OffenceReportForm.this, OffenseListActivity.class); OffenceReportForm.this.startActivityForResult(intent, REPORT_RESULT); } }); offense_type_text = (TextView) findViewById(R.id.offense_type_text); offencesSelectedTextView = (TextView) findViewById(R.id.offence_list); offensesCommittedTextview = (TextView) findViewById(R.id.offences_committed); TextView name = (TextView) findViewById(R.id.name); name.setText(namePassed); final RadioButton court = (RadioButton) findViewById(R.id.court); court.setTypeface(MainOffence.Roboto_BoldCondensed); final RadioButton guilty = (RadioButton) findViewById(R.id.guilty); guilty.setTypeface(MainOffence.Roboto_BoldCondensed); guilty.setChecked(true); court.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { guilty.setChecked(false); commit = false; } } }); guilty.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { court.setChecked(false); commit = true; } } }); final String[] paymentMethodsArray = this.getResources().getStringArray(R.array.payment_methods); final Spinner paymentMethodSpinner = (Spinner) findViewById(R.id.payment_method_spinner); final RadioButton paid = (RadioButton) findViewById(R.id.paid); paid.setTypeface(MainOffence.Roboto_Regular); final RadioButton not_paid = (RadioButton) findViewById(R.id.not_paid); final TextView receipt_title = (TextView) findViewById(R.id.receipt_title); receiptEditText = (EditText) findViewById(R.id.receipt); receipt_title.setTypeface(MainOffence.Roboto_BoldCondensed); not_paid.setTypeface(MainOffence.Roboto_Regular); not_paid.setChecked(true); paymentMethodSpinner.setBackground(null); paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { paymentStatus = true; paymentMethodTitle.setVisibility(View.VISIBLE); paymentMethodSpinner.setVisibility(View.VISIBLE); paymentMethod = paymentMethodsArray[0]; paymentMethodSpinner.setSelection(0); receipt_title.setVisibility(View.VISIBLE); receiptEditText.setVisibility(View.VISIBLE); } } }); not_paid.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b == true) { paymentStatus = false; paymentMethodTitle.setVisibility(View.GONE); paymentMethodSpinner.setVisibility(View.GONE); receipt_title.setVisibility(View.GONE); receiptEditText.setVisibility(View.GONE); paymentMethod = ""; receiptEditText.setText(""); } } }); PaymentMethodSpinnerAdapter adapter = new PaymentMethodSpinnerAdapter( getSupportActionBar().getThemedContext(), R.layout.row_menu, paymentMethodsArray); paymentMethodSpinner.setAdapter(adapter); paymentMethodSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { paymentMethod = paymentMethodsArray[position]; if (position == 0) { receiptEditText.setVisibility(View.VISIBLE); receipt_title.setVisibility(View.VISIBLE); } else { receiptEditText.setVisibility(View.GONE); receipt_title.setVisibility(View.GONE); } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); }