本文整理汇总了Java中com.snappydb.DBFactory类的典型用法代码示例。如果您正苦于以下问题:Java DBFactory类的具体用法?Java DBFactory怎么用?Java DBFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DBFactory类属于com.snappydb包,在下文中一共展示了DBFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: whenDefaultGifsAreLoaded
import com.snappydb.DBFactory; //导入依赖的package包/类
@Test
public void whenDefaultGifsAreLoaded() {
try {
DB db = DBFactory.open(getTargetContext());
db.destroy();
} catch (Exception e) {
Log.e("TEST", e.getLocalizedMessage(), e);
}
mHelper.dispatchFakeAppState(ImmutableAppState.builder().build());
mHelper.replacePersistenceMiddleware(new DataManager(getTargetContext()));
GifActionCreator.getInstance().setDispatcher(mock(DispatcherImpl.class));
mActivityTestRule.launchActivity(new Intent());
Map<String, Gif> expectedGifs = getAppStateDefault().getGifs();
RecyclerTestLocker locker = new RecyclerTestLocker(getRecyclerView(), expectedGifs.size());
locker.waitForEspresso();
Map<Strings, Gif> gotGifs = ((GifsAdapter) getRecyclerView().getAdapter()).getGifs();
assertEquals(expectedGifs, gotGifs);
GifActionCreator.getInstance().setDispatcher(getFluxxan().getDispatcher());
}
示例2: snappydbExecute
import com.snappydb.DBFactory; //导入依赖的package包/类
/**
* @param context Context
* @param dbName String
* @param updateOperation SnappyDBUpdateOperation
*/
public static void snappydbExecute(Context context, String dbName, SnappyDBUpdateOperation updateOperation) {
DB snappydb = null;
try {
snappydb = DBFactory.open(context, dbName);
updateOperation.update(snappydb);
snappydb.close();
} catch (SnappydbException e) {
Log.e(TAG, e.getLocalizedMessage());
try {
if (snappydb != null && snappydb.isOpen() ) {
snappydb.close();
}
} catch (SnappydbException e1) {
Log.e(TAG, e.getLocalizedMessage());
}
}
}
示例3: initView
import com.snappydb.DBFactory; //导入依赖的package包/类
private void initView() {
id = getArguments().getString(CHANNELID);
name = getArguments().getString(CHANNELNAME);
if (TextUtils.isEmpty(id) || TextUtils.isEmpty(name)) {
return;
}
try {
snappydb = DBFactory.open(getActivity());
old_data = snappydb.getObject(id, NewsItemData.class);
} catch (SnappydbException e) {
e.printStackTrace();
}
initRecycleView();
if (old_data == null) {
getData();
} else {
setData(old_data);
}
}
示例4: savePinnedApps
import com.snappydb.DBFactory; //导入依赖的package包/类
public void savePinnedApps () throws SnappydbException
{
/*
SharedPreferences prefs = this.getContext ().getSharedPreferences ("pinned", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit ();
editor.clear ();
for (int i = 0; i < this.pinned.size (); i++)
{
App app = this.pinned.get (i);
StringBuilder packageAndActivityName = new StringBuilder (app.getPackageName ())
.append ("\n")
.append (app.getActivityName ());
editor.putString (Integer.toString (i), packageAndActivityName.toString ());
}
editor.apply ();*/
DB db = DBFactory.open (this.getContext ());
db.put ("launcher_pinnedApps", this.pinned.toArray ());
db.close ();
this.parent.pinnedAppsChanged ();
}
示例5: onClick
import com.snappydb.DBFactory; //导入依赖的package包/类
@Override
public void onClick(View v) {
new GuillotineAnimation.GuillotineBuilder(guillotineMenu, guillotineMenu.findViewById(R.id.guillotine_hamburger), contentHamburger)
.setStartDelay(RIPPLE_DURATION)
.setActionBarViewForAnimation(toolbar)
.setClosedOnStart(true)
.build();
switch (v.getId())
{
case R.id.activity_group:
Toast.makeText(this,"My Events",Toast.LENGTH_SHORT).show();
break;
case R.id.feed_group:
Intent intent2=new Intent(HomeActivity.this,FeedActivity.class);
startActivity(intent2);
break;
case R.id.profile_group:
Intent intent1=new Intent(HomeActivity.this,ProfileActivity.class);
startActivity(intent1);
break;
case R.id.settings_group:
LogSaver.appendLog("Facebook Logged Out :"+LoginManager.getInstance());
LoginManager.getInstance().logOut();
try {
DB db = DBFactory.open(getApplicationContext(), "users");
db.destroy();
db.close();
}
catch (SnappydbException e){e.printStackTrace();}
Intent intent=new Intent(HomeActivity.this,MainActivity.class);
startActivity(intent);
finish();
LogSaver.appendLog("Facebook Logged Out");
break;
}
}
示例6: SnappyDB
import com.snappydb.DBFactory; //导入依赖的package包/类
public SnappyDB(Context context){
try {
snappydb = DBFactory.open(context);
this.context = context;
} catch (SnappydbException e) {
e.printStackTrace();
}
}
示例7: cleanDatabase
import com.snappydb.DBFactory; //导入依赖的package包/类
@Override
protected void cleanDatabase() {
try {
snappydb.destroy();
//Create again
snappydb = DBFactory.open(context);
} catch (SnappydbException e) {
e.printStackTrace();
}
}
示例8: getAppStateFromDB
import com.snappydb.DBFactory; //导入依赖的package包/类
private AppState getAppStateFromDB() {
AppState appstate = null;
try {
DB db = DBFactory.open(getTargetContext());
appstate = AppState.fromJson(db.get(TAG_APP_STATE));
db.close();
} catch (SnappydbException | IOException e) {
Log.e(getClass().getSimpleName(), "error", e);
}
return appstate;
}
示例9: saveAppState
import com.snappydb.DBFactory; //导入依赖的package包/类
private void saveAppState(AppState appState) {
try {
DB db = DBFactory.open(getTargetContext());
db.put(TAG_APP_STATE, appState.toJson());
db.close();
} catch (SnappydbException | IOException e) {
Log.e(getClass().getSimpleName(), "error", e);
}
}
示例10: load
import com.snappydb.DBFactory; //导入依赖的package包/类
public static SharedPrefStore load(Context context) {
try {
return new SharedPrefStore(DBFactory.open(context, Constants.SHARED_PREFS_FILE));
} catch (SnappydbException e) {
e.printStackTrace();
return null;
}
}
示例11: openDatabase
import com.snappydb.DBFactory; //导入依赖的package包/类
public void openDatabase() {
if (db == null)
try {
db = DBFactory.open(context);
} catch (SnappydbException e) {
snappyErrorHandler.handlerError(e);
}
}
示例12: init
import com.snappydb.DBFactory; //导入依赖的package包/类
public static void init(Context context) {
if (db == null) {
try {
db = DBFactory.open(context);
} catch (SnappydbException e) {
Log.e("RxSnappy", "Failed to open database", e);
}
}
}
示例13: TelepatSnappyDb
import com.snappydb.DBFactory; //导入依赖的package包/类
public TelepatSnappyDb(Context mContext) {
this.mContext = mContext;
try {
snappyDb = DBFactory.open(mContext, DB_NAME);
} catch (SnappydbException e) {
e.printStackTrace();
}
}
示例14: empty
import com.snappydb.DBFactory; //导入依赖的package包/类
/**
* Empty the internal DB
*/
@Override
public void empty() {
try {
snappyDb.destroy();
snappyDb = DBFactory.open(mContext, DB_NAME);
} catch (SnappydbException e) {
e.printStackTrace();
}
}
示例15: openDb
import com.snappydb.DBFactory; //导入依赖的package包/类
private void openDb() {
try {
snappyDb = DBFactory.open(mContext);
} catch(Exception e) {
Log.i(Constants.APP_NAME, "Error occurred while opening snappyDB");
}
}