当前位置: 首页>>代码示例>>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;未经允许,请勿转载。