use of org.androidannotations.annotations.UiThread in project SunDay by iQuick.
the class WeatherUpdateService method updateTime.
@UiThread
void updateTime() {
Date date = new Date();
// 定义SimpleDateFormat对象
remoteView.setTextViewText(R.id.tv_provider_time, DateUtil.getCurTime());
remoteView.setTextViewText(R.id.tv_provider_week, DateUtil.getCurWeek());
remoteView.setOnClickPendingIntent(R.id.rl_provider_widget, PendingIntent.getActivity(this, 0, new Intent(this, MainActivity_.class), 0));
remoteView.setOnClickPendingIntent(R.id.ll_provider_right, PendingIntent.getBroadcast(this, 1, new Intent(ACTION_NEXT_CITY), 0));
ComponentName componentName = new ComponentName(getApplication(), WeatherWidget.class);
AppWidgetManager.getInstance(getApplication()).updateAppWidget(componentName, remoteView);
}
use of org.androidannotations.annotations.UiThread in project SunDay by iQuick.
the class WeatherUpdateService method updateWeather.
@UiThread
void updateWeather() {
if (mSunModel != null) {
if (mSunModel.realtime.cityName != null)
remoteView.setTextViewText(R.id.tv_provider_city, mSunModel.realtime.cityName);
remoteView.setTextViewText(R.id.tv_provider_temp, mSunModel.realtime.weather.temp + "℃");
remoteView.setTextViewText(R.id.tv_provider_weather, mSunModel.realtime.weather.info);
remoteView.setImageViewResource(R.id.iv_provider_weather, WeatherUtil.getIcon(mSunModel.realtime.weather.info));
}
ComponentName componentName = new ComponentName(getApplication(), WeatherWidget.class);
AppWidgetManager.getInstance(getApplication()).updateAppWidget(componentName, remoteView);
}
use of org.androidannotations.annotations.UiThread in project androidannotations by androidannotations.
the class UiThreadHandler method validate.
@Override
public void validate(Element element, ElementValidation valid) {
super.validate(element, valid);
coreValidatorHelper.usesEnqueueIfHasId(element, valid);
UiThread annotation = element.getAnnotation(UiThread.class);
long delay = annotation.delay();
UiThread.Propagation propagation = annotation.propagation();
if (delay != 0 && propagation == UiThread.Propagation.REUSE) {
valid.addWarning("propagation=REUSE is ignored when using a delay");
}
}
use of org.androidannotations.annotations.UiThread in project androidannotations by androidannotations.
the class UiThreadHandler method process.
@Override
public void process(Element element, EComponentHolder holder) throws Exception {
ExecutableElement executableElement = (ExecutableElement) element;
JMethod delegatingMethod = codeModelHelper.overrideAnnotatedMethod(executableElement, holder);
JBlock previousBody = codeModelHelper.removeBody(delegatingMethod);
JDefinedClass anonymousRunnableClass = codeModelHelper.createDelegatingAnonymousRunnableClass(previousBody);
UiThread annotation = element.getAnnotation(UiThread.class);
long delay = annotation.delay();
UiThread.Propagation propagation = annotation.propagation();
if (delay == 0 && propagation == UiThread.Propagation.REUSE) {
// Put in the check for the UI thread.
addUIThreadCheck(delegatingMethod, previousBody, holder);
}
delegatingMethod.body().add(//
getJClass(UiThreadExecutor.class).staticInvoke(METHOD_RUN_TASK).arg(//
annotation.id()).arg(//
_new(anonymousRunnableClass)).arg(lit(delay)));
}
use of org.androidannotations.annotations.UiThread in project androidannotations by androidannotations.
the class MyActivity method showNotificationsDelayed.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@UiThread(delay = 2000)
void showNotificationsDelayed() {
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);
Notification notification = new Notification.Builder(this).setSmallIcon(R.drawable.icon).setContentTitle("My notification").setContentText("Hello, World!").setContentIntent(contentIntent).getNotification();
notificationManager.notify(1, notification);
}
Aggregations