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

The following examples show how to use android.widget.ImageView#setBackgroundDrawable() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: RoMote   File: ImageWorker.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView.
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td =
                new TransitionDrawable(new Drawable[] {
                        new ColorDrawable(android.R.color.transparent),
                        drawable
                });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(
                new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}
 
Example 2
Source Project: YiBo   File: AccountHolder.java    License: Apache License 2.0 6 votes vote down vote up
public AccountHolder(View convertView) {
	if (convertView == null) {
		throw new IllegalArgumentException("convertView is null!");
	}
	ivProfilePicture = (ImageView)convertView.findViewById(R.id.ivProfileImage);
	tvScreenName = (TextView)convertView.findViewById(R.id.tvScreenName);
	tvSPName = (TextView)convertView.findViewById(R.id.tvSPName);
	tvExpiredHint = (TextView)convertView.findViewById(R.id.tvExpiredHint);
	ivLineSeperator = (ImageView)convertView.findViewById(R.id.ivLineSeperator);
	ivDelAccount = (ImageView)convertView.findViewById(R.id.ivDelAccount);
	
	//设置主题 
	theme = ThemeUtil.createTheme(convertView.getContext());
	tvScreenName.setTextColor(theme.getColor("content"));
	tvSPName.setTextColor(theme.getColor("quote"));
	tvExpiredHint.setTextColor(theme.getColor("red"));
	ivLineSeperator.setBackgroundDrawable(theme.getDrawable("line_seperator"));
	ivDelAccount.setImageDrawable(theme.getDrawable("icon_account_delete_normal"));
}
 
Example 3
Source Project: AndroidUtilCode   File: DebugItem.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void bind(@NonNull ItemViewHolder holder, int position) {
    ImageView menuItemIconIv = holder.findViewById(R.id.menuItemIconIv);
    TextView menuItemNameTv = holder.findViewById(R.id.menuItemNameTv);

    ClickUtils.applyPressedBgDark(holder.itemView);
    ClickUtils.applyPressedViewScale(holder.itemView);

    menuItemIconIv.setBackgroundDrawable(new PolygonDrawable(5, mColor));
    menuItemIconIv.setImageResource(mDebug.getIcon());
    menuItemNameTv.setText(StringUtils.getString(mDebug.getName()));
    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mDebug.onClick(v);
        }
    });
}
 
Example 4
Source Project: YiBo   File: GroupHolder.java    License: Apache License 2.0 6 votes vote down vote up
public GroupHolder(View convertView) {
	if (convertView == null) {
		throw new IllegalArgumentException("convertView is null!");
	}
	ivGroup = (ImageView)convertView.findViewById(R.id.ivGroup);
	tvGroupName = (TextView)convertView.findViewById(R.id.tvGroupName);
	tvImpress = (TextView)convertView.findViewById(R.id.tvImpress);
	ivMoreDetail = (ImageView)convertView.findViewById(R.id.ivMoreDetail);
	
	Theme theme = ThemeUtil.createTheme(convertView.getContext());
	ivGroup.setImageDrawable(theme.getDrawable("icon_group"));
	tvGroupName.setTextColor(theme.getColor("content"));
	if (tvImpress != null) {
	    tvImpress.setTextColor(theme.getColor("remark"));
	}
	if (ivMoreDetail != null) {
		ivMoreDetail.setBackgroundDrawable(theme.getDrawable("icon_more_detail"));
	}
}
 
Example 5
public void setPreviewColor() {
    if (this.mView == null) {
        return;
    }
    final ImageView iView = new ImageView(getContext());
    final LinearLayout widgetFrameView = ((LinearLayout) this.mView
            .findViewById(android.R.id.widget_frame));
    if (widgetFrameView == null) {
        return;
    }
    widgetFrameView.setPadding(widgetFrameView.getPaddingLeft(),
            widgetFrameView.getPaddingTop(), (int) (this.mDensity * 8),
            widgetFrameView.getPaddingBottom());
    // remove already create preview image
    final int count = widgetFrameView.getChildCount();
    if (count > 0) {
        widgetFrameView.removeViews(0, count);
    }
    widgetFrameView.addView(iView);
    iView.setBackgroundDrawable(new AlphaPatternDrawable(
            (int) (5 * this.mDensity)));
    iView.setImageBitmap(getPreviewBitmap());
}
 
Example 6
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_contact_detail);

    Bundle args = getIntent().getExtras();
    String contactName = args.getString("ContactName");
    String contactUID  = args.getString("ContactID");

    /* set the toolbar */
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(contactName);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle(contactName);

    /* set the background header */
    ImageView header = (ImageView) findViewById(R.id.header_background);
    ColorGenerator generator = ColorGenerator.DEFAULT;
    header.setBackgroundDrawable(
            builder.build(contactName.substring(0, 1),
            generator.getColor(contactUID)));

    /* setting up the view pager and the tablayout */
    TabLayout tabLayout = (TabLayout) findViewById(R.id.contact_tab_layout);
    ViewPager viewPager = (ViewPager) findViewById(R.id.contact_viewpager);
    ContactDetailPagerAdapter pagerAdapter = new ContactDetailPagerAdapter(getSupportFragmentManager(), args);
    viewPager.setAdapter(pagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setSelectedTabIndicatorHeight(10);
}
 
Example 7
Source Project: imsdk-android   File: FaceGridView.java    License: MIT License 5 votes vote down vote up
private void initDots(EmoticionMap eMap,int index) {
    if (eMap == null)
        return;
    bottomDot.removeAllViews();
    int itemCountPerPage = eMap.showAll == 0 ? 8 : 21;
    int viewPagerPageSize = (int) Math.ceil(((double) eMap.count)
            / ((double) itemCountPerPage));

    if (viewPagerPageSize > 0) {
        if (viewPagerPageSize == 1) {
            bottomDot.setVisibility(View.GONE);
        } else {
            bottomDot.setVisibility(View.VISIBLE);
            imageViews = new ImageView[viewPagerPageSize];
            int dotFileHeight = Utils.dipToPixels(context, 5);
            int dotFileWidth = Utils.dipToPixels(context, 5);
            int dotMargin = Utils.dipToPixels(context, 4);
            for (int i = 0; i < viewPagerPageSize; i++) {
                ImageView image = new ImageView(context);
                image.setTag(i);
                LayoutParams params = new LayoutParams(dotFileWidth, dotFileHeight);
                params.setMargins(dotMargin, dotMargin, dotMargin, dotMargin);
                image.setBackgroundDrawable(new DotFile(context).setStateDrawable());
                image.setEnabled(false);
                bottomDot.addView(image, params);
                imageViews[i] = image;
            }
            imageViews[index].setEnabled(true);
        }
    }
}
 
Example 8
Source Project: imsdk-android   File: OperationView.java    License: MIT License 5 votes vote down vote up
public void initIndicator(int index){
    ll_inicatore.removeAllViews();
    int viewPagerPageSize =  mChatOperationsAdapter.getCount();

    if (viewPagerPageSize > 0) {
        if (viewPagerPageSize == 1) {
            ll_inicatore.setVisibility(View.GONE);
        } else {
            ll_inicatore.setVisibility(View.VISIBLE);
            imageViews = new ImageView[viewPagerPageSize];
            int dotFileHeight = Utils.dipToPixels(mContext, 5);
            int dotFileWidth = Utils.dipToPixels(mContext, 5);
            int dotMargin = Utils.dipToPixels(mContext, 4);
            for (int i = 0; i < viewPagerPageSize; i++) {
                ImageView image = new ImageView(mContext);
                image.setTag(i);
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(dotFileWidth, dotFileHeight);
                params.setMargins(dotMargin, dotMargin, dotMargin, dotMargin);
                image.setBackgroundDrawable(new DotFile(mContext).setStateDrawable());
                image.setEnabled(false);
                ll_inicatore.addView(image, params);
                imageViews[i] = image;
            }
            imageViews[index].setEnabled(true);
        }
    }
}
 
Example 9
Source Project: PhoneTutorial   File: ButtonFloat.java    License: Apache License 2.0 5 votes vote down vote up
public ButtonFloat(Context context, AttributeSet attrs) {
	super(context, attrs);
	setBackgroundResource(R.drawable.background_button_float);
	sizeRadius = 28;
	setDefaultProperties();
	icon = new ImageView(context);
	if(drawableIcon != null) {
		try {
			icon.setBackground(drawableIcon);
		} catch (NoSuchMethodError e) {
			icon.setBackgroundDrawable(drawableIcon);
		}
	}
	RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources()));
	params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
	icon.setLayoutParams(params);
	addView(icon);		
	
	LayerDrawable layer = (LayerDrawable) getBackground();
	GradientDrawable shape =  (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground);
	shape.setColor(backgroundColor);
	
	post(new Runnable() {
		
		@Override
		public void run() {
			showPosition = ViewHelper.getY(ButtonFloat.this) - Utils.dpToPx(24, getResources());
			hidePosition = ViewHelper.getY(ButtonFloat.this) + getHeight() * 3;
			ViewHelper.setY(ButtonFloat.this, hidePosition);
		}
	});
	
}
 
Example 10
Source Project: WeGit   File: BitmapUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static void setIconFont(Context context, ImageView iv, Icon icon,
                               int rsid) {
    IconicFontDrawable iconDraw = new IconicFontDrawable(context);
    iconDraw.setIcon(icon);
    iconDraw.setIconColor(context.getResources().getColor(rsid));
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        iv.setBackground(iconDraw);
    else
        iv.setBackgroundDrawable(iconDraw);
}
 
Example 11
public BitmapWorkerTask(ImageView imageView, Bitmap.CompressFormat format) {
    // Use a WeakReference to ensure the ImageView can be garbage collected
    imageView.setBackgroundDrawable(imageView.getContext()
            .getResources().getDrawable(R.drawable.fplib_rectangle));
    imageViewReference = new WeakReference<ImageView>(imageView);
    mFormat = format;
}
 
Example 12
private View instantiateShareMenuItem(ShareMenuField f) {
    LinearLayout shareItem = new LinearLayout(getActivity());
    shareItem.setOrientation(LinearLayout.VERTICAL);
    shareItem.setGravity(Gravity.CENTER_HORIZONTAL);

    TextView title = new TextView(getActivity());
    title.setGravity(Gravity.CENTER);
    title.setTextColor(ActorSDK.sharedActor().style.getTextSecondaryColor());
    title.setText(f.getTitle());
    title.setTextSize(14);

    ImageView icon = new ImageView(getActivity());
    icon.setClickable(true);
    if (f.getSelector() != 0) {
        icon.setBackgroundResource(f.getSelector());
    } else {
        icon.setBackgroundDrawable(ShareMenuButtonFactory.get(f.getColor(), getActivity()));
        icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        icon.setImageResource(f.getIcon());
    }

    shareItem.addView(icon, shareIconSize, shareIconSize);
    shareItem.addView(title);

    View.OnClickListener l = v -> {
        hide();
        onItemClicked(v.getId());
    };
    icon.setId(f.getId());
    icon.setOnClickListener(l);

    shareItem.setTag(R.id.title, title);
    shareItem.setTag(R.id.icon, icon);
    shareItem.setTag(R.id.list, l);

    return shareItem;
}
 
Example 13
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    ivRefresh = (ImageView) findViewById(R.id.ivRefresh);
    mDrawable = new SunRefreshDrawable(getContext(), this, mTriggerOffset, getScreenWidth(getContext()));
    ivRefresh.setBackgroundDrawable(mDrawable);


}
 
Example 14
Source Project: bither-android   File: DialogTotalBtc.java    License: Apache License 2.0 4 votes vote down vote up
public DialogTotalBtc(Context context) {
    super(context);
    setContentView(R.layout.dialog_total_btc);
    tvBtc = (TextView) findViewById(R.id.tv_btc);
    vPieChart = (PieChartView) findViewById(R.id.pie);
    flPieContainer = (FrameLayout) findViewById(R.id.fl_pie_container);
    ivPrivate = (ImageView) findViewById(R.id.iv_private);
    tvPrivate = (TextView) findViewById(R.id.tv_private);
    tvPrivateMoney = (TextView) findViewById(R.id.tv_private_money);
    ivPrivateSymbol = (ImageView) findViewById(R.id.iv_private_symbol);
    ivWatchOnly = (ImageView) findViewById(R.id.iv_watchonly);
    tvWatchOnly = (TextView) findViewById(R.id.tv_watchonly);
    tvWatchOnlyMoney = (TextView) findViewById(R.id.tv_watchonly_money);
    ivWatchOnlySymbol = (ImageView) findViewById(R.id.iv_watchonly_symbol);
    ivHDM = (ImageView) findViewById(R.id.iv_hdm);
    tvHDM = (TextView) findViewById(R.id.tv_hdm);
    tvHDMMoney = (TextView) findViewById(R.id.tv_hdm_money);
    ivHDMSymbol = (ImageView) findViewById(R.id.iv_hdm_symbol);
    ivHD = (ImageView) findViewById(R.id.iv_hd);
    tvHD = (TextView) findViewById(R.id.tv_hd);
    tvHDMoney = (TextView) findViewById(R.id.tv_hd_money);
    ivHDSymbol = (ImageView) findViewById(R.id.iv_hd_symbol);
    ivHdMonitored = (ImageView) findViewById(R.id.iv_hd_monitored);
    tvHdMonitored = (TextView) findViewById(R.id.tv_hd_monitored);
    tvHdMonitoredMoney = (TextView) findViewById(R.id.tv_hd_monitored_money);
    ivHdMonitoredSymbol = (ImageView) findViewById(R.id.iv_hd_monitored_symbol);
    ivHdmEnterprise = (ImageView) findViewById(R.id.iv_hdm_enterprise);
    tvHdmEnterprise = (TextView) findViewById(R.id.tv_hdm_enterprise);
    tvHdmEnterpriseMoney = (TextView) findViewById(R.id.tv_hdm_enterprise_money);
    ivHdmEnterpriseSymbol = (ImageView) findViewById(R.id.iv_hdm_enterprise_symbol);
    llPrivate = (LinearLayout) findViewById(R.id.ll_private);
    llWatchOnly = (LinearLayout) findViewById(R.id.ll_watchonly);
    llHDM = (LinearLayout) findViewById(R.id.ll_hdm);
    llHD = (LinearLayout) findViewById(R.id.ll_hd);
    llHdMonitored = (LinearLayout) findViewById(R.id.ll_hd_monitored);
    llHdmEnterprise = (LinearLayout) findViewById(R.id.ll_hdm_enterprise);
    flLogo = (RotatableFrameLayout) findViewById(R.id.fl_logo);
    findViewById(R.id.ll_below_chart).setOnClickListener(dismissClick);
    ivHD.setBackgroundDrawable(vPieChart.getSymbolForIndex(0));
    ivHdMonitored.setBackgroundDrawable(vPieChart.getSymbolForIndex(1));
    ivHDM.setBackgroundDrawable(vPieChart.getSymbolForIndex(2));
    ivPrivate.setBackgroundDrawable(vPieChart.getSymbolForIndex(3));
    ivWatchOnly.setBackgroundDrawable(vPieChart.getSymbolForIndex(4));
    ivHdmEnterprise.setBackgroundDrawable(vPieChart.getSymbolForIndex(5));
    vPieChart.setRotateListener(this);
}
 
Example 15
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 16
public EditTextEmoji(Context context, SizeNotifierFrameLayout parent, BaseFragment fragment, int style) {
    super(context);
    currentStyle = style;

    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
    parentFragment = fragment;
    sizeNotifierLayout = parent;
    sizeNotifierLayout.setDelegate(this);

    editText = new EditTextBoldCursor(context) {
        @Override
        public boolean onTouchEvent(MotionEvent event) {
            if (isPopupShowing() && event.getAction() == MotionEvent.ACTION_DOWN) {
                showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2);
                openKeyboardInternal();
            }
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                if (!AndroidUtilities.showKeyboard(this)) {
                    clearFocus();
                    requestFocus();
                }
            }
            try {
                return super.onTouchEvent(event);
            } catch (Exception e) {
                FileLog.e(e);
            }
            return false;
        }

        @Override
        public boolean requestRectangleOnScreen(Rect rectangle) {
            if (smoothKeyboard) {
                rectangle.bottom += AndroidUtilities.dp(1000);
            }
            return super.requestRectangleOnScreen(rectangle);
        }
    };
    editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    editText.setFocusable(editText.isEnabled());
    editText.setCursorSize(AndroidUtilities.dp(20));
    editText.setCursorWidth(1.5f);
    editText.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    if (style == STYLE_FRAGMENT) {
        editText.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
        editText.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
        editText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
        editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        editText.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(40) : 0, 0, LocaleController.isRTL ? 0 : AndroidUtilities.dp(40), AndroidUtilities.dp(8));
        addView(editText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 11 : 0, 1, LocaleController.isRTL ? 0 : 11, 0));
    } else {
        editText.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
        editText.setHintTextColor(Theme.getColor(Theme.key_dialogTextHint));
        editText.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
        editText.setBackgroundDrawable(null);
        editText.setPadding(0, 0, 0, 0);
        addView(editText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 48, 0, 0, 0));
    }

    emojiButton = new ImageView(context);
    emojiButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
    emojiButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    if (style == STYLE_FRAGMENT) {
        emojiButton.setImageResource(R.drawable.smiles_tab_smiles);
        addView(emojiButton, LayoutHelper.createFrame(48, 48, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT), 0, 0, 0, 7));
    } else {
        emojiButton.setImageResource(R.drawable.input_smile);
        addView(emojiButton, LayoutHelper.createFrame(48, 48, Gravity.CENTER_VERTICAL | Gravity.LEFT, 0, 0, 0, 0));
    }
    if (Build.VERSION.SDK_INT >= 21) {
        emojiButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
    }
    emojiButton.setOnClickListener(view -> {
        if (!emojiButton.isEnabled()) {
            return;
        }
        if (!isPopupShowing()) {
            showPopup(1);
            emojiView.onOpen(editText.length() > 0);
            editText.requestFocus();
        } else {
            openKeyboardInternal();
        }
    });
    emojiButton.setContentDescription(LocaleController.getString("Emoji", R.string.Emoji));
}
 
Example 17
Source Project: Telegram   File: ThemeCell.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ThemeCell(Context context, boolean nightTheme) {
    super(context);

    setWillNotDraw(false);

    isNightTheme = nightTheme;

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
    paintStroke.setStyle(Paint.Style.STROKE);
    paintStroke.setStrokeWidth(AndroidUtilities.dp(2));

    textView = new TextView(context);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setPadding(0, 0, 0, AndroidUtilities.dp(1));
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 53 + 48 + 4 : 60, 0, LocaleController.isRTL ? 60 : 53 + 48 + 4, 0));

    checkImage = new ImageView(context);
    checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY));
    checkImage.setImageResource(R.drawable.sticker_added);

    if (!isNightTheme) {
        addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 21 + 38, 0, 21 + 38, 0));

        optionsButton = new ImageView(context);
        optionsButton.setFocusable(false);
        optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
        optionsButton.setImageResource(R.drawable.ic_ab_other);
        optionsButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
        optionsButton.setScaleType(ImageView.ScaleType.CENTER);
        optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
        addView(optionsButton, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP));
    } else {
        addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 21, 0, 21, 0));
    }
}
 
Example 18
public FilterCell(Context context) {
    super(context);
    setWillNotDraw(false);

    moveImageView = new ImageView(context);
    moveImageView.setFocusable(false);
    moveImageView.setScaleType(ImageView.ScaleType.CENTER);
    moveImageView.setImageResource(R.drawable.list_reorder);
    moveImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
    moveImageView.setClickable(true);
    addView(moveImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : 64, 14, LocaleController.isRTL ? 64 : 80, 0));

    valueTextView = new TextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
    valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    valueTextView.setLines(1);
    valueTextView.setMaxLines(1);
    valueTextView.setSingleLine(true);
    valueTextView.setPadding(0, 0, 0, 0);
    valueTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 80 : 64, 35, LocaleController.isRTL ? 64 : 80, 0));
    valueTextView.setVisibility(GONE);

    optionsImageView = new ImageView(context);
    optionsImageView.setFocusable(false);
    optionsImageView.setScaleType(ImageView.ScaleType.CENTER);
    optionsImageView.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
    optionsImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
    optionsImageView.setImageResource(R.drawable.msg_actions);
    addView(optionsImageView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 6, 0, 6, 0));
}
 
Example 19
Source Project: YiBo   File: ImageViewer4GifActivity.java    License: Apache License 2.0 4 votes vote down vote up
private void initComponent() {
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
	LinearLayout llToolbar = (LinearLayout)findViewById(R.id.llToolbar);
	ivRotateLeft = (ImageView) findViewById(R.id.ivRotateLeft);
	ivRotateRight = (ImageView) findViewById(R.id.ivRotateRight);
	ivZoomIn = (ImageView) findViewById(R.id.ivZoomIn);
	ivZoomOut = (ImageView) findViewById(R.id.ivZoomOut);
	
	ThemeUtil.setSecondaryImageHeader(llHeaderBase);
	llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar"));
	int padding8 = theme.dip2px(8);
	llToolbar.setPadding(padding8, padding8, padding8, padding8);
	ivRotateLeft.setBackgroundDrawable(theme.getDrawable("selector_btn_image_rotate_left"));
	ivRotateRight.setBackgroundDrawable(theme.getDrawable("selector_btn_image_rotate_right"));
	ivZoomIn.setBackgroundDrawable(theme.getDrawable("selector_btn_image_zoom_in"));
	ivZoomOut.setBackgroundDrawable(theme.getDrawable("selector_btn_image_zoom_out"));
	
	TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle);
	tvTitle.setText(R.string.title_image_viewer);

	btnOperate = (Button) findViewById(R.id.btnOperate);

	ivImageViewer = (ImageViewTouchBase) findViewById(R.id.ivImageViewer);
	ivImageViewer.setRecycler(new ImageViewTouchBase.Recycler() {
		@Override
		public void recycle(Bitmap b) {
			if (!(b == null || b.isRecycled())) {
				if (Logger.isDebug()) {
					Log.d(TAG, "Recycle Bitmap : " + b);
				}
				b.recycle();
			}
		}
	});

	ivImageViewer.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			if (mode == Mode.View) {
				updateView();
			}
		}
	});
}
 
Example 20
Source Project: WeekCalendar   File: WeekCalendar.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public View getItemView(final int position, View convertView, final ViewHolder viewHolder) {
    final CalendarData calendar = (CalendarData) getItem(position);
    final TextView dayView = (TextView) viewHolder.getView(R.id.tv_calendar_day);
    final TextView weekView = (TextView) viewHolder.getView(R.id.tv_calendar_week);
    ImageView corner_mark_iv = (ImageView) viewHolder.getView(R.id.corner_mark_iv);
    weekView.setText(WeekCalendarUtil.getWeekString(mContext).get(position));
    dayView.setTextSize(daysTextSize);
    weekView.setTextSize(weekTextSize);
    weekView.setBackgroundColor(weekBackgroundColor);
    if (isCornerMark) {
        corner_mark_iv.setBackgroundDrawable(cornerMarkBg);
    } else {
        corner_mark_iv.setVisibility(View.GONE);
    }
    if (!hideTodayName) {
        if (!calendar.isSameDay(today)) {
            dayView.setText(String.valueOf(calendar.day));
        } else {
            dayView.setText(String.valueOf("今"));
        }
    } else {
        dayView.setText(String.valueOf(calendar.day));
    }
    if (calendar.isSameDay(theDayOfSelected)) {//被选中的日期是白的
        dayView.setTextColor(daysSelectedTextColor);
        dayView.setBackgroundDrawable(daysSelectedBackground);
    } else if (calendar.isLastMonthDay || calendar.isNextMonthDay) {//上一个月、下一个月的日期是灰色的
        dayView.setTextColor(Color.LTGRAY);
        dayView.setBackgroundDrawable(null);
    } else if (calendar.isSameDay(today)) {//当天的日期是橘黄色的
        dayView.setTextColor(todayTextColor);
        dayView.setText("今");
        dayView.setBackgroundDrawable(null);
    } else {
        dayView.setBackgroundDrawable(null);
        dayView.setTextColor(weekTextColor);
    }

    if (selectDateList != null) {
        for (int i = 0; i < selectDateList.size(); i++) {
            String dateStr = selectDateList.get(i);
            String[] dates = dateStr.split("-");
            CalendarData cd = new CalendarData();
            cd.year = Integer.parseInt(dates[0]);
            cd.month = Integer.parseInt(dates[1]);
            cd.day = Integer.parseInt(dates[2]);
            if (calendar.isSameDay(cd)) {
                corner_mark_iv.setVisibility(View.VISIBLE);
                break;
            } else {
                corner_mark_iv.setVisibility(View.GONE);
            }
        }
    }

    //如果设置了回调,则设置点击事件
    dayView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            theDayOfSelected = datas.get(position);
            theDayForShow = datas.get(position);
            notifyDataSetChanged();
            if (listener != null) {
                listener.onDateClick(getTheDayOfSelected());
            }
        }
    });
    return convertView;
}