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


Java DatabaseReference.setValue方法代碼示例

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


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

示例1: updateIndex

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
public Promise<Void, BError, Void> updateIndex(){

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

        Map<String, String> values = new HashMap<String, String>();
        
        String name = model.getMetaName();
        String email = model.getMetaEmail();
        String phoneNumber = model.metaStringForKey(BDefines.Keys.BPhone);

        values.put(BDefines.Keys.BName, StringUtils.isNotEmpty(name) ? AbstractNetworkAdapter.processForQuery(name) : "");
        values.put(BDefines.Keys.BEmail, StringUtils.isNotEmpty(email) ? AbstractNetworkAdapter.processForQuery(email) : "");

        if (BDefines.IndexUserPhoneNumber && StringUtils.isNotBlank(phoneNumber))
            values.put(BDefines.Keys.BPhone, AbstractNetworkAdapter.processForQuery(phoneNumber));


        DatabaseReference ref = FirebasePaths.indexRef().child(entityId);

        ref.setValue(values, new DatabaseReference.CompletionListener() {
            @Override
            public void onComplete(DatabaseError firebaseError, DatabaseReference firebase) {
                if (firebaseError==null)
                {
                    deferred.resolve(null);
                }
                else{
                    deferred.reject(getFirebaseError(firebaseError));
                }
            }
        });
        
        
        return deferred.promise();
    }
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:36,代碼來源:BUserWrapper.java

示例2: sendData

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
public void sendData(String mealOrder) {
    DatabaseReference node = FirebaseDatabase.getInstance().getReference().child("Orders").push();
    ///final String key = node.getKey();
    String userId = getUid();
    node.setValue(new Order(mealOrder,userId));
    //final DatabaseReference mCustomerDatabase= FirebaseDatabase.getInstance().getReference().child("Users").child(userId);
    //node.setValue(new Order(mealOrder,userId));
}
 
開發者ID:thandomy,項目名稱:foodie,代碼行數:9,代碼來源:Order.java

示例3: goOnline

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
/**
 * Set the user online value to true.
 * 
 * When firebase disconnect this will be auto change to false.
 **/
public void goOnline(){
    DatabaseReference userOnlineRef = FirebasePaths.userOnlineRef(entityId);

    // Set the current state of the user as online.
    // And add a listener so when the user log off from firebase he will be set as disconnected.
    userOnlineRef.setValue(true);
    userOnlineRef.onDisconnect().setValue(false);
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:14,代碼來源:BUserWrapper.java

示例4: updateBanList

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
/**
 * update the banlist
 * @param username the user's username
 * @param operation the direction of operation (add/remove)
 */
private void updateBanList(String username, boolean operation) {
    if (operation) {
        UserDetails.addBanList(username);
    } else {
        UserDetails.removeBanList(username);
    }
    DatabaseReference df_2 = FirebaseDatabase.getInstance().getReference("banList");
    df_2.setValue(UserDetails.getBanList());
}
 
開發者ID:IvoryCandy,項目名稱:Plus1s,代碼行數:15,代碼來源:BanActivity.java

示例5: save

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@OnClick(R.id.save_button)
public void save() {
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("message");

    myRef.setValue(dataEditText.getText().toString());
}
 
開發者ID:micromasterandroid,項目名稱:androidadvanced,代碼行數:8,代碼來源:MainActivity.java

示例6: onCreate

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add);
    setTitle("Add");

    username = getIntent().getStringExtra("username");
    userUid = getIntent().getStringExtra("userUid");

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("message");

    myRef.setValue("Hello, World!");

}
 
開發者ID:Th3VileOne,項目名稱:ReminderPrj,代碼行數:16,代碼來源:addActivity.java

示例7: addNewUserToFirebase

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
private void addNewUserToFirebase( final Spinner mGenderSpinner ) {
    Map<String,Object> additions = new HashMap<>();

    additions.put( "email", tempEmail );
    additions.put( "suspended", false );
    additions.put( "locked", false );
    additions.put( "firstName", tempFirstName );
    additions.put( "middleName", tempMiddleName );
    additions.put( "lastName", tempLastName );

    // Personal Info
    additions.put( "bio", "" );

    String tempDoB = "" + tempDoBYear + "-" + (tempDoBMonth < 10 ? "0" + tempDoBMonth : tempDoBMonth)
            + "-" + (tempDoBDay < 10 ? "0" + tempDoBDay : tempDoBDay);

    additions.put( "birth_date", tempDoB );

    if ( mGenderSpinner.getSelectedItem().toString().equals( "Male" ) ) {
        additions.put( "gender", "male" );
    }
    else if ( mGenderSpinner.getSelectedItem().toString().equals( "Female" ) ) {
        additions.put( "gender", "female" );
    }
    else {
        additions.put( "gender", "non-binary" );
    }

    // Location
    additions.put( "city", "" );
    additions.put( "state", "" );
    additions.put( "country", "" );

    additions.put( "latitude", 0 );
    additions.put( "longitude", 0 );

    DatabaseReference ref = dbHelper.getDb().getReference().child(getString(R.string.sign_up_firebase_user)).child(dbHelper.getUser().getUid());
    ref.setValue( additions );
}
 
開發者ID:chrisqz95,項目名稱:couch-potatoes,代碼行數:40,代碼來源:SignUpActivity.java

示例8: push

import com.google.firebase.database.DatabaseReference; //導入方法依賴的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

示例9: onOptionsItemSelected

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.save_media) {
        switch (mediaType) {
            case 1: // text
                DateTime now = DateTime.now();
                DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
                JournalEntry currentEntry = new JournalEntry();
                currentEntry.setCaption(entry_caption.getText().toString());
                currentEntry.setType(mediaType);
                currentEntry.setLat(ALLENDALE_LAT);
                currentEntry.setLng(ALLENDATE_LNG);
                currentEntry.setDate(fmt.print(now));

                DatabaseReference savedEntry = entriesRef.push();
                savedEntry.setValue(currentEntry);
                Snackbar.make(entry_caption,
                        "Your entry is saved",
                        Snackbar.LENGTH_LONG).show();
                break;
            case 2: // photo
                uploadMedia(mediaType, "image/jpeg", "photos");
                break;
            case 3: // audio
                uploadMedia(mediaType, "audio/m4a", "audio");

                break;
            case 4: // video
                uploadMedia(mediaType, "video/mp4", "videos");
                break;
        }
        return true;
    }
    return false;
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:36,代碼來源:MediaDetailsActivity.java

示例10: writeDataBase

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
private void writeDataBase(String message){
    // Write a message to the database
    FirebaseApp.initializeApp(getActivity());
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    Calendar mCal = Calendar.getInstance();
    CharSequence s = DateFormat.format("yyyy-MM-dd kk:mm:ss", mCal.getTime());
    DatabaseReference myRef = database.getReference((String) s);
    myRef.setValue(message);
}
 
開發者ID:kamisakihideyoshi,項目名稱:TaipeiTechRefined,代碼行數:10,代碼來源:FeedbackFragment.java

示例11: addCategorieClick

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@OnClick(R.id.addCategorieButton)
public void addCategorieClick() {
    String text = categoryEditText.getText().toString();
    if(!text.isEmpty()) {
        DatabaseReference dbRefChield = dbRef.push();
        Category cat = new Category();
        cat.setId(dbRefChield.getKey());
        cat.setName(text);
        dbRefChield.setValue(cat);
        categoryEditText.setText("");
    } else {
        Snackbar.make(categoryEditText, R.string.empty_category_snackbar_text, Snackbar.LENGTH_LONG).show();
    }
}
 
開發者ID:feliperce,項目名稱:MyNotes,代碼行數:15,代碼來源:CategoryActivity.java

示例12: onCreateView

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    FirebaseAuth auth = FirebaseAuth.getInstance();
    final String uid = auth.getCurrentUser().getUid();
    final DatabaseReference ref = database.getReference("users").child(uid).child("distress");
    ref.setValue(dist);
    final View rootView = inflater.inflate(R.layout.fragment_distress, null, false);

    final TextView tvDistress = (TextView) rootView.findViewById(R.id.tvDistress);
    ImageView ivDistressSignal = (ImageView) rootView.findViewById(R.id.ivDistressSignal);
    ivDistressSignal.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(dist) {
                ref.setValue(false);
                dist = false;
                tvDistress.setText("All Clear");
            }
            else {
                ref.setValue(true);
                dist = true;
                tvDistress.setText("Group Notified");
            }
        }
    });
    return rootView;
}
 
開發者ID:mremondi,項目名稱:Hyke,代碼行數:29,代碼來源:DistressFragment.java

示例13: add

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
/**
 * Add a new FollowRequest to Firebase.
 * @param followRequest
 */
@Override
public void add(FollowRequest followRequest) {
    DatabaseReference newRef = mFollowRequestRef.push();
    String key = newRef.getKey();
    followRequest.setKey(key);
    newRef.setValue(followRequest);
}
 
開發者ID:CMPUT301F17T13,項目名稱:cat-is-a-dog,代碼行數:12,代碼來源:FollowRequestRepository.java

示例14: saveStatus

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
private void saveStatus() {
    DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference().child("users").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child("status");
    mDatabase.setValue(mETxtStatus.getText().toString());
}
 
開發者ID:mustafaozhan,項目名稱:Howl,代碼行數:5,代碼來源:SettingsFragment.java

示例15: saveUsername

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
private void saveUsername() {
    DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference().child("users").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child("nameAndSurname");
    mDatabase.setValue(mETxtUsername.getText().toString());

}
 
開發者ID:mustafaozhan,項目名稱:Howl,代碼行數:6,代碼來源:SettingsFragment.java


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