本文整理汇总了Java中com.google.android.agera.Updatable类的典型用法代码示例。如果您正苦于以下问题:Java Updatable类的具体用法?Java Updatable怎么用?Java Updatable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Updatable类属于com.google.android.agera包,在下文中一共展示了Updatable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public void run() {
long c = get();
Updatable u = actual;
for (;;) {
long d = coalesce ? 1 : c;
for (long i = 0; i < d; i++) {
if (cancelled) {
return;
}
u.update();
}
c = addAndGet(-c);
if (c == 0L) {
break;
}
}
}
示例2: addUpdatable
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public void addUpdatable(@NonNull Updatable updatable) {
UpdatableAsSubscriber s;
synchronized (this) {
if (updatables == null) {
throw new IllegalStateException("The source Rx Observable has terminated");
}
if (updatables.containsKey(updatable)) {
throw new IllegalStateException("The Updatable is already added");
}
s = new UpdatableAsSubscriber(updatable);
updatables.put(updatable, s);
}
source.unsafeSubscribe(s);
}
示例3: onLoadData
import com.google.android.agera.Updatable; //导入依赖的package包/类
protected void onLoadData() {
final MessageStore store = MessageStore.messagesStore(getApplicationContext());
messagesRepository = store.getSimpleMessagesRepository();
// TODO: 16/8/9 double notify!
dataUpdatable = new Updatable() {
@Override public void update() {
messages.addAll(messagesRepository.get());
presenter.notifyDataSetChanged();
// Maybe we have another graceful way
messagesRepository.removeUpdatable(dataUpdatable);
dataUpdatable = null;
}
};
messagesRepository.addUpdatable(dataUpdatable);
messageFactory = new MessageFactory.Builder()
.setFromUserId(TimeKey.userId)
.setToUserId(provideServiceId())
.build();
MessageFactory messageFactory4Service = new MessageFactory.Builder()
.setFromUserId(provideServiceId())
.setToUserId(TimeKey.userId)
.build();
TextContent welcome = new TextContent("Can I help you?");
messages.add(messageFactory4Service.newMessage(welcome));
}
示例4: onAdd
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
protected void onAdd(@NonNull Updatable updatable, @NonNull Updatable wrapper) {
for (int i = 0; i < count; i++) {
if (isListening(updatable)) {
updatable.update();
}
}
}
示例5: initData
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override protected void initData() {
SaveVolley saveVolley = SaveVolleys
.<GankData>request(TEST_URL)
.method(Method.GET)
.parseStyle(FASTJSON)
.classOf(GankData.class)
.createRequest()
.context(this)
.compile();
final Repository<GankResultData> repository = Repositories
.repositoryWithInitialValue(INITIAL_VALUE)
.observe(saveVolley.getReservoir())
.onUpdatesPerLoop()
.goTo(executor)
.attemptGetFrom(saveVolley.getReservoir())
.orSkip()
.thenAttemptTransform(new Function<Object, Result<GankResultData>>() {
/**
* Returns the result of applying this function to {@code input}.
*/
@NonNull @Override public Result<GankResultData> apply(@NonNull Object input) {
if (input instanceof GankData) {
return Result.success(((GankData) input).results.get(0));
} else if (input instanceof VolleyError) {
return Result.failure((VolleyError) input);
}
return Result.failure();
}
})
.orSkip()
.compile();
repository.addUpdatable(new Updatable() {
@Override public void update() {
getContentText.setText(repository.get().toString());
}
});
}
示例6: initData
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override protected void initData() {
SaveVolley saveVolley = SaveVolleys
.<GankData>request(TEST_URL)
.method(Method.GET)
.parseStyle(GSON)
.classOf(GankData.class)
.createRequest()
.context(this)
.compile();
final Repository<GankResultData> repository = Repositories.repositoryWithInitialValue(
INITIAL_VALUE)
.observe(saveVolley.getReservoir())
.onUpdatesPerLoop()
.goTo(executor)
.attemptGetFrom(saveVolley.getReservoir())
.orSkip()
.thenAttemptTransform(new Function<Object, Result<GankResultData>>() {
/**
* Returns the result of applying this function to {@code input}.
*/
@NonNull @Override public Result<GankResultData> apply(@NonNull Object input) {
if (input instanceof GankData) {
return Result.success(((GankData) input).results.get(0));
} else if (input instanceof VolleyError) {
return Result.failure((VolleyError) input);
}
return Result.failure();
}
})
.orSkip()
.compile();
repository.addUpdatable(new Updatable() {
@Override public void update() {
getContentText.setText(repository.get().toString());
}
});
}
示例7: addUpdatable
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public final void addUpdatable(@NonNull Updatable updatable) {
U wrapper = createWrapper(updatable);
if (map.putIfAbsent(updatable, wrapper) != null) {
throw new IllegalStateException("The updatable instance has been already added");
}
onAdd(updatable, wrapper);
}
示例8: removeUpdatable
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public final void removeUpdatable(@NonNull Updatable updatable) {
U wrapper = map.remove(updatable);
if (wrapper == null) {
throw new IllegalStateException("The updatable is (no longer) registered with this Observable");
}
onRemove(updatable, wrapper);
}
示例9: initData
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override protected void initData() {
SaveVolley saveVolley = SaveVolleys
.<GankData>request(TEST_URL)
.method(Method.GET)
.parseStyle(GSON)
.classOf(GankData.class)
.createRequest()
.context(this)
.compile();
final Repository<GankResultData> repository = Repositories
.repositoryWithInitialValue(INITIAL_VALUE)
.observe(saveVolley.getReservoir())
.onUpdatesPerLoop()
.goTo(executor)
.attemptGetFrom(saveVolley.getReservoir())
.orSkip()
.thenAttemptTransform(new Function<Object, Result<GankResultData>>() {
/**
* Returns the result of applying this function to {@code input}.
*/
@NonNull @Override public Result<GankResultData> apply(@NonNull Object input) {
if (input instanceof GankData) {
return Result.success(((GankData) input).results.get(0));
} else if (input instanceof VolleyError) {
return Result.failure((VolleyError) input);
}
return Result.failure();
}
})
.orSkip()
.compile();
repository.addUpdatable(new Updatable() {
@Override public void update() {
getContentText.setText(repository.get().toString());
}
});
}
示例10: TakeUntilUpdatable
import com.google.android.agera.Updatable; //导入依赖的package包/类
TakeUntilUpdatable(Updatable actual, AgeraTakeUntil parent, Observable other) {
this.actual = actual;
this.parent = parent;
this.other = other;
this.otherUpdatable = new Updatable() {
@Override
public void update() {
updateOther();
}
};
}
示例11: onAdd
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
protected void onAdd(@NonNull final Updatable updatable, @NonNull Trampoline wrapper) {
wrapper.offer(new Runnable() {
@Override
public void run() {
source.addUpdatable(updatable);
}
});
}
示例12: onRemove
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
protected void onRemove(@NonNull final Updatable updatable, @NonNull Trampoline wrapper) {
wrapper.offer(new Runnable() {
@Override
public void run() {
source.removeUpdatable(updatable);
}
});
}
示例13: addUpdatable
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public void addUpdatable(@NonNull final Updatable updatable) {
handler.post(new Runnable() {
@Override
public void run() {
source.addUpdatable(updatable);
}
});
}
示例14: removeUpdatable
import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public void removeUpdatable(@NonNull final Updatable updatable) {
handler.post(new Runnable() {
@Override
public void run() {
source.removeUpdatable(updatable);
}
});
}
示例15: createWrapper
import com.google.android.agera.Updatable; //导入依赖的package包/类
@NonNull
@Override
protected FlatMapUpdatable createWrapper(@NonNull Updatable updatable) {
Supplier<Observable> supplier = new Supplier<Observable>() {
int i;
@NonNull
@Override
public Observable get() {
return sources[i++];
}
};
return new FlatMapUpdatable(updatable, supplier);
}