List of usage examples for android.graphics.drawable GradientDrawable setColor
public void setColor(@Nullable ColorStateList colorStateList)
From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java
void checkSelectedDays(View rootView, boolean[] days) { Log.d(TAG, "Checking selected days: " + Arrays.toString(days)); schedule.setDays(days);// www . j a va 2 s .c om TextView mo = ((TextView) rootView.findViewById(R.id.day_mo)); TextView tu = ((TextView) rootView.findViewById(R.id.day_tu)); TextView we = ((TextView) rootView.findViewById(R.id.day_we)); TextView th = ((TextView) rootView.findViewById(R.id.day_th)); TextView fr = ((TextView) rootView.findViewById(R.id.day_fr)); TextView sa = ((TextView) rootView.findViewById(R.id.day_sa)); TextView su = ((TextView) rootView.findViewById(R.id.day_su)); TextView[] daysTvs = new TextView[] { mo, tu, we, th, fr, sa, su }; for (int i = 0; i < daysTvs.length; i++) { boolean isSelected = days[i]; StateListDrawable sld = (StateListDrawable) daysTvs[i].getBackground(); GradientDrawable shape = (GradientDrawable) sld.getCurrent(); shape.setColor(isSelected ? color : Color.WHITE); daysTvs[i].setTypeface(null, isSelected ? Typeface.BOLD : Typeface.NORMAL); daysTvs[i].setTextColor(isSelected ? Color.WHITE : Color.BLACK); } }
From source file:com.htc.dotdesign.ToolBoxService.java
private void initBrushColor() { Resources res = getResources(); final int size = 4 * 3; int[] btn_id = new int[size]; btn_id[0] = R.id.btn_color_11;/*from w w w . j a v a2 s . c o m*/ btn_id[1] = R.id.btn_color_12; btn_id[2] = R.id.btn_color_13; btn_id[3] = R.id.btn_color_14; btn_id[4] = R.id.btn_color_21; btn_id[5] = R.id.btn_color_22; btn_id[6] = R.id.btn_color_23; btn_id[7] = R.id.btn_color_24; btn_id[8] = R.id.btn_color_31; btn_id[9] = R.id.btn_color_32; btn_id[10] = R.id.btn_color_33; btn_id[11] = R.id.btn_color_34; int[] color_id = new int[size]; color_id[0] = R.color.palette_color_11; color_id[1] = R.color.palette_color_12; color_id[2] = R.color.palette_color_13; color_id[3] = R.color.palette_color_14; color_id[4] = R.color.palette_color_21; color_id[5] = R.color.palette_color_22; color_id[6] = R.color.palette_color_23; color_id[7] = R.color.palette_color_24; color_id[8] = R.color.palette_color_31; color_id[9] = R.color.palette_color_32; color_id[10] = R.color.palette_color_33; color_id[11] = R.color.palette_color_34; if (res != null) { ImageView button = null; GradientDrawable drawable = null; for (int i = 0; i < size; i++) { button = (ImageView) mPalette.findViewById(btn_id[i]); if (button != null) { drawable = (GradientDrawable) button.getDrawable(); drawable.setColor(res.getColor(color_id[i])); mBtnColor.put(btn_id[i], res.getColor(color_id[i])); button.setOnClickListener(mButtonListener); if (i == 0) { mCurrBrushColorView = button; mCurrBrushColor = res.getColor(color_id[i]); setSelectedColor(mCurrBrushColorView); } } } } }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java
void setupDaySelectionListeners(final View rootView) { View.OnClickListener listener = new View.OnClickListener() { @Override//from w w w.ja v a 2 s. c om public void onClick(View view) { TextView text = ((TextView) view); int index; switch (text.getId()) { case R.id.day_mo: schedule.toggleSelectedDay(0); index = 0; break; case R.id.day_tu: schedule.toggleSelectedDay(1); index = 1; break; case R.id.day_we: schedule.toggleSelectedDay(2); index = 2; break; case R.id.day_th: index = 3; schedule.toggleSelectedDay(3); break; case R.id.day_fr: schedule.toggleSelectedDay(4); index = 4; break; case R.id.day_sa: schedule.toggleSelectedDay(5); index = 5; break; case R.id.day_su: schedule.toggleSelectedDay(6); index = 6; break; default: return; } boolean daySelected = schedule.days()[index]; StateListDrawable sld = (StateListDrawable) text.getBackground(); GradientDrawable shape = (GradientDrawable) sld.getCurrent(); shape.setColor(daySelected ? color : Color.WHITE); text.setTypeface(null, daySelected ? Typeface.BOLD : Typeface.NORMAL); text.setTextColor(daySelected ? Color.WHITE : Color.BLACK); boolean allDaysSelected = schedule.allDaysSelected(); if (schedule.type() == Schedule.SCHEDULE_TYPE_EVERYDAY && !allDaysSelected) { setRepeatType(Schedule.SCHEDULE_TYPE_SOMEDAYS, rootView, false); ignoreNextEvent = true; repeatTypeSpinner.setSelection(1); } else if (schedule.type() == Schedule.SCHEDULE_TYPE_SOMEDAYS && allDaysSelected) { repeatTypeSpinner.setSelection(0); schedule.setType(Schedule.SCHEDULE_TYPE_EVERYDAY); } Log.d(TAG, "All days selected: " + allDaysSelected + ", repeatType: " + schedule.type()); } }; rootView.findViewById(R.id.day_mo).setOnClickListener(listener); rootView.findViewById(R.id.day_tu).setOnClickListener(listener); rootView.findViewById(R.id.day_we).setOnClickListener(listener); rootView.findViewById(R.id.day_th).setOnClickListener(listener); rootView.findViewById(R.id.day_fr).setOnClickListener(listener); rootView.findViewById(R.id.day_sa).setOnClickListener(listener); rootView.findViewById(R.id.day_su).setOnClickListener(listener); }
From source file:com.odoo.addons.calendar.CalendarDashboard.java
@Override public void onViewBind(View view, Cursor cursor, ODataRow row) { String type = row.getString("data_type"); Log.v("ASD", "data_type----->" + type); GradientDrawable shape = (GradientDrawable) getActivity().getResources() .getDrawable(R.drawable.circle_mask_secondary); int icon = -1; ImageView iconView = (ImageView) view.findViewById(R.id.event_icon); if (type.equals("separator")) { OControls.setText(view, R.id.list_separator, row.getString("name")); } else {/*from w w w . ja va2s.c om*/ String colorCode = CalendarUtils.getColorData(row.getInt("color_index")).getString("code"); shape.setColor(Color.parseColor(colorCode)); String date = "false"; String desc = null; if (row.getString("description").equals("false")) { row.put("description", ""); } if (type.equals("event")) { desc = row.getString("description"); icon = R.drawable.ic_action_event; if (row.getString("allday").equals("false")) { date = row.getString("date_start"); view.findViewById(R.id.allDay).setVisibility(View.GONE); } else { TextView allDayTag = (TextView) view.findViewById(R.id.allDay); allDayTag.setTextColor(Color.parseColor(colorCode)); allDayTag.setVisibility(View.VISIBLE); } } if (type.equals("phone_call")) { icon = R.drawable.ic_action_phone; date = row.getString("date"); desc = row.getString("description"); } if (type.equals("opportunity")) { icon = R.drawable.ic_action_opportunities; ODataRow stage_id = row.getM2ORecord("stage_id").browse(); float probability = -1; if (stage_id != null && !stage_id.getString("probability").equals("false") && (stage_id.getString("type").equals("opportunity") || stage_id.getString("type").equals("both"))) { if (!stage_id.getString("name").equals("New")) probability = stage_id.getFloat("probability"); } if (probability == 0) { // Lost icon = R.drawable.ic_action_mark_lost; } else if (probability >= 100) { // Won icon = R.drawable.ic_action_mark_won; } desc = row.getString("planned_revenue") + " " + ResCurrency.getSymbol(getActivity(), row.getInt("company_currency")) + " at " + row.getString("probability") + " %"; if (!row.getString("title_action").equals("false")) { desc += "\n" + row.getString("title_action"); } OControls.setText(view, R.id.event_description, desc); } if (!date.equals("false")) { Date dateNow = new Date(); Date eventDate = ODateUtils.createDateObject(date, ODateUtils.DEFAULT_FORMAT, false); date = ODateUtils.convertToDefault(date, ODateUtils.DEFAULT_FORMAT, "hh:mm a"); OControls.setText(view, R.id.event_time, date); if (dateNow.after(eventDate) && !row.getBoolean("is_done")) { colorCode = "#cc0000"; } } OControls.setText(view, R.id.event_description, desc); Boolean is_done = row.getString("is_done").equals("1"); OControls.setImage(view, R.id.event_icon, icon); iconView.setBackgroundDrawable(shape); int title_color = (is_done) ? Color.LTGRAY : Color.parseColor("#414141"); int time_color = (is_done) ? Color.LTGRAY : Color.parseColor(colorCode); int desc_color = (is_done) ? Color.LTGRAY : _c(R.color.body_text_2); int allDay_color = (is_done) ? Color.LTGRAY : Color.parseColor(colorCode); OControls.setTextColor(view, R.id.event_name, title_color); OControls.setTextColor(view, R.id.event_time, time_color); OControls.setTextColor(view, R.id.event_description, desc_color); OControls.setTextColor(view, R.id.allDay, allDay_color); if (is_done) { view.findViewById(R.id.event_icon).setBackgroundResource(R.drawable.circle_mask_gray); OControls.setTextViewStrikeThrough(view, R.id.event_name); OControls.setTextViewStrikeThrough(view, R.id.event_time); OControls.setTextViewStrikeThrough(view, R.id.event_description); OControls.setTextViewStrikeThrough(view, R.id.allDay); } OControls.setText(view, R.id.event_name, row.getString("name")); Log.v("ASD", " row.getString(\"name\")----->" + row.getString("name")); } }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
void checkSelectedDays(View rootView, boolean[] days) { Log.d(TAG, "Checking selected days: " + Arrays.toString(days)); schedule.setDays(days);//from w w w . j a va 2 s. c o m TextView mo = ((TextView) rootView.findViewById(R.id.day_mo)); TextView tu = ((TextView) rootView.findViewById(R.id.day_tu)); TextView we = ((TextView) rootView.findViewById(R.id.day_we)); TextView th = ((TextView) rootView.findViewById(R.id.day_th)); TextView fr = ((TextView) rootView.findViewById(R.id.day_fr)); TextView sa = ((TextView) rootView.findViewById(R.id.day_sa)); TextView su = ((TextView) rootView.findViewById(R.id.day_su)); TextView[] daysTvs = new TextView[] { mo, tu, we, th, fr, sa, su }; for (int i = 0; i < daysTvs.length; i++) { boolean isSelected = days[i]; StateListDrawable sld = (StateListDrawable) daysTvs[i].getBackground(); GradientDrawable shape = (GradientDrawable) sld.getCurrent(); shape.setColor(isSelected ? color : Color.WHITE); daysTvs[i].setTextColor(isSelected ? Color.WHITE : color); daysTvs[i].setTypeface(null, isSelected ? Typeface.BOLD : Typeface.NORMAL); } }
From source file:com.android.incallui.CallCardFragment.java
/** * Get the overall InCallUI background colors and apply to call card. *///from w ww.j a va 2 s .c o m public void updateColors() { MaterialPalette themeColors = InCallPresenter.getInstance().getThemeColors(); if (mCurrentThemeColors != null && mCurrentThemeColors.equals(themeColors)) { return; } if (getResources().getBoolean(R.bool.is_layout_landscape)) { final GradientDrawable drawable = (GradientDrawable) mPrimaryCallCardContainer.getBackground(); drawable.setColor(themeColors.mPrimaryColor); } else { mPrimaryCallCardContainer.setBackgroundColor(themeColors.mPrimaryColor); } mCallButtonsContainer.setBackgroundColor(themeColors.mPrimaryColor); mCallSubject.setTextColor(themeColors.mPrimaryColor); mContactContext.setBackgroundColor(themeColors.mPrimaryColor); //TODO: set color of message text in call context "recent messages" to be the theme color. mCurrentThemeColors = themeColors; }
From source file:com.todoroo.astrid.activity.TaskEditFragment.java
private void setupWaitingOnMe() { if (!isNewTask) { WaitingOnMe wom = waitingOnMeDao.findByTask(model.getUuid()); if (wom != null) { final View waitingOnMe = getView().findViewById(R.id.waiting_on_me); waitingOnMe.setVisibility(View.VISIBLE); int themeColor = getResources().getColor(ThemeService.getTaskEditThemeColor()); TextView dismiss = (TextView) waitingOnMe.findViewById(R.id.wom_dismiss); dismiss.setOnClickListener(new OnClickListener() { @Override/*from w w w.ja va 2 s. c o m*/ public void onClick(View v) { WaitingOnMe template = new WaitingOnMe(); template.setValue(WaitingOnMe.DELETED_AT, DateUtilities.now()); waitingOnMeDao.update(WaitingOnMe.TASK_UUID.eq(model.getUuid()), template); waitingOnMe.setVisibility(View.GONE); } }); dismiss.setTextColor(getResources().getColor(R.color.task_edit_deadline_gray)); GradientDrawable gd = new GradientDrawable(); gd.setColor(ThemeService.getDarkVsLight(Color.rgb(0xee, 0xee, 0xee), Color.rgb(0x22, 0x22, 0x22), false)); gd.setCornerRadius(4.0f); dismiss.setBackgroundDrawable(gd); TextView ack = (TextView) waitingOnMe.findViewById(R.id.wom_acknowledge); ack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { WaitingOnMe template = new WaitingOnMe(); template.setValue(WaitingOnMe.ACKNOWLEDGED, 1); waitingOnMeDao.update(WaitingOnMe.TASK_UUID.eq(model.getUuid()), template); waitingOnMe.setVisibility(View.GONE); } }); ack.setTextColor(themeColor); gd = new GradientDrawable(); gd.setColor(ThemeService.getDarkVsLight(Color.WHITE, Color.rgb(0x22, 0x22, 0x22), false)); gd.setCornerRadius(4.0f); ack.setBackgroundDrawable(gd); TextView womText = (TextView) waitingOnMe.findViewById(R.id.wom_message); womText.setText(getWomText(wom)); womText.setTextColor(themeColor); ImageView womIcon = (ImageView) waitingOnMe.findViewById(R.id.wom_icon); womIcon.setImageResource(ThemeService.getTaskEditDrawable(R.drawable.tea_icn_waiting, R.drawable.tea_icn_waiting_lightblue)); } } }
From source file:org.onebusaway.android.ui.ArrivalsListHeader.java
/** * Refreshes the arrival info data to be displayed in the header based on the most recent * arrival info, and sets the number of arrival rows that should be displayed in the header *//*from w ww . j ava 2 s. co m*/ private void refreshArrivalInfoData() { mArrivalInfo = mController.getArrivalInfo(); mHeaderArrivalInfo.clear(); if (mArrivalInfo != null && !mInNameEdit) { // Get the indexes for arrival times that should be featured in the header ArrayList<Integer> etaIndexes = ArrivalInfo.findPreferredArrivalIndexes(mArrivalInfo); if (etaIndexes != null) { // We have a non-negative ETA for at least one bus - fill the first arrival row final int i1 = etaIndexes.get(0); ObaArrivalInfo info1 = mArrivalInfo.get(i1).getInfo(); boolean isFavorite = ObaContract.RouteHeadsignFavorites.isFavorite(mContext, info1.getRouteId(), info1.getHeadsign(), info1.getStopId()); mEtaRouteFavorite1 .setImageResource(isFavorite ? R.drawable.focus_star_on : R.drawable.focus_star_off); mEtaRouteName1.setText(info1.getShortName()); mEtaRouteDirection1.setText(info1.getHeadsign()); long eta = mArrivalInfo.get(i1).getEta(); if (eta == 0) { mEtaArrivalInfo1.setText(mContext.getString(R.string.stop_info_eta_now)); mEtaArrivalInfo1.setTextSize(ETA_TEXT_NOW_SIZE_SP); UIUtils.hideViewWithAnimation(mEtaMin1, mShortAnimationDuration); } else if (eta > 0) { mEtaArrivalInfo1.setText(Long.toString(eta)); mEtaArrivalInfo1.setTextSize(ETA_TEXT_SIZE_SP); UIUtils.showViewWithAnimation(mEtaMin1, mShortAnimationDuration); } mEtaAndMin1.setBackgroundResource(R.drawable.round_corners_style_b_header_status); GradientDrawable d1 = (GradientDrawable) mEtaAndMin1.getBackground(); final int c1 = mArrivalInfo.get(i1).getColor(); if (c1 != R.color.stop_info_ontime) { // Show early/late/scheduled color d1.setColor(mResources.getColor(c1)); } else { // For on-time, use header default color d1.setColor(mResources.getColor(R.color.theme_primary)); } mEtaAndMin1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mPopup1 != null && mPopup1.isShowing()) { mPopup1.dismiss(); return; } mPopup1 = setupPopup(0, c1, mArrivalInfo.get(i1).getStatusText()); mPopup1.showAsDropDown(mEtaAndMin1); } }); if (mArrivalInfo.get(i1).getPredicted()) { // We have real-time data - show the indicator UIUtils.showViewWithAnimation(mEtaRealtime1, mShortAnimationDuration); } else { // We only have schedule data - hide the indicator mEtaRealtime1.setVisibility(View.INVISIBLE); // If this is frequency-based data, indicate that arrival is approximate if (mArrivalInfo.get(i1).getInfo().getFrequency() != null) { mEtaArrivalInfo1.setText(mResources.getString(R.string.stop_info_frequency_approximate) + mEtaArrivalInfo1.getText()); } } // Save the arrival info for the options menu later mHeaderArrivalInfo.add(mArrivalInfo.get(i1)); // If there is another arrival, fill the second row with it if (etaIndexes.size() >= 2) { final int i2 = etaIndexes.get(1); ObaArrivalInfo info2 = mArrivalInfo.get(i2).getInfo(); boolean isFavorite2 = ObaContract.RouteHeadsignFavorites.isFavorite(mContext, info2.getRouteId(), info2.getHeadsign(), info2.getStopId()); mEtaRouteFavorite2 .setImageResource(isFavorite2 ? R.drawable.focus_star_on : R.drawable.focus_star_off); mEtaRouteName2.setText(info2.getShortName()); mEtaRouteDirection2.setText(info2.getHeadsign()); eta = mArrivalInfo.get(i2).getEta(); if (eta == 0) { mEtaArrivalInfo2.setText(mContext.getString(R.string.stop_info_eta_now)); mEtaArrivalInfo2.setTextSize(ETA_TEXT_NOW_SIZE_SP); UIUtils.hideViewWithAnimation(mEtaMin2, mShortAnimationDuration); } else if (eta > 0) { mEtaArrivalInfo2.setText(Long.toString(eta)); mEtaArrivalInfo2.setTextSize(ETA_TEXT_SIZE_SP); UIUtils.showViewWithAnimation(mEtaMin2, mShortAnimationDuration); } mEtaAndMin2.setBackgroundResource(R.drawable.round_corners_style_b_header_status); GradientDrawable d2 = (GradientDrawable) mEtaAndMin2.getBackground(); final int c2 = mArrivalInfo.get(i2).getColor(); if (c2 != R.color.stop_info_ontime) { // Show early/late/scheduled color d2.setColor(mResources.getColor(c2)); } else { // For on-time, use header default color d2.setColor(mResources.getColor(R.color.theme_primary)); } mEtaAndMin2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mPopup2 != null && mPopup2.isShowing()) { mPopup2.dismiss(); return; } mPopup2 = setupPopup(1, c2, mArrivalInfo.get(i2).getStatusText()); mPopup2.showAsDropDown(mEtaAndMin2); } }); if (mArrivalInfo.get(i2).getPredicted()) { // We have real-time data - show the indicator UIUtils.showViewWithAnimation(mEtaRealtime2, mShortAnimationDuration); } else { // We only have schedule data - hide the indicator mEtaRealtime2.setVisibility(View.INVISIBLE); // If this is frequency-based data, indicate that arrival is approximate if (mArrivalInfo.get(i2).getInfo().getFrequency() != null) { mEtaArrivalInfo2.setText(mResources.getString(R.string.stop_info_frequency_approximate) + mEtaArrivalInfo2.getText()); } } mNumHeaderArrivals = 2; // Save the arrival info for the options menu later mHeaderArrivalInfo.add(mArrivalInfo.get(i2)); } else { mNumHeaderArrivals = 1; } } else { // Show abbreviated "no upcoming arrivals" message (e.g., "35+ min") int minAfter = mController.getMinutesAfter(); if (minAfter != -1) { mNoArrivals.setText(UIUtils.getNoArrivalsMessage(mContext, minAfter, false, false)); } else { minAfter = 35; // Assume 35 minutes, because that's the API default mNoArrivals.setText(UIUtils.getNoArrivalsMessage(mContext, minAfter, false, false)); } mNumHeaderArrivals = 0; } } }
From source file:org.zywx.wbpalmstar.plugin.chatkeyboard.ACEChatKeyboardView.java
private void initKeyboardParams(JSONObject json) { try {//w w w . java 2 s . co m // mRecordTipsLayout init DisplayMetrics dm = getResources().getDisplayMetrics(); mRecordTipsLayout.getLayoutParams().height = dm.heightPixels / 2; // EmojiconsXmlPath mEmojiconsXmlPath = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_EMOJICONS); initEmojicons(); mEmojiconsPager.setAdapter(new EmotjiconsPagerAdapter()); // mSharesXmlPath mSharesXmlPath = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SHARES); initShares(); mSharesPager.setAdapter(new SharesPagerAdapter()); // placeHold @see placeholder if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_PLACEHOLD)) { String placeholder = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_PLACEHOLD); mEditText.setHint(placeholder); } // placeholder if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_PLACEHOLDER)) { String placeholder = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_PLACEHOLDER); mEditText.setHint(placeholder); } // touchDownImg if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_TOUCHDOWNIMG)) { String touchDownImg = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_TOUCHDOWNIMG); touchDownImg = touchDownImg.substring(BUtility.F_Widget_RES_SCHEMA.length()); touchDownImg = BUtility.F_Widget_RES_path + touchDownImg; Bitmap mTouchDownImgBitmap = mUexBaseObj.getBitmap(touchDownImg); if (mTouchDownImgBitmap != null) { mTouchDownImg = new BitmapDrawable(getResources(), mTouchDownImgBitmap); } } if (mTouchDownImg != null) { mRecordTipsImage.setImageDrawable(mTouchDownImg); } else { mTouchDownImgDefaule = getResources().getDrawable(CRes.plugin_chatkeyboard_voice_recording); if (mTouchDownImgDefaule != null) { mRecordTipsImage.setImageDrawable(mTouchDownImgDefaule); } } // dragOutsideImg if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_DRAGOUTSIDEIMG)) { String dragOutsideImg = json .getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_DRAGOUTSIDEIMG); dragOutsideImg = dragOutsideImg.substring(BUtility.F_Widget_RES_SCHEMA.length()); dragOutsideImg = BUtility.F_Widget_RES_path + dragOutsideImg; Bitmap mDragOutsideImgBitmap = mUexBaseObj.getBitmap(dragOutsideImg); if (mDragOutsideImgBitmap != null) { mDragOutsideImg = new BitmapDrawable(getResources(), mDragOutsideImgBitmap); } } if (mDragOutsideImg == null) { mDragOutsideImgDefaule = getResources().getDrawable(CRes.plugin_chatkeyboard_voice_cancle); } // textColor EditText if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_INPUTTEXTCOLOR)) { String textColor = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_INPUTTEXTCOLOR); mEditText.setTextColor(BUtility.parseColor(textColor)); } // textColor mRecordTimes if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_TEXTCOLOR)) { String textColor = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_TEXTCOLOR); mRecordTimes.setTextColor(BUtility.parseColor(textColor)); } // textSize mRecordTimes if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_TEXTSIZE)) { String textSize = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_TEXTSIZE); try { mRecordTimes.setTextSize(Float.parseFloat(textSize)); } catch (Exception e) { e.printStackTrace(); } } // sendBtnText if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_TEXT)) { String sendBtnText = json.getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_TEXT); mBtnSend.setText(sendBtnText); } // sendBtnTextSize if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_TEXTSIZE)) { String sendBtnTextSize = json .getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_TEXTSIZE); try { mBtnSend.setTextSize(Float.parseFloat(sendBtnTextSize)); } catch (Exception e) { e.printStackTrace(); } } // sendBtnTextColor if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_TEXTCOLOR)) { String sendBtnTextColor = json .getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_TEXTCOLOR); mBtnSend.setTextColor(BUtility.parseColor(sendBtnTextColor)); } // sendBtn Color Set try { // Selector need StateListDrawable StateListDrawable myGrad = (StateListDrawable) mBtnSend.getBackground(); // sendBtn Color Normal if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_BG_COLOR_UP)) { String sendBtnbgColorUp = json .getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_BG_COLOR_UP); GradientDrawable drawable = (GradientDrawable) myGrad.getCurrent(); drawable.setColor(BUtility.parseColor(sendBtnbgColorUp)); } // sendBtn Color Pressed if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_BG_COLOR_DOWN)) { String sendBtnbgColorDown = json .getString(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_SEND_BTN_BG_COLOR_DOWN); mBtnSend.setPressed(true); GradientDrawable drawable = (GradientDrawable) myGrad.getCurrent(); drawable.setColor(BUtility.parseColor(sendBtnbgColorDown)); mBtnSend.setPressed(false); } } catch (Exception e) { e.printStackTrace(); } // inputMode 0:Text 1:voice if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_INPUT_MODE)) { mInputMode = json.getInt(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_INPUT_MODE); } // keywords if (json.has(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_KEYWORDS)) { JSONArray keywordArray = json .getJSONArray(EChatKeyboardUtils.CHATKEYBOARD_PARAMS_JSON_KEY_KEYWORDS); for (int i = 0; i < keywordArray.length(); i++) { keywords.add(keywordArray.getString(i)); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.mixiaoxiao.support.widget.SmoothSwitch.java
private GradientDrawable makeTrackDrawable(int color, int thumbWidth, int thumbHeight, float radius, int padding) { GradientDrawable trackDrawable = new GradientDrawable(); if (padding > 0) { trackDrawable.setStroke(padding, Color.TRANSPARENT); }/*from w w w . j av a 2 s .c om*/ trackDrawable.setCornerRadius(radius); trackDrawable.setSize((int) (thumbWidth * Default.DEFAULT_MEASURE_FACTOR), thumbHeight); trackDrawable.setColor(getTrackColor(color)); return trackDrawable; }