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 { // obtain handler
MessageHandler* handler = messageEnvelope.handler; MessageHandler* handler = messageEnvelope.handler;
Message message = messageEnvelope.message; Message message = messageEnvelope.message;
mMessageEnvelopes.erase(mMessageEnvelopes.begin());//removeAt(0); mMessageEnvelopes.pop_front();
mSendingMessage = true; mSendingMessage = true;
mLock.unlock(); mLock.unlock();

View File

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

View File

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