コード例 #1
0
    @Override
    public void onReceive(Context context, Intent intent) {
      String action = intent.getAction();
      if (action.equals(Intent.ACTION_TIME_TICK)) {
        //				view.setDateTime();
        LogUtil.info(
            "---------isOff="
                + ConfigManager.getBooleanValue(getApplicationContext(), "SCREEN_OFF", false));
        if (ConfigManager.getBooleanValue(getApplicationContext(), "SCREEN_OFF", false)) {
          //					view.stopDraw();
        }

        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        mTvDate.setText(df.format(new Date()));
        mTvWeek.setText(mWeekDay[DateUtil.getWeekOfDate(new Date()) - 1]);
        df = new SimpleDateFormat("HH:mm");
        mTvTime.setText(df.format(new Date()));
      }
    }
コード例 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //		view = new UnlockView(this, this);
    //		setContentView(view);

    mLockView = View.inflate(this, R.layout.activity_unlock, null);
    mLockLayer = new LockLayer(this);
    mLockLayer.setLockView(mLockView);
    mLockLayer.lock();
    PullDoorView.setHandler(mHandler);

    mTvTime = (TextView) mLockView.findViewById(R.id.tv_unlock_time);
    mTvLunar = (TextView) mLockView.findViewById(R.id.tv_unlock_lunar);
    mTvDate = (TextView) mLockView.findViewById(R.id.tv_unlock_date);
    mTvWeek = (TextView) mLockView.findViewById(R.id.tv_unlock_week);
    mTvCallNum = (TextView) mLockView.findViewById(R.id.tv_unlock_unread_call_num);
    mTvMessageNum = (TextView) mLockView.findViewById(R.id.tv_unlock_unread_message_num);
    mLlMissCall = (LinearLayout) mLockView.findViewById(R.id.ll_unlock_unread_call);
    mLlUnReadMessage = (LinearLayout) mLockView.findViewById(R.id.ll_unlock_unread_message);
    mIvArrow = (ImageView) mLockView.findViewById(R.id.iv_unlock_arrow);

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    mTvDate.setText(df.format(new Date()));
    mTvWeek.setText(mWeekDay[DateUtil.getWeekOfDate(new Date()) - 1]);
    df = new SimpleDateFormat("HH:mm");
    mTvTime.setText(df.format(new Date()));

    mTvLunar.setText(TimeUtils.getLunarInfoYear());

    int missCall = readMissCall();
    int unReadMessage = readUnReadMessage();

    if (missCall > 0) {
      mLlMissCall.setVisibility(View.VISIBLE);
      mTvCallNum.setText("" + missCall);
    }

    if (unReadMessage > 0) {
      mLlUnReadMessage.setVisibility(View.VISIBLE);
      mTvMessageNum.setText("" + unReadMessage);
    }

    mIvArrow.setImageResource(R.anim.unlock_slider_arrow);
    mAnimationArrow = (AnimationDrawable) mIvArrow.getDrawable();
    mAnimationArrow.start();

    Intent intentService = new Intent(this, LockService.class);
    this.startService(intentService);

    receiver = new HomeKeyEventBroadCastReceiver();

    IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);

    registerReceiver(receiver, intentFilter);

    registerTimeChange();

    onoffReceivce = new ScrrenOnOffReceiver();

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    registerReceiver(onoffReceivce, filter);

    // 电话监听
    tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    phoneStateListener = new MyPhoneStateListener();
    tm.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);

    missManager = new MissCallAndSmsManage(this, newMmsContentObserver);
    missManager.registerObserver();
  }