Search in sources :

Example 1 with CountdownView

use of cn.iwgang.countdownview.CountdownView in project CountdownView by iwgang.

the class DynamicShowActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dynamic);
    mCvCountdownViewTest = (CountdownView) findViewById(R.id.cv_countdownViewTest);
    mCvCountdownViewTestHasBg = (CountdownView) findViewById(R.id.cv_countdownViewTestHasBg);
    mLlBackgroundConfigContainer = findViewById(R.id.ll_backgroundConfigContainer);
    mLlConvertDaysToHoursContainer = findViewById(R.id.ll_convertDaysToHoursContainer);
    mCvCountdownViewTest.start(TIME);
    findViewById(R.id.btn_theme1).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            if (hasBackgroundCountdownView) {
                DynamicConfig.BackgroundInfo backgroundInfo = new DynamicConfig.BackgroundInfo();
                backgroundInfo.setColor(0xFFFF54BC).setSize(30f).setRadius(0f).setShowTimeBgDivisionLine(false);
                dynamicConfigBuilder.setTimeTextSize(15).setTimeTextColor(0xFFFFFFFF).setTimeTextBold(true).setSuffixTextColor(0xFF000000).setSuffixTextSize(15).setBackgroundInfo(backgroundInfo).setShowDay(false).setShowHour(true).setShowMinute(true).setShowSecond(true).setShowMillisecond(true);
            } else {
                dynamicConfigBuilder.setTimeTextSize(35).setTimeTextColor(0xFFFF5000).setTimeTextBold(true).setSuffixTextColor(0xFFFF5000).setSuffixTextSize(30).setSuffixTextBold(false).setSuffix(":").setSuffixMillisecond(// Remove millisecond suffix
                "").setSuffixGravity(DynamicConfig.SuffixGravity.CENTER).setShowDay(false).setShowHour(false).setShowMinute(true).setShowSecond(true).setShowMillisecond(true);
            }
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_theme2).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            if (hasBackgroundCountdownView) {
                DynamicConfig.BackgroundInfo backgroundInfo = new DynamicConfig.BackgroundInfo();
                backgroundInfo.setColor(0xFFFF5000).setSize(60f).setRadius(30f).setShowTimeBgDivisionLine(false);
                dynamicConfigBuilder.setTimeTextSize(42).setTimeTextColor(0xFFFFFFFF).setTimeTextBold(true).setSuffixTextColor(0xFF000000).setSuffixTextSize(42).setSuffixTextBold(true).setBackgroundInfo(backgroundInfo).setShowDay(false).setShowHour(true).setShowMinute(true).setShowSecond(true).setShowMillisecond(false);
            } else {
                dynamicConfigBuilder.setTimeTextSize(60).setTimeTextColor(0xFF444444).setTimeTextBold(false).setSuffixTextColor(0xFF444444).setSuffixTextSize(20).setSuffixTextBold(false).setSuffixMinute("m").setSuffixMinuteLeftMargin(5).setSuffixMinuteRightMargin(10).setSuffixSecond("s").setSuffixSecondLeftMargin(5).setSuffixGravity(DynamicConfig.SuffixGravity.BOTTOM).setShowDay(false).setShowHour(false).setShowMinute(true).setShowSecond(true).setShowMillisecond(false);
            }
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_theme3).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            if (hasBackgroundCountdownView) {
                DynamicConfig.BackgroundInfo backgroundInfo = new DynamicConfig.BackgroundInfo();
                backgroundInfo.setColor(0xFF444444).setSize(40f).setRadius(3f).setShowTimeBgDivisionLine(true).setDivisionLineColor(Color.parseColor("#30FFFFFF")).setDivisionLineSize(1f);
                dynamicConfigBuilder.setTimeTextSize(22).setTimeTextColor(0xFFFFFFFF).setTimeTextBold(true).setSuffixTextColor(0xFF000000).setSuffixTextSize(18).setSuffixTextBold(true).setBackgroundInfo(backgroundInfo).setShowDay(true).setShowHour(true).setShowMinute(true).setShowSecond(true).setShowMillisecond(true);
            } else {
                dynamicConfigBuilder.setTimeTextSize(22).setTimeTextColor(0xFF000000).setTimeTextBold(false).setSuffixTextColor(0xFF000000).setSuffixTextSize(12).setSuffixTextBold(false).setSuffixDay("天").setSuffixHour("小时").setSuffixMinute("分钟").setSuffixSecond("秒").setSuffixMillisecond("毫秒").setSuffixGravity(DynamicConfig.SuffixGravity.TOP).setShowDay(true).setShowHour(true).setShowMinute(true).setShowSecond(true).setShowMillisecond(true);
            }
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_timeTextSizePlus).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setTimeTextSize(++timeTextSize);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_timeTextSizeSubtract).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (timeTextSize == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setTimeTextSize(--timeTextSize);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_modTimeTextColor).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 dynamicConfig = new DynamicConfig.Builder().setTimeTextColor(pickedColor).build();
                    if (hasBackgroundCountdownView) {
                        mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
                    } else {
                        mCvCountdownViewTest.dynamicShow(dynamicConfig);
                    }
                }
            });
            picker.show();
        }
    });
    findViewById(R.id.btn_suffixTextSizePlus).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setSuffixTextSize(++suffixTextSize);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_suffixTextSizeSubtract).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (timeTextSize == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setSuffixTextSize(--suffixTextSize);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_modSuffixTextColor).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 dynamicConfig = new DynamicConfig.Builder().setSuffixTextColor(pickedColor).build();
                    if (hasBackgroundCountdownView) {
                        mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
                    } else {
                        mCvCountdownViewTest.dynamicShow(dynamicConfig);
                    }
                }
            });
            picker.show();
        }
    });
    findViewById(R.id.btn_suffixGravityTop).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig dynamicConfig = new DynamicConfig.Builder().setSuffixGravity(DynamicConfig.SuffixGravity.TOP).build();
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfig);
            }
        }
    });
    findViewById(R.id.btn_suffixGravityCenter).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig dynamicConfig = new DynamicConfig.Builder().setSuffixGravity(DynamicConfig.SuffixGravity.CENTER).build();
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfig);
            }
        }
    });
    findViewById(R.id.btn_suffixGravityBottom).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig dynamicConfig = new DynamicConfig.Builder().setSuffixGravity(DynamicConfig.SuffixGravity.BOTTOM).build();
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfig);
            }
        }
    });
    findViewById(R.id.btn_refTimeShow).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isShowDay && !isShowHour && !isShowMinute && !isShowSecond && !isShowMillisecond) {
                Toast.makeText(DynamicShowActivity.this, "Select at least one item", Toast.LENGTH_LONG).show();
                return;
            }
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setShowDay(isShowDay).setShowHour(isShowHour).setShowMinute(isShowMinute).setShowSecond(isShowSecond).setShowMillisecond(isShowMillisecond);
            if (hasBackgroundCountdownView) {
                mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
            } else {
                mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
            }
        }
    });
    findViewById(R.id.btn_bgSizePlus).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setSize(++timeBgSize));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    findViewById(R.id.btn_bgSizeSubtract).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (timeBgSize == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setSize(--timeBgSize));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    findViewById(R.id.btn_modBgColor).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 dynamicConfig = new DynamicConfig.Builder().setBackgroundInfo(new DynamicConfig.BackgroundInfo().setColor(pickedColor)).build();
                    mCvCountdownViewTestHasBg.dynamicShow(dynamicConfig);
                }
            });
            picker.show();
        }
    });
    findViewById(R.id.btn_bgRadiusPlus).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setRadius(++bgRadius));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    findViewById(R.id.btn_bgRadiusSubtract).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (bgRadius == 0)
                return;
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setRadius(--bgRadius));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    final Button btnModBgDivisionLineColor = (Button) findViewById(R.id.btn_modBgDivisionLineColor);
    btnModBgDivisionLineColor.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().setShowTimeBgDivisionLine(true).setDivisionLineColor(pickedColor));
                    mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
                }
            });
            picker.show();
        }
    });
    ((CheckBox) findViewById(R.id.cb_bgDivisionLine)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            btnModBgDivisionLineColor.setEnabled(isChecked);
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setBackgroundInfo(new DynamicConfig.BackgroundInfo().setShowTimeBgDivisionLine(isChecked));
            mCvCountdownViewTestHasBg.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    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);
    final EditText etSuffixSecond = (EditText) findViewById(R.id.et_suffixSecond);
    final EditText etSuffixMillisecond = (EditText) findViewById(R.id.et_suffixMillisecond);
    findViewById(R.id.btm_refSuffix).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setSuffixDay(etSuffixDay.getText().toString()).setSuffixHour(etSuffixHour.getText().toString()).setSuffixMinute(etSuffixMinute.getText().toString()).setSuffixSecond(etSuffixSecond.getText().toString()).setSuffixMillisecond(etSuffixMillisecond.getText().toString());
            mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    ((CheckBox) findViewById(R.id.cb_hasBackground)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            hasBackgroundCountdownView = isChecked;
            mLlBackgroundConfigContainer.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            mCvCountdownViewTest.setVisibility(!isChecked ? View.VISIBLE : View.GONE);
            mCvCountdownViewTestHasBg.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            if (isChecked) {
                mCvCountdownViewTest.stop();
                mCvCountdownViewTestHasBg.start(TIME);
                mLlConvertDaysToHoursContainer.setVisibility(View.GONE);
            } else {
                mCvCountdownViewTestHasBg.stop();
                mCvCountdownViewTest.start(TIME);
                mLlConvertDaysToHoursContainer.setVisibility(View.VISIBLE);
            }
        }
    });
    final Button btnConvertDaysToHours = (Button) findViewById(R.id.btn_convertDaysToHours);
    findViewById(R.id.btn_convertDaysToHours).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            isConvertDaysToHours = !isConvertDaysToHours;
            btnConvertDaysToHours.setText(isConvertDaysToHours ? "转换" : "不转换");
            DynamicConfig.Builder dynamicConfigBuilder = new DynamicConfig.Builder();
            dynamicConfigBuilder.setConvertDaysToHours(isConvertDaysToHours);
            dynamicConfigBuilder.setShowDay(!isConvertDaysToHours);
            mCvCountdownViewTest.dynamicShow(dynamicConfigBuilder.build());
        }
    });
    handlerCheckBoxSel();
}
Also used : EditText(android.widget.EditText) ColorPicker(cn.qqtheme.framework.picker.ColorPicker) DynamicConfig(cn.iwgang.countdownview.DynamicConfig) View(android.view.View) CountdownView(cn.iwgang.countdownview.CountdownView) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) CheckBox(android.widget.CheckBox) CompoundButton(android.widget.CompoundButton)

Example 2 with CountdownView

use of cn.iwgang.countdownview.CountdownView in project CountdownView by iwgang.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    CountdownView mCvCountdownViewTest1 = (CountdownView) findViewById(R.id.cv_countdownViewTest1);
    mCvCountdownViewTest1.setTag("test1");
    long time1 = (long) 5 * 60 * 60 * 1000;
    mCvCountdownViewTest1.start(time1);
    CountdownView mCvCountdownViewTest2 = (CountdownView) findViewById(R.id.cv_countdownViewTest2);
    mCvCountdownViewTest2.setTag("test2");
    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;
    mCvCountdownViewTest21.start(time21);
    CountdownView mCvCountdownViewTest22 = (CountdownView) findViewById(R.id.cv_countdownViewTest22);
    mCvCountdownViewTest22.setTag("test22");
    long time22 = (long) 30 * 60 * 1000;
    mCvCountdownViewTest22.start(time22);
    CountdownView mCvCountdownViewTest3 = (CountdownView) findViewById(R.id.cv_countdownViewTest3);
    long time3 = (long) 9 * 60 * 60 * 1000;
    mCvCountdownViewTest3.start(time3);
    CountdownView mCvCountdownViewTest4 = (CountdownView) findViewById(R.id.cv_countdownViewTest4);
    long time4 = (long) 150 * 24 * 60 * 60 * 1000;
    mCvCountdownViewTest4.start(time4);
    CountdownView cv_convertDaysToHours = (CountdownView) findViewById(R.id.cv_convertDaysToHours);
    // long timeConvertDaysToHours = (long) 150 * 24 * 60 * 60 * 1000;
    cv_convertDaysToHours.start(time4);
    final CountdownView mCvCountdownViewTest5 = (CountdownView) findViewById(R.id.cv_countdownViewTest5);
    new AsyncTask<Void, Long, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
            long time = 0;
            while (true) {
                try {
                    Thread.sleep(1000);
                    time += 1000;
                    publishProgress(time);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }

        @Override
        protected void onProgressUpdate(Long... values) {
            super.onProgressUpdate(values);
            mCvCountdownViewTest5.updateShow(values[0]);
        }
    }.execute();
    CountdownView mCvCountdownViewTest6 = (CountdownView) findViewById(R.id.cv_countdownViewTest6);
    long time6 = (long) 2 * 60 * 60 * 1000;
    mCvCountdownViewTest6.start(time6);
    findViewById(R.id.btn_toDynamicShowActivity).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, DynamicShowActivity.class));
        }
    });
    findViewById(R.id.btn_toListViewActivity).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, ListViewActivity.class));
        }
    });
    findViewById(R.id.btn_toRecyclerViewActivity).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, RecyclerViewActivity.class));
        }
    });
}
Also used : Intent(android.content.Intent) View(android.view.View) CountdownView(cn.iwgang.countdownview.CountdownView) CountdownView(cn.iwgang.countdownview.CountdownView)

Aggregations

View (android.view.View)2 CountdownView (cn.iwgang.countdownview.CountdownView)2 Intent (android.content.Intent)1 Button (android.widget.Button)1 CheckBox (android.widget.CheckBox)1 CompoundButton (android.widget.CompoundButton)1 EditText (android.widget.EditText)1 DynamicConfig (cn.iwgang.countdownview.DynamicConfig)1 ColorPicker (cn.qqtheme.framework.picker.ColorPicker)1