當前位置: 首頁>>代碼示例>>Java>>正文


Java FlowManager類代碼示例

本文整理匯總了Java中com.raizlabs.android.dbflow.config.FlowManager的典型用法代碼示例。如果您正苦於以下問題:Java FlowManager類的具體用法?Java FlowManager怎麽用?Java FlowManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FlowManager類屬於com.raizlabs.android.dbflow.config包,在下文中一共展示了FlowManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: save

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
/**
 * 新增或者修改數據庫的統一方法
 * @param tClass 傳遞一個class信息
 * @param models 這個class對應的實例的數組
 * @param <Model> 這個實例的泛型 限定條件是BaseModel
 */
public static<Model extends BaseModel> void save(final Class<Model> tClass, final Model... models) {
    if (models==null||models.length==0) return;
    // 當前數據庫的一個管理者
    DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
    // 提交一個事務
    definition.beginTransactionAsync(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            // 執行
            ModelAdapter<Model> adapter = FlowManager.getModelAdapter(tClass);
            // 保存
            adapter.saveAll(Arrays.asList(models));
            // 喚起通知
            instance.notifySave(tClass,models);
        }
    }).build().execute();
}
 
開發者ID:FZZFVII,項目名稱:pipe,代碼行數:24,代碼來源:DbHelper.java

示例2: delete

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
/**
 * 刪除數據庫的的統一方法
 * @param tClass 傳遞一個class信息
 * @param models 這個class對應的實例的數組
 * @param <Model> 這個實例的泛型 限定條件是BaseModel
 */
public static<Model extends BaseModel> void delete(final Class<Model> tClass, final Model... models) {
    if (models==null||models.length==0) return;
    // 當前數據庫的一個管理者
    DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
    // 提交一個事務
    definition.beginTransactionAsync(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            // 執行
            ModelAdapter<Model> adapter = FlowManager.getModelAdapter(tClass);
            // 刪除
            adapter.deleteAll(Arrays.asList(models));
            // 喚起通知
            instance.notifyDelete(tClass,models);
        }
    }).build().execute();
}
 
開發者ID:FZZFVII,項目名稱:pipe,代碼行數:24,代碼來源:DbHelper.java

示例3: updateGroup

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
/**
 * 從成員中找出成員對應的群,並對群進行更新
 *
 * @param members 群成員列表
 */
private void updateGroup(GroupMember... members) {
    // 不重複集合
    final Set<String> groupIds = new HashSet<>();
    for (GroupMember member : members) {
        // 添加群Id
        groupIds.add(member.getGroup().getId());
    }

    // 異步的數據庫查詢,並異步的發起二次通知
    DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
    definition.beginTransactionAsync(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            // 找到需要通知的群
            List<Group> groups = SQLite.select()
                    .from(Group.class)
                    .where(Group_Table.id.in(groupIds))
                    .queryList();

            // 調用直接進行一次通知分發
            instance.notifySave(Group.class, groups.toArray(new Group[0]));

        }
    }).build().execute();
}
 
開發者ID:FZZFVII,項目名稱:pipe,代碼行數:31,代碼來源:DbHelper.java

示例4: save

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
@Override
public Completable save(List<Recipe> recipes) {
    return Completable.defer(() -> {
        SQLite.delete(DBFlowRecipe.class).execute();
        SQLite.delete(DBFlowIngredient.class).execute();
        SQLite.delete(DBFlowStep.class).execute();
        FastStoreModelTransaction
                .insertBuilder(FlowManager.getModelAdapter(DBFlowRecipe.class))
                .addAll(DBFlowRecipe.Mapper.fromDomain(recipes))
                .build()
                .execute(database);
        for (Recipe recipe : recipes) {
            FastStoreModelTransaction
                    .insertBuilder(FlowManager.getModelAdapter(DBFlowIngredient.class))
                    .addAll(DBFlowIngredient.Mapper.fromDomain(recipe.ingredients(), recipe.id()))
                    .build()
                    .execute(database);
            FastStoreModelTransaction
                    .insertBuilder(FlowManager.getModelAdapter(DBFlowStep.class))
                    .addAll(DBFlowStep.Mapper.fromDomain(recipe.steps(), recipe.id()))
                    .build()
                    .execute(database);
        }
        return Completable.complete();
    });
}
 
開發者ID:ecarrara-araujo,項目名稱:yabaking,代碼行數:27,代碼來源:DBFlowLocalDataSource.java

示例5: onCreate

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    // instantiates DBFlow
    FlowManager.init(new FlowConfig.Builder(this).build());

    // instantiate volley request
    VolleyRequestQueue.getInstance().initialize(this);

    // start push notification service
    startService(new Intent(this, InstanceIDService.class));

    // instantiate app data
    initialize(this);
}
 
開發者ID:Q115,項目名稱:Goalie_Android,代碼行數:17,代碼來源:MainApplication.java

示例6: performIndividualAdapterOperations

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private void performIndividualAdapterOperations() {
    for (int i = 0; i < mModelList.size(); i++) {
        @ModelOperation int operation = mOperationList.get(i);
        Object model = mModelList.get(i);
        ModelAdapter modelAdapter = FlowManager.getModelAdapter(model.getClass());

        if (operation == MODEL_OPERATION_SAVE) {
            modelAdapter.save(model);
        } else if (operation == MODEL_OPERATION_DELETE) {
            modelAdapter.delete(model);
        } else if (operation == MODEL_OPERATION_INSERT) {
            modelAdapter.insert(model);
        } else if (operation == MODEL_OPERATION_UPDATE) {
            modelAdapter.update(model);
        }
    }
}
 
開發者ID:roadhouse-dev,項目名稱:RxDbflow,代碼行數:19,代碼來源:RxModelOperationTransaction.java

示例7: onNext

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
@Override
public void onNext(T o) {
    mActual.onNext(o);

    for (int i = 0; i < mSubscribedClasses.size(); i++) {
        mFlowContentObserver.registerForContentChanges(FlowManager.getContext(), mSubscribedClasses.get(i));
    }

    mFlowContentObserver.addOnTableChangedListener(
            new FlowContentObserver.OnTableChangedListener() {
                @Override
                public void onTableChanged(@Nullable Class<?> tableChanged, BaseModel.Action action) {
                    if(isDisposed()){
                        return;
                    }

                    if (!mIsInTransaction) {
                        mActual.onNext(mRestartAction.run());
                    } else {
                        mHasPendingChange = true;
                    }
                }
            });
}
 
開發者ID:roadhouse-dev,項目名稱:RxDbflow,代碼行數:25,代碼來源:DBFlowRestartOnChange.java

示例8: deleteAndInsertEntities

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
@CheckResult
@NonNull
@Override
public Single<List<D>> deleteAndInsertEntities(@Nullable List<D> entitiesToInsert,
                                               @NonNull SQLOperator... conditionsToDelete) {
  return Single
      .fromCallable(() -> {
        FlowManager.getDatabase(getAppDataBaseClass())
            .executeTransaction(databaseWrapper -> {
              SQLite.delete(getModelClass())
                  .where(conditionsToDelete)
                  .execute();
              Stream.ofNullable(entitiesToInsert)
                  .forEach(BaseModel::save);
            });
        return entitiesToInsert;
      })
      .subscribeOn(Schedulers.io());
}
 
開發者ID:xmartlabs,項目名稱:bigbang,代碼行數:20,代碼來源:DbFlowController.java

示例9: onCreate

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
@Override
public void onCreate() {
  super.onCreate();
  Fabric.with(this, new Crashlytics());
  FlowManager.init(this);
  MobileAds.initialize(this, "ca-app-pub-9985743520520066~4279780475");

  sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

  String userAgent =
      String.format(Locale.UK, "%s.%d", BuildConfig.APPLICATION_ID, BuildConfig.VERSION_CODE);
  String sessionKeyKey = getString(R.string.saved_session_key);
  LastfmApi api = new LastfmApi();
  Caller caller = Caller.getInstance();

  if (sharedPreferences.contains(sessionKeyKey)) {
    String sessionKey = sharedPreferences.getString(sessionKeyKey, null);
    lastfmClient = new LastfmClient(api, caller, userAgent, sessionKey);
  } else {
    lastfmClient = new LastfmClient(api, caller, userAgent);
  }

  scroballDB = new ScroballDB();
  eventBus.register(this);
}
 
開發者ID:peterjosling,項目名稱:scroball,代碼行數:26,代碼來源:ScroballApplication.java

示例10: onCreate

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    FlowManager.init(new FlowConfig.Builder(this).build());

    Properties properties = new Properties();
    InputStream stream = null;
    try {
        stream = getAssets().open("conf.properties");
        properties.load(stream);
        CrashReport.initCrashReport(getApplicationContext(), properties.getProperty("bugly.appId"), false);
    } catch (IOException e) {
        Log.w(TAG, e);
    } finally {
        Streams.safeClose(stream);
    }
}
 
開發者ID:YieldNull,項目名稱:Biu,代碼行數:18,代碼來源:MyApplication.java

示例11: migrateSurveyTable

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
private void migrateSurveyTable(SQLiteDatabase database) {
    ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);

    //Create temporal table
    String sql=myAdapter.getCreationQuery();
    Log.d("DBMIGRATION", "old table " + sql);
    sql=sql.replace("Survey", "Survey_temp");
    Log.d("DBMIGRATION", "create temp table " + sql);
    database.execSQL(sql);

    //Insert the data in temporal table
    String sqlCopy="INSERT INTO Survey_temp(id_survey, id_tab_group, id_org_unit, id_user, creation_date, completion_date, upload_date, schedule_date, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid FROM Survey";
    database.execSQL(sqlCopy);

    //Replace old table by new table with the new column name.
    database.execSQL("DROP TABLE IF EXISTS Survey");
    database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
 
開發者ID:EyeSeeTea,項目名稱:EDSApp,代碼行數:19,代碼來源:Migration9RenameTables.java

示例12: migrateProgramTable

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
private void migrateProgramTable(SQLiteDatabase database) {

        ModelAdapter myAdapter = FlowManager.getModelAdapter(Program.class);
        String programTable = "Program";
        String programTempTable = "Program_temp";
        //Create temporal table
        String sql = myAdapter.getCreationQuery();
        Log.d("DBMIGRATION", "old table " + sql);
        sql = sql.replace(programTable, programTempTable);
        Log.d("DBMIGRATION", "create temp table " + sql);
        database.execSQL(sql);
        //Insert the data in temporal table
        String sqlCopy = "INSERT INTO " + programTempTable
                + "(id_program, uid, name, stage_uid) SELECT id_program, uid, name, programStage "
                + "FROM "
                + programTable;
        database.execSQL(sqlCopy);

        //Replace old table by new table with the new column name.
        database.execSQL("DROP TABLE IF EXISTS " + programTable);
        database.execSQL("ALTER TABLE " + programTempTable + " RENAME TO " + programTable);
    }
 
開發者ID:EyeSeeTea,項目名稱:EDSApp,代碼行數:23,代碼來源:Migration12UpdateEdsTables.java

示例13: migrateSurveyTable

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
private void migrateSurveyTable(SQLiteDatabase database) {
    ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);

    //Create temporal table
    String sql = myAdapter.getCreationQuery();
    Log.d("DBMIGRATION", "old table " + sql);
    sql = sql.replace("Survey", "Survey_temp");
    Log.d("DBMIGRATION", "create temp table " + sql);
    database.execSQL(sql);

    //Insert the data in temporal table
    String sqlCopy =
            "INSERT INTO Survey_temp(id_survey, id_program, id_org_unit, id_user, "
                    + "creation_date, completion_date, upload_date, scheduled_date, status, "
                    + "eventuid) SELECT id_survey, id_program, id_org_unit, id_user, "
                    + "creation_date, completion_date, upload_date, schedule_date, status, "
                    + "eventuid FROM Survey";
    database.execSQL(sqlCopy);

    //Replace old table by new table with the new column name.
    database.execSQL("DROP TABLE IF EXISTS Survey");
    database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
 
開發者ID:EyeSeeTea,項目名稱:EDSApp,代碼行數:24,代碼來源:Migration12UpdateEdsTables.java

示例14: migrate

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
@Override
public void migrate(SQLiteDatabase database) {
    //The column name can't be renamed in sqlite. It is needed create a temporal table with the new column name.
    ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);

    //Create temporal table
    String sql=myAdapter.getCreationQuery();
    Log.d("DBMIGRATION", "old table " + sql);
    sql=sql.replace("Survey", "Survey_temp");
    Log.d("DBMIGRATION", "create temp table " + sql);
    database.execSQL(sql);

    //Insert the data in temporal table
    String sqlCopy="INSERT INTO Survey_temp(id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, eventDate, scheduledDate, status, eventuid FROM Survey";
    database.execSQL(sqlCopy);

    //Replace old table by new table with the new column name.
    database.execSQL("DROP TABLE IF EXISTS Survey");
    database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
 
開發者ID:EyeSeeTea,項目名稱:EDSApp,代碼行數:21,代碼來源:Migration7RenameEventDate.java

示例15: migrateSurveyTable

import com.raizlabs.android.dbflow.config.FlowManager; //導入依賴的package包/類
private void migrateSurveyTable(SQLiteDatabase database) {
    ModelAdapter myAdapter = FlowManager.getModelAdapter(Survey.class);

    //Create temporal table
    String sql=myAdapter.getCreationQuery();
    Log.d("DBMIGRATION", "old table " + sql);
    sql=sql.replace("Survey", "Survey_temp");
    Log.d("DBMIGRATION", "create temp table " + sql);
    database.execSQL(sql);

    //Insert the data in temporal table
    String sqlCopy="INSERT INTO Survey_temp(id_survey, id_program, id_org_unit, id_user, creation_date, completion_date, upload_date, scheduled_date, status, eventuid) SELECT id_survey, id_tab_group, id_org_unit, id_user, creationDate, completionDate, uploadedDate, scheduledDate, status, eventuid FROM Survey";
    database.execSQL(sqlCopy);

    //Replace old table by new table with the new column name.
    database.execSQL("DROP TABLE IF EXISTS Survey");
    database.execSQL("ALTER TABLE Survey_temp RENAME TO Survey");
}
 
開發者ID:EyeSeeTea,項目名稱:EDSApp,代碼行數:19,代碼來源:Migration10RenameTables.java


注:本文中的com.raizlabs.android.dbflow.config.FlowManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。