当前位置: 首页>>代码示例>>Java>>正文


Java BoxStore类代码示例

本文整理汇总了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();
                }
            });
        }
    });
}
 
开发者ID:greenrobot,项目名称:ObjectBoxRxJava,代码行数:26,代码来源:RxBoxStore.java

示例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;
}
 
开发者ID:kosiarska,项目名称:ObjectBoxDebugBrowser,代码行数:22,代码来源:DatabaseHelper.java

示例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());
        }

    }
}
 
开发者ID:kosiarska,项目名称:ObjectBoxDebugBrowser,代码行数:21,代码来源:RequestHandler.java

示例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;
}
 
开发者ID:greenrobot-team,项目名称:greenrobot-examples,代码行数:9,代码来源:ExampleApp.java

示例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);
    }
}
 
开发者ID:mreichelt,项目名称:ObjectBox-viewer,代码行数:8,代码来源:ObjectBoxViewer.java

示例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;
}
 
开发者ID:kosiarska,项目名称:ObjectBoxDebugBrowser,代码行数:10,代码来源:DatabaseHelper.java

示例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);
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:38,代码来源:MainActivity.java

示例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());
    }
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:16,代码来源:ToMany.java

示例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);
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:30,代码来源:QueryPublisher.java

示例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);
        }
    };
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:10,代码来源:EntityLongIndex_.java

示例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;
}
 
开发者ID:cyrilpillai,项目名称:SuperNatives,代码行数:10,代码来源:AppModule.java

示例12: getBoxStore

import io.objectbox.BoxStore; //导入依赖的package包/类
public BoxStore getBoxStore() {
    return boxStore;
}
 
开发者ID:greenrobot,项目名称:ObjectBoxRxJava,代码行数:4,代码来源:MockQuery.java

示例13: provideBoxStore

import io.objectbox.BoxStore; //导入依赖的package包/类
@Provides
@Singleton
BoxStore provideBoxStore() {
    return mStore;
}
 
开发者ID:coldsteelbr,项目名称:simple_fitness_diary,代码行数:6,代码来源:ObjectBoxModule.java

示例14: createCursor

import io.objectbox.BoxStore; //导入依赖的package包/类
public Cursor<User> createCursor(Transaction tx, long cursorHandle, BoxStore boxStoreForEntities) {
    return new UserCursor(tx, cursorHandle, boxStoreForEntities);
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:4,代码来源:UserCursor.java

示例15: UserCursor

import io.objectbox.BoxStore; //导入依赖的package包/类
public UserCursor(Transaction tx, long cursor, BoxStore boxStore) {
    super(tx, cursor, User_.__INSTANCE, boxStore);
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:4,代码来源:UserCursor.java


注:本文中的io.objectbox.BoxStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。