本文整理汇总了Java中co.realtime.storage.TableRef类的典型用法代码示例。如果您正苦于以下问题:Java TableRef类的具体用法?Java TableRef怎么用?Java TableRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TableRef类属于co.realtime.storage包,在下文中一共展示了TableRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: push
import co.realtime.storage.TableRef; //导入依赖的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.TableRef; //导入依赖的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.TableRef; //导入依赖的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.TableRef; //导入依赖的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.TableRef; //导入依赖的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: update
import co.realtime.storage.TableRef; //导入依赖的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);
}
示例7: getItems
import co.realtime.storage.TableRef; //导入依赖的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);
}
});
}
示例8: pushMsg
import co.realtime.storage.TableRef; //导入依赖的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);
}
});
}
示例9: pushMsg
import co.realtime.storage.TableRef; //导入依赖的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);
}
});
}
示例10: table
import co.realtime.storage.TableRef; //导入依赖的package包/类
@ReactMethod
public void table(String tableName, Integer sId, String tId){
StorageRef storageRef = _storagerefs.get(sId);
if (storageRef == null)
return;
TableRef tableRef;
try{
tableRef = storageRef.table(tableName);
appendTable(tableRef, sId, tId);
}catch (NullPointerException e){
return;
}
}
示例11: appendTable
import co.realtime.storage.TableRef; //导入依赖的package包/类
private void appendTable(TableRef table, Integer sId, String tId){
HashMap<String, TableRef> objs = _tableRefs.get(sId);
if (objs == null)
objs = new HashMap();
objs.put(tId, table);
_tableRefs.put(sId, objs);
}
示例12: asc
import co.realtime.storage.TableRef; //导入依赖的package包/类
/**
* TableRef interface
*/
@ReactMethod
public void asc(final Integer sId, String table){
TableRef tableRef = _tableRefs.get(sId).get(table);
if (tableRef == null)
return;
TableRef res = tableRef.asc();
}
示例13: desc
import co.realtime.storage.TableRef; //导入依赖的package包/类
@ReactMethod
public void desc(final Integer sId, String table){
TableRef tableRef = _tableRefs.get(sId).get(table);
if (tableRef == null)
return;
TableRef res = tableRef.desc();
}
示例14: beginsWithString
import co.realtime.storage.TableRef; //导入依赖的package包/类
@ReactMethod
public void beginsWithString(final String item, final String value, Integer sId, String table){
TableRef tableRef = _tableRefs.get(sId).get(table);
if (tableRef == null)
return;
TableRef res = tableRef.beginsWith(item, new ItemAttribute(value));
}
示例15: beginsWithNumber
import co.realtime.storage.TableRef; //导入依赖的package包/类
@ReactMethod
public void beginsWithNumber(final String item, final String value, Integer sId, String table){
TableRef tableRef = _tableRefs.get(sId).get(table);
if (tableRef == null)
return;
if (value.contains(".")){
tableRef.beginsWith(item, new ItemAttribute(Double.parseDouble(value)));
}else{
tableRef.beginsWith(item, new ItemAttribute(Integer.parseInt(value)));
}
}