Skip to content

Commit

Permalink
修复bug,增加获取其他频道内容方法
Browse files Browse the repository at this point in the history
  • Loading branch information
chengzhicao committed Mar 22, 2019
1 parent 75cf068 commit 702cb88
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 16 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ dependencies {
|void addPlate(String plateName, List<Channel> channelList)| 添加频道板块
|void inflateData()| 添加完频道板块之后,进行填充数据,要在addPlate方法之后调用
|boolean isChange()| 频道序列是否发生变化
|List<Channel> getMyChannel()| 获取我的频道内容
|List<List<Channel>> getOtherChannel()| 获取其他频道内容

# 接口

Expand Down Expand Up @@ -71,22 +73,25 @@ dependencies {
|channelFocusedTextColor| 设置编辑且点击状态下频道字体颜色
|channelTextSize| 设置频道字体大小
|tipEditBackground| 设置编辑按键背景
|platesTitleBackground| 设置频道板块标题背景
|tipEditTextColor| 设置编辑按键颜色
|platesTitleColor| 设置频道板块标题颜色
|platesTitleBold| 设置频道板块标题是否加粗
|tipEditTextSize| 设置编辑按键字体大小
|tipFinishBackground| 设置完成按键背景
|tipFinishTextColor| 设置完成按键颜色
|tipFinishTextSize| 设置完成按键字体大小
|platesTitleBold| 设置频道板块标题是否加粗
|platesTitleBackground| 设置频道板块标题背景
|platesTitleColor| 设置频道板块标题颜色
|platesTitleSize| 设置频道板块标题大小
|platesTitleHeight| 频道板块title高度
|platesTitleLeftRightPadding| 频道板块title左右padding
|otherSubTitleBackground| 设置其它频道板块的副标题背景
|otherSubTitleTextColor| 设置其它频道板块的副标题颜色
|otherSubTitleTextSize| 设置其它频道板块的副标题字体大小
|otherSubTitleName| 设置其它未选频道的副标题
|subTitleBackground| 设置已选频道板块的副标题背景
|subTitleTextColor| 设置已选频道板块的副标题颜色
|subTitleTextSize| 设置已选频道板块的副标题字体大小
|subTitleName| 设置已选频道的副标题
|otherSubTitleName| 设置其它未选频道的副标题

# 示例

Expand Down
4 changes: 2 additions & 2 deletions channelview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0.6"
versionCode 2
versionName "1.0.7"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
95 changes: 85 additions & 10 deletions channelview/src/main/java/com/cheng/channel/ChannelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,18 @@ public class ChannelView extends ScrollView {
@DrawableRes
private int tipEditBackground;

@DrawableRes
private int tipFinishBackground;

@DrawableRes
private int platesTitleBackground;

@ColorInt
private int tipEditTextColor;

@ColorInt
private int tipFinishTextColor;

@ColorInt
private int platesTitleColor;

Expand All @@ -126,6 +132,8 @@ public class ChannelView extends ScrollView {

private int tipEditTextSize;

private int tipFinishTextSize;

private int channelTextSize;

private List<TextView> fixedTextView = new ArrayList<>();
Expand Down Expand Up @@ -179,6 +187,9 @@ public ChannelView(Context context, AttributeSet attrs, int defStyleAttr) {
subTitleTextSize = typedArray.getDimensionPixelSize(R.styleable.ChannelView_subTitleTextSize, getResources().getDimensionPixelSize(R.dimen.subTitleTextSize));
subTitleName = typedArray.getString(R.styleable.ChannelView_subTitleName);
otherSubTitleName = typedArray.getString(R.styleable.ChannelView_otherSubTitleName);
tipFinishBackground = typedArray.getResourceId(R.styleable.ChannelView_tipFinishBackground, R.drawable.bg_channel_transparent);
tipFinishTextColor = typedArray.getColor(R.styleable.ChannelView_tipFinishTextColor, getResources().getColor(R.color.channelNormalTextColor));
tipFinishTextSize = typedArray.getDimensionPixelSize(R.styleable.ChannelView_tipFinishTextSize, getResources().getDimensionPixelSize(R.dimen.channelTextSize));
typedArray.recycle();
if (subTitleName == null) {
subTitleName = "";
Expand Down Expand Up @@ -369,9 +380,20 @@ public void setPlatesTitleColor(@ColorInt int platesTitleColor) {
*/
public void setTipEditBackground(@DrawableRes int tipEditBackground) {
this.tipEditBackground = tipEditBackground;
if (channelLayout != null && channelLayout.tipEdit != null && channelLayout.tipFinish != null) {
if (channelLayout != null && channelLayout.tipEdit != null) {
channelLayout.tipEdit.setBackgroundResource(tipEditBackground);
channelLayout.tipFinish.setBackgroundResource(tipEditBackground);
}
}

/**
* 设置完成按键背景
*
* @param tipFinishBackground
*/
public void setTipFinishBackground(@DrawableRes int tipFinishBackground) {
this.tipFinishBackground = tipFinishBackground;
if (channelLayout != null && channelLayout.tipFinish != null) {
channelLayout.tipFinish.setBackgroundResource(tipFinishBackground);
}
}

Expand All @@ -382,9 +404,20 @@ public void setTipEditBackground(@DrawableRes int tipEditBackground) {
*/
public void setTipEditTextColor(@ColorInt int tipEditTextColor) {
this.tipEditTextColor = tipEditTextColor;
if (channelLayout != null && channelLayout.tipEdit != null && channelLayout.tipFinish != null) {
if (channelLayout != null && channelLayout.tipEdit != null) {
channelLayout.tipEdit.setTextColor(tipEditTextColor);
channelLayout.tipFinish.setTextColor(tipEditTextColor);
}
}

/**
* 设置完成按键颜色
*
* @param tipFinishTextColor
*/
public void setTipFinishTextColor(@ColorInt int tipFinishTextColor) {
this.tipFinishTextColor = tipFinishTextColor;
if (channelLayout != null && channelLayout.tipFinish != null) {
channelLayout.tipFinish.setTextColor(tipFinishTextColor);
}
}

Expand Down Expand Up @@ -430,20 +463,39 @@ public void setPlatesTitleSizeRes(@DimenRes int platesTitleSize) {
*/
public void setTipEditTextSize(int unit, int tipEditTextSize) {
this.tipEditTextSize = (int) TypedValue.applyDimension(unit, tipEditTextSize, getResources().getDisplayMetrics());
if (channelLayout != null && channelLayout.tipEdit != null && channelLayout.tipFinish != null) {
if (channelLayout != null && channelLayout.tipEdit != null) {
channelLayout.tipEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, this.tipEditTextSize);
channelLayout.tipFinish.setTextSize(TypedValue.COMPLEX_UNIT_PX, this.tipEditTextSize);
}
}

public void setTipEditTextSizeRes(@DimenRes int tipEditTextSize) {
this.tipEditTextSize = getResources().getDimensionPixelSize(tipEditTextSize);
if (channelLayout != null && channelLayout.tipEdit != null && channelLayout.tipFinish != null) {
if (channelLayout != null && channelLayout.tipEdit != null) {
channelLayout.tipEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, this.tipEditTextSize);
channelLayout.tipFinish.setTextSize(TypedValue.COMPLEX_UNIT_PX, this.tipEditTextSize);
}
}

/**
* 设置完成按键字体大小
*
* @param unit
* @param tipFinishTextSize
*/
public void setTipFinishTextSize(int unit, int tipFinishTextSize) {
this.tipFinishTextSize = (int) TypedValue.applyDimension(unit, tipFinishTextSize, getResources().getDisplayMetrics());
if (channelLayout != null && channelLayout.tipFinish != null) {
channelLayout.tipFinish.setTextSize(TypedValue.COMPLEX_UNIT_PX, this.tipFinishTextSize);
}
}

public void setTipFinishTextSizeRes(@DimenRes int tipFinishTextSize) {
this.tipFinishTextSize = getResources().getDimensionPixelSize(tipFinishTextSize);
if (channelLayout != null && channelLayout.tipFinish != null) {
channelLayout.tipFinish.setTextSize(TypedValue.COMPLEX_UNIT_PX, this.tipFinishTextSize);
}
}


/**
* 设置其它频道板块的副标题背景
*
Expand Down Expand Up @@ -591,6 +643,26 @@ public List<Channel> getMyChannel() {
return channels;
}

/**
* 获取其他频道
*
* @return
*/
public List<List<Channel>> getOtherChannel() {
List<List<Channel>> otherChannels = new ArrayList<>();
if (channelLayout != null && channelLayout.channelGroups.size() > 0) {
int len = channelLayout.channelGroups.size();
for (int i = 1; i < len; i++) {
List<Channel> channels = new ArrayList<>();
for (View view : channelLayout.channelGroups.get(i)) {
channels.add(((ChannelAttr) view.getTag()).channel);
}
otherChannels.add(channels);
}
}
return otherChannels;
}

private int[] myChannelCode;

/**
Expand Down Expand Up @@ -818,11 +890,13 @@ private void addChannelView() {
tipEdit.setOnClickListener(this);
tipEdit.setBackgroundResource(tipEditBackground);
tipEdit.setTextColor(tipEditTextColor);
tipEdit.setTextSize(TypedValue.COMPLEX_UNIT_PX, tipEditTextSize);
tipFinish = view.findViewById(R.id.tv_tip_finish);
tipFinish.setVisibility(INVISIBLE);
tipFinish.setOnClickListener(this);
tipFinish.setBackgroundResource(tipEditBackground);
tipFinish.setTextColor(tipEditTextColor);
tipFinish.setBackgroundResource(tipFinishBackground);
tipFinish.setTextColor(tipFinishTextColor);
tipFinish.setTextSize(TypedValue.COMPLEX_UNIT_PX, tipFinishTextSize);
subTitle = otherSubTitle;
subTitle.setText(subTitleName);
subTitle.setTextColor(subTitleTextColor);
Expand All @@ -842,6 +916,7 @@ private void addChannelView() {
view.setTag(channelTitleAttr);
TextView tvTitle = view.findViewById(R.id.tv_title);
tvTitle.setText(aKeySet);
tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, platesTitleSize);
tvTitle.setBackgroundResource(platesTitleBackground);
tvTitle.setTextColor(platesTitleColor);
if (platesTitleBold) {
Expand Down
3 changes: 3 additions & 0 deletions channelview/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
<attr name="subTitleTextSize" format="dimension" />
<attr name="subTitleName" format="string" />
<attr name="otherSubTitleName" format="string" />
<attr name="tipFinishBackground" format="reference" />
<attr name="tipFinishTextColor" format="color" />
<attr name="tipFinishTextSize" format="dimension" />
</declare-styleable>
</resources>

0 comments on commit 702cb88

Please sign in to comment.