小编Scr*_*eer的帖子

Android:无法解析方法'findFirstVisibleItemPosition()'?

我正在尝试在回收站视图上编写无限滚动的代码.这是给我编译错误的片段:

@Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

                visibleItemCount = mLayoutManager.getChildCount();
                totalItemCount = mLayoutManager.getItemCount();
                pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();

                if ( (visibleItemCount+pastVisiblesItems) >= totalItemCount) {
                    Log.v("...", "Last Item Wow !");
                }
Run Code Online (Sandbox Code Playgroud)

我之前写的声明是:

mLayoutManager = new LinearLayoutManager(this);
Run Code Online (Sandbox Code Playgroud)

mLayoutManager是RecyclerView.LayoutManager类的对象

android android-recyclerview

7
推荐指数
1
解决办法
1万
查看次数

Django Rest Framework身份验证被拒绝

我使用PSA在Django上验证了我的用户并让用户在用户模型中注册,甚至令牌模型都注册了用户和令牌.

但是当我发送此请求时:

curl -X POST -H "Authorization:Token 87e939184457ccc064485444a90e3ebf417xxxxx" http://192.168.x.x:8000/user-profiles/>error.html 
Run Code Online (Sandbox Code Playgroud)

我明白了

{"detail":"您无权执行此操作."}

如果我寄这个:

curl -X POST --user "VedantDasSwain:87e939184457ccc064485444a90e3ebf417xxxxx" http://192.168.x.x:8000/user-profiles/>error.html 
Run Code Online (Sandbox Code Playgroud)

我明白了

{"detail":"用户名/密码无效"}

这些是我的设置文件中的相关代码段:

'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',
        'rest_framework.permissions.IsAdminUser',),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication',
    ),
Run Code Online (Sandbox Code Playgroud)

这是PSA设置的一部分:

AUTHENTICATION_BACKENDS = (
    'social.backends.facebook.FacebookOAuth2',

    'django.contrib.auth.backends.ModelBackend',
)
Run Code Online (Sandbox Code Playgroud)

有没有人遇到过这种类型的东西?这是什么解决方案?

python django django-rest-framework

6
推荐指数
1
解决办法
1736
查看次数