本文整理汇总了Java中co.realtime.storage.ext.OnError类的典型用法代码示例。如果您正苦于以下问题:Java OnError类的具体用法?Java OnError怎么用?Java OnError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnError类属于co.realtime.storage.ext包,在下文中一共展示了OnError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: push
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void push(ReadableMap aItem, Integer sId, String table){
TableRef tableRef = _tableRefs.get(sId).get(table);
aItem.keySetIterator();
tableRef.push(convertReadableMap(aItem), new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
}
});
}
示例2: getItems
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void getItems(final Integer sId, final String table){
TableRef tableRef = _tableRefs.get(sId).get(table);
tableRef.getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
sendEvent(getReactApplicationContext(), table + "-getItems", convertlinkedMap(itemSnapshot.val()));
}else
sendEvent(getReactApplicationContext(), table + "-getItems", null);
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
sendEvent(getReactApplicationContext(), table + "-getItems", map);
}
});
}
示例3: meta
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void meta(final Integer sId, final String table){
TableRef tableRef = _tableRefs.get(sId).get(table);
tableRef.meta(new OnTableMetadata() {
@Override
public void run(TableMetadata tableMetadata) {
sendEvent(getReactApplicationContext(), table + "-meta", tableMetadata.toString());
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
sendEvent(getReactApplicationContext(), table + "-meta", map);
}
});
}
示例4: once
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void once(final String eventType, final Integer sId, final String table){
StorageRef.StorageEvent event = convertStorageEvent(eventType);
TableRef tableRef = _tableRefs.get(sId).get(table);
tableRef.once(event, new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
sendEvent(getReactApplicationContext(), table + "-once-" + eventType, convertlinkedMap(itemSnapshot.val()));
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
sendEvent(getReactApplicationContext(), table + "-once-" + eventType, map);
}
});
}
示例5: onceCustom
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void onceCustom(final String eventType, String aPrimaryKeyValue, final Integer sId, final String table){
StorageRef.StorageEvent event = convertStorageEvent(eventType);
TableRef tableRef = _tableRefs.get(sId).get(table);
tableRef.once(event, new ItemAttribute(aPrimaryKeyValue), new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
sendEvent(getReactApplicationContext(), table + "-once-" + eventType, convertlinkedMap(itemSnapshot.val()));
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
sendEvent(getReactApplicationContext(), table + "-once-" + eventType, map);
}
});
}
示例6: itemRefdel
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void itemRefdel(Integer iId, final Callback success, final Callback error){
ItemRef item = _itemRefs.get(iId);
if (item == null)
return;
item.del(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
success.invoke(convertlinkedMap(itemSnapshot.val()));
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
error.invoke(map);
}
});
}
示例7: itemRefget
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void itemRefget(Integer iId, final Callback success, final Callback error){
ItemRef item = _itemRefs.get(iId);
if (item == null)
return;
item.get(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
success.invoke(convertlinkedMap(itemSnapshot.val()));
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
error.invoke(map);
}
});
}
示例8: itemRefset
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void itemRefset(ReadableMap attributes, Integer iId, final Callback success, final Callback error){
ItemRef item = _itemRefs.get(iId);
if (item == null)
return;
item.set(convertReadableMap(attributes), new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
success.invoke(convertlinkedMap(itemSnapshot.val()));
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
error.invoke(map);
}
});
}
示例9: itemRefincrCustom
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void itemRefincrCustom(String property, Integer iId, final Callback success, final Callback error){
ItemRef item = _itemRefs.get(iId);
if (item == null)
return;
item.incr(property, new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
success.invoke(convertlinkedMap(itemSnapshot.val()));
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
error.invoke(map);
}
});
}
示例10: itemRefdecrCustom
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
@ReactMethod
public void itemRefdecrCustom(String property, Integer iId, final Callback success, final Callback error){
ItemRef item = _itemRefs.get(iId);
if (item == null)
return;
item.decr(property, new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
success.invoke(convertlinkedMap(itemSnapshot.val()));
}
}, new OnError() {
@Override
public void run(Integer integer, String s) {
WritableNativeMap map = new WritableNativeMap();
map.putString("error", s);
error.invoke(map);
}
});
}
示例11: update
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
public void update(final OnItemSnapshot finish) {
ItemAttribute primaryKey = new ItemAttribute(gameID);
ItemAttribute secondaryKey = new ItemAttribute(playerID);
LinkedHashMap<String, ItemAttribute> playerInfo = new LinkedHashMap<String, ItemAttribute>();
playerInfo.put("gameID", primaryKey);
playerInfo.put("playerID", secondaryKey);
playerInfo.put("playerName", new ItemAttribute(name));
playerInfo.put("score", new ItemAttribute(score));
gameTableRef.push(playerInfo, finish, new OnError() {
@Override
public void run(Integer code, String errorMessage) {
System.out.println(String.format("Player update:: error %d (%s)", code, errorMessage));
if(finish != null) {
finish.run(null);
}
}
});
}
示例12: update
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
public void update(TableRef tableRef, final OnItemSnapshot onFinished) {
System.out.println(String.format("Tile.update state=%d coordinate=%s", state, coordinate));
ItemAttribute primaryKey = new ItemAttribute(gameID);
ItemAttribute secondaryKey = new ItemAttribute(coordinate);
OnError onError = new OnError() {
@Override
public void run(Integer integer, String s) {
// we really should try to recover from this error, like retrying,
// but we are too lazy atm ...
if(onFinished != null)
onFinished.run(null);
}
};
LinkedHashMap<String, ItemAttribute> tile = new LinkedHashMap<String, ItemAttribute>();
tile.put("state", new ItemAttribute(state));
tile.put("playerID", new ItemAttribute(playerID));
if(atomicCounter == 1)
tile.put("atomicCounter", new ItemAttribute(atomicCounter));
tableRef.item(primaryKey, secondaryKey).set(tile, onFinished, onError);
}
示例13: getItems
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
private void getItems(){
final ProgressDialog pd = new ProgressDialog(this);
pd.setCancelable(false);
pd.setProgressStyle(android.R.style.Widget_ProgressBar_Small);
pd.show();
TableRef tableRef = StorageHandler.selfHandler.storageRef.table(Config.TABLE_NAME);
tableRef.equals(Config.PRIMARY_KEY,new ItemAttribute(channel)).getItems(new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
String content = itemSnapshot.val().get(Config.ITEM_PROPERTY_MESSAGE).toString();
String user = itemSnapshot.val().get(Config.ITEM_PROPERTY_NICKNAME).toString();
String date = itemSnapshot.val().get(Config.ITEM_PROPERTY_DATE).toString();
final Message newMsg = new Message(user, content, date);
MessageActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
setmsg(newMsg);
}
});
} else {
pd.dismiss();
}
}
}, new OnError() {
@Override
public void run(Integer integer, String exception) {
pd.dismiss();
Log.e("Exception", "Exception " + exception);
}
});
}
示例14: pushMsg
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
private void pushMsg(Message msg) {
LinkedHashMap<String, ItemAttribute> lhm = new LinkedHashMap<String, ItemAttribute>();
// Put elements to the map
lhm.put(Config.PRIMARY_KEY, new ItemAttribute(channel));
Calendar calendar = Calendar.getInstance();
Long currentTime = System.currentTimeMillis();
calendar.setTimeInMillis(currentTime);
//For match with i0S timestamp
calendar.add(Calendar.YEAR,-31);
String timeStamp = String.valueOf(calendar.getTimeInMillis()/1000);
lhm.put(Config.SECONDARY_KEY, new ItemAttribute(timeStamp));
lhm.put(Config.ITEM_PROPERTY_MESSAGE, new ItemAttribute(msg.content));
lhm.put(Config.ITEM_PROPERTY_DATE, new ItemAttribute(msg.date));
lhm.put(Config.ITEM_PROPERTY_NICKNAME, new ItemAttribute(msg.user));
TableRef tableRef = storageRef.table(Config.TABLE_NAME);
tableRef.push(lhm, new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item inserted: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("TableRef", "Error inserting item: " + errorMessage);
}
});
}
示例15: pushMsg
import co.realtime.storage.ext.OnError; //导入依赖的package包/类
public void pushMsg(Message msg, String channel) {
LinkedHashMap<String,ItemAttribute> lhm = new LinkedHashMap<String,ItemAttribute>();
lhm.put(Config.PRIMARY_KEY, new ItemAttribute(channel));
Calendar calendar = Calendar.getInstance();
Long currentTime = System.currentTimeMillis();
calendar.setTimeInMillis(currentTime);
//For match with i0S timestamp
calendar.add(Calendar.YEAR,-31);
String timeStamp = String.valueOf(calendar.getTimeInMillis()/1000);
lhm.put(Config.SECONDARY_KEY, new ItemAttribute(timeStamp));
lhm.put(Config.ITEM_PROPERTY_NICKNAME, new ItemAttribute(msg.user));
lhm.put(Config.ITEM_PROPERTY_DATE, new ItemAttribute(msg.date));
lhm.put(Config.ITEM_PROPERTY_MESSAGE, new ItemAttribute(msg.content));
TableRef tableRef = storageRef.table(Config.TABLE_NAME);
tableRef.push(lhm,new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
if (itemSnapshot != null) {
Log.d("TableRef", "Item inserted: " + itemSnapshot.val());
}
}
}, new OnError() {
@Override
public void run(Integer integer, String errorMessage) {
Log.e("TableRef", "Error inserting item: " + errorMessage);
}
});
}