本文整理匯總了Java中com.google.firebase.database.DatabaseError類的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseError類的具體用法?Java DatabaseError怎麽用?Java DatabaseError使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DatabaseError類屬於com.google.firebase.database包,在下文中一共展示了DatabaseError類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: wrapOnComplete
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
public static Pair<Task<Void>, DatabaseReference.CompletionListener> wrapOnComplete(
DatabaseReference.CompletionListener optListener) {
if (optListener == null) {
final TaskCompletionSource<Void> source = new TaskCompletionSource<>();
DatabaseReference.CompletionListener listener =
new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError error, DatabaseReference ref) {
if (error != null) {
source.setException(error.toException());
} else {
source.setResult(null);
}
}
};
return new Pair<>(source.getTask(), listener);
} else {
// If a listener is supplied we do not want to create a Task
return new Pair<>(null, optListener);
}
}
示例2: changePassword
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
@Override
public Promise<Void, BError, Void> changePassword(String email, String oldPassword, String newPassword){
final Deferred<Void, BError, Void> deferred = new DeferredObject<>();
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
OnCompleteListener<Void> resultHandler = new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
deferred.resolve(null);
} else {
deferred.reject(getFirebaseError(DatabaseError.fromException(task.getException())));
}
}
};
user.updatePassword(newPassword).addOnCompleteListener(resultHandler);
return deferred.promise();
}
示例3: sendPasswordResetMail
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
@Override
public Promise<Void, BError, Void> sendPasswordResetMail(String email){
final Deferred<Void, BError, Void> deferred = new DeferredObject<>();
OnCompleteListener<Void> resultHandler = new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
if(DEBUG) Timber.v("Email sent");
deferred.resolve(null);
} else {
deferred.reject(getFirebaseError(DatabaseError.fromException(task.getException())));
}
}
};
FirebaseAuth.getInstance().sendPasswordResetEmail(email).addOnCompleteListener(resultHandler);
return deferred.promise();
}
示例4: readClientID
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
public void readClientID() {
String path = String.format("/users/%s/clientID", mCurrentUser.getUid());
DatabaseReference clientIDRef;
clientIDRef = mDatabase.getReference(path);
ValueEventListener clientIDRefListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// clientIDRef.removeEventListener(clientIDRefListener);
mClientID = dataSnapshot.getValue(String.class);
}
@Override
public void onCancelled(DatabaseError databaseError) {
mClientID = null;
// clientIDRef.removeEventListener(clientIDRefListener);
}
};
clientIDRef.addListenerForSingleValueEvent(clientIDRefListener);
}
示例5: setUserRelation
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
public void setUserRelation(final String USER_EMAIL,
final ViewAppHolder.SearchViewHolder searchViewHolder){
FirebaseHelper.getUserDatabaseReference(USER_LINK_FIREBASE)
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
boolean userInFriendList = checkUserInFriendList(dataSnapshot,USER_EMAIL);
boolean userInFriendRequest = checkUserInFriendRequest(dataSnapshot,USER_EMAIL);
boolean currentUserSendFriendRequest = checkCurrentUserRequestSend(dataSnapshot,USER_EMAIL);
userSearchUi.setUserView(userInFriendList, userInFriendRequest,
currentUserSendFriendRequest, searchViewHolder,
USER_EMAIL);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
示例6: push
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
public Observable<Void> push() {
final DatabaseReference child = easyFirebaseDb.databaseReference.child(name);
for (Map.Entry<String, Object> entry : values.entrySet()) {
child.child(entry.getKey()).setValue(entry.getValue());
}
return Observable.create(new Observable.OnSubscribe<Void>() {
@Override
public void call(final Subscriber<? super Void> subscriber) {
child.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
subscriber.onNext(null);
subscriber.onCompleted();
}
@Override
public void onCancelled(DatabaseError databaseError) {
subscriber.onError(databaseError.toException());
}
});
}
});
}
示例7: onListenComplete
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
@Override
public List<? extends Event> onListenComplete(DatabaseError error) {
if (error == null) {
QuerySpec query = this.view.getQuery();
if (tag != null) {
return SyncTree.this.applyTaggedListenComplete(tag);
} else {
return SyncTree.this.applyListenComplete(query.getPath());
}
} else {
logger.warn("Listen at " + view.getQuery().getPath() + " failed: " + error.toString());
// If a listen failed, kill all of the listeners here, not just the one that triggered the
// error. Note that this may need to be scoped to just this listener if we change
// permissions on filtered children
return SyncTree.this.removeAllEventRegistrations(view.getQuery(), error);
}
}
示例8: loaditems
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
private void loaditems() {
Query query = mDatabase.orderByChild("createdBy").equalTo(mAuth.getCurrentUser().getUid());
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
items.clear();
itemKey.clear();
for(DataSnapshot snap : dataSnapshot.getChildren()) {
if(snap.child("isItemSold").getValue(String.class)==null){
items.add(snap.child("itemName").getValue(String.class));
itemKey.add(snap.getKey());
}
}
loadListView();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
示例9: canGetProfilePicUrl
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
@Test
public void canGetProfilePicUrl() {
final String testUserForPic = "Test User for Pic";
final String url = "http://url.test.ch";
firebaseHelper.addOrUpdateUser(TEST_USER, testUserForPic);
firebaseHelper.setOrUpdateProfilePicUrl(testUserForPic, url);
firebaseHelper.getProfilePicUrl(testUserForPic, new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String fetchedUrl = (String) dataSnapshot.getValue();
Assert.assertTrue(url.equals(fetchedUrl));
}
@Override
public void onCancelled(DatabaseError databaseError) {
throw databaseError.toException();
}
});
}
示例10: load
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
@Override
public void load() {
showProgressDialog(getActivity().getString(R.string.loading_text));
getDatabaseManager().getUserReference().addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
mUser = dataSnapshot.getValue(User.class);
populateUserInfo();
populateUserStatsChart();
loadBadge();
}
hideProgressDialog();
}
@Override
public void onCancelled(DatabaseError databaseError) {
hideProgressDialog();
}
});
}
示例11: DoorSettings
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
public DoorSettings(){
database = FirebaseDatabase.getInstance();
doorSettingsRef = database.getReference("doorsettings");
doorSettingsRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.e("db", "dbok in doorsettings.java");
active = ((boolean) dataSnapshot.child("active").getValue());
lockH = ((Number) dataSnapshot.child("lockH").getValue()).intValue();
lockM = ((Number) dataSnapshot.child("lockM").getValue()).intValue();
unlockH = ((Number) dataSnapshot.child("unlockH").getValue()).intValue();
unlockM = ((Number) dataSnapshot.child("unlockM").getValue()).intValue();
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e("db", "dberror in doorsettings.java");
Log.e("db",databaseError.toString());
active = false;
}
});
}
示例12: updateChildren
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
/**
* Update the specific child keys to the specified values.
*
* @param ref reference represents a particular location in your database.
* @param updateData The paths to update and their new values
* @return a {@link Completable} which is complete when the update children call finish successfully.
*/
@NonNull
public static Completable updateChildren(@NonNull final DatabaseReference ref,
@NonNull final Map<String, Object> updateData) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
ref.updateChildren(updateData, new DatabaseReference.CompletionListener() {
@Override
public void onComplete(DatabaseError error, DatabaseReference databaseReference) {
if (error != null) {
emitter.onError(new RxFirebaseDataException(error));
} else {
emitter.onComplete();
}
}
});
}
});
}
示例13: onStart
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
@Override
public void onStart() {
super.onStart();
final ValueEventListener userListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Details detailsModel = dataSnapshot.getValue(Details.class);
if (dataSnapshot.exists()) {
aboutMeTextView.setText(detailsModel.aboutMe);
birthDateTextView.setText(detailsModel.birthDate);
heightTextView.setText(detailsModel.height);
} else {
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
mDatabase.addValueEventListener(userListener);
}
示例14: checkForData
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
public void checkForData(final FirebaseActionListenerCallback listener){
ValueEventListener postListener = new ValueEventListener() {
@Override public void onDataChange(com.google.firebase.database.DataSnapshot dataSnapshot) {
if (dataSnapshot.getChildrenCount() > 0) {
listener.onSuccess();
} else {
listener.onError(null);
}
}
@Override public void onCancelled(DatabaseError databaseError) {
Log.d("FIREBASE API", databaseError.getMessage());
}
};
mPhotoDatabaseReference.addValueEventListener(postListener);
}
示例15: get
import com.google.firebase.database.DatabaseError; //導入依賴的package包/類
/**
* Get a FollowRequest from Firebase.
* @param key
* @param resultListener
*/
@Override
public void get(String key, final OnResultListener<FollowRequest> resultListener) {
mFollowRequestRef.child(key).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
FollowRequest request = dataSnapshot.getValue(FollowRequest.class);
resultListener.onResult(request);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}