本文整理汇总了Java中com.snappydb.SnappydbException类的典型用法代码示例。如果您正苦于以下问题:Java SnappydbException类的具体用法?Java SnappydbException怎么用?Java SnappydbException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SnappydbException类属于com.snappydb包,在下文中一共展示了SnappydbException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPostExecute
import com.snappydb.SnappydbException; //导入依赖的package包/类
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.GONE);
if (s.equalsIgnoreCase("Success"))
{
try {
snappyDB.put("Email", etemail.getText().toString());
snappyDB.put("Password", etpassword.getText().toString());
snappyDB.close();
}
catch (SnappydbException e){e.printStackTrace();}
Intent intent=new Intent(LoginActivity.this,HomeActivity.class);
startActivity(intent);
finish();
}
}
示例2: searchAllPostsOrderByDate
import com.snappydb.SnappydbException; //导入依赖的package包/类
@Override
protected List<Post> searchAllPostsOrderByDate() {
List<Post> result = new ArrayList<>();
try {
String keys[] = snappydb.findKeys(POST_PREFIX);
for (String key: keys) {
Post post = snappydb.getObject(key, Post.class);
result.add(post);
}
} catch (SnappydbException e) {
e.printStackTrace();
}
Collections.sort(result, new PostComparator());
return result;
}
示例3: init
import com.snappydb.SnappydbException; //导入依赖的package包/类
@Override
public ControllerParent<InternetShield> init(String tag) {
// TODO Auto-generated method stub\
try {
InternetManager.getInstance();
// initializing local db for fetched responses
if (InternetManager.getInstance().getCachDB() == null || !InternetManager.getInstance().getCachDB().isOpen())
InternetManager.getInstance().init(getApplication());
else {
if (!InternetManager.getInstance().getCachDB().isOpen()) {
InternetManager.getInstance().close();
InternetManager.resetInstance().init(getApplication());
}
}
} catch (SnappydbException e) {
e.printStackTrace();
}
// if (true)
// throw new ClassCastException();
return super.init(tag);
}
示例4: snappydbExecute
import com.snappydb.SnappydbException; //导入依赖的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());
}
}
}
示例5: setValue
import com.snappydb.SnappydbException; //导入依赖的package包/类
protected void setValue(String key, Boolean value, boolean ignoreCache) throws SnappydbException, RxSnappyException {
synchronized (db) {
if (key == null) {
throw new KeyIsNullException();
}
if (value == null) {
throw new ValueIsNullException();
}
if (!ignoreCache) {
db.put(generateKey(key), value);
removePreviousCachedElement(key);
} else {
db.put(key, value);
}
}
}
示例6: setStringListValue
import com.snappydb.SnappydbException; //导入依赖的package包/类
protected void setStringListValue(String key, List<String> value, boolean ignoreCache) throws SnappydbException, RxSnappyException {
synchronized (db) {
if (key == null) {
throw new KeyIsNullException();
}
if (value == null) {
throw new ValueIsNullException();
}
if (!ignoreCache) {
db.put(generateKey(key), value.toArray(new String[value.size()]));
removePreviousCachedElement(key);
} else {
db.put(key, value.toArray(new String[value.size()]));
}
}
}
示例7: testDataCacheIsValid
import com.snappydb.SnappydbException; //导入依赖的package包/类
@SmallTest
public void testDataCacheIsValid() throws SnappydbException {
String key = "asd";
DummyData dummyData = DataGenerator.generateNewDummyData();
rxSnappyClient.setObject(key, dummyData)
.toBlocking().first();
try {
Thread.sleep(2500L);
} catch (InterruptedException e) {
}
DummyData actual = rxSnappyClient.getObject(key, 5000L, DummyData.class)
.toBlocking().first();
assertEquals(dummyData, actual);
}
示例8: getChannelObjects
import com.snappydb.SnappydbException; //导入依赖的package包/类
/**
* Retrieve a list of all stored objects for a channel
* @param channelIdentifier the identifier of the channel the object is stored in
* @param type the class the objects should be casted to
* @return
*/
@Override
public List<TelepatBaseModel> getChannelObjects(String channelIdentifier, Class type) {
String[] keys = channelKeys(channelIdentifier);
ArrayList<TelepatBaseModel> objects = new ArrayList<>();
for(String key : keys) {
try {
TelepatBaseModel obj = (TelepatBaseModel)snappyDb.get(key, type);
if(obj == null || obj.getId() == null) continue;
objects.add(obj);
} catch (SnappydbException ignored) { }
}
Collections.sort(objects, new Comparator<TelepatBaseModel>() {
@Override
public int compare(TelepatBaseModel lhs, TelepatBaseModel rhs) {
return (lhs.getId()).compareTo(rhs.getId());
}
});
TelepatLogger.log("Retrieved "+channelIdentifier+ " objects. Size: "+objects.size());
return objects;
}
示例9: initView
import com.snappydb.SnappydbException; //导入依赖的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);
}
}
示例10: enumerate
import com.snappydb.SnappydbException; //导入依赖的package包/类
@Override
public void enumerate(EnumerationCallback<T> enumerationCallback, boolean withValue) {
ArrayList<T> results = new ArrayList<T>();
try {
String[] keys = snappyDB.findKeys(this.prefix);
for (String key : keys) {
byte[] value;
if (withValue) value = snappyDB.getBytes(key);
else value = null;
T record = enumerationCallback.onRecord(getOriginalKey(key), value);
if (record != null) results.add(record);
}
} catch (SnappydbException e) {
Log.w(TAG, "Enumeration failed", e);
}
enumerationCallback.onComplete(results);
}
示例11: savePinnedApps
import com.snappydb.SnappydbException; //导入依赖的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 ();
}
示例12: unpin
import com.snappydb.SnappydbException; //导入依赖的package包/类
public boolean unpin (App app, boolean showToast) throws SnappydbException
{
boolean modified = this.pinned.remove (app);
if (showToast)
{
String message;
if (modified)
message = " " + this.getContext ().getResources ().getString (R.string.unpinned);
else
message = " " + this.getContext ().getResources ().getString (R.string.notpinned);
Toast.makeText (this.getContext (), app.getLabel () + message, Toast.LENGTH_SHORT).show ();
}
be.robinj.distrohopper.desktop.launcher.AppLauncher appLauncher = (be.robinj.distrohopper.desktop.launcher.AppLauncher) this.llLauncherPinnedApps.findViewWithTag (app);
this.llLauncherPinnedApps.removeView (appLauncher);
this.savePinnedApps ();
return modified;
}
示例13: onClick
import com.snappydb.SnappydbException; //导入依赖的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;
}
}
示例14: SnappyDB
import com.snappydb.SnappydbException; //导入依赖的package包/类
public SnappyDB(Context context){
try {
snappydb = DBFactory.open(context);
this.context = context;
} catch (SnappydbException e) {
e.printStackTrace();
}
}
示例15: cleanDatabase
import com.snappydb.SnappydbException; //导入依赖的package包/类
@Override
protected void cleanDatabase() {
try {
snappydb.destroy();
//Create again
snappydb = DBFactory.open(context);
} catch (SnappydbException e) {
e.printStackTrace();
}
}