Java Code Examples for android.widget.ImageView#setVisibility()

The following examples show how to use android.widget.ImageView#setVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewExtractorsTest.java    From litho with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  final Activity activity = Robolectric.buildActivity(Activity.class).create().get();

  mLithoDrawable = activity.getResources().getDrawable(R.drawable.litho);

  mView = new View(activity);

  mTextView = new TextView(activity);
  mTextView.setText("example");

  mGoneTextView = new TextView(activity);
  mGoneTextView.setText("gone");
  mGoneTextView.setVisibility(View.GONE);

  mImageView = new ImageView(activity);
  mImageView.setImageDrawable(mLithoDrawable);

  mGoneImageView = new ImageView(activity);
  mGoneImageView.setImageDrawable(mLithoDrawable);
  mGoneImageView.setVisibility(View.GONE);
}
 
Example 2
Source File: LinearBreadcrumb.java    From GithubApp with Apache License 2.0 6 votes vote down vote up
public void addCrumb(@NonNull Crumb crumb, boolean refreshLayout) {
    LinearLayout view = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.bread_crumb, this, false);
    view.setTag(mCrumbs.size());
    view.setOnClickListener(this);

    ImageView iv = (ImageView) view.getChildAt(1);
    Drawable arrow = getResources().getDrawable(R.drawable.ic_right_arrow);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        if (arrow != null) {
            arrow.setAutoMirrored(true);
        }
    }
    iv.setImageDrawable(arrow);
    iv.setVisibility(View.GONE);

    mChildFrame.addView(view, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mCrumbs.add(crumb);
    if (refreshLayout) {
        mActive = mCrumbs.size() - 1;
        requestLayout();
    }
    invalidateActivatedAll();
}
 
Example 3
Source File: MarkerInfoWindow.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override public void onOpen(Object item) {
	super.onOpen(item);
	
	mMarkerRef = (Marker)item;
	if (mView==null) {
		Log.w(IMapView.LOGTAG, "Error trapped, MarkerInfoWindow.open, mView is null!");
		return;
	}
	//handle image
	ImageView imageView = (ImageView)mView.findViewById(mImageId /*R.id.image*/);
	Drawable image = mMarkerRef.getImage();
	if (image != null){
		imageView.setImageDrawable(image); //or setBackgroundDrawable(image)?
		imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
		imageView.setVisibility(View.VISIBLE);
	} else
		imageView.setVisibility(View.GONE);
}
 
Example 4
Source File: HeaderView.java    From HeaderView with MIT License 6 votes vote down vote up
private void addArrow() {
    arrow = new ImageView(getContext());
    arrow.setImageResource(R.drawable.hv_arrow);
    arrow.setBackgroundResource(Utils.selectableItemBackground(getContext()));
    arrow.setColorFilter(hvTextColor);
    arrow.setOnClickListener(v -> {
        if (hvFragmentManager != null) {
            ProfileChooserFragment profileChooserFragment = ProfileChooserFragment.newInstance(profileSparseArray, itemArrayList, hvHighlightColor, hvShowAddButton, hvDialogTitle, hvAddIconDrawable);
            profileChooserFragment.setCallback(HeaderView.this);
            profileChooserFragment.setTypeface(typeface);
            profileChooserFragment.show(hvFragmentManager, ProfileChooserFragment.FRAGMENT_TAG);
        } else {
            profileChooser = new ProfileChooser(getContext(), profileSparseArray, itemArrayList, hvHighlightColor, hvShowAddButton, hvDialogTitle, hvAddIconDrawable, typeface);
            profileChooser.setCallback(HeaderView.this);
            profileChooser.show();
        }
    });
    arrow.setVisibility(hvShowArrow ? VISIBLE : GONE);
    addView(arrow, 6);
}
 
Example 5
Source File: ShoppingListCursorAdapter.java    From ShoppingList with MIT License 6 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {
	ShoppingList shoppingList = getItem(cursor.getPosition());

	TextView tvId = (TextView) view.findViewById(R.id.idShoppingList);
	tvId.setText(String.valueOf(shoppingList.getId()));

	ImageView imAllItemsChecked = (ImageView) view.findViewById(R.id.allItemsChecked);
	boolean checked = ItemShoppingListDAO.isAllItemsChecked(context, shoppingList.getId());

	imAllItemsChecked.setImageResource(checked ? R.drawable.btn_check_on_holo_dark : R.drawable.btn_check_off_holo_dark);
	imAllItemsChecked.setVisibility(View.VISIBLE);

	TextView tvName = (TextView) view.findViewById(R.id.nameShoppingList);
	tvName.setText(shoppingList.getName());
	tvName.setPaintFlags(checked ? Paint.STRIKE_THRU_TEXT_FLAG : Paint.ANTI_ALIAS_FLAG);
	tvName.setTypeface(null, checked ? Typeface.ITALIC : Typeface.NORMAL);

	TextView tvDate = (TextView) view.findViewById(R.id.dateShoppingList);
	tvDate.setText(CustomDateFormat.getFormatedDate(shoppingList.getDate()));

	TextView tvTime = (TextView) view.findViewById(R.id.timeShoppingList);
	tvTime.setText(CustomDateFormat.getFormatedTime(shoppingList.getDate()));

}
 
Example 6
Source File: ImagePreviewAdapter.java    From imsdk-android with MIT License 6 votes vote down vote up
private void loadFailed(SubsamplingScaleImageViewDragClose imageView, ImageView imageGif, ProgressBar progressBar,
                        Exception e) {
    progressBar.setVisibility(View.GONE);
    imageGif.setVisibility(View.GONE);
    imageView.setVisibility(View.VISIBLE);

    imageView.setZoomEnabled(false);
    imageView.setImage(ImageSource.resource(ImagePreview.getInstance().getErrorPlaceHolder()));

    String errorMsg = "加载失败";
    if (e != null) {
        errorMsg = errorMsg.concat(":\n").concat(e.getMessage());
    }
    if (errorMsg.length() > 200) {
        errorMsg = errorMsg.substring(0, 199);
    }
    ToastUtil.getInstance()._short(activity.getApplicationContext(), errorMsg);
}
 
Example 7
Source File: EditPage.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
private ImageView getImagePin() {
	ivPin = new ImageView(getContext());
	int resId = getBitmapRes(activity, "pin");
	if (resId > 0) {
		ivPin.setImageResource(resId);
	}
	int dp_80 = dipToPx(getContext(), 80);
	int dp_36 = dipToPx(getContext(), 36);
	RelativeLayout.LayoutParams lp
			= new RelativeLayout.LayoutParams(dp_80, dp_36);
	lp.topMargin = dipToPx(getContext(), 6);
	lp.addRule(RelativeLayout.ALIGN_TOP, llBody.getId());
	lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	ivPin.setLayoutParams(lp);
	ivPin.setVisibility(View.GONE);

	return ivPin;
}
 
Example 8
Source File: SearchHistoryListViewAdapter.java    From wallpaper with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("ViewHolder")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	convertView = inflater.inflate(R.layout.item_shousuo, null);
	TextView tv = (TextView) convertView.findViewById(R.id.item_shousuo_tv);
	ImageView imageView = (ImageView) convertView.findViewById(R.id.searchHistoryListView_imageView);
	if(position==0){
		tv.setText("清除历史");
		imageView.setVisibility(View.INVISIBLE);
		tv.setTextColor(Color.parseColor("#999999"));
	}else{
		String historyItem = mSearchHistories.get(position-1);
	    tv.setText(historyItem);
	}
	return convertView;
}
 
Example 9
Source File: WearListAdapter.java    From AndroidWear-OpenWear with MIT License 5 votes vote down vote up
@Override
public void onBindView(TextView textView, ImageView iconView, int position) {
    // TODO Auto-generated method stub
    Feature item = getItem(position);
    textView.setText(item.name);

    iconView.setVisibility(View.GONE);
}
 
Example 10
Source File: PullRefreshLayout.java    From android-PullRefreshLayout with MIT License 5 votes vote down vote up
public PullRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.refresh_PullRefreshLayout);
    final int type = a.getInteger(R.styleable.refresh_PullRefreshLayout_refreshType, STYLE_MATERIAL);
    final int colorsId = a.getResourceId(R.styleable.refresh_PullRefreshLayout_refreshColors, 0);
    final int colorId = a.getResourceId(R.styleable.refresh_PullRefreshLayout_refreshColor, 0);
    a.recycle();

    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    int defaultDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
    mDurationToStartPosition = defaultDuration;
    mDurationToCorrectPosition = defaultDuration;
    mSpinnerFinalOffset = mTotalDragDistance = dp2px(DRAG_MAX_DISTANCE);

    if (colorsId > 0) {
        mColorSchemeColors = context.getResources().getIntArray(colorsId);
    } else {
        mColorSchemeColors = new int[]{Color.rgb(0xC9, 0x34, 0x37), Color.rgb(0x37, 0x5B, 0xF1), Color.rgb(0xF7, 0xD2, 0x3E), Color.rgb(0x34, 0xA3, 0x50)};
    }

    if (colorId > 0) {
        mColorSchemeColors = new int[]{context.getResources().getColor(colorId)};
    }

    mRefreshView = new ImageView(context);
    setRefreshStyle(type);
    mRefreshView.setVisibility(View.GONE);
    addView(mRefreshView, 0);
    setWillNotDraw(false);
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
}
 
Example 11
Source File: RichEditText.java    From RichEditor with MIT License 5 votes vote down vote up
/**
 * 控制视频、gif、长图标识的显示和隐藏
 *
 * @param imageItemView    包裹图标的外层View
 * @param blockImageSpanVm 相关实体
 */
private void setMarkIconVisibility(View imageItemView, BlockImageSpanVm blockImageSpanVm) {
    ImageView ivVideoIcon = imageItemView.findViewById(R.id.ivVideoIcon);
    TextView tvGifOrLongImageMark = imageItemView.findViewById(R.id.tvGifOrLongImageMark);

    // 控制视频、gif、长图标识图标的显示和隐藏
    ivVideoIcon.setVisibility(GONE);
    tvGifOrLongImageMark.setVisibility(GONE);

    // 处理视频
    if (blockImageSpanVm.isVideo() && gIsShowVideoMark && gVideoMarkResourceId != 0) {
        // 视频封面,显示视频标识
        Drawable videoIconDrawable = AppCompatResources.getDrawable(mActivity, gVideoMarkResourceId);
        if (videoIconDrawable != null) {
            ivVideoIcon.setVisibility(VISIBLE);
            ivVideoIcon.setImageDrawable(videoIconDrawable);
            ViewGroup.LayoutParams layoutParams = ivVideoIcon.getLayoutParams();
            layoutParams.width = videoIconDrawable.getIntrinsicWidth();
            layoutParams.height = videoIconDrawable.getIntrinsicHeight();
        }
        return;
    }


    // 处理长图
    if (blockImageSpanVm.isLong() && gIsShowLongImageMark) {
        // 长图,显示长图标识
        tvGifOrLongImageMark.setVisibility(VISIBLE);
        tvGifOrLongImageMark.setText(ImageTypeMarkEnum.LONG);
        return;
    }

    // 处理gif
    if (blockImageSpanVm.isGif() && gIsShowGifMark) {
        // gif, 显示gif标识
        tvGifOrLongImageMark.setVisibility(VISIBLE);
        tvGifOrLongImageMark.setText(ImageTypeMarkEnum.GIF);
    }
}
 
Example 12
Source File: JoystickView.java    From RobotCA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Update the virtual joystick to indicate a contact down has occurred.
 */
private void onContactDown() {
    // The divets should be completely opaque indicating
    // the virtual joystick is active.
    thumbDivet.setAlpha(1.0f);
    magnitudeText.setAlpha(1.0f);
    // Previous contact location need not be shown any more.
    lastVelocityDivet.setAlpha(0.0f);
    // Restore the orientation tacks.
    for (ImageView tack : orientationWidget) {
        tack.setVisibility(VISIBLE);
    }
}
 
Example 13
Source File: WheelItem.java    From WheelView with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化
 */
private void init() {
    LinearLayout layout = new LinearLayout(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            WheelUtils.dip2px(getContext(),
            WheelConstants
                    .WHEEL_ITEM_HEIGHT));
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setPadding(WheelConstants.WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING,
            WheelConstants
            .WHEEL_ITEM_PADDING, WheelConstants.WHEEL_ITEM_PADDING);
    layout.setGravity(Gravity.CENTER);
    addView(layout, layoutParams);

    // 图片
    mImage = new ImageView(getContext());
    mImage.setTag(WheelConstants.WHEEL_ITEM_IMAGE_TAG);
    mImage.setVisibility(View.GONE);
    LayoutParams imageParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    imageParams.rightMargin = WheelConstants.WHEEL_ITEM_MARGIN;
    layout.addView(mImage, imageParams);

    // 文本
    mText = new TextView(getContext());
    mText.setTag(WheelConstants.WHEEL_ITEM_TEXT_TAG);
    mText.setEllipsize(TextUtils.TruncateAt.END);
    mText.setSingleLine();
    mText.setIncludeFontPadding(false);
    mText.setGravity(Gravity.CENTER);
    mText.setTextColor(Color.BLACK);
    LayoutParams textParams = new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    layout.addView(mText, textParams);
}
 
Example 14
Source File: TinyGifDrawableLoader.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
public void loadGifDrawable(Context context, @RawRes @DrawableRes int gifDrawableResId, ImageView iv, int playTimes) {
        if (context == null || iv == null) {
            return;
        }
        iv.setVisibility(View.VISIBLE);
        theDisPlayImageView = new WeakReference<>(iv);//added by fee 2019-07-08: 将当前要显示的ImageView控件引用起来,但不适用本类用于给不同的ImageView加载
        this.playTimes = playTimes;
        //注:如果不是gif资源,则在asGif()时会抛异常
        RequestBuilder<GifDrawable> requestBuilder =
                Glide.with(context.getApplicationContext())
                        .asGif()
//                        .load(gifDrawableResId)
                ;
        if (
                playTimes >= 1 ||
                loadCallback != null) {//指定了播放次数,则需要监听动画执行的结束
            requestBuilder.listener(this)
            ;
        }
        RequestOptions options = new RequestOptions();
        options.diskCacheStrategy(DiskCacheStrategy.RESOURCE);
        requestBuilder.apply(options)
//        listener(this)
                .load(gifDrawableResId)
                .into(iv)
        ;
    }
 
Example 15
Source File: CityWeatherActivity.java    From LittleFreshWeather with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    ++mSpecialWeatherNumLightning;
    if (mSpecialWeatherNumLightning <= mSpecialWeatherNumLimitLightning) {
        int toolbarHeight = 0;
        int screenHeight = DensityUtil.getScreenHeight(CityWeatherActivity.this);
        int screenWidth = DensityUtil.getScreenWidth(CityWeatherActivity.this);

        ImageView imageView = new ImageView(CityWeatherActivity.this);
        imageView.setVisibility(View.VISIBLE);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        if ((mSpecialWeatherNumLightning & 0x1) == 0) {
            //imageView.setImageResource(R.drawable.lightning_2);
            mPresenter.getImageViewSrc(imageView, R.drawable.lightning_2);
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layoutParams.setMargins(0, toolbarHeight + mRandom.nextInt(screenHeight >> 2), screenWidth >> 2 + mRandom.nextInt(screenWidth >> 2), 0);
        } else {
            //imageView.setImageResource(R.drawable.lightning_1);
            mPresenter.getImageViewSrc(imageView, R.drawable.lightning_1);
            layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layoutParams.setMargins(mRandom.nextInt(screenWidth >> 2), toolbarHeight + mRandom.nextInt(screenHeight >> 2), 0, 0);
        }
        rlBackgroundView.addView(imageView, layoutParams);

        ObjectAnimator animator = ObjectAnimator.ofFloat(imageView, "alpha", 0, 1);
        animator.setDuration(LIGHTNING_SPEED_H);
        animator.setRepeatMode(ObjectAnimator.REVERSE);
        animator.setRepeatCount(3);
        animator.setInterpolator(new AccelerateInterpolator());
        animator.start();

        mHandler.postDelayed(lightningProc, LIGHTNING_GEN_INTERVAL + mRandom.nextInt(LIGHTNING_GEN_INTERVAL));
    } else {
        mSpecialWeatherNumLightning = 0;
        mHandler.postDelayed(lightningProc, LIGHTNING_GEN_INTERVAL + mRandom.nextInt(LIGHTNING_GEN_INTERVAL));
    }
}
 
Example 16
Source File: AnalogComplicationConfigRecyclerViewAdapter.java    From wear-os-samples with Apache License 2.0 5 votes vote down vote up
private void updateComplicationView(ComplicationProviderInfo complicationProviderInfo,
    ImageButton button, ImageView background) {
    if (complicationProviderInfo != null) {
        button.setImageIcon(complicationProviderInfo.providerIcon);
        button.setContentDescription(
            mContext.getString(R.string.edit_complication,
                complicationProviderInfo.appName + " " +
                    complicationProviderInfo.providerName));
        background.setVisibility(View.VISIBLE);
    } else {
        button.setImageDrawable(mDefaultComplicationDrawable);
        button.setContentDescription(mContext.getString(R.string.add_complication));
        background.setVisibility(View.INVISIBLE);
    }
}
 
Example 17
Source File: StickerSetCell.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public StickerSetCell(Context context, int option) {
    super(context);
    this.option = option;

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity(LayoutHelper.getAbsoluteGravityStart());
    addView(textView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, 71, 9, 46, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setGravity(LayoutHelper.getAbsoluteGravityStart());
    addView(valueTextView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, 71, 32, 46, 0));

    imageView = new BackupImageView(context);
    imageView.setAspectFit(true);
    imageView.setLayerNum(1);
    addView(imageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 13, 9, LocaleController.isRTL ? 13 : 0, 0));

    if (option == 2) {
        progressView = new RadialProgressView(getContext());
        progressView.setProgressColor(Theme.getColor(Theme.key_dialogProgressCircle));
        progressView.setSize(AndroidUtilities.dp(30));
        addView(progressView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 5, LocaleController.isRTL ? 12 : 0, 0));
    } else if (option != 0) {
        optionsButton = new ImageView(context);
        optionsButton.setFocusable(false);
        optionsButton.setScaleType(ImageView.ScaleType.CENTER);
        optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
        if (option == 1) {
            optionsButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
            optionsButton.setImageResource(R.drawable.msg_actions);
            addView(optionsButton, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL));

            reorderButton = new ImageView(context);
            reorderButton.setAlpha(0f);
            reorderButton.setVisibility(GONE);
            reorderButton.setScaleType(ImageView.ScaleType.CENTER);
            reorderButton.setImageResource(R.drawable.list_reorder);
            reorderButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
            addView(reorderButton, LayoutHelper.createFrameRelatively(58, 58, Gravity.END));

            checkBox = new CheckBox2(context, 21);
            checkBox.setColor(null, Theme.key_windowBackgroundWhite, Theme.key_checkboxCheck);
            checkBox.setDrawUnchecked(false);
            checkBox.setDrawBackgroundAsArc(3);
            addView(checkBox, LayoutHelper.createFrameRelatively(24, 24, Gravity.START, 34, 30, 0, 0));
        } else if (option == 3) {
            optionsButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY));
            optionsButton.setImageResource(R.drawable.sticker_added);
            addView(optionsButton, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, (LocaleController.isRTL ? 10 : 0), 9, (LocaleController.isRTL ? 0 : 10), 0));
        }
    }
}
 
Example 18
Source File: AppUtils.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * update message status automatically
 *
 * @param view TextView message status
 */
public static void rightMessageStatus(ImageView view, ProtoGlobal.RoomMessageStatus status, ProtoGlobal.RoomMessageType messageType, boolean isSenderMe) {
    if (view == null) {
        return;
    }
    if (!isSenderMe) {
        view.setVisibility(View.GONE);
        return;
    } else {
        view.setVisibility(View.VISIBLE);
    }
    switch (status) {
        case DELIVERED:
            setImageDrawable(view, R.drawable.ic_double_check);
            //DrawableCompat.setTint(view.getDrawable().mutate(), Color.BLACK);
            break;
        case FAILED:
            setImageDrawable(view, R.drawable.ic_error_igap);
            if (messageType == ProtoGlobal.RoomMessageType.IMAGE || messageType == ProtoGlobal.RoomMessageType.VIDEO || messageType == ProtoGlobal.RoomMessageType.GIF) {
                DrawableCompat.setTint(view.getDrawable().mutate(), Color.WHITE);
            } else {
                DrawableCompat.setTint(view.getDrawable().mutate(), Color.RED);
            }
            break;
        case LISTENED:
        case SEEN:
            setImageDrawable(view, R.drawable.ic_double_check);
            final Drawable originalDrawable = view.getDrawable();
            final Drawable wrappedDrawable = DrawableCompat.wrap(originalDrawable);
            DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(view.getContext().getResources().getColor(R.color.iGapColor)));
            break;
        case SENDING:
            setImageDrawable(view, R.drawable.ic_clock);
            if (messageType == ProtoGlobal.RoomMessageType.IMAGE || messageType == ProtoGlobal.RoomMessageType.VIDEO || messageType == ProtoGlobal.RoomMessageType.GIF) {
                DrawableCompat.setTint(view.getDrawable().mutate(), Color.WHITE);
            } else {
                DrawableCompat.setTint(view.getDrawable().mutate(), Color.BLACK);
            }
            break;
        case SENT:
            setImageDrawable(view, R.drawable.ic_check);
            if (messageType == ProtoGlobal.RoomMessageType.IMAGE || messageType == ProtoGlobal.RoomMessageType.VIDEO || messageType == ProtoGlobal.RoomMessageType.GIF) {
                DrawableCompat.setTint(view.getDrawable().mutate(), Color.WHITE);
            } else {
                DrawableCompat.setTint(view.getDrawable().mutate(), Color.BLACK);
            }
            break;
        default:
            view.setVisibility(View.GONE);
            break;
    }
}
 
Example 19
Source File: OdooActivity.java    From hr with GNU Affero General Public License v3.0 4 votes vote down vote up
private void setupAccountBox() {
    mDrawerAccountContainer = (LinearLayout) findViewById(R.id.accountList);
    View chosenAccountView = findViewById(R.id.drawerAccountView);
    OUser currentUser = OUser.current(this);
    if (currentUser == null) {
        chosenAccountView.setVisibility(View.GONE);
        mDrawerAccountContainer.setVisibility(View.GONE);
        return;
    } else {
        chosenAccountView.setVisibility(View.VISIBLE);
        mDrawerAccountContainer.setVisibility(View.INVISIBLE);
    }

    ImageView avatar = (ImageView) chosenAccountView.findViewById(R.id.profile_image);
    TextView name = (TextView) chosenAccountView.findViewById(R.id.profile_name_text);
    TextView url = (TextView) chosenAccountView.findViewById(R.id.profile_url_text);

    name.setText(currentUser.getName());
    url.setText((currentUser.isOAuthLogin()) ? currentUser.getInstanceURL() : currentUser.getHost());

    if (!currentUser.getAvatar().equals("false")) {
        Bitmap bitmap = BitmapUtils.getBitmapImage(this, currentUser.getAvatar());
        if (bitmap != null)
            avatar.setImageBitmap(bitmap);
    }

    // Setting Accounts
    List<OUser> accounts = OdooAccountManager.getAllAccounts(this);
    if (accounts.size() > 0) {
        chosenAccountView.setEnabled(true);
        ImageView boxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator);
        boxIndicator.setVisibility(View.VISIBLE);
        chosenAccountView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mAccountBoxExpanded = !mAccountBoxExpanded;
                accountBoxToggle();
            }
        });
        populateAccountList(currentUser, accounts);
    }
}
 
Example 20
Source File: CheckableListAdapter.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.cell_checkable_item, parent, false);
    }
    Version1TextView text = (Version1TextView) convertView.findViewById(R.id.title);
    ImageView checkbox = (ImageView) convertView.findViewById(R.id.checkbox);

    int checked = isLightColorScheme() ? R.drawable.circle_check_black_filled : R.drawable.circle_check_white_filled;
    int unchecked = isLightColorScheme() ? R.drawable.circle_hollow_black : R.drawable.circle_hollow_white;

    checkbox.setImageResource(selectedItem == position ? checked : unchecked);
    checkbox.setVisibility(View.VISIBLE);

    text.setText(array[position]);
    if (!isEnabled(position)) {
        text.setTextColor(Color.GRAY);
    } else {
        if(isLightColorScheme()) {
            text.setTextColor(Color.BLACK);
        }
        else {
            text.setTextColor(Color.WHITE);
        }
    }

    convertView.setTag(position);
    convertView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(isEnabled((int)v.getTag())) {
                selectedItem = (int)v.getTag();
                notifyDataSetChanged();
                if (callback != null) {
                    callback.onSelectionChanged();
                }
            }
        }
    });

    return convertView;
}