下面列出了android.widget.LinearLayout#getLayoutParams ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void drawProgress(@NonNull LinearLayout layoutProgress,
@NonNull GradientDrawable progressDrawable,
float max,
float progress,
float totalWidth,
int radius,
int padding,
boolean isReverse) {
int newRadius = radius - (padding / 2);
progressDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius});
layoutProgress.setBackground(progressDrawable);
float ratio = max / progress;
int progressWidth = (int) ((totalWidth - (padding * 2)) / ratio);
ViewGroup.MarginLayoutParams progressParams = (ViewGroup.MarginLayoutParams) layoutProgress.getLayoutParams();
progressParams.width = progressWidth;
if (padding + (progressWidth / 2) < radius) {
int margin = Math.max(radius - padding, 0) - (progressWidth / 2);
progressParams.topMargin = margin;
progressParams.bottomMargin = margin;
} else {
progressParams.topMargin = 0;
progressParams.bottomMargin = 0;
}
layoutProgress.setLayoutParams(progressParams);
}
private void setupProgressReversing(@NonNull LinearLayout layoutProgress, boolean isReverse) {
RelativeLayout.LayoutParams progressParams = (RelativeLayout.LayoutParams) layoutProgress.getLayoutParams();
removeLayoutParamsRule(progressParams);
if (isReverse) {
progressParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
progressParams.addRule(RelativeLayout.ALIGN_PARENT_END);
}
} else {
progressParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
progressParams.addRule(RelativeLayout.ALIGN_PARENT_START);
}
}
layoutProgress.setLayoutParams(progressParams);
}
@SuppressWarnings("deprecation")
@Override
protected void drawProgress(LinearLayout layoutProgress, float max, float progress, float totalWidth,
int radius, int padding, int colorProgress, boolean isReverse) {
GradientDrawable backgroundDrawable = createGradientDrawable(colorProgress);
int newRadius = radius - (padding / 2);
if (isReverse && progress != max)
backgroundDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius});
else
backgroundDrawable.setCornerRadii(new float[]{0, 0, newRadius, newRadius, newRadius, newRadius, 0, 0});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
layoutProgress.setBackground(backgroundDrawable);
} else {
layoutProgress.setBackgroundDrawable(backgroundDrawable);
}
float ratio = max / progress;
int progressWidth = (int) ((totalWidth - ((padding * 2) + ivProgressIcon.getWidth())) / ratio);
ViewGroup.LayoutParams progressParams = layoutProgress.getLayoutParams();
progressParams.width = progressWidth;
layoutProgress.setLayoutParams(progressParams);
}
@Override
protected void drawProgress(LinearLayout layoutProgress, float max, float progress, float totalWidth,
int radius, int padding, int colorProgress, boolean isReverse) {
GradientDrawable backgroundDrawable = createGradientDrawable(colorProgress);
int newRadius = radius - (padding / 2);
backgroundDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
layoutProgress.setBackground(backgroundDrawable);
} else {
layoutProgress.setBackgroundDrawable(backgroundDrawable);
}
float ratio = max / progress;
int progressWidth = (int) ((totalWidth - (padding * 2)) / ratio);
ViewGroup.LayoutParams progressParams = layoutProgress.getLayoutParams();
progressParams.width = progressWidth;
layoutProgress.setLayoutParams(progressParams);
}
private void setupReverse(LinearLayout layoutProgress) {
RelativeLayout.LayoutParams progressParams = (RelativeLayout.LayoutParams) layoutProgress.getLayoutParams();
removeLayoutParamsRule(progressParams);
if (isReverse) {
progressParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
// For support with RTL on API 17 or more
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
progressParams.addRule(RelativeLayout.ALIGN_PARENT_END);
} else {
progressParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
// For support with RTL on API 17 or more
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
progressParams.addRule(RelativeLayout.ALIGN_PARENT_START);
}
layoutProgress.setLayoutParams(progressParams);
}
public Dock(Context context) {
onAppClickListener = new OnAppClickListener((Apps)context);
if (((Apps)context).options.getString(Keys.PASSWORD, "").length() > 0) {
onAppLongClickListener = new OnAppUnlockLongClickListener(context);
} else {
onAppLongClickListener = new OnAppLongClickListener((Apps)context);
}
contextRef = new SoftReference<Context>(context);
dockBar = (LinearLayout) ((Apps)context).findViewById(R.id.dock_bar);
defaultHeight = dockBar.getLayoutParams().height;
apps = new ArrayList<BaseData>();
buttons = new ArrayList<ImageView>();
buttons.add((ImageView)((Apps)context).findViewById(R.id.button1));
buttons.add((ImageView)((Apps)context).findViewById(R.id.button2));
buttons.add((ImageView)((Apps)context).findViewById(R.id.button3));
buttons.add((ImageView)((Apps)context).findViewById(R.id.button4));
buttons.add((ImageView)((Apps)context).findViewById(R.id.button5));
}
public void initMenu() {
menuLayout = (DrawerLayout) fa.findViewById(R.id.menu_layout);
menuElementsList = (ListView) fa.findViewById(R.id.menu_elements);
// ������Ӱ
menuLayout.setDrawerShadow(R.drawable.drawer_shadow,GravityCompat.START);
myApp = (MyApplication)fa.getApplication();
menuItemList = new ArrayList<MenuItemBean>();
menuItemList = MenuBaseUtils.arrayToList(fa);
slideMenuAdapter = new SlideMenuAdapter(menuItemList,menuLayout,fa);
menuElementsList.setAdapter(slideMenuAdapter);
menuElementsList.setOnItemClickListener(this);
setCurrentFragment(0);
//���ò�˵����
menuContentLayout = (LinearLayout)menuLayout.findViewById(R.id.menu_content_layout);
menuContentLayout.getLayoutParams().width = MenuBaseUtils.getScreenPixels(fa).getScreenWidth()*2/3;
exitLayout = (LinearLayout)menuLayout.findViewById(R.id.exit_layout);
exitLayout.setOnClickListener(this);
profileLayout = (LinearLayout)menuLayout.findViewById(R.id.profile_layout);
profileLayout.setOnClickListener(this);
}
/**
* 显示是否线性布局时的分组信息
*
* @param helper
* @param isShow 是否显示
* @param time 时间戳
* @describe
*/
private void showLineraLayoutGroup(boolean isShow, BaseViewHolder helper, long time) {
// 有分组的列,marginTop为8dp,否则,为0dp
LinearLayout ll = helper.getView(R.id.ll_note_list_linear);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ll.getLayoutParams();
if (isShow) {
helper.setVisible(R.id.tv_note_list_linear_month, true);
setLinearGroupStyle(helper, time);
params.setMargins(SizeUtils.dp2px(0), SizeUtils.dp2px(8), SizeUtils.dp2px(0), SizeUtils.dp2px(0));
ll.setLayoutParams(params);
} else {
helper.setVisible(R.id.tv_note_list_linear_month, false);
params.setMargins(SizeUtils.dp2px(0), SizeUtils.dp2px(0), SizeUtils.dp2px(0), SizeUtils.dp2px(0));
ll.setLayoutParams(params);
}
}
protected void adjustMarginAndPadding(){
FrameLayout contentLayout = (FrameLayout) findViewById(R.id.content_layout);
if(contentLayout != null){
if(Build.VERSION.SDK_INT >= 23) {
contentLayout.setPaddingRelative(0, contentLayout.getPaddingTop(), 0, Util.getNavigationBarHeight(this));
} else if(Build.VERSION.SDK_INT == 18){
contentLayout.setPaddingRelative(0, 0, 0, 0);
if(this instanceof SettingsActivity){
LinearLayout childView = (LinearLayout) contentLayout.getChildAt(0);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) childView.getLayoutParams();
params.topMargin = params.bottomMargin;
childView.setLayoutParams(params);
}
}
}
}
@Override
public void setInsets(Rect insets) {
LinearLayout layout = (LinearLayout)
findViewById(R.id.settings_container);
FrameLayout.LayoutParams lp =
(FrameLayout.LayoutParams) layout.getLayoutParams();
lp.bottomMargin = insets.bottom;
layout.setLayoutParams(lp);
}
@Override
protected void drawProgress(@NonNull LinearLayout layoutProgress,
@NonNull GradientDrawable progressDrawable,
float max,
float progress,
float totalWidth,
int radius,
int padding,
boolean isReverse) {
int newRadius = radius - (padding / 2);
progressDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius});
layoutProgress.setBackground(progressDrawable);
float ratio = max / progress;
int progressWidth = (int) ((totalWidth - (padding * 2)) / ratio);
ViewGroup.MarginLayoutParams progressParams = (ViewGroup.MarginLayoutParams) layoutProgress.getLayoutParams();
if (padding + (progressWidth / 2) < radius) {
int margin = Math.max(radius - padding, 0) - (progressWidth / 2);
progressParams.topMargin = margin;
progressParams.bottomMargin = margin;
} else {
progressParams.topMargin = 0;
progressParams.bottomMargin = 0;
}
progressParams.width = progressWidth;
layoutProgress.setLayoutParams(progressParams);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nim_easy_alert_dialog_with_listview);
LinearLayout root = (LinearLayout) findViewById(R.id.easy_alert_dialog_layout);
ViewGroup.LayoutParams params = root.getLayoutParams();
params.width = (int) ScreenUtil.getDialogWidth();
root.setLayoutParams(params);
addFootView(root);
titleView = findViewById(R.id.easy_dialog_title_view);
if (titleView != null) {
setTitleVisible(isTitleVisible);
}
titleTextView = (TextView) findViewById(R.id.easy_dialog_title_text_view);
if (titleTextView != null) {
setTitle(title);
}
titleBtn = (ImageButton) findViewById(R.id.easy_dialog_title_button);
if (titleBtn != null) {
setTitleBtnVisible(isTitleBtnVisible);
setTitleBtnListener(titleListener);
}
listView = (ListView) findViewById(R.id.easy_dialog_list_view);
if (itemSize > 0) {
updateListView();
}
}
@Override
protected void drawProgress(@NonNull LinearLayout layoutProgress,
@NonNull GradientDrawable progressDrawable,
float max,
float progress,
float totalWidth,
int radius,
int padding,
boolean isReverse) {
int newRadius = radius - (padding / 2);
if (isReverse && progress != max) {
progressDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius});
} else {
progressDrawable.setCornerRadii(new float[]{0, 0, newRadius, newRadius, newRadius, newRadius, 0, 0});
}
layoutProgress.setBackground(progressDrawable);
float ratio = max / progress;
int progressWidth = (int) ((totalWidth - ((padding * 2) + ivProgressIcon.getWidth())) / ratio);
ViewGroup.MarginLayoutParams progressParams = (ViewGroup.MarginLayoutParams) layoutProgress.getLayoutParams();
if (isReverse) {
if (padding + (progressWidth / 2) < radius) {
int margin = Math.max(radius - padding, 0) - (progressWidth / 2);
progressParams.topMargin = margin;
progressParams.bottomMargin = margin;
} else {
progressParams.topMargin = 0;
progressParams.bottomMargin = 0;
}
}
progressParams.width = progressWidth;
layoutProgress.setLayoutParams(progressParams);
}
@Override
protected void drawProgress(@NonNull LinearLayout layoutProgress,
@NonNull GradientDrawable progressDrawable,
float max,
float progress,
float totalWidth,
int radius,
int padding,
boolean isReverse) {
int newRadius = radius - (padding / 2);
progressDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius});
layoutProgress.setBackground(progressDrawable);
float ratio = max / progress;
int progressWidth = (int) ((totalWidth - (padding * 2)) / ratio);
ViewGroup.MarginLayoutParams progressParams = (ViewGroup.MarginLayoutParams) layoutProgress.getLayoutParams();
if (padding + (progressWidth / 2) < radius) {
int margin = Math.max(radius - padding, 0) - (progressWidth / 2);
progressParams.topMargin = margin;
progressParams.bottomMargin = margin;
} else {
progressParams.topMargin = 0;
progressParams.bottomMargin = 0;
}
progressParams.width = progressWidth;
layoutProgress.setLayoutParams(progressParams);
}
public void setActionBarProperties(final LinearLayout ll) {
final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ll.getLayoutParams();
lp.height = getActionBarHeight();
ll.setLayoutParams(lp);
}
private void initSearchView() {
mSearchAutoComplete = searchView.findViewById(R.id.search_src_text);
searchView.setQueryHint(getString(R.string.search_book_key));
//获取到TextView的控件
mSearchAutoComplete.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
mSearchAutoComplete.setPadding(15, 0, 0, 0);
searchView.onActionViewExpanded();
LinearLayout editFrame = searchView.findViewById(androidx.appcompat.R.id.search_edit_frame);
ImageView closeButton = searchView.findViewById(androidx.appcompat.R.id.search_close_btn);
ImageView goButton = searchView.findViewById(androidx.appcompat.R.id.search_go_btn);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) editFrame.getLayoutParams();
params.setMargins(20, 0, 10, 0);
editFrame.setLayoutParams(params);
closeButton.setScaleX(0.9f);
closeButton.setScaleY(0.9f);
closeButton.setPadding(0, 0, 0, 0);
goButton.setPadding(0, 0, 0, 0);
searchView.setSubmitButtonEnabled(true);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
if (TextUtils.isEmpty(query))
return false;
searchKey = query.trim();
if (!searchKey.toLowerCase().startsWith("set:")) {
toSearch();
searchView.clearFocus();
return false;
} else {
parseSecretCode(searchKey);
finish();
return false;
}
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText != null) {
List<BookInfoBean> beans = BookshelfHelp.searchBookInfo(newText);
searchBookshelfAdapter.setItems(beans);
if (beans.size() > 0) {
tvBookshelf.setVisibility(View.VISIBLE);
rvBookshelf.setVisibility(View.VISIBLE);
} else {
tvBookshelf.setVisibility(View.GONE);
rvBookshelf.setVisibility(View.GONE);
}
} else {
tvBookshelf.setVisibility(View.GONE);
rvBookshelf.setVisibility(View.GONE);
}
if (!newText.toLowerCase().startsWith("set")) {
mPresenter.querySearchHistory(newText);
} else {
showHideSetting();
}
return false;
}
});
searchView.setOnQueryTextFocusChangeListener((view, b) -> {
showHistory = b;
if (!b && searchView.getQuery().toString().trim().equals("")) {
finish();
}
if (showHistory) {
fabSearchStop.hide();
mPresenter.stopSearch();
}
openOrCloseHistory(showHistory);
});
}
private void initSecondaryTabs() {
this.mHeadTitleView = UIsUtils.inflate(getActivity(), R.layout.half_lunbo_title, null);
this.mTabTitleContainer = (LinearLayout) this.mHeadTitleView.findViewById(R.id.tabTitleContainer);
LayoutParams tabTitlParams = new LayoutParams(-1, -2);
tabTitlParams.height = UIsUtils.zoomWidth(40);
this.mTabTitleContainer.setLayoutParams(tabTitlParams);
String[] titles = getResources().getStringArray(R.array.channel_Titles);
int j = titles.length;
this.mTitleList = new ArrayList();
for (int i = 0; i < j; i++) {
RelativeLayout titleRelative = new RelativeLayout(getActivity());
LayoutParams params = new LayoutParams(-1, -2);
params.weight = 1.0f;
titleRelative.setLayoutParams(params);
TextView text = new TextView(getActivity());
text.setBackgroundColor(getActivity().getResources().getColor(2131492949));
text.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
text.setGravity(17);
text.setTextSize(1, 15.0f);
text.setText(titles[i]);
text.setTag(Integer.valueOf(i));
if (i == 1) {
this.mCurrentSelectTab = text;
text.setTextColor(getResources().getColor(2131493202));
} else {
text.setTextColor(getResources().getColor(2131493022));
}
text.setOnClickListener(this.mTabClickListener);
titleRelative.addView(text);
this.mTabTitleContainer.addView(titleRelative);
if (i < j - 1) {
View lineView = new View(getActivity());
lineView.setBackgroundColor(getResources().getColor(2131493321));
RelativeLayout.LayoutParams lineParams = new RelativeLayout.LayoutParams(-1, -1);
lineParams.width = 1;
lineParams.height = UIsUtils.zoomWidth(24);
lineView.setLayoutParams(lineParams);
this.mTabTitleContainer.addView(lineView);
}
this.mTitleList.add(titleRelative);
}
this.mSaveLinearLayout = (LinearLayout) this.mHeadTitleView.findViewById(R.id.saveRootLinear);
LinearLayout saveChildLayout = (LinearLayout) this.mHeadTitleView.findViewById(R.id.saveChildLinear);
LayoutParams saveLinearParams = (LayoutParams) saveChildLayout.getLayoutParams();
saveLinearParams.height = UIsUtils.zoomWidth(65);
saveChildLayout.setLayoutParams(saveLinearParams);
saveChildLayout.setPadding(UIsUtils.zoomWidth(15), 0, 0, 0);
this.mSaveLinearLayout.setOnClickListener(this.mAddToFavariteListener);
this.mListView.addHeaderView(this.mHeadTitleView);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
viewsReady();
setCardsBackground();
refreshLayoutStyle(refreshLayout);
refreshLayout.setOnRefreshListener(this::loadData);
PauseOnScrollListener pauseOnScrollListener = new PauseOnScrollListener(ImageLoader.getInstance(), true, true);
recyclerView.addOnScrollListener(pauseOnScrollListener);
adapter = new BrandAdapter();
recyclerView.setColumnWidth(App.get().dpToPx(144));
recyclerView.setAdapter(adapter);
try {
GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager();
recyclerView.addItemDecoration(new BrandFragment.SpacingItemDecoration(gridLayoutManager, App.px8));
} catch (Exception ex) {
ex.printStackTrace();
}
adapter.setItemClickListener(this);
SearchManager searchManager = (SearchManager) getMainActivity().getSystemService(Context.SEARCH_SERVICE);
if (null != searchManager) {
searchView.setSearchableInfo(searchManager.getSearchableInfo(getMainActivity().getComponentName()));
}
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
startSearch(query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
searchView.setQueryHint(getString(R.string.search_keywords));
LinearLayout searchEditFrame = (LinearLayout) searchView.findViewById(R.id.search_edit_frame);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) searchEditFrame.getLayoutParams();
params.leftMargin = 0;
View searchSrcText = searchView.findViewById(R.id.search_src_text);
searchSrcText.setPadding(0, searchSrcText.getPaddingTop(), 0, searchSrcText.getPaddingBottom());
searchMenuItem.expandActionView();
}
@CallSuper
protected void updateLayoutForReceive(VH holder) {
ViewGroup frameLayout = (ViewGroup) holder.itemView.findViewById(R.id.mainContainer);
ImageView imgTick = (ImageView) holder.itemView.findViewById(R.id.cslr_txt_tic);
TextView messageText = (TextView) holder.itemView.findViewById(R.id.messageSenderTextMessage);
LinearLayout root = (LinearLayout) holder.itemView.findViewById(R.id.contentContainer);
LinearLayout timeLayout = (LinearLayout) root.getParent();
timeLayout.setGravity(Gravity.LEFT);
if (messageText != null) {
messageText.setTextColor(Color.parseColor(G.textBubble));
}
// ProtoGlobal.RoomMessageType messageType = mMessage.forwardedFrom == null ? mMessage.messageType : mMessage.forwardedFrom.getMessageType();
if (G.isDarkTheme) {
setTextColor(imgTick, R.color.white);
} else {
setTextColor(imgTick, R.color.colorOldBlack);
}
((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).gravity = Gravity.LEFT;
((LinearLayout.LayoutParams) root.getLayoutParams()).gravity = Gravity.LEFT;
if (G.isDarkTheme) {
((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangel_white_round_dark);
} else {
((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangel_white_round);
}
/**
* add main layout margin to prevent getting match parent completely
* set to mainContainer not itemView because of selecting item foreground
*/
GradientDrawable circleDarkColor = (GradientDrawable) ((View) root.getParent()).getBackground();
circleDarkColor.setColor(Color.parseColor(G.bubbleChatReceive));
((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).leftMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp10);
((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).rightMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp28);
}
@CallSuper
protected void updateLayoutForSend(VH holder) {
ViewGroup frameLayout = (ViewGroup) holder.itemView.findViewById(R.id.mainContainer);
((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).gravity = Gravity.RIGHT;
LinearLayout root = (LinearLayout) holder.itemView.findViewById(R.id.contentContainer);
((LinearLayout.LayoutParams) root.getLayoutParams()).gravity = Gravity.RIGHT;
LinearLayout timeLayout = (LinearLayout) root.getParent();
timeLayout.setGravity(Gravity.RIGHT);
ImageView imgTick = (ImageView) holder.itemView.findViewById(R.id.cslr_txt_tic);
TextView messageText = (TextView) holder.itemView.findViewById(R.id.messageSenderTextMessage);
// TextView iconHearing = (TextView) holder.itemView.findViewById(R.id.cslr_txt_hearing);
if (messageText != null) {
messageText.setTextColor(Color.parseColor(G.textBubble));
}
// ProtoGlobal.RoomMessageType messageType = mMessage.forwardedFrom == null ? mMessage.messageType : mMessage.forwardedFrom.getMessageType();
ProtoGlobal.RoomMessageStatus status = ProtoGlobal.RoomMessageStatus.UNRECOGNIZED;
if (mMessage.status != null) {
try {
status = ProtoGlobal.RoomMessageStatus.valueOf(mMessage.status);
} catch (RuntimeException e) {
e.printStackTrace();
}
}
if (status == ProtoGlobal.RoomMessageStatus.SEEN) {
if (G.isDarkTheme) {
setTextColor(imgTick, R.color.iGapColor);
} else {
setTextColor(imgTick, R.color.backgroundColorCall2);
}
} else if (status == ProtoGlobal.RoomMessageStatus.LISTENED) {
// iconHearing.setVisibility(View.VISIBLE);
if (G.isDarkTheme) {
setTextColor(imgTick, R.color.iGapColor);
} else {
setTextColor(imgTick, R.color.backgroundColorCall2);
}
imgTick.setVisibility(View.VISIBLE);
} else {
// setTextColor(imgTick, Color.parseColor(G.txtIconCheck));
imgTick.setColorFilter(Color.parseColor(G.txtIconCheck));
}
if (G.isDarkTheme) {
((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangle_send_round_color_dark);
} else {
((View) (holder.itemView.findViewById(R.id.contentContainer)).getParent()).setBackgroundResource(R.drawable.rectangle_send_round_color);
}
GradientDrawable circleDarkColor = (GradientDrawable) ((View) root.getParent()).getBackground();
circleDarkColor.setColor(Color.parseColor(G.bubbleChatSend));
/**
* add main layout margin to prevent getting match parent completely
* set to mainContainer not itemView because of selecting item foreground
*/
((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).leftMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp28);
((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).rightMargin = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.dp10);
//((LinearLayout.LayoutParams) (holder.itemView.findViewById(R.id.contentContainer).getLayoutParams())).rightMargin = (int) holder.itemView.getResources().getDimension(R.dimen.messageBox_minusLeftRightMargin);
//((LinearLayout.LayoutParams) (holder.itemView.findViewById(R.id.contentContainer).getLayoutParams())).leftMargin = 0;
}