我正在使用谷歌的firebase,我在用户身份验证方面遇到了一些麻烦.使用Facebook登录后,我在AuthStateListener中获取FirebaseUser,但是如何通过facebook或不同方式检测此用户是否已记录?
更新正如@Frank van Puffelen所说,FirebaseAuth.getInstance().getCurrentUser().getProviderId()应该返回"facebook",但在我的情况下它会返回"firebase".现在我无法弄清楚这种行为的原因是什么.当我收到FacebookToken时,我会这样做:
AuthCredential credential = FacebookAuthProvider.getCredential(facebookToken.getToken());
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if (!task.isSuccessful()) {
}
}
});
Run Code Online (Sandbox Code Playgroud)
然后在调用onComplete()方法之前,我的AuthStateListener获取用户哪个提供者ID不应该是"facebook".难道我做错了什么?我按照官方谷歌文档
我有一个圆形的弹出窗口,我希望它部分超出屏幕范围。为了调用窗口,我使用了:popup.showAsDropDown(imageButton, OFFSET_X, OFFSET_Y);它应该如下所示:
要剪辑我使用的视图:popup.setClippingEnabled(false);
它可以工作,它看起来就像我在 API 级别低于 21 的设备上所期望的那样......
不幸的是,在 android L(棒棒糖)上它看起来像这样:
圆圈被剪在顶部,但在右侧,它刚好到达屏幕边缘。有什么想法如何解决这个问题吗?
我附上调用弹出窗口的源代码
private void showPopup(final Activity context, ImageButton imageButton ) {
// Inflate the popup_layout.xml
FrameLayout viewGroup = (FrameLayout) context.findViewById(R.id.popup);
final LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View layout = layoutInflater.inflate(R.layout.popup, viewGroup);
layout.startAnimation(range_animation_start);
layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int popupHeight = layout.getMeasuredHeight();
int popupWidth = layout.getMeasuredWidth();
// Creating the PopupWindow
final PopupWindow popup = new PopupWindow(layout);
popup.setContentView(layout);
popup.setWidth(popupWidth);
popup.setHeight(popupHeight);
popup.setFocusable(true);
// Some offset to align the popup …Run Code Online (Sandbox Code Playgroud) 据我所知,在 Bag Of Words 方法中,特征是一组单词及其在文档中的频率计数。另一方面,N-grams,例如unigrams也完全一样,只是没有考虑单词出现的频率。
我想使用 sklearn 和 CountVectorizer 来实现 BOW 和 n-gram 方法。
对于 BOW,我的代码如下所示:
CountVectorizer(ngram_range=(1, 1), max_features=3000)
Run Code Online (Sandbox Code Playgroud)
是否足以将“二进制”参数设置为 True 以执行 n-gram 特征选择?
CountVectorizer(ngram_range=(1, 1), max_features=3000, binary=True)
Run Code Online (Sandbox Code Playgroud)
n-gram 相对于 BOW 方法的优势是什么?
python feature-extraction n-gram feature-selection scikit-learn
我面临的问题与此问题几乎相同:
这个解决方案非常有效:
.container {
display: -webkit-flex;
}
.container>div:first-child{
white-space:nowrap;
-webkit-order:1;
-webkit-flex: 1;
-webkit-flex: 0 1 auto; /*important*/
text-overflow: ellipsis;
overflow:hidden;
min-width:0px; /* new algorithm mises the calculation of the width */
}
.container > div:last-child {
-webkit-flex: 1;
-webkit-order:2;
background: red;
-webkit-flex:1 0 auto; /*important*/
}
.container > div:first-child:hover{
white-space:normal;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<div>foo barfoo bar</div>
<div>foo bar</div>
</div>
<div class="container">
<div>foo barfoo barfoo barfoo barfoo barfoo barfoo bar
foo barfoo barfoo barfoo barfoo barfoo barfoo bar
foo barfoo …Run Code Online (Sandbox Code Playgroud)我想检查软件键盘是否可见.我读过这个 话题.
final View activityRootView = findViewById(R.id.activityRoot);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...
... do something here
}
}
});
Run Code Online (Sandbox Code Playgroud)
但是activityRootView.getRootView().getHeight()并且activityRootView.getHeight()始终返回相同的值,并不关心键盘是否可见.有什么想法吗?因为这个解决方案似乎适用于其他人.
android ×3
css ×1
css3 ×1
firebase ×1
flexbox ×1
html ×1
n-gram ×1
popupwindow ×1
python ×1
scikit-learn ×1