当前位置: 首页>>代码示例>>Java>>正文


Java ServerValue类代码示例

本文整理汇总了Java中com.google.firebase.database.ServerValue的典型用法代码示例。如果您正苦于以下问题:Java ServerValue类的具体用法?Java ServerValue怎么用?Java ServerValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServerValue类属于com.google.firebase.database包,在下文中一共展示了ServerValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: User

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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;
}
 
开发者ID:r3bl-alliance,项目名称:starterproject_todolist_react_redux_firebase_ts_md,代码行数:22,代码来源:User.java

示例2: toMap

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
@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;
}
 
开发者ID:braulio94,项目名称:Quadro,代码行数:19,代码来源:Post.java

示例3: onPostLike

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
@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) {

        }
    });
}
 
开发者ID:firebase,项目名称:friendlypix-android,代码行数:22,代码来源:FeedsActivity.java

示例4: sendFileTextMessageToFirebase

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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);
}
 
开发者ID:arunrajora,项目名称:Chit-Chat,代码行数:27,代码来源:FirebaseUtils.java

示例5: toMap

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
@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;
}
 
开发者ID:smukov,项目名称:AvI,代码行数:20,代码来源:UserInfo.java

示例6: ParcelableCard

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:dasfoo,项目名称:delern,代码行数:23,代码来源:ParcelableCard.java

示例7: create

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:dasfoo,项目名称:delern,代码行数:22,代码来源:Card.java

示例8: Attendance

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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;
}
 
开发者ID:eurosecom,项目名称:Attendance,代码行数:26,代码来源:Attendance.java

示例9: createUserInFirebaseHelper

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
@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();

        }


    });
}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:34,代码来源:LoginPresenter.java

示例10: getItemData

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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;
}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:31,代码来源:AddActivity.java

示例11: verifyPresence

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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");
            }
        });
    }
 
开发者ID:codingdojoangola,项目名称:cda-app,代码行数:34,代码来源:ChatActivity.java

示例12: serialize

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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;
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:12,代码来源:BMessageWrapper.java

示例13: push

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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();
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:28,代码来源:BMessageWrapper.java

示例14: serialize

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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;
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:10,代码来源:BUserWrapper.java

示例15: UserAccount

import com.google.firebase.database.ServerValue; //导入依赖的package包/类
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);
}
 
开发者ID:MohamedNagyMostafa,项目名称:IM_Here,代码行数:12,代码来源:UserAccount.java


注:本文中的com.google.firebase.database.ServerValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。