Search in sources :

Example 1 with OnReadBeanListener

use of com.abubusoft.kripton.android.sqlite.OnReadBeanListener in project kripton by xcesco.

the class TestRx method testRunSyncWithListener.

@Test
public void testRunSyncWithListener() {
    BindXenoDataSource dataSource = BindXenoDataSource.instance();
    dataSource.execute(new BindXenoDataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindXenoDaoFactory daoFactory) {
            CountryDaoImpl dao = daoFactory.getCountryDao();
            for (int i = 0; i < COUNTER; i++) {
                Country bean = new Country();
                bean.code = "code" + i;
                bean.callingCode = "" + i;
                bean.name = "name" + i;
                // Object bean = new
                dao.insert(bean);
            }
            dao.selectAll();
            return TransactionResult.COMMIT;
        }
    });
    dataSource.execute(new BindXenoDataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindXenoDaoFactory daoFactory) {
            System.out.println("onSubscribe");
            CountryDaoImpl dao = daoFactory.getCountryDao();
            dao.selectAll(new OnReadBeanListener<Country>() {

                @Override
                public void onRead(Country bean, int row, int rowCount) {
                    System.out.println("onNext" + bean);
                }
            });
            System.out.println("onComplete");
            return TransactionResult.COMMIT;
        }
    });
}
Also used : CountryDaoImpl(sqlite.feature.rx.persistence.CountryDaoImpl) BindXenoDataSource(sqlite.feature.rx.persistence.BindXenoDataSource) TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) OnReadBeanListener(com.abubusoft.kripton.android.sqlite.OnReadBeanListener) Country(sqlite.feature.rx.model.Country) BindXenoDaoFactory(sqlite.feature.rx.persistence.BindXenoDaoFactory) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

BaseAndroidTest (base.BaseAndroidTest)1 OnReadBeanListener (com.abubusoft.kripton.android.sqlite.OnReadBeanListener)1 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)1 Test (org.junit.Test)1 Country (sqlite.feature.rx.model.Country)1 BindXenoDaoFactory (sqlite.feature.rx.persistence.BindXenoDaoFactory)1 BindXenoDataSource (sqlite.feature.rx.persistence.BindXenoDataSource)1 CountryDaoImpl (sqlite.feature.rx.persistence.CountryDaoImpl)1