当前位置: 首页>>代码示例>>Java>>正文


Java FirebaseException类代码示例

本文整理汇总了Java中com.google.firebase.FirebaseException的典型用法代码示例。如果您正苦于以下问题:Java FirebaseException类的具体用法?Java FirebaseException怎么用?Java FirebaseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FirebaseException类属于com.google.firebase包,在下文中一共展示了FirebaseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: phoneNumberVerificationCB

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void phoneNumberVerificationCB() {
    mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {

        @Override
        public void onVerificationCompleted(PhoneAuthCredential credential) {
            Log.d(TAG, "onVerificationCompleted:" + credential);
            credent = credential;
        }

        @Override
        public void onVerificationFailed(FirebaseException e) {
            Log.w(TAG, "onVerificationFailed", e);

            if (e instanceof FirebaseAuthInvalidCredentialsException) {
                // Invalid request
                // ...
            } else if (e instanceof FirebaseTooManyRequestsException) {
                // The SMS quota for the project has been exceeded
                // ...
            }
        }
    };
}
 
开发者ID:kcj8855,项目名称:Ae4Team,代码行数:24,代码来源:ChangePhoneNumberActivity.java

示例2: observe

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private Observable<DataSnapshot> observe(final Query ref) {
    return Observable.create(emitter -> {
        final ValueEventListener listener =
                ref.addValueEventListener(new ValueEventListener() {
                    @Override public void onDataChange(DataSnapshot dataSnapshot) {
                        emitter.onNext(dataSnapshot);
                    }

                    @Override public void onCancelled(DatabaseError databaseError) {
                        emitter.onError(new FirebaseException(databaseError.getMessage()));
                    }
                });

        emitter.setCancellable(() -> ref.removeEventListener(listener));
    });
}
 
开发者ID:riteshakya037,项目名称:Wallpapers-Android-Clean-Architecture,代码行数:17,代码来源:Comments.java

示例3: createIfNotExists

import com.google.firebase.FirebaseException; //导入依赖的package包/类
protected <T extends Entity, R> Observable<R> createIfNotExists(DatabaseReference databaseReference, T value, R successResponse) {
    return Observable.create(new Observable.OnSubscribe<R>() {
        @Override
        public void call(Subscriber<? super R> subscriber) {
            databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    if (dataSnapshot.getValue() == null) {
                        postQuery(databaseReference, value, false, successResponse)
                                .subscribe(subscriber);
                    } else {
                        subscriber.onNext(successResponse);
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    subscriber.onError(new FirebaseException(databaseError.getMessage()));
                }
            });
        }
    });
}
 
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:24,代码来源:FirebaseEntityStore.java

示例4: getQuery

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private <T> Observable<T> getQuery(Query query, Action2<Subscriber<? super T>, DataSnapshot> onNextAction, boolean subscribeForSingleEvent) {
    return Observable.create(subscriber -> {
        ValueEventListener eventListener = new ValueEventListener() {

            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                onNextAction.call(subscriber, dataSnapshot);
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
                subscriber.onError(new FirebaseException(databaseError.getMessage()));
            }
        };
        if (subscribeForSingleEvent) {
            query.addListenerForSingleValueEvent(eventListener);
        } else {
            query.addValueEventListener(eventListener);
        }
        subscriber.add(Subscriptions.create(() -> query.removeEventListener(eventListener)));
    });
}
 
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:23,代码来源:FirebaseEntityStore.java

示例5: postQuery

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private <T extends Entity, R> Observable<R> postQuery(DatabaseReference databaseReference, T value, boolean newChild, R successResponse) {

        return Observable.create(new Observable.OnSubscribe<R>() {
            @Override
            public void call(Subscriber<? super R> subscriber) {
                DatabaseReference reference = databaseReference;
                if (newChild) {
                    if (value.getId() == null) {
                        reference = databaseReference.push();
                        value.setId(reference.getKey());
                    } else {
                        reference = databaseReference.child(value.getId());
                    }
                }
                reference.setValue(value, (databaseError, databaseReference1) -> {
                    if (databaseError == null) {
                        subscriber.onNext(successResponse);
                    } else {
                        subscriber.onError(new FirebaseException(databaseError.getMessage()));
                    }
                });
            }
        });
    }
 
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:25,代码来源:FirebaseEntityStore.java

示例6: handelError

import com.google.firebase.FirebaseException; //导入依赖的package包/类
public static String handelError(Throwable error) {
    if (isRelatedToNetwork(error)) {
        return App.getGlobalContext().getString(R.string.error_network_no_internet_connection);
    } else if (error instanceof HttpException) {
        try {
            HttpException retroError = (HttpException) error;
            ApiError errorObj = new Gson().fromJson(retroError.response().errorBody().charStream(), ApiError.class);
            return ErrorFactory.getErrorMessage(errorObj.getCode());
        } catch (Throwable e) {
            e.printStackTrace();
        }
    } else if (error instanceof FirebaseException) {
        return error.getMessage();
    }

    return ErrorFactory.getErrorMessage(ErrorFactory.GENERAL_DEFAULT_ERROR);
}
 
开发者ID:scott7462,项目名称:Udacity-Capstone-Project,代码行数:18,代码来源:ApiErrorRest.java

示例7: sendComment

import com.google.firebase.FirebaseException; //导入依赖的package包/类
@Override public Observable sendComment(final String photoId, final String message) {
    return Observable.create(new Observable.OnSubscribe<Boolean>() {
        @Override
        public void call(final Subscriber<? super Boolean> subscriber) {
            databaseReference.child(DatabaseNames.TABLE_COMMENTS)
                             .child(String.valueOf(photoId))
                             .push()
                             .setValue(new PhotoComment(Calendar.getInstance().getTime(), message))
                             .addOnCompleteListener(new OnCompleteListener<Void>() {
                                 @Override public void onComplete(@NonNull Task<Void> task) {
                                     subscriber.onNext(task.isSuccessful());
                                     subscriber.onCompleted();
                                 }
                             })
                             .addOnFailureListener(new OnFailureListener() {
                                 @Override public void onFailure(@NonNull Exception e) {
                                     subscriber.onError(new FirebaseException(e.getMessage()));
                                 }
                             });
        }
    });
}
 
开发者ID:lolevsky,项目名称:Android-Clean-Architecture,代码行数:23,代码来源:Comments.java

示例8: observe

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private Observable<DataSnapshot> observe(final Query ref) {
    return Observable.create(new Observable.OnSubscribe<DataSnapshot>() {
        @Override
        public void call(final Subscriber<? super DataSnapshot> subscriber) {
            final ValueEventListener listener = ref.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    subscriber.onNext(dataSnapshot);
                }

                @Override public void onCancelled(DatabaseError databaseError) {
                    subscriber.onError(new FirebaseException(databaseError.getMessage()));
                }
            });

            // When the subscription is cancelled, remove the listener
            subscriber.add(Subscriptions.create(new Action0() {
                @Override
                public void call() {
                    ref.removeEventListener(listener);
                }
            }));
        }
    });
}
 
开发者ID:lolevsky,项目名称:Android-Clean-Architecture,代码行数:26,代码来源:Comments.java

示例9: verifyPhoneNumber

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void verifyPhoneNumber(final String phoneNumber, final CallbackContext callbackContext) {
    cordova.getThreadPool().execute(new Runnable() {
        @Override
        public void run() {
            phoneAuthProvider.verifyPhoneNumber(phoneNumber, 0, MILLISECONDS, cordova.getActivity(),
                new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
                    @Override
                    public void onVerificationCompleted(PhoneAuthCredential credential) {
                        FirebaseUser user = firebaseAuth.getCurrentUser();
                        if (user == null) {
                            firebaseAuth.signInWithCredential(credential);
                        } else {
                            user.updatePhoneNumber(credential);
                        }

                        callbackContext.success("");
                    }

                    @Override
                    public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
                        callbackContext.success(verificationId);
                    }

                    @Override
                    public void onVerificationFailed(FirebaseException e) {
                        callbackContext.error(e.getMessage());
                    }
                }
            );
        }
    });
}
 
开发者ID:chemerisuk,项目名称:cordova-plugin-firebase-authentication,代码行数:33,代码来源:FirebaseAuthenticationPlugin.java

示例10: sendComment

import com.google.firebase.FirebaseException; //导入依赖的package包/类
@Override public Observable sendComment(final String photoId, final CommentsModel message) {
    return Observable.create((ObservableOnSubscribe<Boolean>) emitter -> databaseReference.child(DatabaseNames.TABLE_COMMENTS)
            .child(String.valueOf(photoId))
            .push()
            .setValue(message)
            .addOnCompleteListener(task -> {
                emitter.onNext(task.isSuccessful());
                emitter.onComplete();
            })
            .addOnFailureListener(e -> {
                e.printStackTrace();
                emitter.onError(new FirebaseException(e.getMessage()));
            }));
}
 
开发者ID:riteshakya037,项目名称:Wallpapers-Android-Clean-Architecture,代码行数:15,代码来源:Comments.java

示例11: verifyPhoneNumber

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void verifyPhoneNumber(final String phoneNumber, final long timeout, final CallbackContext callbackContext) {
    cordova.getThreadPool().execute(new Runnable() {
        @Override
        public void run() {
            phoneAuthProvider.verifyPhoneNumber(phoneNumber, timeout, MILLISECONDS, cordova.getActivity(),
                new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
                    @Override
                    public void onVerificationCompleted(PhoneAuthCredential credential) {
                        FirebaseUser user = firebaseAuth.getCurrentUser();
                        if (user == null) {
                            firebaseAuth.signInWithCredential(credential);
                        } else {
                            user.updatePhoneNumber(credential);
                        }
                    }

                    @Override
                    public void onCodeSent(String verificationId, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
                        callbackContext.success(verificationId);
                    }

                    @Override
                    public void onVerificationFailed(FirebaseException e) {
                        callbackContext.error(e.getMessage());
                    }
                }
            );
        }
    });
}
 
开发者ID:kanodeveloper,项目名称:cordova-plugin-firebase-performance-ka,代码行数:31,代码来源:FirebaseAuthenticationPlugin.java

示例12: signInGoogle

import com.google.firebase.FirebaseException; //导入依赖的package包/类
@Override
public void signInGoogle(GoogleSignInAccount acct, Subscriber<String> subscriber, CreateUser createUser) {
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    auth.signInWithCredential(credential)
            .addOnCompleteListener(task -> {
                if (!subscriber.isUnsubscribed()) {
                    if (task.isSuccessful()) {
                        saveUser(task.getResult().getUser(), subscriber, createUser);
                    } else {
                        subscriber.onError(new FirebaseException(task.getException().getMessage()));
                    }
                }
            });
}
 
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:15,代码来源:AuthManagerImpl.java

示例13: deleteQuery

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private <R> Observable<R> deleteQuery(DatabaseReference databaseReference, R successResponse) {
    return Observable.create(new Observable.OnSubscribe<R>() {
        @Override
        public void call(Subscriber<? super R> subscriber) {
            databaseReference.removeValue((databaseError, databaseReference1) -> {
                if (databaseError == null) {
                    subscriber.onNext(successResponse);
                } else {
                    subscriber.onError(new FirebaseException(databaseError.getMessage()));
                }
            });
        }
    });
}
 
开发者ID:ihorvitruk,项目名称:buddysearch,代码行数:15,代码来源:FirebaseEntityStore.java

示例14: observe

import com.google.firebase.FirebaseException; //导入依赖的package包/类
public static Observable<DataSnapshot> observe(final Query ref) {

        return Observable.create(new Observable.OnSubscribe<DataSnapshot>() {

            @Override
            public void call(final Subscriber<? super DataSnapshot> subscriber) {
                final ValueEventListener listener = ref.addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                        subscriber.onNext(dataSnapshot);
                    }

                    @Override
                    public void onCancelled(DatabaseError databaseError) {
                        // Turn the FirebaseError into a throwable to conform to the API
                        subscriber.onError(new FirebaseException(databaseError.getMessage()));
                    }
                });

                // When the subscription is cancelled, remove the listener
                subscriber.add(Subscriptions.create(new Action0() {
                    @Override
                    public void call() {
                        ref.removeEventListener(listener);
                    }
                }));
            }
        });
    }
 
开发者ID:chungtruong,项目名称:AndroidDataBinding,代码行数:30,代码来源:RxFirebase.java

示例15: onVerificationFailed

import com.google.firebase.FirebaseException; //导入依赖的package包/类
private void onVerificationFailed(@NonNull FirebaseException ex) {
    dismissLoadingDialog();

    if (ex instanceof FirebaseAuthException) {
        FirebaseAuthError error = FirebaseAuthError.fromException((FirebaseAuthException) ex);

        switch (error) {
            case ERROR_INVALID_PHONE_NUMBER:
                VerifyPhoneNumberFragment verifyPhoneNumberFragment = (VerifyPhoneNumberFragment)
                        getSupportFragmentManager().findFragmentByTag(VerifyPhoneNumberFragment.TAG);

                if (verifyPhoneNumberFragment != null) {
                    verifyPhoneNumberFragment.showError(
                            getString(R.string.fui_invalid_phone_number));
                }
                break;
            case ERROR_TOO_MANY_REQUESTS:
                showAlertDialog(getString(R.string.fui_error_too_many_attempts), null);
                break;
            case ERROR_QUOTA_EXCEEDED:
                showAlertDialog(getString(R.string.fui_error_quota_exceeded), null);
                break;
            default:
                Log.w(PHONE_VERIFICATION_LOG_TAG, error.getDescription(), ex);
                showAlertDialog(error.getDescription(), null);
        }
    } else {
        Log.w(PHONE_VERIFICATION_LOG_TAG, ex.getLocalizedMessage());
        showAlertDialog(ex.getLocalizedMessage(), null);
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:32,代码来源:PhoneActivity.java


注:本文中的com.google.firebase.FirebaseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。