Search in sources :

Example 1 with BindApp0DataSource

use of sqlite.feature.livedata.persistence0.BindApp0DataSource in project kripton by xcesco.

the class TestLiveDataRuntime method testRun.

@Test
public void testRun() throws InterruptedException {
    // .build(DataSourceOptions.builder().inMemory(false).build());
    BindApp0DataSource ds = BindApp0DataSource.instance();
    System.out.println("aa" + KriptonTaskExecutor.getInstance().isMainThread());
    LiveData<List<Person>> liveData = ds.getDaoPerson0().select("Manero");
    liveData.observeForever(new Observer<List<Person>>() {

        @Override
        public void onChanged(List<Person> t) {
            System.out.println("*********** " + t.size());
        }
    });
    ds.execute(new BindApp0DataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindApp0DaoFactory daoFactory) {
            Person person = new Person();
            person.name = "Manero";
            person.surname = "Tonj";
            daoFactory.getDaoPerson0().insert(person);
            return TransactionResult.COMMIT;
        }
    });
    Thread.sleep(1000);
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) BindApp0DataSource(sqlite.feature.livedata.persistence0.BindApp0DataSource) List(java.util.List) BindApp0DaoFactory(sqlite.feature.livedata.persistence0.BindApp0DaoFactory) Person(sqlite.feature.livedata.data.Person) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

BaseAndroidTest (base.BaseAndroidTest)1 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)1 List (java.util.List)1 Test (org.junit.Test)1 Person (sqlite.feature.livedata.data.Person)1 BindApp0DaoFactory (sqlite.feature.livedata.persistence0.BindApp0DaoFactory)1 BindApp0DataSource (sqlite.feature.livedata.persistence0.BindApp0DataSource)1