Skip to content

Commit

Permalink
更新到v2.1:
Browse files Browse the repository at this point in the history
1. 细节优化及已知bug修复
2. 增加背景边框设置功能 fix #10
  • Loading branch information
iwgang committed Jun 30, 2016
1 parent a52cfd9 commit 4c20fa0
Show file tree
Hide file tree
Showing 16 changed files with 757 additions and 353 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
# CountdownView
Android Countdown Widget,Use canvas draw,Supports Multiple styles

[Download demo apk](https://raw.githubusercontent.com/iwgang/CountdownView/master/Demo_2.0.apk)
[Download demo apk](https://raw.githubusercontent.com/iwgang/CountdownView/master/demoapk/Demo_2.1.apk)

### Screenshot
![](https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/g_main.gif)
![](https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/s_main.png)

![](https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/g_config.gif)
![](https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/g_config2.gif)

<img src="https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/s_list.jpg" width="400px" height="650px"/>

### Gradle
compile 'com.github.iwgang:countdownview:2.0'
compile 'com.github.iwgang:countdownview:2.1'

### Code
```
Expand Down Expand Up @@ -93,6 +93,10 @@ suffixMinuteRightMargin | dimension | 0
suffixSecondLeftMargin | dimension | 0
suffixSecondRightMargin | dimension | 0
suffixMillisecondLeftMargin | dimension | 0
isShowTimeBgBorder | boolean | false
timeBgBorderColor | color | #000000
timeBgBorderSize | dimension | 1dp
timeBgBorderRadius | dimension | 0

### Other
* **Multiple countdownView specified value**
Expand Down
10 changes: 7 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
# CountdownView
Android倒计时控件,使用Canvas绘制,支持多种样式

[下载DemoAPK](https://raw.githubusercontent.com/iwgang/CountdownView/master/Demo_2.0.apk)
[下载DemoAPK](https://raw.githubusercontent.com/iwgang/CountdownView/master/demoapk/Demo_2.1.apk)

### Screenshot
![](https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/g_main.gif)
![](https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/s_main.png)

![](https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/g_config.gif)
![](https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/g_config2.gif)

<img src="https://raw.githubusercontent.com/iwgang/CountdownView/master/screenshot/s_list.jpg" width="400px" height="650px"/>

### Gradle
compile 'com.github.iwgang:countdownview:2.0'
compile 'com.github.iwgang:countdownview:2.1'

### Code
```
Expand Down Expand Up @@ -93,6 +93,10 @@ suffixMinuteRightMargin | dimension | 0
suffixSecondLeftMargin | dimension | 0
suffixSecondRightMargin | dimension | 0
suffixMillisecondLeftMargin | dimension | 0
isShowTimeBgBorder | boolean | false
timeBgBorderColor | color | #000000
timeBgBorderSize | dimension | 1dp
timeBgBorderRadius | dimension | 0

### 其它
* **多个CountdownView时,给每个指定值**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import cn.qqtheme.framework.picker.ColorPicker;


@SuppressWarnings("ALL")
public class DynamicShowActivity extends AppCompatActivity {
private final long TIME = (long)8 * 24 * 60 * 60 * 1000;

Expand All @@ -28,6 +29,8 @@ public class DynamicShowActivity extends AppCompatActivity {
private boolean isShowDay = true, isShowHour = true, isShowMinute = true, isShowSecond = true, isShowMillisecond = true;
private float timeBgSize = 40;
private float bgRadius = 3;
private float bgBorderSize;
private float bgBorderRadius;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -387,6 +390,78 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});

final Button btnBgBorderSizePlus = (Button) findViewById(R.id.btn_bgBorderSizePlus);
final Button btnBgBorderSizeSubtract = (Button) findViewById(R.id.btn_bgBorderSizeSubtract);
final Button btnBgBorderRadiusPlus = (Button) findViewById(R.id.btn_bgBorderRadiusPlus);
final Button btnBgBorderRadiusSubtract = (Button) findViewById(R.id.btn_bgBorderRadiusSubtract);
btnBgBorderSizePlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderSize(++bgBorderSize));
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
}
});
btnBgBorderSizeSubtract.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (bgBorderSize == 0) return;
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderSize(--bgBorderSize));
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
}
});
btnBgBorderRadiusPlus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderRadius(++bgBorderRadius));
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
}
});
btnBgBorderRadiusSubtract.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (bgBorderRadius == 0) return;
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderRadius(--bgBorderRadius));
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
}
});

final Button btnModBgBorderColor = (Button) findViewById(R.id.btn_modBgBorderColor);
btnModBgBorderColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ColorPicker picker = new ColorPicker(DynamicShowActivity.this);
picker.setOnColorPickListener(new ColorPicker.OnColorPickListener() {
@Override
public void onColorPicked(int pickedColor) {
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderColor(pickedColor));
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
}
});
picker.show();
}
});

((CheckBox)findViewById(R.id.cb_bgBorder)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
btnModBgBorderColor.setEnabled(isChecked);
btnBgBorderSizePlus.setEnabled(isChecked);
btnBgBorderSizeSubtract.setEnabled(isChecked);
btnBgBorderRadiusPlus.setEnabled(isChecked);
btnBgBorderRadiusSubtract.setEnabled(isChecked);

DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(isChecked));
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
}
});
((CheckBox)findViewById(R.id.cb_bgBorder)).setChecked(false);

final EditText etSuffixDay = (EditText) findViewById(R.id.et_suffixDay);
final EditText etSuffixHour = (EditText) findViewById(R.id.et_suffixHour);
final EditText etSuffixMinute = (EditText) findViewById(R.id.et_suffixMinute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ protected void onCreate(Bundle savedInstanceState) {
long time2 = (long)30 * 60 * 1000;
mCvCountdownViewTest2.start(time2);

CountdownView cvCountdownViewTest211 = (CountdownView)findViewById(R.id.cv_countdownViewTest211);
cvCountdownViewTest211.setTag("test21");
long time211 = (long)30 * 60 * 1000;
cvCountdownViewTest211.start(time211);

CountdownView mCvCountdownViewTest21 = (CountdownView)findViewById(R.id.cv_countdownViewTest21);
mCvCountdownViewTest21.setTag("test21");
long time21 = (long)24 * 60 * 60 * 1000;
Expand Down
136 changes: 104 additions & 32 deletions app/src/main/res/layout/activity_dynamic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -421,63 +421,60 @@
android:layout_gravity="center_vertical"
android:text="大小:" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<Button
android:id="@+id/btn_bgSizePlus"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="+" />

<Button
android:id="@+id/btn_bgSizeSubtract"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="-" />

</LinearLayout>

<Button
android:id="@+id/btn_modBgColor"
android:layout_width="0dp"
android:id="@+id/btn_bgSizePlus"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_weight="1"
android:gravity="center"
android:text="背景颜色" />

</LinearLayout>
android:text="+" />

<Button
android:id="@+id/btn_bgSizeSubtract"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="-" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:text="圆角:" />

<Button
android:id="@+id/btn_bgRadiusPlus"
android:layout_width="50dp"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="+" />

<Button
android:id="@+id/btn_bgRadiusSubtract"
android:layout_width="50dp"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="-" />

<Button
android:id="@+id/btn_modBgColor"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="2"
android:gravity="center"
android:text="背景颜色" />

</LinearLayout>


<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">

<CheckBox
android:id="@+id/cb_bgDivisionLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:checked="true"
android:text="divider" />

Expand All @@ -489,6 +486,81 @@
android:layout_weight="1"
android:gravity="center"
android:text="Divider颜色" />

<CheckBox
android:id="@+id/cb_bgBorder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:checked="true"
android:text="边框" />

<Button
android:id="@+id/btn_modBgBorderColor"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity="center"
android:text="边框颜色" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="边框大小:" />

<Button
android:id="@+id/btn_bgBorderSizePlus"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="+" />

<Button
android:id="@+id/btn_bgBorderSizeSubtract"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="-" />

</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:text="边框圆角:" />

<Button
android:id="@+id/btn_bgBorderRadiusPlus"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="+" />

<Button
android:id="@+id/btn_bgBorderRadiusSubtract"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:text="-" />
</LinearLayout>
</LinearLayout>

</LinearLayout>
Expand Down
Loading

0 comments on commit 4c20fa0

Please sign in to comment.