com.firebase.client.Query Java Examples

The following examples show how to use com.firebase.client.Query. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessageFragment.java    From io16experiment-master with Apache License 2.0 4 votes vote down vote up
/**
 * Retrieve the next device from Firebase and generate the appropriate message
 */
private void getNextDeviceFirebase() {
    // Retrieve next deviceId from Firebase
    Firebase nextDeviceRef = new Firebase(Constants.FIREBASE_URL_DEVICES).child(mFirebaseUid);
    Query queryRef = nextDeviceRef.orderByChild(Constants.FIREBASE_PROPERTY_DEVICE_NUMBER).equalTo(mDeviceNum + 1);
    queryRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot item : dataSnapshot.getChildren()) {
                Device d = item.getValue(Device.class);
                if (d != null) {
                    LogUtils.LOGE("***> child updated", "device connected: " + d.isConnected());
                    // If the device has connected to the parent uid, handle the message display based on whether
                    // the message has been received by the child device
                    if (d.isConnected()) {
                        if (!PreferencesUtils.getBoolean(mActivity, R.string.key_message_received, false)){
                            PreferencesUtils.setBoolean(mActivity, R.string.key_message_received, true);

                            // Once the message has been received by the child device, unpublish the message so the
                            // next device can begin broadcasting
                            unpublish();
                            mDiscover.setVisibility(View.GONE);
                            mIntroConnectDevice.setText(mActivity.getString(R.string.text_message_received));
                        }
                    } else {
                        // The device has not been connected yet, so generate the message to be sent and prepare
                        // to publish
                        LogUtils.LOGE("***> child updated", "device: " + d.getDeviceId());

                        // Update message
                        String message = mActivity.getString(R.string.message_body, mFirebaseUid, mDeviceNum + 1,
                                mTotalDevices, d.getDeviceId());
                        LogUtils.LOGE("***> child message", message);
                        mDeviceInfoMessage = DeviceMessage.newNearbyMessage(
                                InstanceID.getInstance(mActivity.getApplicationContext()).getId(), message);
                    }
                }
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
        }
    });
}
 
Example #2
Source File: ClimbListAdapter.java    From climb-tracker with Apache License 2.0 4 votes vote down vote up
public ClimbListAdapter(Query ref, int layout, Activity activity) {
    super(ref, Climb.class, layout, activity);
}
 
Example #3
Source File: ChatListAdapter.java    From AndroidChat with MIT License 4 votes vote down vote up
public ChatListAdapter(Query ref, Activity activity, int layout, String mUsername) {
    super(ref, Chat.class, layout, activity);
    this.mUsername = mUsername;
}