change analogclock's timer message to runnable

This commit is contained in:
侯歌 2021-08-05 18:40:10 +08:00
parent c42bc74405
commit 01f9f55aa5
3 changed files with 10 additions and 13 deletions

View File

@ -233,7 +233,7 @@ Done: ;
{ // obtain handler
MessageHandler* handler = messageEnvelope.handler;
Message message = messageEnvelope.message;
mMessageEnvelopes.erase(mMessageEnvelopes.begin());//removeAt(0);
mMessageEnvelopes.pop_front();
mSendingMessage = true;
mLock.unlock();

View File

@ -54,22 +54,18 @@ Drawable*AnalogClock::getClockDrawable(int id){
}
void AnalogClock::onAttached(){
//sendMessage(WM_TIMER,0,0,1000);
}
/*bool AnalogClock::onMessage(DWORD msg,DWORD wp,ULONG lp){
if(msg==WM_TIMER){
mRunner=[&](){
std::time_t t = std::time(NULL);
struct std::tm when= *std::localtime(&t);
std::get_time(&when,"%R");
mHour=when.tm_hour;
mMinutes=when.tm_min;
mSeconds=when.tm_sec;
//sendMessage(msg,wp,lp,1000);
invalidate(nullptr);
return true;
postDelayed(mRunner,800);
};
postDelayed(mRunner,800);
}
return View::onMessage(msg,wp,lp);
}*/
void AnalogClock::onDraw(Canvas&canvas){
View::onDraw(canvas);

View File

@ -12,6 +12,7 @@ private:
Drawable* mMinuteHand;
Drawable* mSecondHand;
Drawable* mDial;
Runnable mRunner;
protected:
void onAttached();
void onDraw(Canvas&canvas)override;