Example usage for android.view View INVISIBLE

List of usage examples for android.view View INVISIBLE

Introduction

In this page you can find the example usage for android.view View INVISIBLE.

Prototype

int INVISIBLE

To view the source code for android.view View INVISIBLE.

Click Source Link

Document

This view is invisible, but it still takes up space for layout purposes.

Usage

From source file:gc.david.dfm.ui.MainActivity.java

/**
 * Swaps starting point in the main content view
 *//*from w  w w .  j  a v a  2 s  .  c om*/
private void selectItem(int position) {
    Mint.leaveBreadcrumb("MainActivity::selectItem " + position);
    if (position != 0) {
        if (position == 1) {
            Mint.logEvent("Distance from current point");
        } else if (position == 2) {
            Mint.logEvent("Distance from any point");
        }
        distanceMode = (position == FIRST_DRAWER_ITEM_INDEX) ? // TODO change this because the header!!!!
                DistanceMode.DISTANCE_FROM_CURRENT_POINT : DistanceMode.DISTANCE_FROM_ANY_POINT;

        Mint.addExtraData("distanceMode", String.valueOf(distanceMode));

        // Highlight the selected item and close the drawer
        drawerList.setItemChecked(position, true);
        drawerLayout.closeDrawer(drawerList);

        calculatingDistance = false;

        coordinates = Lists.newArrayList();
        googleMap.clear();
        if (showingElevationTask != null) {
            showingElevationTask.cancel(true);
        }
        rlElevationChart.setVisibility(View.INVISIBLE);
        elevationChartShown = false;
        fixMapPadding();
    } else {
        Mint.leaveBreadcrumb("MainActivity::selectItem 0 not valid!");
    }
}

From source file:au.com.wallaceit.reddinator.Rservice.java

private void hideWidgetLoader(boolean goToTopOfList, boolean showError) {
    AppWidgetManager mgr = AppWidgetManager.getInstance(mContext);
    // get theme layout id
    int layout = 1;
    switch (Integer.valueOf(mSharedPreferences.getString("widgetthemepref", "1"))) {
    case 1:/*w  w  w . j av  a 2s .  c  o  m*/
        layout = R.layout.widgetmain;
        break;
    case 2:
        layout = R.layout.widgetdark;
        break;
    case 3:
        layout = R.layout.widgetholo;
        break;
    case 4:
        layout = R.layout.widgetdarkholo;
        break;
    case 5:
        layout = R.layout.widgettrans;
        break;
    }
    RemoteViews views = new RemoteViews(mContext.getPackageName(), layout);
    views.setViewVisibility(R.id.srloader, View.INVISIBLE);
    // go to the top of the list view
    if (goToTopOfList) {
        views.setScrollPosition(R.id.listview, 0);
    }
    if (showError) {
        views.setViewVisibility(R.id.erroricon, View.VISIBLE);
    }
    mgr.partiallyUpdateAppWidget(appWidgetId, views);
}

From source file:com.easemob.qixin.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 ww  .  j  a v a  2  s.co  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);

    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
            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.hybris.mobile.app.commerce.fragment.ProductDetailFragmentBase.java

/**
 * Before/After requests actions//from   ww w  .j  a v  a  2  s . co  m
 *
 * @param isBefore
 */
protected void afterBeforeRequest(boolean isBefore) {
    if (mProduct != null) {
        mStocklevelTextLoading.setVisibility(isBefore ? View.VISIBLE : View.INVISIBLE);
        mStocklevelText.setVisibility(isBefore ? View.INVISIBLE : View.VISIBLE);
    }

    // Before the request we disable the edit text for the quantity and the add to cart button
    if (isBefore) {
        mQuantityEditText.setText("");
        setClickableAddToCartButton();
    }

    UIUtils.showLoadingActionBar(getActivity(), isBefore);
}

From source file:com.facebook.android.friendsmash.GameFragment.java

private void fireFirstImageWithUserID(String userID) {
    final Session session = Session.getActiveSession();

    // With the user id, fetch and set their name, then start the firing of images
    friendToSmashIDProvided = userID;//from ww w  . ja va 2s . co  m
    Request userGraphPathRequest = Request.newGraphPathRequest(session, friendToSmashIDProvided,
            new Request.Callback() {

                @Override
                public void onCompleted(Response response) {
                    FacebookRequestError error = response.getError();
                    if (error != null) {
                        Log.e(FriendSmashApplication.TAG, error.toString());
                        closeAndHandleError(error);
                    } else if (session == Session.getActiveSession()) {
                        if (response != null) {
                            // Extract the user name from the response
                            friendToSmashFirstName = response.getGraphObjectAs(GraphUser.class).getFirstName();
                        }
                        if (friendToSmashFirstName != null) {
                            // If the first name of the friend to smash has been set, set the text in the smashPlayerNameTextView
                            // and hide the progress spinner now that the user's details have been fetched
                            progressContainer.setVisibility(View.INVISIBLE);
                            setSmashPlayerNameTextView();

                            // Now you're ready to fire the first image
                            spawnImage(false);
                        }
                    }
                }
            });
    Request.executeBatchAsync(userGraphPathRequest);
}

From source file:cn.kangeqiu.kq.activity.MainActivity.java

/**
 * ?/*w w  w  .  j a  v a2 s.  c o  m*/
 */
public void updateAllUnreadLabel(int sysUnreadCount) {
    // ???
    int countNormal = getUnreadMsgCountTotal();

    // ?
    count = countNormal + sysUnreadCount;

    // update
    if (count > 0) {
        unreadLabel.setText(String.valueOf(count));
        unreadLabel.setVisibility(View.VISIBLE);
    } else {
        unreadLabel.setVisibility(View.INVISIBLE);
    }
}

From source file:com.xpple.jahoqy.adapter.MessageAdapter.java

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() == 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  ww. j  a v  a  2s.  c o  m*/

        } else if (message.getType() == 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() == 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() == 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() == 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() == 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 == Direct.RECEIVE) {
        //demousername?nick
        UserUtils.setUserNick(message.getFrom(), holder.tv_usernick);
    }
    if (message.direct == Direct.SEND) {
        UserUtils.setCurrentUserNick(holder.tv_usernick);
    }
    // ??????textview
    if (!(chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == 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 == 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() == Type.TXT)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_TEXT);
                else if (message.getType() == Type.VOICE)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VOICE);
                else if (message.getType() == Type.IMAGE)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_PICTURE);
                else if (message.getType() == Type.LOCATION)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_LOCATION);
                else if (message.getType() == Type.FILE)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_FILE);
                else if (message.getType() == 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.amazon.android.contentbrowser.helper.AuthHelper.java

/**
 * Load powered by logo from preferences with Glide.
 *
 * @param context                The context to use.
 * @param poweredByLogoImageView The image view to use.
 *//*from ww w. j  a v  a2  s  .  c  om*/
public void loadPoweredByLogo(Context context, ImageView poweredByLogoImageView) {

    try {
        String mvpdUrl = Preferences.getString(PreferencesConstants.MVPD_LOGO_URL);

        if (poweredByLogoImageView == null || mvpdUrl.isEmpty()) {
            Log.d(TAG, "No MVPD image view or URL found.");
            return;
        }
        poweredByLogoImageView.setVisibility(View.INVISIBLE);

        RequestListener listener = new RequestListener<String, GlideDrawable>() {
            @Override
            public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                    boolean isFirstResource) {

                poweredByLogoImageView.setVisibility(View.INVISIBLE);
                Log.e(TAG, "Get image with glide failed for powered by logo!!!", e);
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target,
                    boolean isFromMemoryCache, boolean isFirstResource) {

                poweredByLogoImageView.setVisibility(View.VISIBLE);
                return false;
            }
        };

        GlideHelper.loadImageIntoView(poweredByLogoImageView, context, mvpdUrl, listener,
                android.R.color.transparent,
                new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent)));
    } catch (Exception e) {
        Log.e(TAG, "loadPoweredByLogo failed, activity may not include it.", e);
    }
}

From source file:com.game.simple.Game3.java

public static void turnOffAd() {
    self.runOnUiThread(new Runnable() {

        @Override/*from  ww  w . ja va2  s.com*/
        public void run() {
            adView.setVisibility(View.INVISIBLE);
            Log.e("-ADs", "turn off");

        }
    });

}

From source file:com.shengtao.chat.chatUI.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() == Type.IMAGE) {
            try {
                holder.iv = ((ImageView) convertView.findViewById(id.iv_sendPicture));
                holder.iv_avatar = (ImageView) convertView.findViewById(id.iv_userhead);
                holder.tv = (TextView) convertView.findViewById(id.percentage);
                holder.pb = (ProgressBar) convertView.findViewById(id.progressBar);
                holder.staus_iv = (ImageView) convertView.findViewById(id.msg_status);
                holder.tv_usernick = (TextView) convertView.findViewById(id.tv_userid);
            } catch (Exception e) {
            }//w  w w . j av  a  2s.  c o m

        } else if (message.getType() == Type.TXT) {

            try {
                holder.pb = (ProgressBar) convertView.findViewById(id.pb_sending);
                holder.staus_iv = (ImageView) convertView.findViewById(id.msg_status);
                holder.iv_avatar = (ImageView) convertView.findViewById(id.iv_userhead);
                // 
                holder.tv = (TextView) convertView.findViewById(id.tv_chatcontent);
                holder.tv_usernick = (TextView) convertView.findViewById(id.tv_userid);

                holder.tvTitle = (TextView) convertView.findViewById(id.tvTitle);
                holder.tvList = (LinearLayout) convertView.findViewById(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(id.iv_call_icon);
                holder.tv = (TextView) convertView.findViewById(id.tv_chatcontent);
            }

        } else if (message.getType() == Type.VOICE) {
            try {
                holder.iv = ((ImageView) convertView.findViewById(id.iv_voice));
                holder.iv_avatar = (ImageView) convertView.findViewById(id.iv_userhead);
                holder.tv = (TextView) convertView.findViewById(id.tv_length);
                holder.pb = (ProgressBar) convertView.findViewById(id.pb_sending);
                holder.staus_iv = (ImageView) convertView.findViewById(id.msg_status);
                holder.tv_usernick = (TextView) convertView.findViewById(id.tv_userid);
                holder.iv_read_status = (ImageView) convertView.findViewById(id.iv_unread_voice);
            } catch (Exception e) {
            }
        } else if (message.getType() == Type.LOCATION) {
            try {
                holder.iv_avatar = (ImageView) convertView.findViewById(id.iv_userhead);
                holder.tv = (TextView) convertView.findViewById(id.tv_location);
                holder.pb = (ProgressBar) convertView.findViewById(id.pb_sending);
                holder.staus_iv = (ImageView) convertView.findViewById(id.msg_status);
                holder.tv_usernick = (TextView) convertView.findViewById(id.tv_userid);
            } catch (Exception e) {
            }
        } else if (message.getType() == Type.VIDEO) {
            try {
                holder.iv = ((ImageView) convertView.findViewById(id.chatting_content_iv));
                holder.iv_avatar = (ImageView) convertView.findViewById(id.iv_userhead);
                holder.tv = (TextView) convertView.findViewById(id.percentage);
                holder.pb = (ProgressBar) convertView.findViewById(id.progressBar);
                holder.staus_iv = (ImageView) convertView.findViewById(id.msg_status);
                holder.size = (TextView) convertView.findViewById(id.chatting_size_iv);
                holder.timeLength = (TextView) convertView.findViewById(id.chatting_length_iv);
                holder.playBtn = (ImageView) convertView.findViewById(id.chatting_status_btn);
                holder.container_status_btn = (LinearLayout) convertView.findViewById(id.container_status_btn);
                holder.tv_usernick = (TextView) convertView.findViewById(id.tv_userid);

            } catch (Exception e) {
            }
        } else if (message.getType() == Type.FILE) {
            try {
                holder.iv_avatar = (ImageView) convertView.findViewById(id.iv_userhead);
                holder.tv_file_name = (TextView) convertView.findViewById(id.tv_file_name);
                holder.tv_file_size = (TextView) convertView.findViewById(id.tv_file_size);
                holder.pb = (ProgressBar) convertView.findViewById(id.pb_sending);
                holder.staus_iv = (ImageView) convertView.findViewById(id.msg_status);
                holder.tv_file_download_state = (TextView) convertView.findViewById(id.tv_file_state);
                holder.ll_container = (LinearLayout) convertView.findViewById(id.ll_file_container);
                // 
                holder.tv = (TextView) convertView.findViewById(id.percentage);
            } catch (Exception e) {
            }
            try {
                holder.tv_usernick = (TextView) convertView.findViewById(id.tv_userid);
            } catch (Exception e) {
            }

        }

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    // ??????
    if ((chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == Direct.RECEIVE) {
        //demousername?nick

        UserUtils.setUserNick(message.getFrom(), holder.tv_usernick);
    }
    if (message.direct == Direct.SEND) {
        UserUtils.setCurrentUserNick(holder.tv_usernick);
    }
    // ??????textview
    if (!(chatType == ChatType.GroupChat || chatType == ChatType.ChatRoom) && message.direct == Direct.SEND) {
        holder.tv_ack = (TextView) convertView.findViewById(id.tv_ack);
        holder.tv_delivered = (TextView) convertView.findViewById(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.tv_usernick);

    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 == Direct.SEND) {
        View statusView = convertView.findViewById(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(string.confirm_resend));
                intent.putExtra("title", activity.getString(string.resend));
                intent.putExtra("cancel", true);
                intent.putExtra("position", position);
                if (message.getType() == Type.TXT)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_TEXT);
                else if (message.getType() == Type.VOICE)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VOICE);
                else if (message.getType() == Type.IMAGE)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_PICTURE);
                else if (message.getType() == Type.LOCATION)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_LOCATION);
                else if (message.getType() == Type.FILE)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_FILE);
                else if (message.getType() == Type.VIDEO)
                    activity.startActivityForResult(intent, ChatActivity.REQUEST_CODE_VIDEO);

            }
        });

    } else {
        final String st = context.getResources().getString(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(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;
}