Java 类com.google.firebase.database.ServerValue 实例源码

项目:Quadro    文件:Post.java   
@Exclude
public Map<String, Object> toMap() {
    HashMap<String, Object> result = new HashMap<>();
    result.put("uid", uid);
    result.put("author", author);
    result.put("title", title);
    result.put("body", body);
    result.put("image", image);
    result.put("starCount", starCount);
    result.put("stars", stars);
    result.put("authorImage", authorImage);
    result.put("authorName", authorName);
    result.put("authorJobTitle", authorJobTitle);
    result.put("aboutTheAuthor", aboutTheAuthor);
    result.put("timeStamp", ServerValue.TIMESTAMP);

    return result;
}
项目:friendlypix-android    文件:FeedsActivity.java   
@Override
public void onPostLike(final String postKey) {
    final String userKey = FirebaseUtil.getCurrentUserId();
    final DatabaseReference postLikesRef = FirebaseUtil.getLikesRef();
    postLikesRef.child(postKey).child(userKey).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (dataSnapshot.exists()) {
                // User already liked this post, so we toggle like off.
                postLikesRef.child(postKey).child(userKey).removeValue();
            } else {
                postLikesRef.child(postKey).child(userKey).setValue(ServerValue.TIMESTAMP);
            }
        }

        @Override
        public void onCancelled(DatabaseError firebaseError) {

        }
    });
}
项目:starterproject_todolist_react_redux_firebase_ts_md    文件:User.java   
public User(FirebaseUser param) {
  if (param.getUid() != null) {
    uid = param.getUid();
  }
  if (param.getProviderId() != null) {
    providerId = param.getProviderId();
  }
  if (param.getDisplayName() != null) {
    displayName = param.getDisplayName();
  }
  if (param.getPhotoUrl() != null) {
    photoUrl = param.getPhotoUrl().toString();
  }
  if (param.getEmail() != null) {
    email = param.getEmail();
  }
  emailVerified = param.isEmailVerified();
  isAnonymous = param.isAnonymous();

  timestamp = ServerValue.TIMESTAMP;
}
项目:Chit-Chat    文件:FirebaseUtils.java   
public static void sendFileTextMessageToFirebase(FirebaseDatabase firebaseDatabase, ChatItemDataModel item, String from_id) {
    DatabaseReference itemDatabaseReference;
    if (item.is_bot) {
        itemDatabaseReference = firebaseDatabase.getReference("botChatItems/" + item.contact_id + "/");
    } else {
        itemDatabaseReference = firebaseDatabase.getReference("chatItems/" +
                item.contact_id.substring(1) + "/");
    }
    DatabaseReference revItemReference = firebaseDatabase.getReference("chatItems/" +
            from_id.substring(1) + "/").child("-" + item.chat_id);
    final String id_on_server = itemDatabaseReference.push().getKey().substring(1);
    itemDatabaseReference = itemDatabaseReference.child(id_on_server);

    HashMap<String, Object> fbvalues = new HashMap<>();
    fbvalues.put("sender", from_id);
    fbvalues.put("receiver", item.contact_id);
    fbvalues.put("is_bot", item.is_bot);
    fbvalues.put("type", item.message_type);
    fbvalues.put("content", item.message);
    fbvalues.put("id", id_on_server);
    fbvalues.put("timestamp", item.timestamp);
    fbvalues.put("g_timestamp", ServerValue.TIMESTAMP);

    revItemReference.updateChildren(fbvalues);
    itemDatabaseReference.updateChildren(fbvalues);
}
项目:AvI    文件:UserInfo.java   
@Exclude
@Override
public Map<String, Object> toMap() {
    HashMap<String, Object> result = new HashMap<>();
    result.put("lastModifiedTime", ServerValue.TIMESTAMP);
    result.put("authId", authId);
    result.put("name", name);
    result.put("email", email);
    result.put("pictureUrl", pictureUrl);
    result.put("employment", employment);
    result.put("education", education);
    result.put("knowledgeableIn", knowledgeableIn);
    result.put("interests", interests);
    result.put("currentGoals", currentGoals);
    result.put("locationLat", locationLat);
    result.put("locationLon", locationLon);

    return result;
}
项目:delern    文件:ParcelableCard.java   
/**
 * Parcelable deserializer.
 *
 * @param in parcel.
 */
@SuppressWarnings(
        /* Thread class loader is empty during instrumented tests (2 APK in a single process) */
        "PMD.UseProperClassLoader"
)
protected ParcelableCard(final Parcel in) {
    mCard = new Card(ParcelableDeck.get(in.readParcelable(
            ParcelableCard.class.getClassLoader())));
    mCard.setKey(in.readString());
    mCard.setBack(in.readString());
    mCard.setFront(in.readString());
    long createdAt = in.readLong();
    if (createdAt == PARCEL_SERVER_VALUE_TIMESTAMP) {
        mCard.setCreatedAt(ServerValue.TIMESTAMP);
    } else {
        mCard.setCreatedAt(createdAt);
    }
}
项目:delern    文件:Card.java   
/**
 * Method for adding card to FB.
 *
 * @return FirebaseTaskAdapter for the write operation.
 */
@Exclude
public Completable create() {
    ScheduledCard scheduledCard = new ScheduledCard(getDeck());
    scheduledCard.setLevel(Level.L0.name());
    // TODO(dotdoom): figure out better repeatAt
    scheduledCard.setRepeatAt(0);
    setParent(scheduledCard);
    // This field is used to sync other people's decks, so must be the server value
    // at the time this reaches Firebase server.
    setCreatedAt(ServerValue.TIMESTAMP);

    return new MultiWrite()
            .save(this)
            .save(scheduledCard)
            .write();
}
项目:Attendance    文件:Attendance.java   
public Attendance(String usico, String usid, String ume, String dmxa, String dmna, String daod, String dado, String dnixa,
                  String hodxb, String longi, String lati, String datm, String usosc, String usname, String aprv) {
    this.usico = usico;
    this.usid = usid;
    this.ume = getUme(daod);
    this.dmxa = dmxa;
    this.dmna = dmna;
    this.daod = daod;
    this.dado = dado;
    this.dnixa = dnixa;
    this.hodxb = hodxb;
    this.longi = longi;
    this.lati = lati;
    this.datm = datm;

    HashMap<String, Object> datsObj = new HashMap<String, Object>();
    datsObj.put("date", ServerValue.TIMESTAMP);
    this.dats = datsObj;

    this.aprv = aprv;
    this.usosc = usosc;
    this.cplxb = "0";
    this.rok = "2017";
    this.usname = usname;
}
项目:Attendance    文件:Attendance.java   
public Attendance(String usico, String usid, String ume, String dmxa, String dmna, String daod, String dado, String dnixa,
                  String hodxb, String longi, String lati, String datm, String usosc, String usname ) {
    this.usico = usico;
    this.usid = usid;
    this.ume = getUme(daod);
    this.dmxa = dmxa;
    this.dmna = dmna;
    this.daod = daod;
    this.dado = dado;
    this.dnixa = dnixa;
    this.hodxb = hodxb;
    this.longi = longi;
    this.lati = lati;
    this.datm = datm;

    HashMap<String, Object> datsObj = new HashMap<String, Object>();
    datsObj.put("date", ServerValue.TIMESTAMP);
    this.dats = datsObj;

    this.aprv = "0";
    this.usosc = usosc;
    this.cplxb = "0";
    this.rok = "2017";
    this.usname = usname;
}
项目:Viajes    文件:LoginPresenter.java   
@Override
public void createUserInFirebaseHelper(String uid, final User user) {
    final DatabaseReference userLocation =
            FirebaseDatabase.getInstance().getReferenceFromUrl(Constants.FIREBASE_URL_USERS).child(uid);

    /**
     * See if there is already a user (for example, if they already logged in with an associated
     * Google account.
     */
    userLocation.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            /* If there is no user, make one */
            if (dataSnapshot.getValue() == null) {
             /* Set raw version of date to the ServerValue.TIMESTAMP value and save into dateCreatedMap */
                HashMap<String, Object> timestampJoined = new HashMap<>();
                timestampJoined.put(Constants.FIREBASE_PROPERTY_TIMESTAMP, ServerValue.TIMESTAMP);
                user.setTimestampJoined(timestampJoined);
                userLocation.setValue(user);
            }
        }


        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.i("error",databaseError.getMessage());
            mLoginView.showUserCreateErrorMessage();

        }


    });
}
项目:Viajes    文件:AddActivity.java   
private Hotel getItemData() {
    Hotel hotel = new Hotel();

    try {
        String Hotel_Name = name.getText().toString();
        String Hotel_Phone = phone.getText().toString();
        String Hotel_Website = website.getText().toString();

        hotel.setName(Hotel_Name);
        hotel.setPhone(Hotel_Phone);
        hotel.setWebsite(Hotel_Website);
        hotel.setPrice(price);
        hotel.setTime(ServerValue.TIMESTAMP);
        hotel.setLat(latitude);
        hotel.setLon(longitude);
        hotel.setPets(pets_click);
        hotel.setPool(pool_click);
        hotel.setGym(gym_click);
        hotel.setResturant(restaurant_click);
        hotel.setWifi(wifi_click);
        hotel.setBeach(beach_click);
        hotel.setBreakfast(breakfast_click);
        hotel.setSpa(spa_click);

    }
    catch (Exception ex){
        Toast.makeText(this, "error in price num max 300$", Toast.LENGTH_SHORT).show();
    }
    return hotel;
}
项目:cda-app    文件:ChatActivity.java   
public void verifyPresence(){

        final FirebaseDatabase database = FirebaseDatabase.getInstance();
        final DatabaseReference myConnectionsRef = database.getReference().child("user").child(userID).child("status");
        final DatabaseReference lastOnlineRef = database.getReference().child("user").child(userID).child("lastOnline");
        final DatabaseReference connectedRef = database.getReference(".info/connected");

        connectedRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                boolean connected = snapshot.getValue(Boolean.class);
                if (connected) {
                    DatabaseReference con = myConnectionsRef.push();

                    // when this device disconnects, remove it
                    con.onDisconnect().removeValue();

                    // when I disconnect, update the last time I was seen online
                    lastOnlineRef.onDisconnect().setValue(ServerValue.TIMESTAMP);

                    // add this device to my connections list
                    // this value could contain info about the device or a timestamp too
                    //con.setValue(Boolean.TRUE);
                    con.setValue(Boolean.TRUE);
                }
            }

            @Override
            public void onCancelled(DatabaseError error) {
                System.err.println("Listener was cancelled at .info/connected");
            }
        });
    }
项目:AndroidBackendlessChat    文件:BMessageWrapper.java   
Map<String, Object> serialize(){
    Map<String, Object> values = new HashMap<String, Object>();

    values.put(BDefines.Keys.BPayload, model.getText());
    values.put(BDefines.Keys.BDate, ServerValue.TIMESTAMP);
    values.put(BDefines.Keys.BType, model.getType());
    values.put(BDefines.Keys.BUserFirebaseId, model.getBUserSender().getEntityID());


    return values;
}
项目:AndroidBackendlessChat    文件:BMessageWrapper.java   
public Promise<BMessage, BError, BMessage>  push(){
    if (DEBUG) Timber.v("push");

    final Deferred<BMessage, BError, BMessage> deferred = new DeferredObject<>();

    // Getting the message ref. Will be created if not exist.
    DatabaseReference ref = ref();
    model.setEntityID(ref.getKey());

    DaoCore.updateEntity(model);

    ref.setValue(serialize(), ServerValue.TIMESTAMP, new DatabaseReference.CompletionListener() {
        @Override
        public void onComplete(DatabaseError firebaseError, DatabaseReference firebase) {

            if (DEBUG) Timber.v("push message, onDone");

            if (firebaseError == null) {
                deferred.resolve(BMessageWrapper.this.model);
            } else {
                deferred.reject(getFirebaseError(firebaseError));
            }
        }
    });

    return deferred.promise();
}
项目:AndroidBackendlessChat    文件:BUserWrapper.java   
Map<String, Object> serialize(){
    Map<String, Object> values = new HashMap<String, Object>();

    values.put(BDefines.Keys.BColor, StringUtils.isEmpty(model.getMessageColor()) ? "" : model.getMessageColor());
    values.put(BDefines.Keys.BMeta, model.metaMap());
    values.put(BDefines.Keys.BLastOnline, ServerValue.TIMESTAMP);

    return values;
}
项目:chat-sdk-android-push-firebase    文件:BMessageWrapper.java   
Map<String, Object> serialize(){
    Map<String, Object> values = new HashMap<String, Object>();

    values.put(BDefines.Keys.BPayload, model.getText());
    values.put(BDefines.Keys.BDate, ServerValue.TIMESTAMP);
    values.put(BDefines.Keys.BType, model.getType());
    values.put(BDefines.Keys.BUserFirebaseId, model.getBUserSender().getEntityID());


    return values;
}
项目:chat-sdk-android-push-firebase    文件:BMessageWrapper.java   
public Promise<BMessage, BError, BMessage>  push(){
    if (DEBUG) Timber.v("push");

    final Deferred<BMessage, BError, BMessage> deferred = new DeferredObject<>();

    // Getting the message ref. Will be created if not exist.
    DatabaseReference ref = ref();
    model.setEntityID(ref.getKey());

    DaoCore.updateEntity(model);

    ref.setValue(serialize(), ServerValue.TIMESTAMP, new DatabaseReference.CompletionListener() {
        @Override
        public void onComplete(DatabaseError firebaseError, DatabaseReference firebase) {

            if (DEBUG) Timber.v("push message, onDone");

            if (firebaseError == null) {
                deferred.resolve(BMessageWrapper.this.model);
            } else {
                deferred.reject(getFirebaseError(firebaseError));
            }
        }
    });

    return deferred.promise();
}
项目:chat-sdk-android-push-firebase    文件:BUserWrapper.java   
Map<String, Object> serialize(){
    Map<String, Object> values = new HashMap<String, Object>();

    values.put(BDefines.Keys.BColor, StringUtils.isEmpty(model.getMessageColor()) ? "" : model.getMessageColor());
    values.put(BDefines.Keys.BMeta, model.metaMap());
    values.put(BDefines.Keys.BLastOnline, ServerValue.TIMESTAMP);

    return values;
}
项目:IM_Here    文件:UserAccount.java   
public UserAccount(String userName,
                   String userEmail,
                   String userImage){

    this.userEmail = userEmail;
    this.userName = userName;
    this.userImage = userImage;

    createdAccountTime = new HashMap<>();
    createdAccountTime.put("date", ServerValue.TIMESTAMP);
}
项目:IM_Here    文件:Notification.java   
public Notification(String notificationImage, String notificationFirstText,
                    String notificationSecondText, List<String> notificationData,
                    int notificationType){

    this.notificationImage = notificationImage;
    this.notificationFirstText = notificationFirstText;
    this.notificationSecondText = notificationSecondText;
    this.notificationData = notificationData;
    this.notificationType = notificationType;
    notificationDate = new HashMap<>();
    notificationDate.put("date", ServerValue.TIMESTAMP);

}
项目:FCM-toolbox    文件:PresenceEventListener.java   
static void updateConnectionReference(DatabaseReference connectionRef, String token) {
    HashMap<String, Object> result = new HashMap<>(3);
    Locale locale = Locale.getDefault();
    final String displayName = Build.MODEL.toLowerCase(locale).startsWith(Build.MANUFACTURER.toLowerCase(locale)) ? Build.MODEL
            : Build.MANUFACTURER.toUpperCase(locale) + " " + Build.MODEL;
    result.put("name", displayName);
    result.put("token", token);
    result.put("timestamp", ServerValue.TIMESTAMP);
    connectionRef.setValue(result);
}
项目:memory-game    文件:ScoreboardLevel.java   
public Map<String, Object> toMap() {
    Map<String, Object> map = new HashMap<>();
    map.put(FirebaseStructure.Scoreboards.LEVEL, level);
    map.put(FirebaseStructure.Scoreboards.Scores.NICKNAME, nickname);
    map.put(FirebaseStructure.Scoreboards.Scores.SUBMIT_DATETIME, ServerValue.TIMESTAMP);
    map.put(FirebaseStructure.Scoreboards.Scores.SCORE, score);
    map.put(FirebaseStructure.Scoreboards.Scores.REMAINING_TIME, timeRemaining);
    map.put(FirebaseStructure.Scoreboards.Scores.WEIGHT, weight);
    return map;
}
项目:android-things-electricity-monitor    文件:ElectricityMonitorActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_electricity_monitor);

    firebaseDatabase = FirebaseDatabase.getInstance().getReference();
    final String key = firebaseDatabase.child(FIREBASE_LOGS).push().getKey();

    electricityLog = new ElectricityLog();

    final DatabaseReference onlineRef = firebaseDatabase.child(FIREBASE_INFO_CONNECTED);
    final DatabaseReference currentUserRef = firebaseDatabase.child(FIREBASE_ONLINE_ENDPOINT);
    onlineRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(final DataSnapshot dataSnapshot) {
            Log.d(TAG, "DataSnapshot:" + dataSnapshot);
            if (dataSnapshot.getValue(Boolean.class)) {
                electricityLog.setTimestampOn(ServerValue.TIMESTAMP);
                final DatabaseReference currentLogDbRef = firebaseDatabase.child(FIREBASE_LOGS).child(key);
                currentLogDbRef.setValue(electricityLog);

                currentUserRef.setValue(true);
                currentUserRef.onDisconnect().setValue(false);

                electricityLog.setTimestampOff(ServerValue.TIMESTAMP);
                currentLogDbRef.onDisconnect().setValue(electricityLog);

            }
        }

        @Override
        public void onCancelled(final DatabaseError databaseError) {
            Log.d(TAG, "DatabaseError:" + databaseError);
        }
    });
}
项目:Android-MVP-vs-MVVM-Samples    文件:EntityTranslator.java   
@Exclude
public static Map<String, Object> toMap(final CheckIn checkIn) {

    final Map<String, Object> result = new HashMap<>();

    result.put("email", checkIn.email);
    result.put("checkInMessage", checkIn.checkInMessage);
    result.put("timestamp", checkIn.timestamp == null ? ServerValue.TIMESTAMP : checkIn.timestamp);

    return result;
}
项目:ChatUp    文件:LocationService.java   
@Override
public void onLocationChanged(Location location) {
    //Log.d(TAG, "onLocationChanged: " + location.getLatitude() + " " + location.getLongitude());
    if (location.getLatitude() != lat || location.getLongitude() != lon) {
        lat = location.getLatitude();
        lon = location.getLongitude();
        mLocationRef.setValue(new LocationM(lat, lon, ServerValue.TIMESTAMP));
    }
}
项目:ChatUp    文件:MessageService.java   
private void userPresence() {
    // since I can connect from multiple devices, we store each connection instance separately
    // any time that connectionsRef's value is null (i.e. has no children) I am offline
    final FirebaseDatabase database = FirebaseDatabase.getInstance();
    final DatabaseReference myConnectionsRef = database.getReference("/status/" + Utils.getUid() + "/connections");

    // stores the timestamp of my last disconnect (the last time I was seen online)
    final DatabaseReference lastOnlineRef = database.getReference("/status/" + Utils.getUid() + "/lastOnline");

    final DatabaseReference connectedRef = database.getReference(".info/connected");
    connectedRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
            boolean connected = snapshot.getValue(Boolean.class);
            if (connected) {
                // add this device to my connections list
                // this value could contain info about the device or a timestamp too
                // DatabaseReference con = myConnectionsRef.push();
                myConnectionsRef.setValue(Boolean.TRUE);

                // when this device disconnects, remove it
                myConnectionsRef.onDisconnect().removeValue();

                // when I disconnect, update the last time I was seen online
                lastOnlineRef.onDisconnect().setValue(ServerValue.TIMESTAMP);
            }
        }

        @Override
        public void onCancelled(DatabaseError error) {
            System.err.println("Listener was cancelled at .info/connected");
        }
    });
}
项目:ChatUp    文件:ChatFragment.java   
private void sendTextMessage() {
    if (mMessageBoxState == 1) {

        final MessageObject message = new MessageObject(mMessageBox.getText().toString().trim(),
                ServerValue.TIMESTAMP,
                mMyUid,
                mUser.getUid());
        if (!isIOnline) message.setState(MessageObject.STATE_NOT_SENT);

        DatabaseReference order = mChatRoomRef.push();
        message.setMessageID(order.getKey());

        final String messageId = message.getMessageID();

        mVisitedMessages.put(messageId, 1);
        mMessageList.add(message);
        mAdapter.notifyItemInserted(mMessageList.size() - 1);


        order.setValue(message, new DatabaseReference.CompletionListener() {
            @Override
            public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
                if (databaseError == null) {
                    getMessageFromChatRoom(messageId);
                }
            }
        });

        updateLastMessageNode(messageId);


        mRecyclerView.scrollToPosition(mMessageList.size() - 1);
        mMessageBox.setText("");
    }
}
项目:ChatUp    文件:ChatFragment.java   
@Override
protected void onPostExecute(String s) {
    //     mAlertDialog.dismiss();
    if (s == null || s.length() == 0) {
        if (getActivity() != null)
            Toast.makeText(getActivity(), "image not sent", Toast.LENGTH_SHORT).show();
        return;
    } else if (s.equals("1")) {
        Toast.makeText(getContext(), "not uploaded Please Fix mobile time", Toast.LENGTH_SHORT).show();
        return;
    }
    final MessageObject ms = new MessageObject(s, ServerValue.TIMESTAMP, MessageObject.IMAGE, mMyUid, mUser.getUid());
    //Firebase ord = mRef.push();
    DatabaseReference order = mChatRoomRef.push();
    ms.setMessageID(order.getKey());
    order.setValue(ms, new DatabaseReference.CompletionListener() {
        @Override
        public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
            if (databaseError == null) {
                mAdapter.notifyDataSetChanged();
            }
        }
    });
    mFile = null;
    mMessageList.add(ms);
    mVisitedMessages.put(ms.getMessageID(), 1);
    mAdapter.notifyDataSetChanged();
    mRecyclerView.scrollToPosition(mMessageList.size() - 1);
}
项目:ChatUp    文件:CreateAccountActivity.java   
/**
 * Creates a new user in Firebase from the Java POJO
 */
protected static void createUserInFirebaseHelper(String uid, final User user) {
    final DatabaseReference userLocation =
            FirebaseDatabase.getInstance().getReferenceFromUrl(Constants.FIREBASE_URL_USERS).child(uid);

    /**
     * See if there is already a user (for example, if they already logged in with an associated
     * Google account.
     */
    userLocation.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            /* If there is no user, make one */
            if (dataSnapshot.getValue() == null) {
             /* Set raw version of date to the ServerValue.TIMESTAMP value and save into dateCreatedMap */
                HashMap<String, Object> timestampJoined = new HashMap<>();
                timestampJoined.put(Constants.FIREBASE_PROPERTY_TIMESTAMP, ServerValue.TIMESTAMP);
                user.setTimestampJoined(timestampJoined);

                userLocation.setValue(user);
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.d(TAG, "ERROR: " + databaseError.getMessage());

        }


    });
}
项目:Chit-Chat    文件:FirebaseUtils.java   
public static String sendChatMessageToFirebase(FirebaseDatabase firebaseDatabase, ChatItemDataModel item, String ph_no) {
    DatabaseReference itemDatabaseReference;
    if (item.is_bot) {
        itemDatabaseReference = firebaseDatabase.getReference("botChatItems/" + item.contact_id + "/");
    } else {
        itemDatabaseReference = firebaseDatabase.getReference("chatItems/" +
                item.contact_id.substring(1) + "/");
    }
    DatabaseReference revItemReference = firebaseDatabase.getReference("chatItems/" +
            ph_no.substring(1) + "/");
    final String id_on_server = itemDatabaseReference.push().getKey().substring(1);
    itemDatabaseReference = itemDatabaseReference.child(id_on_server);
    final String cur_id_on_server = revItemReference.push().getKey().substring(1);
    HashMap<String, Object> fbvalues = new HashMap<>();
    fbvalues.put("sender", ph_no);
    fbvalues.put("receiver", item.contact_id);
    fbvalues.put("is_bot", item.is_bot);
    fbvalues.put("type", item.message_type);
    fbvalues.put("content", item.message);
    fbvalues.put("id", id_on_server);
    fbvalues.put("timestamp", item.timestamp);
    fbvalues.put("g_timestamp", ServerValue.TIMESTAMP);

    revItemReference.child("-" + cur_id_on_server).updateChildren(fbvalues);
    itemDatabaseReference.updateChildren(fbvalues);
    return cur_id_on_server;
}
项目:Chit-Chat    文件:FetchNewChatData.java   
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
    if (dataSnapshot.getValue(Boolean.class)) {
        DatabaseReference con = onlineReference.push();
        HashMap<String, Object> value = new HashMap<>();
        value.put("online", Boolean.TRUE);
        value.put("connect", ServerValue.TIMESTAMP);
        con.setValue(value);
        value.put("online", Boolean.FALSE);
        value.put("disconnect", ServerValue.TIMESTAMP);
        con.onDisconnect().updateChildren(value);
    }
}
项目:AvI    文件:ChatMessage.java   
@Exclude
@Override
public Map<String, Object> toMap() {
    HashMap<String, Object> result = new HashMap<>();
    result.put("sender", senderId);
    result.put("message", message);
    result.put("timestamp", ServerValue.TIMESTAMP);
    return result;
}
项目:doorbell    文件:DoorbellActivity.java   
/**
 * Handle image processing in Firebase and Cloud Vision.
 */
private void onPictureTaken(final byte[] imageBytes) {
    if (imageBytes != null) {
        final DatabaseReference log = mDatabase.getReference("logs").push();
        String imageStr = Base64.encodeToString(imageBytes, Base64.NO_WRAP | Base64.URL_SAFE);
        // upload image to firebase
        log.child("timestamp").setValue(ServerValue.TIMESTAMP);
        log.child("image").setValue(imageStr);

        mCloudHandler.post(new Runnable() {
            @Override
            public void run() {
                Log.d(TAG, "sending image to cloud vision");
                // annotate image by uploading to Cloud Vision API
                try {
                    Map<String, Float> annotations = CloudVisionUtils.annotateImage(imageBytes);
                    Log.d(TAG, "cloud vision annotations:" + annotations);
                    if (annotations != null) {
                        log.child("annotations").setValue(annotations);
                    }
                } catch (IOException e) {
                    Log.e(TAG, "Cloud Vison API error: ", e);
                }
            }
        });
    }
}
项目:stockita-point-of-sale    文件:BaseActivity.java   
/**
 * This helper method is to check and listen for the user connection, and also
 * log time stamp when the user disconnect.
 */
private void presenceFunction() {

    // Initialize the .info/connected
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    mUserPresenceRef = database.getReference(".info/connected");

    // Get an instance reference to the location of the user's /usersLog/<uid>/lastOnline
    final DatabaseReference lastOnlineRef = database.getReference()
            .child(Constants.FIREBASE_USER_LOG_LOCATION)
            .child(mUserUid)
            .child(Constants.FIREBASE_PROPERTY_LAST_ONLINE);


    // Initialize the listeners
    mUserPresenceListener = new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

            // Get the boolean value of the connection status
            boolean connected = dataSnapshot.getValue(Boolean.class);

            if (connected) {

                // when I disconnect, update the last time I was seen online
                lastOnlineRef.onDisconnect().setValue(ServerValue.TIMESTAMP);
            }

        }

        @Override
        public void onCancelled(@NonNull DatabaseError databaseError) {
            // Nothing
        }
    };

    // Add the listeners instance to the database database instance
    mUserPresenceRef.addValueEventListener(mUserPresenceListener);

}
项目:stockita-point-of-sale    文件:Utility.java   
/**
 * Create new user profile into Firebase location users
 *
 * @param userName  The user name
 * @param userUID   The user UID from Firebase Auth
 * @param userEmail The user encoded email
 */
public static void createUser(Context context, String userName, String userUID, String userEmail, String userPhoto) {

    // Encoded the email that the user just signed in with
    String encodedUserEmail = Utility.encodeEmail(userEmail);

    // This is the Firebase server value time stamp HashMap
    HashMap<String, Object> timestampCreated = new HashMap<>();

    // Pack the ServerValue.TIMESTAMP into a HashMap
    timestampCreated.put(Constants.FIREBASE_PROPERTY_TIMESTAMP, ServerValue.TIMESTAMP);

    /**
     * Pass those data into java object
     */
    UserModel userModel = new UserModel(userName, userUID, userEmail, userPhoto, timestampCreated);

    /**
     * Initialize the DatabaseReference
     */
    DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();

    /**
     * Get reference into the users location
     */
    DatabaseReference usersLocation = databaseReference.child(Constants.FIREBASE_USER_LOCATION);


    /**
     * Add the user object into the users location in Firebase database
     */
    usersLocation.child(userUID).setValue(userModel);

}
项目:MikuyConcept    文件:Meal.java   
public Meal(String user, Product appetizer, Product entree, Product dessert, Product bevevage) {
    this.user = user;
    this.restaurantId = 1;
    this.appetizer = appetizer;
    this.entree = entree;
    this.dessert = dessert;
    this.bevevage = bevevage;
    this.timestamp = ServerValue.TIMESTAMP;
    this.immutablePrice = (appetizer!=null?appetizer.price:0) +
            (entree!=null?entree.price:0) +
            (dessert!=null?dessert.price:0) +
            (bevevage!=null?bevevage.price:0);
}
项目:Attendance    文件:ApproveListFragment.java   
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mAdapter = new ApproveRxAdapter(Collections.<Attendance>emptyList(), _rxBus);
    getApproveSubscriber = new ApproveListFragment.GetApproveSubscriber();

    gettimestramp = FirebaseDatabase.getInstance().getReference("gettimestamp");
    getTimeListener = new ValueEventListener() {
        public void onDataChange(DataSnapshot dataSnapshot) {
            timestampx=dataSnapshot.getValue().toString();
            Log.d(TAG, "TIMESTAMP onActcreate " + timestampx);
        }
        public void onCancelled(DatabaseError databaseError) { }
    };

    gettimestramp.addValueEventListener(getTimeListener);
    gettimestramp.setValue(ServerValue.TIMESTAMP);


    // Set up Layout Manager, reverse layout
    mManager = new LinearLayoutManager(getActivity());
    mManager.setReverseLayout(true);
    mManager.setStackFromEnd(true);
    mRecycler.setLayoutManager(mManager);
    mRecycler.setAdapter(mAdapter);
    mRecycler.setItemAnimator(new FadeInRightAnimator());
    mRecycler.getItemAnimator().setAddDuration(300);
    mRecycler.getItemAnimator().setRemoveDuration(300);
    loadAbsencesForApproving();




}
项目:Attendance    文件:Attendance.java   
public HashMap<String, Object> getDats() {
    //If there is a dateCreated object already, then return that
    if (dats!= null) {
        return dats;
    }
    //Otherwise make a new object set to ServerValue.TIMESTAMP
    HashMap<String, Object> datsObj = new HashMap<String, Object>();
    datsObj.put("date", ServerValue.TIMESTAMP);
    return datsObj;
}
项目:Attendance    文件:MyList.java   
public MyList(String Listname, HashMap<String, String> myusers, String idm, String iname) {
    this.Listname = Listname;
    this.myusers = myusers;
    this.idm = idm;
    this.iname = iname;
    HashMap<String, Object> datsObj = new HashMap<String, Object>();
    datsObj.put("date", ServerValue.TIMESTAMP);
    this.dats = datsObj;

}
项目:Attendance    文件:MyList.java   
public HashMap<String, Object> getDats() {
    //If there is a dateCreated object already, then return that
    if (dats!= null) {
        return dats;
    }
    //Otherwise make a new object set to ServerValue.TIMESTAMP
    HashMap<String, Object> datsObj = new HashMap<String, Object>();
    datsObj.put("date", ServerValue.TIMESTAMP);
    return datsObj;
}