本文整理汇总了Java中com.google.android.agera.Repository类的典型用法代码示例。如果您正苦于以下问题:Java Repository类的具体用法?Java Repository怎么用?Java Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Repository类属于com.google.android.agera包,在下文中一共展示了Repository类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: prepare
import com.google.android.agera.Repository; //导入依赖的package包/类
@SuppressWarnings("unchecked") private void prepare() {
translateReaction = Reservoirs.<Translation>reactionReservoir();
Repository<Result<String>> translationRepo = repositoryWithInitialValue(
Result.<String>absent())
.observe(translateReaction)
.onUpdatesPerLoop()
.attemptGetFrom(translateReaction).orSkip()
.goTo(networkExecutor)
.check(input -> input.getStep() == OnConfirm)
.orEnd((Function<Translation, Result<String>>) input -> {
Log.e("check-confirm", input.toString());
return Result.failure();
})
.mergeIn(YOU_DAO, current2UrlMerger())
.attemptTransform(urlToResponse())
.orEnd(Result::failure)
.goTo(calculationExecutor)
.transform(youdaoResponseToResult())
.goLazy()
.thenTransform(input -> input)
.onDeactivation(SEND_INTERRUPT)
.compile();
translationRepo.addUpdatable(() -> translationRepo.get()
.ifSucceededSendTo(this::handleConfirm)
.ifFailedSendTo(errorHandler()));
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:27,代码来源:TransformService.java
示例2: initData
import com.google.android.agera.Repository; //导入依赖的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());
}
});
}
开发者ID:CaMnter,项目名称:SaveVolley,代码行数:40,代码来源:Okhttp3AgeraGsonActivity.java
示例3: initData
import com.google.android.agera.Repository; //导入依赖的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());
}
});
}
开发者ID:CaMnter,项目名称:SaveVolley,代码行数:40,代码来源:HurlAgeraGsonActivity.java
示例4: initData
import com.google.android.agera.Repository; //导入依赖的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());
}
});
}
开发者ID:CaMnter,项目名称:SaveVolley,代码行数:40,代码来源:HurlAgeraFastjsonActivity.java
示例5: async
import com.google.android.agera.Repository; //导入依赖的package包/类
@NonNull public static Repository<Result<String>> async(Reservoir<String> reaction) {
return repositoryWithInitialValue(Result.<String>absent())
.observe(reaction)
.onUpdatesPerLoop()
.attemptGetFrom(reaction).orSkip()
.goTo(networkExecutor)
.getFrom(YIN)
.attemptTransform(urlToResponse())
.orEnd(Result::failure)
.goTo(calculationExecutor)
.thenTransform(yinResponseToResult())
.onDeactivation(SEND_INTERRUPT)
.compile();
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:15,代码来源:YinRequests.java
示例6: sync
import com.google.android.agera.Repository; //导入依赖的package包/类
@NonNull public static Repository<Result<String>> sync() {
return repositoryWithInitialValue(Result.<String>absent())
.observe()
.onUpdatesPerLoop()
.getFrom(YIN)
.attemptTransform(urlToResponse())
.orEnd(Result::failure)
.thenTransform(yinResponseToResult())
.onDeactivation(SEND_INTERRUPT)
.compile();
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:12,代码来源:YinRequests.java
示例7: async
import com.google.android.agera.Repository; //导入依赖的package包/类
@NonNull public static Repository<Result<String>> async(Reservoir<String> reaction) {
return repositoryWithInitialValue(Result.<String>absent())
.observe(reaction)
.onUpdatesPerLoop()
.attemptGetFrom(reaction).orSkip()
.goTo(networkExecutor)
.getFrom(URL)
.attemptTransform(urlToResponse())
.orEnd(Result::failure)
.goTo(calculationExecutor)
.thenTransform(mapResponse())
.onDeactivation(SEND_INTERRUPT)
.compile();
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:15,代码来源:AndroidSDKRequests.java
示例8: sync
import com.google.android.agera.Repository; //导入依赖的package包/类
@NonNull public static Repository<Result<String>> sync() {
return repositoryWithInitialValue(Result.<String>absent())
.observe()
.onUpdatesPerLoop()
.getFrom(URL)
.attemptTransform(urlToResponse())
.orEnd(Result::failure)
.thenTransform(mapResponse())
.onDeactivation(SEND_INTERRUPT)
.compile();
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:12,代码来源:AndroidSDKRequests.java
示例9: prepare
import com.google.android.agera.Repository; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override public void prepare() {
echoReaction = Reservoirs.<String>reactionReservoir();
Repository<String> echoRepo = repositoryWithInitialValue(empty())
.observe(echoReaction)
.onUpdatesPerLoop()
.thenAttemptGetFrom(echoReaction).orSkip()
.notifyIf((last, cur) -> !cur.isEmpty())
.onDeactivation(SEND_INTERRUPT)
.compile();
getObservableHelper().addToObservable(echoRepo,
() -> getService().newInReceiver().accept(echoRepo.get()));
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:14,代码来源:EchoDelegate.java
示例10: prepare
import com.google.android.agera.Repository; //导入依赖的package包/类
@Override public void prepare() {
yinReaction = Reservoirs.<String>reactionReservoir();
Repository<Result<String>> yinRepo = YinRequests.async(yinReaction);
getObservableHelper().addToObservable(yinRepo, () -> yinRepo.get()
.ifSucceededSendTo(getService().newInReceiver())
.ifFailedSendTo(getService().errorHandler()));
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:8,代码来源:YinDelegate.java
示例11: prepare
import com.google.android.agera.Repository; //导入依赖的package包/类
@Override public void prepare() {
reaction = Reservoirs.<String>reactionReservoir();
Repository<Result<String>> sdkRepo = AndroidSDKRequests.async(reaction);
getObservableHelper().addToObservable(sdkRepo, () -> sdkRepo.get()
.ifSucceededSendTo(getService().newInReceiver())
.ifFailedSendTo(getService().errorHandler()));
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:8,代码来源:AndroidSDKDelegate.java
示例12: NotesStore
import com.google.android.agera.Repository; //导入依赖的package包/类
private NotesStore(@NonNull final Repository<List<NoteGroup>> notesRepository,
@NonNull final Receiver<SqlInsertRequest> insert,
@NonNull final Receiver<SqlUpdateRequest> update,
@NonNull final Receiver<SqlDeleteRequest> delete,
@NonNull final SqlDatabaseSupplier databaseSupplier) {
this.insert = insert;
this.update = update;
this.delete = delete;
this.notesRepository = notesRepository;
this.databaseSupplier = databaseSupplier;
}
开发者ID:google,项目名称:agera,代码行数:12,代码来源:NotesStore.java
示例13: RepositoryPart
import com.google.android.agera.Repository; //导入依赖的package包/类
private RepositoryPart(
@NonNull final Repository repository,
@NonNull final RepositoryPresenter presenter) {
this.repository = repository;
this.presenter = presenter;
this.data = repository.get();
}
开发者ID:google,项目名称:agera,代码行数:8,代码来源:RepositoryAdapter.java
示例14: MessageStore
import com.google.android.agera.Repository; //导入依赖的package包/类
private MessageStore(@NonNull final Repository<List<Message>> messagesRepository,
@NonNull final Receiver<StoreRequest> writeRequestReceiver) {
this.messagesRepository = messagesRepository;
this.writeRequestReceiver = writeRequestReceiver;
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:6,代码来源:MessageStore.java
示例15: getSimpleMessagesRepository
import com.google.android.agera.Repository; //导入依赖的package包/类
@NonNull
public Repository<List<Message>> getSimpleMessagesRepository() {
return messagesRepository;
}
开发者ID:drakeet,项目名称:TimeMachine,代码行数:5,代码来源:MessageStore.java
示例16: getNotesRepository
import com.google.android.agera.Repository; //导入依赖的package包/类
@NonNull
Repository<List<NoteGroup>> getNotesRepository() {
return notesRepository;
}
开发者ID:google,项目名称:agera,代码行数:5,代码来源:NotesStore.java
示例17: add
import com.google.android.agera.Repository; //导入依赖的package包/类
/**
* Specifies that the {@link RepositoryAdapter} being built should present the given
* {@code repository} next (after all previously added repositories, items and static layouts),
* using the given {@code presenter} for any presentation logic.
*
* <p>When the {@code RepositoryAdapter} is active (between {@link #startObserving()} and
* {@link #stopObserving()}), updates from the {@code repository} will cause the data to be
* reloaded, and the {@code presenter} may be asked to produce a sequence of fine-grained events
* capturing the change of data. For mor details, see {@link RepositoryPresenter#getUpdates}.
*
* @param repository The repository to be presented. This can be the same as a previously added
* repository; this makes the resulting {@link RepositoryAdapter} present the same data in
* different positions and/or different ways.
* @param presenter The repository presenter associated with the {@code repository} at this
* position of the {@link RepositoryAdapter}.
* @return This instance, for chaining.
*/
@NonNull
public <T> Builder add(@NonNull final Repository<T> repository,
@NonNull final RepositoryPresenter<T> presenter) {
parts.add(new RepositoryPart(repository, presenter));
return this;
}
开发者ID:google,项目名称:agera,代码行数:24,代码来源:RepositoryAdapter.java
注:本文中的com.google.android.agera.Repository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论