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


Java DatabaseError類代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:22,代碼來源:Utilities.java

示例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();
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:24,代碼來源:BChatcatNetworkAdapter.java

示例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();
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:23,代碼來源:BChatcatNetworkAdapter.java

示例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);
    }
 
開發者ID:ekalyvio,項目名稱:CowBit,代碼行數:23,代碼來源:FirebaseHelper.java

示例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) {

        }
    });
}
 
開發者ID:MohamedNagyMostafa,項目名稱:IM_Here,代碼行數:23,代碼來源:UserDataFirebaseSearch.java

示例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());
                                         }
                                     });
                                 }
                             });
}
 
開發者ID:florent37,項目名稱:EasyFirebase,代碼行數:24,代碼來源:EasyFirebaseDb.java

示例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);
  }
}
 
開發者ID:firebase,項目名稱:firebase-admin-java,代碼行數:19,代碼來源:SyncTree.java

示例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) {

        }
    });
}
 
開發者ID:ppdesai434,項目名稱:MavsSnapUp,代碼行數:23,代碼來源:MyItemsActivity.java

示例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();
        }
    });
}
 
開發者ID:IrrilevantHappyLlamas,項目名稱:Runnest,代碼行數:20,代碼來源:FirebaseHelperTest.java

示例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();
        }
    });
}
 
開發者ID:iskandergaba,項目名稱:Botanist,代碼行數:22,代碼來源:AccountController.java

示例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;
        }
    });
}
 
開發者ID:reevejd,項目名稱:SmartHome,代碼行數:24,代碼來源:DoorSettings.java

示例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();
               }
            }
         });
      }
   });
}
 
開發者ID:DVT,項目名稱:showcase-android,代碼行數:27,代碼來源:RxFirebaseDatabase.java

示例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);
}
 
開發者ID:braulio94,項目名稱:Quadro,代碼行數:26,代碼來源:AboutFragment.java

示例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);
}
 
開發者ID:micromasterandroid,項目名稱:androidadvanced,代碼行數:17,代碼來源:FirebaseAPI.java

示例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) {

        }
    });
}
 
開發者ID:CMPUT301F17T13,項目名稱:cat-is-a-dog,代碼行數:21,代碼來源:FollowRequestRepository.java


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