本文整理汇总了Java中co.realtime.storage.ItemSnapshot类的典型用法代码示例。如果您正苦于以下问题:Java ItemSnapshot类的具体用法?Java ItemSnapshot怎么用?Java ItemSnapshot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemSnapshot类属于co.realtime.storage包,在下文中一共展示了ItemSnapshot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: push
import co.realtime.storage.ItemSnapshot; //导入依赖的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.ItemSnapshot; //导入依赖的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: once
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例4: onceCustom
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例5: itemRefdel
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例6: itemRefget
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例7: itemRefset
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例8: itemRefincrCustom
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例9: itemRefdecrCustom
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例10: getItems
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例11: pushMsg
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例12: pushMsg
import co.realtime.storage.ItemSnapshot; //导入依赖的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);
}
});
}
示例13: on
import co.realtime.storage.ItemSnapshot; //导入依赖的package包/类
@ReactMethod
public void on(final String eventType, final Integer sId, final String table){
StorageRef.StorageEvent event = convertStorageEvent(eventType);
TableRef tableRef = _tableRefs.get(sId).get(table);
tableRef.on(event, new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
sendEvent(getReactApplicationContext(), table + "-on-" + eventType, convertlinkedMap(itemSnapshot.val()));
}
});
}
示例14: onCustom
import co.realtime.storage.ItemSnapshot; //导入依赖的package包/类
@ReactMethod
public void onCustom(final String eventType, String aPrimaryKeyValue, final Integer sId, final String table){
StorageRef.StorageEvent event = convertStorageEvent(eventType);
TableRef tableRef = _tableRefs.get(sId).get(table);
tableRef.on(event, new ItemAttribute(aPrimaryKeyValue), new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
sendEvent(getReactApplicationContext(), table + "-on-" + eventType, convertlinkedMap(itemSnapshot.val()));
}
});
}
示例15: off
import co.realtime.storage.ItemSnapshot; //导入依赖的package包/类
@ReactMethod
public void off(final String eventType, final Integer sId, String table){
StorageRef.StorageEvent event = convertStorageEvent(eventType);
TableRef tableRef = _tableRefs.get(sId).get(table);
tableRef.off(event, new OnItemSnapshot() {
@Override
public void run(ItemSnapshot itemSnapshot) {
}
});
}