本文整理汇总了Java中io.objectbox.BoxStore类的典型用法代码示例。如果您正苦于以下问题:Java BoxStore类的具体用法?Java BoxStore怎么用?Java BoxStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BoxStore类属于io.objectbox包,在下文中一共展示了BoxStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: observable
import io.objectbox.BoxStore; //导入依赖的package包/类
/**
* Using the returned Observable, you can be notified about data changes.
* Once a transaction is committed, you will get info on classes with changed Objects.
*/
public static <T> Observable<Class> observable(final BoxStore boxStore) {
return Observable.create(new ObservableOnSubscribe<Class>() {
@Override
public void subscribe(final ObservableEmitter<Class> emitter) throws Exception {
final DataSubscription dataSubscription = boxStore.subscribe().observer(new DataObserver<Class>() {
@Override
public void onData(Class data) {
if (!emitter.isDisposed()) {
emitter.onNext(data);
}
}
});
emitter.setCancellable(new Cancellable() {
@Override
public void cancel() throws Exception {
dataSubscription.cancel();
}
});
}
});
}
示例2: getTableInfo
import io.objectbox.BoxStore; //导入依赖的package包/类
private static List<TableDataResponse.TableInfo> getTableInfo(BoxStore boxStore, int index) {
List<Class> allEntityClasses = new ArrayList<>(boxStore.getAllEntityClasses());
Log.e("App", " allEntityClasses " + allEntityClasses);
Box<Object> box = boxStore.boxFor(allEntityClasses.get(index));
Log.e("App", " set box store " + boxStore);
Log.e("App", " set box store " + box.count());
Log.e("App", " set box store " + Arrays.toString(box.getEntityInfo().getAllProperties()));
List<TableDataResponse.TableInfo> tableInfoList = new ArrayList<>();
for (Property property : box.getEntityInfo().getAllProperties()) {
TableDataResponse.TableInfo tableInfo = new TableDataResponse.TableInfo();
tableInfo.title = property.dbName;
tableInfo.isPrimary = true;
tableInfoList.add(tableInfo);
}
return tableInfoList;
}
示例3: setBoxStore
import io.objectbox.BoxStore; //导入依赖的package包/类
public void setBoxStore(BoxStore boxStore) {
this.boxStore = boxStore;
List<Class> allEntityClasses = new ArrayList<>(boxStore.getAllEntityClasses());
Log.e("App", " allEntityClasses " + allEntityClasses);
Box<?> box = boxStore.boxFor(allEntityClasses.get(0));
Log.e("App", " set box store " + boxStore);
Log.e("App", " set box store " + box.count());
Log.e("App", " set box store " + Arrays.toString(box.getEntityInfo().getAllProperties()));
for (Object o : box.getAll()) {
Field[] fields = o.getClass().getFields();
for (Field field : fields) {
Log.e("App", "fields " + field.getName());
}
}
}
示例4: getBoxStore
import io.objectbox.BoxStore; //导入依赖的package包/类
public static BoxStore getBoxStore(Context context) {
if (boxStore == null) {
boxStore = MyObjectBox.builder()
.androidContext(context.getApplicationContext())
.build();
}
return boxStore;
}
示例5: init
import io.objectbox.BoxStore; //导入依赖的package包/类
public static void init(BoxStore boxStore, Class clazz) {
try {
httpServer = new HttpServer(boxStore.boxFor(clazz));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例6: getAllTableName
import io.objectbox.BoxStore; //导入依赖的package包/类
public static Response getAllTableName(BoxStore boxStore) {
Response response = new Response();
for (Class aClass : boxStore.getAllEntityClasses()) {
response.rows.add(aClass.getSimpleName());
}
response.isSuccessful = true;
return response;
}
示例7: onCreate
import io.objectbox.BoxStore; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
BoxStore boxStore = ((AndelaTrackChallenge) getApplicationContext()).getBoxStore();
userBox = boxStore.boxFor(User.class);
countryBox = boxStore.boxFor(Country.class);
user = userBox.query().build().findFirst();
profileDialog = ProfileDialog.newInstance(((dialog, which) -> logout()));
// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
// Build a GoogleApiClient with access to the Google Sign-In Api and the
// options specified by gso.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
init();
fab.setOnClickListener(v ->
CurrencyPickerFragment
.newInstance(countryBox.getAll())
.show(MainActivity.this.getSupportFragmentManager(), "currency-picker"));
snackProgressBarManager = new SnackProgressBarManager(coordinatorLayout)
.setProgressBarColor(R.color.colorAccent)
.setOverlayLayoutAlpha(0.6f);
}
示例8: ensureBoxes
import io.objectbox.BoxStore; //导入依赖的package包/类
private void ensureBoxes() {
if (targetBox == null) {
Field boxStoreField = ReflectionCache.getInstance().getField(entity.getClass(), "__boxStore");
try {
boxStore = (BoxStore) boxStoreField.get(entity);
if (boxStore == null) {
throw new DbDetachedException("Cannot resolve relation for detached entities");
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
entityBox = boxStore.boxFor(relationInfo.sourceInfo.getEntityClass());
targetBox = boxStore.boxFor(relationInfo.targetInfo.getEntityClass());
}
}
示例9: subscribe
import io.objectbox.BoxStore; //导入依赖的package包/类
@Override
public synchronized void subscribe(DataObserver<List<T>> observer, @Nullable Object param) {
final BoxStore store = box.getStore();
if (objectClassObserver == null) {
objectClassObserver = new DataObserver<Class<T>>() {
@Override
public void onData(Class<T> objectClass) {
publish();
}
};
}
if (observers.isEmpty()) {
if (objectClassSubscription != null) {
throw new IllegalStateException("Existing subscription found");
}
// Weak: Query references QueryPublisher, which references objectClassObserver.
// Query's DataSubscription references QueryPublisher, which references Query.
// --> Query and its DataSubscription keep objectClassSubscription alive.
// --> If both are gone, the app could not possibly unsubscribe.
// --> OK for objectClassSubscription to be GCed and thus unsubscribed?
// --> However, still subscribed observers to the query will NOT be notified anymore.
objectClassSubscription = store.subscribe(box.getEntityClass())
.weak()
.onlyChanges()
.observer(objectClassObserver);
}
observers.add(observer);
}
示例10: getCursorFactory
import io.objectbox.BoxStore; //导入依赖的package包/类
@Override
public CursorFactory<EntityLongIndex> getCursorFactory() {
return new CursorFactory<EntityLongIndex>() {
@Override
public Cursor<EntityLongIndex> createCursor(Transaction tx, long cursorHandle, @Nullable BoxStore boxStoreForEntities) {
return new EntityLongIndexCursor(tx, cursorHandle, boxStoreForEntities);
}
};
}
示例11: providesBoxStore
import io.objectbox.BoxStore; //导入依赖的package包/类
@Provides
@Singleton
BoxStore providesBoxStore(Context context) {
BoxStore boxStore = MyObjectBox.builder().androidContext(context).build();
if (BuildConfig.DEBUG) {
new AndroidObjectBrowser(boxStore).start(context);
}
return boxStore;
}
示例12: getBoxStore
import io.objectbox.BoxStore; //导入依赖的package包/类
public BoxStore getBoxStore() {
return boxStore;
}
示例13: provideBoxStore
import io.objectbox.BoxStore; //导入依赖的package包/类
@Provides
@Singleton
BoxStore provideBoxStore() {
return mStore;
}
示例14: createCursor
import io.objectbox.BoxStore; //导入依赖的package包/类
public Cursor<User> createCursor(Transaction tx, long cursorHandle, BoxStore boxStoreForEntities) {
return new UserCursor(tx, cursorHandle, boxStoreForEntities);
}
示例15: UserCursor
import io.objectbox.BoxStore; //导入依赖的package包/类
public UserCursor(Transaction tx, long cursor, BoxStore boxStore) {
super(tx, cursor, User_.__INSTANCE, boxStore);
}