@Override
 public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
   calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
   calendar.set(Calendar.MINUTE, minute);
   config.setCountdownTimestamp(calendar.getTimeInMillis());
   tvCountdown.setTime(config.getCountdownTimestamp());
 }
  public LockerModeRing(Context context) {
    super(context);
    config = ConfigManager.getInstance(context);

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(config.getScreenWidth(), config.getScreenWidth());
    params.addRule(RelativeLayout.BELOW, R.id.edi_indicator);
    rpv.setLayoutParams(params);
  }
  @Override
  public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) {
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.DAY_OF_MONTH, day);

    config.setCountdownTimestamp(calendar.getTimeInMillis());
    tpd.setCloseOnSingleTapMinute(false);
    tpd.show(getFragmentManager(), TAG);
    tvCountdown.setTime(config.getCountdownTimestamp());
  }
  private void initUI() {
    ImageView ivBackground = (ImageView) mRootLayout.findViewById(R.id.iv_background);
    WallpaperUtils.showWallpaper(getActivity(), ivBackground, mDao.getCurrent());

    tvCountdownContent = (TextView) mRootLayout.findViewById(R.id.tv_countdown_content);
    tvCountdown = (CountdownTextView) mRootLayout.findViewById(R.id.tv_countdown_time);

    tvCountdownContent.setText(config.getCountdownContent());
    tvCountdown.setTime(config.getCountdownTimestamp());
    tvCountdownContent.setTextColor(config.getWidgetCountdownColor());
    tvCountdown.setTextColor(config.getWidgetCountdownColor());
    tvCountdown.setOnClickListener(this);
    tvCountdownContent.setOnClickListener(this);
    mRootLayout.findViewById(R.id.tv_enable).setOnClickListener(this);
    mRootLayout.findViewById(R.id.tv_disable).setOnClickListener(this);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    config = ConfigManager.getInstance(getActivity());
    mDao = WallpaperDAO.getInstance(getActivity());

    calendar = Calendar.getInstance();
  }
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   switch (requestCode) {
     case Constants.RequestCode.REQUEST_CODE_CHAGE_TEXT_TITLE:
       if (resultCode == Activity.RESULT_OK && data != null) {
         String content = data.getStringExtra(Constants.StringConstant.PARAMS_DATA);
         int color = data.getIntExtra(Constants.StringConstant.PARAMS_DATA1, Color.WHITE);
         config.setCountdownContent(content);
         config.setWidgetCountdownColor(color);
         tvCountdownContent.setText(content);
         tvCountdownContent.setTextColor(color);
         tvCountdown.setTextColor(color);
       }
       break;
     default:
       break;
   }
 }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.tv_enable:
        config.setWidgetCountdownEnable(true);
        getActivity().finish();
        break;
      case R.id.tv_disable:
        config.setWidgetCountdownEnable(false);
        getActivity().finish();
        break;
      case R.id.tv_countdown_content:
        Intent intent = new Intent(getActivity(), CommentActivity.class);
        intent.putExtra(Constants.StringConstant.PARAMS_DATA, config.getCountdownContent());
        intent.putExtra(Constants.StringConstant.PARAMS_DATA1, config.getWidgetCountdownColor());
        startActivityForResult(intent, Constants.RequestCode.REQUEST_CODE_CHAGE_TEXT_TITLE);
        break;
      case R.id.tv_countdown_time:
        calendar.setTimeInMillis(config.getCountdownTimestamp());
        dpd =
            DatePickerDialog.newInstance(
                this,
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH),
                false);
        tpd =
            TimePickerDialog.newInstance(
                this,
                calendar.get(Calendar.HOUR_OF_DAY),
                calendar.get(Calendar.MINUTE),
                false,
                false);

        dpd.setYearRange(Constants.CommonValue.FIRST_YEAR, Constants.CommonValue.LAST_YEAR);
        dpd.setCloseOnSingleTapDay(false);
        dpd.show(getFragmentManager(), TAG);
        break;
      default:
        break;
    }
  }
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btn_reset:
       password = "";
       mBtnDone.setEnabled(false);
       break;
     case R.id.btn_done:
       mConfig.setPatternPassword(MD5Utils.MD5(password));
       getActivity().setResult(Activity.RESULT_OK);
       getActivity().finish();
       break;
     default:
       break;
   }
 }
 @Override
 public void run() {
   if (password.length() > 4) {
     password = password.substring(0, 4);
   }
   if (password.length() == 4) {
     if (mConfig.getDigitalPassword().equals(MD5Utils.MD5(password))) {
       if (!getActivity().isFinishing()) {
         getActivity().finish();
         Intent intent = new Intent(getActivity(), CreatePasswordActivity.class);
         intent.putExtra(
             Constants.StringConstant.PARAMS_DATA, Constants.LockerMode.LOCK_MODE_DIGIT);
         startActivity(intent);
       }
     } else {
       indicator.passwordWrong();
       password = "";
     }
   }
 }
 @Override
 public void run() {
   if (password.length() > 4) {
     password = password.substring(0, 4);
   }
   if (password.length() == 4) {
     if (TextUtils.equals(MD5Utils.MD5(password), config.getDigitalPassword())) {
       if (isLaunchCamera) {
         AppUtils.launchCamera(getContext());
       } else if (notification != null) {
         try {
           notification.contentIntent.send();
         } catch (CanceledException e) {
           e.printStackTrace();
         }
       }
       LockerManager.getInstance(getContext()).unlock();
     } else {
       indicator.passwordWrong();
       password = "";
     }
   }
 }