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


Java Firebase.child方法代码示例

本文整理汇总了Java中com.firebase.client.Firebase.child方法的典型用法代码示例。如果您正苦于以下问题:Java Firebase.child方法的具体用法?Java Firebase.child怎么用?Java Firebase.child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.firebase.client.Firebase的用法示例。


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

示例1: addValuesFireBase

import com.firebase.client.Firebase; //导入方法依赖的package包/类
public void addValuesFireBase(String temperature, String humidade, double latitude, double longitude, String currentDateandTime, String district){
    mRef = new Firebase("https://livingcityapp.firebaseio.com");

    Firebase usersRef = mRef.child(currentDateandTime);

    SimpleDateFormat hora = new SimpleDateFormat("HH:mm:ss");
    String currenthora = hora.format(new Date());

    Map<String, String> map = new HashMap<>();
    map.put("Temperature",temperature);
    map.put("Humidade", humidade);
    map.put("Hora",currenthora);
    map.put("Latitude", Double.toString(latitude));
    map.put("Longitude", Double.toString(longitude));
    map.put("Distrito", district);


    Map<String, Object> mapaCompleto = new HashMap<>();
    mapaCompleto.put(currenthora, map);

    usersRef.updateChildren(mapaCompleto);
}
 
开发者ID:ruipoliveira,项目名称:livingCity-Android,代码行数:23,代码来源:FireBaseModule.java

示例2: addToiletToFirebase

import com.firebase.client.Firebase; //导入方法依赖的package包/类
public void addToiletToFirebase(View v) {
    // Look up all the data: Assumes that no values are NULL
    Firebase rootRef = new Firebase(MainActivity.FIREBASE_URL);
    final Firebase array = rootRef.child("toilets");
    array.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Toilet t = new Toilet(mName, mLocation, mRating, mNotes, mFamilyFriendly, mGenderNeutral, mHandicapAccessible, "");
            array.push().setValue(t);
            // Actually ends the activity
            finish();
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
        }
    });
}
 
开发者ID:thorsteinson,项目名称:porcelain,代码行数:19,代码来源:AddToiletActivity.java

示例3: orderSync

import com.firebase.client.Firebase; //导入方法依赖的package包/类
void orderSync() {
    final Account primaryAccount = Sessions.getPrimaryPhoneAccount(AccountManager.get(getApplicationContext()));
    if (primaryAccount == null) {
        return;
    }
    final Firebase firebase = new Firebase(Constants.FIREBASE_USER_URL + Hasher.hash(primaryAccount.name));
    final Firebase devices = firebase.child("devices");
    if (primaryAccount != null) {
        devices.addListenerForSingleValueEvent(new ValueEventListenerAdapter() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                if (snapshot.exists()) {
                    Intent intent = new Intent(LoggedActivity.this, NotifySyncService.class);
                    intent.putStringArrayListExtra(LoginGCMNotificationService.EXTRA_DEVICES, (ArrayList<String>) snapshot.getValue());
                    startService(intent);
                }
            }
        });
    }
}
 
开发者ID:Sefford,项目名称:BeAuthentic,代码行数:21,代码来源:LoggedActivity.java

示例4: notifyLoginToGCM

import com.firebase.client.Firebase; //导入方法依赖的package包/类
void notifyLoginToGCM(final int type, final String name, final String password, final String authtoken) {
    final Account primaryAccount = Sessions.getPrimaryPhoneAccount(AccountManager.get(getApplicationContext()));
    if (primaryAccount == null) {
        return;
    }
    final Firebase firebase = new Firebase(Constants.FIREBASE_USER_URL + Hasher.hash(primaryAccount.name));
    final Firebase devices = firebase.child("devices");
    if (primaryAccount != null) {
        devices.addListenerForSingleValueEvent(new ValueEventListenerAdapter() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                if (snapshot.exists()) {
                    Intent intent = new Intent(LoginActivity.this, LoginGCMNotificationService.class);
                    intent.putExtra(LoginGCMNotificationService.EXTRA_TYPE, type);
                    intent.putExtra(LoginGCMNotificationService.EXTRA_NAME, name);
                    intent.putExtra(LoginGCMNotificationService.EXTRA_PASSWORD, password);
                    intent.putExtra(LoginGCMNotificationService.EXTRA_AUTHTOKEN, authtoken);
                    intent.putStringArrayListExtra(LoginGCMNotificationService.EXTRA_DEVICES, (ArrayList<String>) snapshot.getValue());
                    startService(intent);
                }
            }
        });
    }
}
 
开发者ID:Sefford,项目名称:BeAuthentic,代码行数:25,代码来源:LoginActivity.java

示例5: sendRegistrationToServer

import com.firebase.client.Firebase; //导入方法依赖的package包/类
/**
 * Persist registration to third-party servers.
 * <p/>
 * Modify this method to associate the user's GCM registration token with any server-side account
 * maintained by your application.
 *
 * @param token The new token.
 */
private void sendRegistrationToServer(final String token) {
    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 devices = firebase.child("devices");
        devices.addListenerForSingleValueEvent(new ValueEventListenerAdapter() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                if (!snapshot.exists()) {
                    devices.setValue(Arrays.asList(token));
                } else {
                    List<String> firebaseDevices = (List<String>) snapshot.getValue();
                    if (!firebaseDevices.contains(token)) {
                        firebaseDevices.add(token);
                        devices.setValue(firebaseDevices);
                    }
                }
            }
        });
    }
}
 
开发者ID:Sefford,项目名称:BeAuthentic,代码行数:30,代码来源:RegistrationIntentService.java

示例6: onActivityResult

import com.firebase.client.Firebase; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_PLACE_PICKER) {
        if (resultCode == Activity.RESULT_OK) {
            Place place = PlacePicker.getPlace(this,data);
            Map<String,Object>shareLocation=new HashMap<>();
            shareLocation.put("time", ServerValue.TIMESTAMP);
            //get data from Login Activity
            Intent in=getIntent();
            Bundle b=in.getExtras();
            String name=b.getString("name");
            Long number=b.getLong("contact_no");
            Toast.makeText(this,"name: "+name+" number: "+number.toString(),Toast.LENGTH_SHORT).show();
            //Map<String,Long>userData=new HashMap<>();
            //userData.put(name,number);
            Map userData=new HashMap();
            userData.put(name,number);
            mFirebase.child(FIREBASE_ROOT_NODE).child(place.getId()).setValue(shareLocation);
            Firebase fire=new Firebase(FIREBASE_URL);
            Firebase userRef=fire.child(FIREBASE_ROOT_NODE);
            Firebase people=userRef.child(place.getId());
            people.updateChildren(userData);
            //mFirebase.child(FIREBASE_ROOT_NODE).child(place.getId());
            //mFirebase.setValue(userData);
            Toast.makeText(this,"added:"+name+" "+number,Toast.LENGTH_SHORT).show();
            //Toast.makeText(this,"added location",Toast.LENGTH_SHORT).show();
        } else if (resultCode == PlacePicker.RESULT_ERROR) {
            Toast.makeText(this, "Places API failure! Check that the API is enabled for your key",
                    Toast.LENGTH_LONG).show();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
 
开发者ID:agarwal-akash,项目名称:BonAppetit_Android-Project,代码行数:35,代码来源:MapsActivity.java

示例7: onCreate

import com.firebase.client.Firebase; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_review);

    getSupportActionBar().setTitle("New Review");

    View parent = findViewById(android.R.id.content);
    setupUI(parent);
    registerListeners();
    //grab this GUID from previous activity to use for searching the database
    key = getIntent().getStringExtra("GUID");

    //grab views to change
    reviewTitle = (TextView) findViewById(R.id.reviewTitle);
    rating = (RatingBar) findViewById(R.id.reviewRating);
    reviewText = (EditText) findViewById(R.id.reviewText);

    //grab the pieces of information from the Firebase
    Firebase rootRef = new Firebase(MainActivity.FIREBASE_URL);
    final Firebase bathroom = rootRef.child("toilets").child(key);
    reviewRef = bathroom.child("review");
    ratingRef = bathroom.child("rating");
    bathroom.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            HashMap<String, Object> fireToilet = (HashMap<String, Object>) dataSnapshot.getValue();

            //changes the title, so the user understands what restroom they're reviewing
            String title = (String) fireToilet.get("name");
            reviewTitle.setText("Create a new review for " + title);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
        }
    });
}
 
开发者ID:thorsteinson,项目名称:porcelain,代码行数:39,代码来源:ReviewActivity.java

示例8: onCreate

import com.firebase.client.Firebase; //导入方法依赖的package包/类
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //Necessary to set Firebase context before using it.
        Firebase.setAndroidContext(getContext());

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            // Load the dummy content specified by the fragment
            // arguments. In a real-world scenario, use a Loader
            // to load content from a content provider.
            mItem = Data.items.get(Long.parseLong(getArguments().getString(ARG_ITEM_ID)));
            Activity activity = this.getActivity();
//            CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
//            if (appBarLayout != null) {
//                appBarLayout.setTitle("");
//            }
        }

        firebase = new Firebase("https://hacker-news.firebaseio.com/v0/");
        firebaseItems = firebase.child("item");


        Log.d("mItem Kids size:", Integer.toString(mItem.kids.size()));
        Data.comments.clear();

    }
 
开发者ID:sahilshekhawat,项目名称:Pocket-Hacker-News,代码行数:28,代码来源:PostDetailFragment.java

示例9: 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

示例10: ProductsService

import com.firebase.client.Firebase; //导入方法依赖的package包/类
public ProductsService(Firebase firebase) {
    this.firebaseNode = firebase.child("products");
}
 
开发者ID:elser,项目名称:FirebaseJUnitExample,代码行数:4,代码来源:ProductsService.java

示例11: createQuery

import com.firebase.client.Firebase; //导入方法依赖的package包/类
@Override
protected Query createQuery(Firebase firebase) {
    return firebase.child(chatroom.getOtherUser().getPresencePath());
}
 
开发者ID:aluxian,项目名称:Codementor,代码行数:5,代码来源:ChatroomItemViewHolder.java

示例12: testFirebase

import com.firebase.client.Firebase; //导入方法依赖的package包/类
void testFirebase() {
    Firebase rootRef = new Firebase("https://fiery-torch-3951.firebaseio.com/");
    final Firebase array = rootRef.child("toilets");
    array.addValueEventListener(new ValueEventListener() {
        boolean addedData = false;

        @Override
        // This callback get's called when the data FIRST becomes available, and then
        // when it changes as well.
        public void onDataChange(DataSnapshot snapshot) {
            Log.v(TAG, "Data change called");
            // Prevents infinite loop, we only want to change the data once
            // Without this, as soon as a value changes, it would trigger another change
            Map<String, HashMap<String, Object>> val = (HashMap<String, HashMap<String, Object>>) snapshot.getValue();

            Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.toilet);
            Bitmap smaller = Bitmap.createScaledBitmap(icon, (icon.getWidth() / 4) * 3, (icon.getHeight() / 4) * 3, false);
            BitmapDescriptor toil = BitmapDescriptorFactory.fromBitmap(smaller);

            //LatLng point = new LatLng(-23,44.00);
            //Place p = new Place("A Bathroom", point, 3.0, "A clean and safe environment");
            //Log.v(TAG, "" + val);
            if (val != null) {
                for (String s : val.keySet()) {
                    HashMap h = val.get(s);

                    // Log.d(TAG, "Added Marker To Map " + h.get("name"));
                    HashMap<String, Double> coords = (HashMap) h.get("latLng");
                    LatLng point = new LatLng((Double) coords.get("latitude"), (Double) coords.get("longitude"));

                    Marker mapPoint = mMap.addMarker(new MarkerOptions()
                            .position(point)
                            .title(s)
                            .snippet("" + h.get("name"))
                            .icon(toil));


                    Place p = new Place((String) h.get("name"),
                            point,
                            (Long) h.get("rating"),
                            (String) h.get("descr"),
                            (Boolean) h.get("isFamilyFriendly"),
                            (Boolean) h.get("isGenderNeutral"),
                            (Boolean) h.get("isHandicapAccessible"),
                            (String) h.get("review"), s);

                    boolean familyFilter = sharedPref.getBoolean("pref_family", false);
                    boolean genderFilter = sharedPref.getBoolean("pref_gender", false);
                    boolean handicapFilter = sharedPref.getBoolean("pref_handicap", false);
                    String ratingFilter = sharedPref.getString("rating_filter", "3");

                    //sets all markers to 'visible' state, in case the filters have changed
                    mapPoint.setVisible(true);

                    //sets all irrelevant data based off of filter and amenity settings
                    if (!((!familyFilter || (familyFilter && (Boolean) h.get("isFamilyFriendly")))
                            && (!genderFilter || (genderFilter && (Boolean) h.get("isGenderNeutral")))
                            && (!handicapFilter || (handicapFilter && (Boolean) h.get("isHandicapAccessible")))
                            && (Long.parseLong(ratingFilter) <= (Long)h.get("rating")))) {
                        mapPoint.setVisible(false);
                    }

                    mMarkerMap.put(mapPoint, p);
                }
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            Log.v(TAG, "The read failed: " + firebaseError.getMessage());
        }
    });
}
 
开发者ID:thorsteinson,项目名称:porcelain,代码行数:74,代码来源:MainActivity.java

示例13: saveItem

import com.firebase.client.Firebase; //导入方法依赖的package包/类
public boolean saveItem() {
    //save title
    if (isTitleVisible) {
        if (!Utils.isEmpty(mRemindItemTitleEditText)) {
            mRemindItem.setTitle(mRemindItemTitleEditText.getText().toString());
        } else if (mRemindItem.getTitle() == null) {
            Toast.makeText(getContext(), R.string.title_field_is_empty, Toast.LENGTH_SHORT).show();
            mRemindItemTitleEditText.requestFocus();
            return false;
        }
    } else {
        if (!Utils.isEmpty(mBigTitle)) {
            mRemindItem.setTitle(mBigTitle.getText().toString());
        } else if (mRemindItem.getTitle() == null) {
            Toast.makeText(getContext(), R.string.title_field_is_empty, Toast.LENGTH_SHORT).show();
            mBigTitle.requestFocus();
            return false;
        }
    }

    String error = validateData();
    if (error != null && !error.isEmpty()) {
        showErrorDialog(error);
        return false;
    }

    Firebase firebaseRef = new Firebase(Utils.getFirebaseUserReminderUrl(mUserUID));
    if (mItemKey != null && !mItemKey.isEmpty()) {
        // update item
        if (mRemindItem.getUID() == 0) {
            // TODO: 15.05.16 remove this after database upgrade
            mRemindItem.setUID(mItemKey.hashCode());
        }
        Firebase updateItemRef = firebaseRef.child(mItemKey);
        updateItemRef.setValue(mRemindItem);
    } else {
        // create item
        Firebase newItemRef = firebaseRef.push();
        mItemKey = newItemRef.getKey();
        mRemindItem.setUID(mItemKey.hashCode());
        newItemRef.setValue(mRemindItem);
    }

    if (mRemindItem.isActive() && !mRemindItem.isCompleted()) {
        Utils.enableAlarmGeofence(getActivity().getApplicationContext(), mRemindItem, mItemKey);
    } else {
        Utils.disableAlarmGeofence(getActivity().getApplicationContext(), mRemindItem);
    }

    return true;
}
 
开发者ID:trigor74,项目名称:travelers-diary,代码行数:52,代码来源:ReminderItemFragment.java

示例14: onStartCommand

import com.firebase.client.Firebase; //导入方法依赖的package包/类
/**
 * track: users/USER_UID/tracks/TRAVEL_UID/TRACK_UID/track/[TIMESTAMP:LOCATION_POINT]
 * track/[TIMESTAMP:LOCATION_POINT] - TrackList class
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent == null) {
        if (!mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()) {
            mGoogleApiClient.connect();
        }
        return Service.START_STICKY;
    }

    String action = intent.getAction();
    if (action == null) {
        action = "";
    }

    switch (action) {
        case ACTION_GET_CURRENT_LOCATION:
            isSingleRequestLocation = true;
            if (mGoogleApiClient.isConnected()) {
                mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
                mLastUpdateTimestamp = System.currentTimeMillis();

                if (mCurrentLocation != null) {
                    isSingleRequestLocation = false;
                    sendCurrentLocation();
                } else {
                    if (!isRequestingLocationUpdates) {
                        startLocationUpdates();
                    }
                }
            } else {
                if (!mGoogleApiClient.isConnecting()) {
                    mGoogleApiClient.connect();
                }
            }
            break;
        case ACTION_START_TRACK:
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
            mTravelId = sharedPreferences.getString(Constants.KEY_ACTIVE_TRAVEL_KEY, null);
            if (mTravelId == null) {
                mTravelId = Constants.FIREBASE_TRAVELS_DEFAULT_TRAVEL_KEY;
            }
            isTrackingEnabled = true;

            Firebase userTracksRef = new Firebase(Utils.getFirebaseUserTracksUrl(mUserUID));
            Firebase newTrackRef = userTracksRef.child(mTravelId).push();
            mTrackRef = newTrackRef.child(Constants.FIREBASE_TRACKS_TRACK);

            if (mGoogleApiClient.isConnected() && !isRequestingLocationUpdates) {
                startLocationUpdates();
            } else {
                if (!mGoogleApiClient.isConnecting()) {
                    mGoogleApiClient.connect();
                }
            }
            break;
        case ACTION_STOP_TRACK:
            isTrackingEnabled = false;
            mTrackRef = null;
            if (mGoogleApiClient.isConnected() && !isSingleRequestLocation && isRequestingLocationUpdates) {
                stopLocationUpdates();
            }
            break;
        case ACTION_CHECK_TRACKING:
            BusProvider.bus().post(new CheckTrackingEvent(isTrackingEnabled));
            break;
        default:
    }

    return Service.START_STICKY;
}
 
开发者ID:trigor74,项目名称:travelers-diary,代码行数:75,代码来源:LocationTrackingService.java

示例15: createFirebaseReference

import com.firebase.client.Firebase; //导入方法依赖的package包/类
/**
 * Creates all firebase references for the current session.
 *
 * @param model
 * @param deviceName
 * @param uniqueID
 * @param demo
 * @param sensor
 * @return
 */
public String createFirebaseReference(String model, String deviceName, String uniqueID, String demo, ThunderBoardSensor sensor) {

    try {

        long currentTime = System.currentTimeMillis();

        String rootDataThundeBoardSessionsUrl = String.format("%s%s/sessions", baseDataThunderBoardUrl, model);
        Timber.d("rootDataThundeBoardSessionsUrl: %s", rootDataThundeBoardSessionsUrl);
        rootDataThundeBoardSessionsReference = new Firebase(rootDataThundeBoardSessionsUrl);
        rootDataThundeBoardSessionsReference.authWithCustomToken(keyFirebase, this);

        String rootDataSessionsUrl = String.format("%s%s", baseDataSessionsUrl, uniqueID);
        Timber.d("rootDataSessionsUrl: %s", rootDataSessionsUrl);
        rootDataSessionsReference = new Firebase(rootDataSessionsUrl);
        rootDataSessionsReference.authWithCustomToken(keyFirebase, this);
        rootDataSessionsDemoReference = rootDataSessionsReference.child(demo);

        // push the start time
        rootDataSessionsReference.child(START_TIME).setValue(currentTime);
        rootDataSessionsReference.child(TEMPERATURE_TYPE).setValue(prefsManager.getPreferences().temperatureType);
        rootDataSessionsReference.child(MEASUREMENTS_TYPE).setValue(prefsManager.getPreferences().measureUnitType);
        Timber.d("root sessions ref: %s", rootDataSessionsReference.getPath().toString());

        // push contactInfo
        ContactInfo ci = new ContactInfo();
        ThunderBoardPreferences prefs = prefsManager.getPreferences();
        ci.emailAddress = prefs.userEmail;
        ci.fullName = prefs.userName;
        ci.title = prefs.userTitle;
        ci.phoneNumber = prefs.userPhone;
        ci.deviceName = deviceName;
        rootDataSessionsReference.child("contactInfo").setValue(ci);

        String demoUrl = String.format("%s%s/%s/%s", baseDemoSessionsUrl, model, uniqueID, demo);
        Timber.d("short demo url: %s", demoUrl);
        rootDataSessionsReference.child(SHORT_URL).setValue(demoUrl);
        // will be overriden later, we do not want to keep it null....
        // if the requirement is to use a short url, then a refactor is needed to wait until it's available
        shortUrl = demoUrl;

        data = new HashMap<>();

        push(sensor);

        pushTimer.start();

        // request in the background
        shortenUrlReference = rootDataSessionsReference;
        shortenUrl(demoUrl);

        rootDataThundeBoardSessionsReference.child(String.valueOf(currentTime)).setValue(uniqueID);

        return demoUrl;

    } catch (FirebaseException e) {
        e.printStackTrace();
        Timber.d(e.getMessage());
        return null;
    }
}
 
开发者ID:SiliconLabs,项目名称:thunderboard-android,代码行数:71,代码来源:CloudManager.java


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