當前位置: 首頁>>代碼示例>>Java>>正文


Java Firebase.setValue方法代碼示例

本文整理匯總了Java中com.firebase.client.Firebase.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Firebase.setValue方法的具體用法?Java Firebase.setValue怎麽用?Java Firebase.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.firebase.client.Firebase的用法示例。


在下文中一共展示了Firebase.setValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setPresenceImpl

import com.firebase.client.Firebase; //導入方法依賴的package包/類
private Task<Void> setPresenceImpl(User user, PresenceType newPresenceType) {
    Task<Void>.TaskCompletionSource taskSource = Task.<Void>create();

    Firebase presenceRef = firebaseRef.child(user.getPresencePath());
    String value = newPresenceType.name().toLowerCase();

    presenceRef.setValue(value, (firebaseError, firebase) -> {
        if (firebaseError != null) {
            taskSource.setError(firebaseError.toException());
        } else {
            taskSource.setResult(null);
        }
    });

    return taskSource.getTask();
}
 
開發者ID:aluxian,項目名稱:Codementor,代碼行數:17,代碼來源:FirebaseTasks.java

示例2: markReadImpl

import com.firebase.client.Firebase; //導入方法依賴的package包/類
private Task<Void> markReadImpl(Chatroom chatroom, Message message) {
    Task<Void>.TaskCompletionSource taskSource = Task.<Void>create();

    long value = new Date().getTime();
    Firebase messageRef = firebaseRef.child(chatroom.getFirebasePath())
            .child(message.getKey())
            .child("read_at");

    messageRef.setValue(value, (firebaseError, firebase) -> {
        if (firebaseError != null) {
            taskSource.setError(firebaseError.toException());
        } else {
            taskSource.setResult(null);
        }
    });

    return taskSource.getTask();
}
 
開發者ID:aluxian,項目名稱:Codementor,代碼行數:19,代碼來源:FirebaseTasks.java

示例3: startTravel

import com.firebase.client.Firebase; //導入方法依賴的package包/類
public static void startTravel(Context context, String travelKey, String travelTitle) {
    /*
      For switch active travel logic see listener mActiveTravelListener in BaseActivity class
    */

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    String userUID = sharedPreferences.getString(Constants.KEY_USER_UID, null);
    String activeTravelKey = sharedPreferences.getString(Constants.KEY_ACTIVE_TRAVEL_KEY, null);
    if (activeTravelKey != null && !Constants.FIREBASE_TRAVELS_DEFAULT_TRAVEL_KEY.equals(activeTravelKey)) {
        setStopTime(context, activeTravelKey);
    }

    Map<String, Object> map = new HashMap<String, Object>();
    map.put(Constants.FIREBASE_ACTIVE_TRAVEL_TITLE, travelTitle);
    map.put(Constants.FIREBASE_ACTIVE_TRAVEL_KEY, travelKey);
    Firebase activeTravelRef = new Firebase(Utils.getFirebaseUserActiveTravelUrl(userUID));
    activeTravelRef.setValue(map);

    ((BaseActivity) context).enableStartTrackingButton(true);
}
 
開發者ID:trigor74,項目名稱:travelers-diary,代碼行數:21,代碼來源:Utils.java

示例4: addTable

import com.firebase.client.Firebase; //導入方法依賴的package包/類
/**
 * Create an object Table in the database
 * @param empty reference for table ("pointer") to the table object
 * @return Firebase object with the reference to the newly created table
 */
public Firebase addTable(){

	Firebase tableRef = root.child("Table");

	ResturantTable table = new ResturantTable();
	Firebase newTableRef = tableRef.push();

	//System.out.println("Creating Table...");
	newTableRef.setValue(table, new Firebase.CompletionListener() {

		@Override
		public void onComplete(FirebaseError arg0, Firebase arg1) {
			//System.out.println("Table created");

		}
	});

	sleep(2);
	table.setRef(newTableRef);
	tableList.put(newTableRef.toString(), table);
	return newTableRef;
}
 
開發者ID:torch2424,項目名稱:CECS343JavaResturant,代碼行數:28,代碼來源:ConnectFirebase.java

示例5: addUserInfoPassword

import com.firebase.client.Firebase; //導入方法依賴的package包/類
public String addUserInfoPassword() {
    //TODO: (Optional) Update for any new fields added to DbUserInfo class
    // set user id
    String uid = mRef.getAuth().getUid();

    // create record
    String profileImageUrl = "Not provided by authData";
    String provider = mRef.getAuth().getProvider();

    EditText nameView = (EditText) mView.findViewById(R.id.register_name);
    String displayName = nameView.getText().toString();

    if(mRef.getAuth().getProviderData().containsKey("profileImageURL")) profileImageUrl = mRef.getAuth().getProviderData().get("profileImageURL").toString();

    // define users
    DbUserInfo newUserInfo = new DbUserInfo(provider, email, profileImageUrl, displayName);
    Firebase pushUser = mRef.child("userInfo/users").push();
    pushUser.setValue(newUserInfo);

    // define userMap
    LoginActivity.populateUserMap(mRef, uid, pushUser.getKey());

    return pushUser.getKey();
}
 
開發者ID:cardenuto,項目名稱:FirebaseLogin,代碼行數:25,代碼來源:LoginRegisterDialog.java

示例6: addUserInfo

import com.firebase.client.Firebase; //導入方法依賴的package包/類
public String addUserInfo(AuthData authData) {
    //TODO: (Optional) Update for any new fields added to DbUserInfo class
    // set user id
    String uid = authData.getUid();

    // create record
    String provider = authData.getProvider();
    String email = getResources().getString(R.string.missing_user_data);
    String profileImageUrl = getResources().getString(R.string.missing_user_data);
    String displayName = getResources().getString(R.string.missing_user_data);

    if(authData.getProviderData().containsKey("email")) email = authData.getProviderData().get("email").toString();
    if(authData.getProviderData().containsKey("profileImageURL")) profileImageUrl = authData.getProviderData().get("profileImageURL").toString();
    if(authData.getProviderData().containsKey("displayName")) displayName = authData.getProviderData().get("displayName").toString();

    // define users
    DbUserInfo newUserInfo = new DbUserInfo(provider, email, profileImageUrl, displayName);
    Firebase pushUser = mRef.child("userInfo/users").push();
    pushUser.setValue(newUserInfo);

    // define userMap
    populateUserMap(mRef, uid, pushUser.getKey());

    return pushUser.getKey();
}
 
開發者ID:cardenuto,項目名稱:FirebaseLogin,代碼行數:26,代碼來源:LoginActivity.java

示例7: handleMessage

import com.firebase.client.Firebase; //導入方法依賴的package包/類
@Override
public boolean handleMessage(Message msg) {
    final Account primaryAccount = Sessions.getPrimaryPhoneAccount(AccountManager.get(getApplicationContext()));
    if (primaryAccount != null) {
        final Firebase firebase = new Firebase(Constants.FIREBASE_USER_URL + Hasher.hash(primaryAccount.name));
        final Firebase message = firebase.child("message");
        message.setValue(etSyncable.getText().toString());
        orderSync();
    }
    return false;
}
 
開發者ID:Sefford,項目名稱:BeAuthentic,代碼行數:12,代碼來源:LoggedActivity.java

示例8: insert

import com.firebase.client.Firebase; //導入方法依賴的package包/類
/**
 * Insert some object in specific repository with random id.
 *
 * @param item Object that you want to insert.
 */
@Override
public T insert(T item) {
    Firebase ref = firebase.push();
    ref.setValue(item);
    item.setId(ref.getKey());
    map.put(ref.getKey(), item);
    return item;
}
 
開發者ID:BlunchDev,項目名稱:blunch_android,代碼行數:14,代碼來源:FirebaseRepository.java

示例9: saveToFirebase

import com.firebase.client.Firebase; //導入方法依賴的package包/類
public static void saveToFirebase(GeoFire geoFire,Firebase db, Tutor tutor, Location location){
    if(location != null) {
        Firebase tutorStore = db.child("tutors").child(tutor.getFullName());
        tutorStore.setValue(tutor);
        geoFire.setLocation(tutor.getFullName(), new GeoLocation(location.getLatitude(), location.getLongitude()));
    }
}
 
開發者ID:StephenVanSon,項目名稱:TutorMe,代碼行數:8,代碼來源:Tutor.java

示例10: touchFirebase

import com.firebase.client.Firebase; //導入方法依賴的package包/類
void touchFirebase(){
        // Write trip to firebase
//        String fbId;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd", Locale.US);

        Firebase tripsRef = new Firebase("https://dazzling-fire-3233.firebaseio.com/trips-started/"+
                sdf.format(new Date(System.currentTimeMillis())));

        Firebase newPushRef = tripsRef.push();
        newPushRef.setValue(System.currentTimeMillis());
//        fbId = newPushRef.getName();
    }
 
開發者ID:RobertTrebor,項目名稱:CycleFrankfurtAndroid,代碼行數:13,代碼來源:RecordingActivity.java

示例11: addPatient

import com.firebase.client.Firebase; //導入方法依賴的package包/類
/**
 * Method for adding a patient for the doctor
 * @param patientEmail - patient email
 */
public void addPatient(String patientEmail) {
    //Getting doctor id_key
    String doc_key = email.replace(".", "");
    //Getting patient id_key
    String pat_key = patientEmail.replace(".", "");
    Firebase firebase = new Firebase("https://care-connect.firebaseio.com/doctors/"
            + doc_key
            + "/patients/" + pat_key);
    firebase.setValue(pat_key);
    //Assigning doc_key to patient
    Firebase patFirebase = new Firebase("https://care-connect.firebaseio.com/patients/" + pat_key + "/doctor_key");
    patFirebase.setValue(doc_key);
}
 
開發者ID:ursopanda,項目名稱:kneeRehabMonitoring,代碼行數:18,代碼來源:DrawerActivity.java

示例12: addPatient

import com.firebase.client.Firebase; //導入方法依賴的package包/類
private void addPatient(Firebase firebase) {
//            FirebaseHelper fb = new FirebaseHelper();
            Patient patient = new Patient(mName, mSurname, mEmail, mPassword, mGender, mPhoneNumber);
//            fb.newPatient(patient, firebase);
            firebase.setValue(patient);
            patientFirebase.removeEventListener(patientListener);

            Toast.makeText(getBaseContext(), "Registration successful!", Toast.LENGTH_LONG).show();
            Intent intent = new Intent(getBaseContext(), LoginActivity.class);
            startActivity(intent);
        }
 
開發者ID:ursopanda,項目名稱:kneeRehabMonitoring,代碼行數:12,代碼來源:RegisterActivity.java

示例13: addDoctor

import com.firebase.client.Firebase; //導入方法依賴的package包/類
private void addDoctor(Firebase firebase) {
            doctorFirebase.removeEventListener(doctorListener);
//            FirebaseHelper fb = new FirebaseHelper();
            Doctor doctor = new Doctor(mName, mSurname, mEmail, mPassword, mPhoneNumber);
//            fb.newDoctor(doctor, firebase);
            firebase.setValue(doctor);

            Toast.makeText(getBaseContext(), "Registration successful!", Toast.LENGTH_LONG).show();
            Intent intent = new Intent(getBaseContext(), LoginActivity.class);
            startActivity(intent);
        }
 
開發者ID:ursopanda,項目名稱:kneeRehabMonitoring,代碼行數:12,代碼來源:RegisterActivity.java

示例14: clearTable

import com.firebase.client.Firebase; //導入方法依賴的package包/類
/**
 *
 * Set the specific table to the inital state
 * @param table Firebase ref to that table object.
 */
public void clearTable(Firebase table){
	//System.out.println("Clearing Table...");
	table.setValue(new ResturantTable(), new Firebase.CompletionListener() {

		@Override
		public void onComplete(FirebaseError arg0, Firebase arg1) {
			//System.out.println("Table cleared");

		}
	});
	sleep(2);
}
 
開發者ID:torch2424,項目名稱:CECS343JavaResturant,代碼行數:18,代碼來源:ConnectFirebase.java

示例15: addItem

import com.firebase.client.Firebase; //導入方法依賴的package包/類
/**
 * Adds a new item to the list, from the main screen.
 * Called from the View when the Add button is pressed;
 * registered via onClick= so no Listener code
 */
public void addItem(View v) {
	String name = mAddTF.getText().toString();
	if (name.isEmpty()) {
		Toast.makeText(this, "Text required!", Toast.LENGTH_SHORT).show();
		return;
	}

       Log.d(TAG, "addItem: trying to add " + name);

	/* Do the work here! Create a Task... */
	Task t = new Task();
	t.setName(mAddTF.getText().toString());
	t.setPriority(Priority.values()[prioSpinner.getSelectedItemPosition()]);
	t.setModified(System.currentTimeMillis());
	t.setStatus(Status.NEW);

	/* NOW: send it to the cloud... */
       Firebase push = ((ApplicationClass)getApplication()).getDatabase().push();
       push.setValue(t);
       Log.d(TAG, "Local key for pushed Task is " + push.getKey());

       // We don't have to add it to the list: our list listener will get an Event soon...

       // ... but if we get here, it's been fed into Fire so we don't need to keep it.
       mAddTF.setText("");
}
 
開發者ID:IanDarwin,項目名稱:TodoAndroidFirebase,代碼行數:32,代碼來源:TaskListActivity.java


注:本文中的com.firebase.client.Firebase.setValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。