当前位置: 首页>>代码示例>>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;未经允许,请勿转载。