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

@ -50,26 +50,22 @@ Drawable*AnalogClock::getClockDrawable(int id){
case MINUTE:return mMinuteHand;
case HOUR :return mHourHand;
default:return nullptr;
}
}
}
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;
}
return View::onMessage(msg,wp,lp);
}*/
postDelayed(mRunner,800);
};
postDelayed(mRunner,800);
}
void AnalogClock::onDraw(Canvas&canvas){
View::onDraw(canvas);

View File

@ -5,13 +5,14 @@ namespace cdroid{
class AnalogClock:public View{
private:
int mSeconds;
int mSeconds;
int mMinutes;
int mHour;
Drawable* mHourHand;
Drawable* mMinuteHand;
Drawable* mSecondHand;
Drawable* mSecondHand;
Drawable* mDial;
Runnable mRunner;
protected:
void onAttached();
void onDraw(Canvas&canvas)override;