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


Java ValueEventListener類代碼示例

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


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

示例1: renderData

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
private void renderData() {
    Query queryRef = mRootRef.child("users").orderByChild(getOrderBy()).limitToLast(100);//we need to iterate them backwards
    queryRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {

            for (DataSnapshot userSnapshot : snapshot.getChildren()) {
                mUsersDataset.add(userSnapshot.getValue(User.class));
            }
            Collections.reverse(mUsersDataset);
            mAdapter = new UserListAdapter(mUsersDataset, getActivity(), getmTabType());
            mRecyclerView.setAdapter(mAdapter);
            mLoadingWrapper.setVisibility(View.GONE);
            mRecyclerView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}
 
開發者ID:silva96,項目名稱:guessthehashtag,代碼行數:23,代碼來源:WeeklyFragment.java

示例2: getPresenceImpl

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
private Task<PresenceType> getPresenceImpl(User user) {
    Task<PresenceType>.TaskCompletionSource taskSource = Task.<PresenceType>create();

    Firebase presenceRef = firebaseRef.child(user.getPresencePath());
    presenceRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            String status = dataSnapshot.getValue(String.class);
            taskSource.setResult(PresenceType.parse(status));
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            taskSource.setError(firebaseError.toException());
        }
    });

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

示例3: checkThings

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
private void checkThings() {
    Calendar cal = Calendar.getInstance();
    boolean monday = cal.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY;
    mWeekResetRef = mRootRef.child("settings").child("week_reset");
    if (monday) {
        mWeekResetRef.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot snapshot) {
                boolean is_reseted = snapshot.getValue(boolean.class);
                if (!is_reseted) {
                    updateAllWeekScores();
                }
            }

            @Override
            public void onCancelled(FirebaseError firebaseError) {

            }
        });
    } else {
        mWeekResetRef.setValue(false);
    }
}
 
開發者ID:silva96,項目名稱:guessthehashtag,代碼行數:24,代碼來源:MainActivity.java

示例4: updateAllWeekScores

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
private void updateAllWeekScores() {
    mRootRef.child("users").addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
            Map<String, Object> week_scores = new HashMap<String, Object>();
            for (DataSnapshot userSnapshot : snapshot.getChildren()) {
                week_scores.put(userSnapshot.child("username").getValue() + "/week_score", 0);
            }
            mRootRef.child("users").updateChildren(week_scores);
            mWeekResetRef.setValue(true);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}
 
開發者ID:silva96,項目名稱:guessthehashtag,代碼行數:19,代碼來源:MainActivity.java

示例5: DataPresenter

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
/**
 * Creates a data presenter.
 *
 * @param dataView The view which will display the data.
 * @param configUrl The firebase endpoint url.
 */
DataPresenter(@NonNull DataView<T> dataView, @NonNull String configUrl) {
    mFirebase = new Firebase(configUrl);
    mData = new ArrayList<>();
    mDataView = dataView;

    mValueEventListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mData.clear();
            for (DataSnapshot data : dataSnapshot.getChildren()) {
                // Data parsing is being done within the extending classes.
                mData.add(parseData(data));
            }
            mDataView.showData(mData);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            Log.d(TAG, "onCancelled: " + firebaseError.getMessage());
            // Deliberately swallow the firebase error here.
            mDataView.showError();
        }
    };
}
 
開發者ID:googlesamples,項目名稱:android-OurStreets,代碼行數:31,代碼來源:DataPresenter.java

示例6: addToiletToFirebase

import com.firebase.client.ValueEventListener; //導入依賴的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

示例7: retrieveData

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
private void retrieveData(String key) {
    Firebase itemRef = new Firebase(Utils.getFirebaseUserReminderUrl(mUserUID))
            .child(key);
    itemRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mRemindItem = dataSnapshot.getValue(ReminderItem.class);
            setViews();
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            Toast.makeText(getContext(), firebaseError.getMessage(), Toast.LENGTH_SHORT).show();
        }
    });
}
 
開發者ID:trigor74,項目名稱:travelers-diary,代碼行數:17,代碼來源:ReminderItemFragment.java

示例8: onPause

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
@Override
protected void onPause() {
    super.onPause();
    firebase.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            updater = (long) dataSnapshot.getValue();
            updater--;
            firebase.setValue(updater);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
    Log.v(this.getClass().getSimpleName(), "onPause()");

    if (tts != null) {
        tts.stop();
        tts.shutdown();
    }
}
 
開發者ID:siddhantvinchurkar,項目名稱:Marv,代碼行數:24,代碼來源:MainActivity.java

示例9: Repository

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
public Repository(String firebaseUrl, final Class<T> modelClass) {
	firebase = new Firebase(firebaseUrl);

	firebase.addValueEventListener(new ValueEventListener() {
		@Override
		public void onDataChange(DataSnapshot snapshot) {
			List<T> items = new ArrayList<>();
			for (DataSnapshot postSnapshot : snapshot.getChildren()) {
				T restaurant = postSnapshot.getValue(modelClass);
				items.add(restaurant);
			}
			Repository.this.items = items;
			notifyDataChanged();
		}
		@Override
		public void onCancelled(FirebaseError firebaseError) {
			/* Do nothing */
		}
	});
}
 
開發者ID:alexmiragall,項目名稱:Gourmet,代碼行數:21,代碼來源:Repository.java

示例10: getSchoolId

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
public void getSchoolId() {

        schoolRef = new Firebase(Constants.FIREBASE_URL+"schools");
        schoolRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                dataSnapshot.getKey();
            }

            @Override
            public void onCancelled(FirebaseError firebaseError) {

            }
        });

    }
 
開發者ID:blessingoraz,項目名稱:Akwukwo,代碼行數:17,代碼來源:ListOfMySchhols.java

示例11: compareEmail

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
public void compareEmail (final UserDetails userDetails, final String emailFromUserDetail, final String userdetailUid) {

		ref.addValueEventListener (new ValueEventListener () {
			@Override
			public void onDataChange (DataSnapshot dataSnapshot) {

				for (DataSnapshot users : dataSnapshot.getChildren ()) {

					String email = (String) users.child ("users").child ("email").getValue ();

					if (emailFromUserDetail.trim ().equalsIgnoreCase (email)) {

						Utils.showShortToast ("Email already exist!", SignUpPageActivity.this);
					} else {
						userRef.child (userdetailUid).setValue (userDetails);
					}
				}
			}

			@Override
			public void onCancelled (FirebaseError firebaseError) {

			}
		});

	}
 
開發者ID:blessingoraz,項目名稱:Akwukwo,代碼行數:27,代碼來源:SignUpPageActivity.java

示例12: getFullPatientsList

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
/**
 * Method for getting full name list of patients
 * @param arrayList - list of all patients
 */
public ArrayList<String> getFullPatientsList(ArrayList<String> arrayList) {
    final ArrayList<String> tmp_list = new ArrayList<>();
    for (String mPatient : arrayList) {
        Firebase firebase = new Firebase("https://care-connect.firebaseio.com/patients/" + mPatient);
        firebase.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                Map<String, Object> pData = (Map<String, Object>) dataSnapshot.getValue();
                tmp_list.add(getPatientFullName(pData));
            }

            @Override
            public void onCancelled(FirebaseError firebaseError) {

            }
        });
    }
    return tmp_list;
}
 
開發者ID:ursopanda,項目名稱:kneeRehabMonitoring,代碼行數:24,代碼來源:DrawerActivity.java

示例13: isPatient

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
/**
 * Method for checking handling whether patients exists or not
 * @param tmp_email - patients email address
 */
@Override
public void isPatient(String tmp_email) {
    addPatientEmail = tmp_email.replace(".", "");
    Firebase firebase = new Firebase("https://care-connect.firebaseio.com/patients/"
            + addPatientEmail);
    firebase.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (exists(dataSnapshot)) {
                checkPatient();
            } else {
                patientDoesNotExistError();
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}
 
開發者ID:ursopanda,項目名稱:kneeRehabMonitoring,代碼行數:26,代碼來源:DrawerActivity.java

示例14: checkPatient

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
/**
 * Method for checking whether there is a patient already added for doctor
 */
public void checkPatient() {
    String doc_key = email.replace(".", "");
    addPatFirebase = new Firebase("https://care-connect.firebaseio.com/doctors/"
            + doc_key + "/patients/"
            + addPatientEmail);
    mListener = addPatFirebase.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (exists(dataSnapshot)) {
                patientAlreadyAddedError();
                return;
            } else {
                addPatient(addPatientEmail);
                patientAdded();
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}
 
開發者ID:ursopanda,項目名稱:kneeRehabMonitoring,代碼行數:27,代碼來源:DrawerActivity.java

示例15: assignPrecept

import com.firebase.client.ValueEventListener; //導入依賴的package包/類
/**
 * Method for assigning precept for patient
 * @param patient_email - patients email address
 * @param o_angle - optimal flexion angle
 * @param m_angle - maximal flexion angle
 * @param duration - rehab duration
 * @param frequency - rehab frequency
 *                  Parameters from input form
 */
@Override
public void assignPrecept(String patient_email, int o_angle, int m_angle, int duration, int frequency) {
    preceptFirebase = new Firebase("https://care-connect.firebaseio.com/patients/"
            + patient_email + "/precept");
    final Precept precept = new Precept(o_angle, m_angle, duration, frequency);

    precpetListener = preceptFirebase.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (exists(dataSnapshot)) {
                preceptExistsError();
            } else {
                //assigning precept and tis values for patient
                preceptFirebase.setValue(precept);
                preceptAdded();
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}
 
開發者ID:ursopanda,項目名稱:kneeRehabMonitoring,代碼行數:34,代碼來源:DrawerActivity.java


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