Skip to content

Commit 4c20fa0

Browse files
committed
更新到v2.1:
1. 细节优化及已知bug修复 2. 增加背景边框设置功能 fix #10
1 parent a52cfd9 commit 4c20fa0

File tree

16 files changed

+757
-353
lines changed

16 files changed

+757
-353
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
# CountdownView
99
Android Countdown Widget,Use canvas draw,Supports Multiple styles
1010

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

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

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

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

2121
### Gradle
22-
compile 'com.github.iwgang:countdownview:2.0'
22+
compile 'com.github.iwgang:countdownview:2.1'
2323

2424
### Code
2525
```
@@ -93,6 +93,10 @@ suffixMinuteRightMargin | dimension | 0
9393
suffixSecondLeftMargin | dimension | 0
9494
suffixSecondRightMargin | dimension | 0
9595
suffixMillisecondLeftMargin | dimension | 0
96+
isShowTimeBgBorder | boolean | false
97+
timeBgBorderColor | color | #000000
98+
timeBgBorderSize | dimension | 1dp
99+
timeBgBorderRadius | dimension | 0
96100

97101
### Other
98102
* **Multiple countdownView specified value**

README_CN.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
# CountdownView
99
Android倒计时控件,使用Canvas绘制,支持多种样式
1010

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

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

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

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

2121
### Gradle
22-
compile 'com.github.iwgang:countdownview:2.0'
22+
compile 'com.github.iwgang:countdownview:2.1'
2323

2424
### Code
2525
```
@@ -93,6 +93,10 @@ suffixMinuteRightMargin | dimension | 0
9393
suffixSecondLeftMargin | dimension | 0
9494
suffixSecondRightMargin | dimension | 0
9595
suffixMillisecondLeftMargin | dimension | 0
96+
isShowTimeBgBorder | boolean | false
97+
timeBgBorderColor | color | #000000
98+
timeBgBorderSize | dimension | 1dp
99+
timeBgBorderRadius | dimension | 0
96100

97101
### 其它
98102
* **多个CountdownView时,给每个指定值**

app/src/main/java/cn/iwgang/countdownviewdemo/DynamicShowActivity.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import cn.qqtheme.framework.picker.ColorPicker;
1616

1717

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

@@ -28,6 +29,8 @@ public class DynamicShowActivity extends AppCompatActivity {
2829
private boolean isShowDay = true, isShowHour = true, isShowMinute = true, isShowSecond = true, isShowMillisecond = true;
2930
private float timeBgSize = 40;
3031
private float bgRadius = 3;
32+
private float bgBorderSize;
33+
private float bgBorderRadius;
3134

3235
@Override
3336
protected void onCreate(Bundle savedInstanceState) {
@@ -387,6 +390,78 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
387390
}
388391
});
389392

393+
final Button btnBgBorderSizePlus = (Button) findViewById(R.id.btn_bgBorderSizePlus);
394+
final Button btnBgBorderSizeSubtract = (Button) findViewById(R.id.btn_bgBorderSizeSubtract);
395+
final Button btnBgBorderRadiusPlus = (Button) findViewById(R.id.btn_bgBorderRadiusPlus);
396+
final Button btnBgBorderRadiusSubtract = (Button) findViewById(R.id.btn_bgBorderRadiusSubtract);
397+
btnBgBorderSizePlus.setOnClickListener(new View.OnClickListener() {
398+
@Override
399+
public void onClick(View v) {
400+
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
401+
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderSize(++bgBorderSize));
402+
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
403+
}
404+
});
405+
btnBgBorderSizeSubtract.setOnClickListener(new View.OnClickListener() {
406+
@Override
407+
public void onClick(View v) {
408+
if (bgBorderSize == 0) return;
409+
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
410+
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderSize(--bgBorderSize));
411+
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
412+
}
413+
});
414+
btnBgBorderRadiusPlus.setOnClickListener(new View.OnClickListener() {
415+
@Override
416+
public void onClick(View v) {
417+
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
418+
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderRadius(++bgBorderRadius));
419+
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
420+
}
421+
});
422+
btnBgBorderRadiusSubtract.setOnClickListener(new View.OnClickListener() {
423+
@Override
424+
public void onClick(View v) {
425+
if (bgBorderRadius == 0) return;
426+
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
427+
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderRadius(--bgBorderRadius));
428+
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
429+
}
430+
});
431+
432+
final Button btnModBgBorderColor = (Button) findViewById(R.id.btn_modBgBorderColor);
433+
btnModBgBorderColor.setOnClickListener(new View.OnClickListener() {
434+
@Override
435+
public void onClick(View v) {
436+
ColorPicker picker = new ColorPicker(DynamicShowActivity.this);
437+
picker.setOnColorPickListener(new ColorPicker.OnColorPickListener() {
438+
@Override
439+
public void onColorPicked(int pickedColor) {
440+
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
441+
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(true).setBorderColor(pickedColor));
442+
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
443+
}
444+
});
445+
picker.show();
446+
}
447+
});
448+
449+
((CheckBox)findViewById(R.id.cb_bgBorder)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
450+
@Override
451+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
452+
btnModBgBorderColor.setEnabled(isChecked);
453+
btnBgBorderSizePlus.setEnabled(isChecked);
454+
btnBgBorderSizeSubtract.setEnabled(isChecked);
455+
btnBgBorderRadiusPlus.setEnabled(isChecked);
456+
btnBgBorderRadiusSubtract.setEnabled(isChecked);
457+
458+
DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
459+
dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgBorder(isChecked));
460+
mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
461+
}
462+
});
463+
((CheckBox)findViewById(R.id.cb_bgBorder)).setChecked(false);
464+
390465
final EditText etSuffixDay = (EditText) findViewById(R.id.et_suffixDay);
391466
final EditText etSuffixHour = (EditText) findViewById(R.id.et_suffixHour);
392467
final EditText etSuffixMinute = (EditText) findViewById(R.id.et_suffixMinute);

app/src/main/java/cn/iwgang/countdownviewdemo/MainActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ protected void onCreate(Bundle savedInstanceState) {
2727
long time2 = (long)30 * 60 * 1000;
2828
mCvCountdownViewTest2.start(time2);
2929

30+
CountdownView cvCountdownViewTest211 = (CountdownView)findViewById(R.id.cv_countdownViewTest211);
31+
cvCountdownViewTest211.setTag("test21");
32+
long time211 = (long)30 * 60 * 1000;
33+
cvCountdownViewTest211.start(time211);
34+
3035
CountdownView mCvCountdownViewTest21 = (CountdownView)findViewById(R.id.cv_countdownViewTest21);
3136
mCvCountdownViewTest21.setTag("test21");
3237
long time21 = (long)24 * 60 * 60 * 1000;

app/src/main/res/layout/activity_dynamic.xml

Lines changed: 104 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -421,63 +421,60 @@
421421
android:layout_gravity="center_vertical"
422422
android:text="大小:" />
423423

424-
<LinearLayout
425-
android:layout_width="wrap_content"
426-
android:layout_height="wrap_content">
427-
428-
<Button
429-
android:id="@+id/btn_bgSizePlus"
430-
android:layout_width="50dp"
431-
android:layout_height="wrap_content"
432-
android:text="+" />
433-
434-
<Button
435-
android:id="@+id/btn_bgSizeSubtract"
436-
android:layout_width="50dp"
437-
android:layout_height="wrap_content"
438-
android:text="-" />
439-
440-
</LinearLayout>
441-
442424
<Button
443-
android:id="@+id/btn_modBgColor"
444-
android:layout_width="0dp"
425+
android:id="@+id/btn_bgSizePlus"
426+
android:layout_width="40dp"
445427
android:layout_height="wrap_content"
446-
android:layout_marginLeft="30dp"
447-
android:layout_weight="1"
448-
android:gravity="center"
449-
android:text="背景颜色" />
450-
451-
</LinearLayout>
428+
android:text="+" />
452429

430+
<Button
431+
android:id="@+id/btn_bgSizeSubtract"
432+
android:layout_width="40dp"
433+
android:layout_height="wrap_content"
434+
android:text="-" />
453435

454-
<LinearLayout
455-
android:layout_width="wrap_content"
456-
android:layout_height="wrap_content">
457436

458437
<TextView
459438
android:layout_width="wrap_content"
460439
android:layout_height="wrap_content"
461440
android:layout_gravity="center_vertical"
441+
android:layout_marginLeft="10dp"
462442
android:text="圆角:" />
463443

464444
<Button
465445
android:id="@+id/btn_bgRadiusPlus"
466-
android:layout_width="50dp"
446+
android:layout_width="40dp"
467447
android:layout_height="wrap_content"
468448
android:text="+" />
469449

470450
<Button
471451
android:id="@+id/btn_bgRadiusSubtract"
472-
android:layout_width="50dp"
452+
android:layout_width="40dp"
473453
android:layout_height="wrap_content"
474454
android:text="-" />
475455

456+
<Button
457+
android:id="@+id/btn_modBgColor"
458+
android:layout_width="0dp"
459+
android:layout_height="wrap_content"
460+
android:layout_marginLeft="10dp"
461+
android:layout_weight="2"
462+
android:gravity="center"
463+
android:text="背景颜色" />
464+
465+
</LinearLayout>
466+
467+
468+
<LinearLayout
469+
android:layout_width="wrap_content"
470+
android:layout_height="wrap_content"
471+
android:gravity="center"
472+
android:orientation="horizontal">
473+
476474
<CheckBox
477475
android:id="@+id/cb_bgDivisionLine"
478476
android:layout_width="wrap_content"
479477
android:layout_height="wrap_content"
480-
android:layout_marginLeft="30dp"
481478
android:checked="true"
482479
android:text="divider" />
483480

@@ -489,6 +486,81 @@
489486
android:layout_weight="1"
490487
android:gravity="center"
491488
android:text="Divider颜色" />
489+
490+
<CheckBox
491+
android:id="@+id/cb_bgBorder"
492+
android:layout_width="wrap_content"
493+
android:layout_height="wrap_content"
494+
android:layout_marginLeft="10dp"
495+
android:checked="true"
496+
android:text="边框" />
497+
498+
<Button
499+
android:id="@+id/btn_modBgBorderColor"
500+
android:layout_width="0dp"
501+
android:layout_height="wrap_content"
502+
android:layout_marginLeft="10dp"
503+
android:layout_weight="1"
504+
android:gravity="center"
505+
android:text="边框颜色" />
506+
</LinearLayout>
507+
508+
<LinearLayout
509+
android:layout_width="match_parent"
510+
android:layout_height="wrap_content"
511+
android:orientation="horizontal">
512+
513+
<LinearLayout
514+
android:layout_width="0dp"
515+
android:layout_height="wrap_content"
516+
android:layout_weight="1"
517+
android:gravity="center_horizontal">
518+
519+
<TextView
520+
android:layout_width="wrap_content"
521+
android:layout_height="wrap_content"
522+
android:layout_gravity="center_vertical"
523+
android:text="边框大小:" />
524+
525+
<Button
526+
android:id="@+id/btn_bgBorderSizePlus"
527+
android:layout_width="40dp"
528+
android:layout_height="wrap_content"
529+
android:text="+" />
530+
531+
<Button
532+
android:id="@+id/btn_bgBorderSizeSubtract"
533+
android:layout_width="40dp"
534+
android:layout_height="wrap_content"
535+
android:text="-" />
536+
537+
</LinearLayout>
538+
539+
<LinearLayout
540+
android:layout_width="0dp"
541+
android:layout_height="wrap_content"
542+
android:layout_weight="1"
543+
android:gravity="center_horizontal">
544+
545+
<TextView
546+
android:layout_width="wrap_content"
547+
android:layout_height="wrap_content"
548+
android:layout_gravity="center_vertical"
549+
android:layout_marginLeft="10dp"
550+
android:text="边框圆角:" />
551+
552+
<Button
553+
android:id="@+id/btn_bgBorderRadiusPlus"
554+
android:layout_width="40dp"
555+
android:layout_height="wrap_content"
556+
android:text="+" />
557+
558+
<Button
559+
android:id="@+id/btn_bgBorderRadiusSubtract"
560+
android:layout_width="40dp"
561+
android:layout_height="wrap_content"
562+
android:text="-" />
563+
</LinearLayout>
492564
</LinearLayout>
493565

494566
</LinearLayout>

0 commit comments

Comments
 (0)