本文整理汇总了Java中com.contentful.vault.Vault类的典型用法代码示例。如果您正苦于以下问题:Java Vault类的具体用法?Java Vault怎么用?Java Vault使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vault类属于com.contentful.vault包,在下文中一共展示了Vault类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: requestModels
import com.contentful.vault.Vault; //导入依赖的package包/类
public void requestModels() {
final CDAClient client = CDAClient.builder()
.setSpace(VRSpace.SPACE_ID)
.setToken(VRSpace.ACCESS_TOKEN)
.build();
vault.requestSync(client);
Vault.observeSyncResults()
.subscribeOn(Schedulers.io())
.flatMap(new Func1<SyncResult, Observable<Product>>() {
@Override public Observable<Product> call(SyncResult syncResult) {
return vault.observe(Product.class).order(Product$Fields.NAME).all();
}
})
.flatMap(new CreateProtoModelAndRenderSign(applicationContext))
.flatMap(new DownloadMeshAsset(applicationContext))
.flatMap(new DownloadTextureAsset(applicationContext))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new EnqueueProtoModel());
}
开发者ID:contentful-labs,项目名称:contentful-cardboard,代码行数:22,代码来源:ContentfulInteractor.java
示例2: bind
import com.contentful.vault.Vault; //导入依赖的package包/类
public void bind(final Listener listener) {
if (listener == null) {
throw new IllegalArgumentException("Listener cannot be null!");
}
vaultSyncSubscription = Vault.observeSyncResults()
.subscribeOn(Schedulers.io())
.subscribe(new Action1<SyncResult>() {
@Override public void call(SyncResult syncResult) {
if (syncResult.isSuccessful()) {
requestEvents(listener);
} else {
listener.onError(syncResult.error());
}
}
});
}
开发者ID:gdg-berlin-android,项目名称:gdg-events-app,代码行数:18,代码来源:EventListInteractor.java
示例3: performLoad
import com.contentful.vault.Vault; //导入依赖的package包/类
@Override protected Result performLoad() {
List<Product> products = Vault.with(App.get(), CatalogueSpace.class).fetch(Product.class).all();
if (categoryRemoteId == null) {
return new Result(products, null);
}
List<Product> filtered = new ArrayList<>();
Category targetCategory = null;
for (Product product : products) {
for (Category category : product.categories()) {
if (categoryRemoteId.equals(category.remoteId())) {
filtered.add(product);
targetCategory = category;
break;
}
}
}
return new Result(filtered, targetCategory);
}
开发者ID:contentful,项目名称:product-catalogue-android,代码行数:20,代码来源:ProductListLoader.java
示例4: getCategoriesWithCount
import com.contentful.vault.Vault; //导入依赖的package包/类
private Map<Category, Integer> getCategoriesWithCount() {
Vault vault = Vault.with(App.get(), CatalogueSpace.class);
List<Category> categories = vault.fetch(Category.class).all();
Map<Category, Integer> res = new HashMap<>();
for (Category category : categories) {
SQLiteDatabase db = vault.getReadableDatabase();
int count = 0;
Cursor cursor = db.rawQuery(QUERY_CATEGORY_COUNT, new String[] { category.remoteId() });
try {
if (cursor.moveToFirst()) {
count = cursor.getInt(0);
}
} finally {
cursor.close();
}
res.put(category, count);
}
return res;
}
开发者ID:contentful,项目名称:product-catalogue-android,代码行数:22,代码来源:NavLoader.java
示例5: observeSyncResults
import com.contentful.vault.Vault; //导入依赖的package包/类
@Test public void observeSyncResults() throws Exception {
enqueue("demo/space.json");
enqueue("demo/types.json");
enqueue("demo/initial.json");
TestSubscriber<SyncResult> subscriber = new TestSubscriber<>();
Vault.observeSyncResults().subscribe(subscriber);
subscriber.assertNoValues();
sync();
subscriber.assertNoErrors();
List<SyncResult> events = subscriber.values();
assertThat(events).hasSize(1);
assertThat(events.get(0).isSuccessful()).isTrue();
assertThat(events.get(0).spaceId()).isEqualTo("cfexampleapi");
}
开发者ID:contentful,项目名称:vault,代码行数:18,代码来源:ObserveTest.java
示例6: performLoad
import com.contentful.vault.Vault; //导入依赖的package包/类
@Override protected Result performLoad() {
Vault vault = Vault.with(getContext(), BlogSpace.class);
List<Post> posts = vault.fetch(Post.class).all();
if (authorRemoteId == null) {
return new Result(posts, null);
}
Author author = vault.fetch(Author.class)
.where("remote_id = ?", authorRemoteId)
.first();
List<Post> filtered = new ArrayList<>();
if (author != null) {
for (Post post : posts) {
if (postAuthorMatches(post, authorRemoteId)) {
filtered.add(post);
}
}
}
return new Result(filtered, author);
}
开发者ID:contentful,项目名称:blog-app-android,代码行数:23,代码来源:PostListLoader.java
示例7: createVault
import com.contentful.vault.Vault; //导入依赖的package包/类
private void createVault() {
if (vault == null) {
vault = Vault.with(this, EventSpace.class);
vault.requestSync(CDAClient
.builder()
.setToken(EventSpace.DELIVERY_API_KEY)
.setSpace(EventSpace.SPACE_ID)
.setCallFactory(createCustomCallFactory())
.build());
}
}
开发者ID:gdg-berlin-android,项目名称:gdg-events-app,代码行数:12,代码来源:MainActivity.java
示例8: setupReloadReceiver
import com.contentful.vault.Vault; //导入依赖的package包/类
private void setupReloadReceiver(boolean register) {
if (register) {
if (reloadReceiver == null) {
reloadReceiver = new BroadcastReceiver() {
@Override public void onReceive(Context context, Intent intent) {
getSupportLoaderManager().restartLoader(LOADER_ID, null, MainActivity.this);
}
};
}
registerReceiver(reloadReceiver, new IntentFilter(Vault.ACTION_SYNC_COMPLETE));
} else {
unregisterReceiver(reloadReceiver);
}
}
开发者ID:contentful,项目名称:gallery-app-android,代码行数:16,代码来源:MainActivity.java
示例9: requestSync
import com.contentful.vault.Vault; //导入依赖的package包/类
public static void requestSync(boolean invalidate) {
Vault.with(get(), GallerySpace.class).requestSync(
SyncConfig.builder()
.setClient(ClientProvider.get())
.setInvalidate(invalidate)
.build());
}
开发者ID:contentful,项目名称:gallery-app-android,代码行数:8,代码来源:App.java
示例10: requestSync
import com.contentful.vault.Vault; //导入依赖的package包/类
public static void requestSync(boolean invalidate) {
Vault.with(get(), CatalogueSpace.class).requestSync(
SyncConfig.builder()
.setClient(ClientProvider.get())
.setInvalidate(invalidate)
.build());
}
开发者ID:contentful,项目名称:product-catalogue-android,代码行数:8,代码来源:App.java
示例11: testUpgrade
import com.contentful.vault.Vault; //导入依赖的package包/类
@Test public void testUpgrade() throws Exception {
Vault v = vault;
v.getReadableDatabase();
v.releaseAll();
v = Vault.with(RuntimeEnvironment.application, Sp2.class);
v.getReadableDatabase();
}
开发者ID:contentful,项目名称:vault,代码行数:8,代码来源:UpgradeTest.java
示例12: failsInvalidSpaceClass
import com.contentful.vault.Vault; //导入依赖的package包/类
@Test public void failsInvalidSpaceClass() throws Exception {
try {
Vault.with(RuntimeEnvironment.application, Object.class);
fail();
} catch (RuntimeException e) {
assertThat(e.getMessage()).isEqualTo(
"Cannot find generated class for space: java.lang.Object");
}
}
开发者ID:contentful,项目名称:vault,代码行数:10,代码来源:VaultTest.java
示例13: onCreate
import com.contentful.vault.Vault; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
ButterKnife.bind(this);
adapter = createAdapter();
createReceivers();
registerReceiver(reloadReceiver, new IntentFilter(Vault.ACTION_SYNC_COMPLETE));
initList();
initSwipeRefresh();
initLoader();
}
开发者ID:contentful,项目名称:blog-app-android,代码行数:13,代码来源:AbsListActivity.java
示例14: requestSync
import com.contentful.vault.Vault; //导入依赖的package包/类
public static void requestSync(boolean invalidate) {
Vault.with(get(), BlogSpace.class).requestSync(
SyncConfig.builder()
.setClient(ClientProvider.get())
.setInvalidate(invalidate)
.build());
}
开发者ID:contentful,项目名称:blog-app-android,代码行数:8,代码来源:App.java
示例15: ContentfulInteractor
import com.contentful.vault.Vault; //导入依赖的package包/类
public ContentfulInteractor(Context applicationContext) {
this(applicationContext, Vault.with(applicationContext, VRSpace.class));
}
开发者ID:contentful-labs,项目名称:contentful-cardboard,代码行数:4,代码来源:ContentfulInteractor.java
示例16: EventListInteractor
import com.contentful.vault.Vault; //导入依赖的package包/类
public EventListInteractor(Vault vault) {
this.vault = vault;
}
开发者ID:gdg-berlin-android,项目名称:gdg-events-app,代码行数:4,代码来源:EventListInteractor.java
示例17: EventListPresenter
import com.contentful.vault.Vault; //导入依赖的package包/类
public EventListPresenter(Vault vault) {
this(new EventListInteractor(vault));
}
开发者ID:gdg-berlin-android,项目名称:gdg-events-app,代码行数:4,代码来源:EventListPresenter.java
示例18: performLoad
import com.contentful.vault.Vault; //导入依赖的package包/类
@Override protected List<Gallery> performLoad() {
return Vault.with(getContext(), GallerySpace.class).fetch(Gallery.class).all();
}
开发者ID:contentful,项目名称:gallery-app-android,代码行数:4,代码来源:GalleryListLoader.java
示例19: onCreate
import com.contentful.vault.Vault; //导入依赖的package包/类
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
createReceivers();
getActivity().registerReceiver(reloadReceiver, new IntentFilter(Vault.ACTION_SYNC_COMPLETE));
}
开发者ID:contentful,项目名称:product-catalogue-android,代码行数:7,代码来源:BaseFragment.java
示例20: setupVault
import com.contentful.vault.Vault; //导入依赖的package包/类
@Override protected void setupVault() {
vault = Vault.with(RuntimeEnvironment.application, VaultSpace.class);
}
开发者ID:contentful,项目名称:vault,代码行数:4,代码来源:BlobTest.java
注:本文中的com.contentful.vault.Vault类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论