小编Sou*_*abh的帖子

无法解决:com.android.support:appcompat-v7:28.0

当我com.android.support:appcompat-v7:28.+在我的项目build.gradle(模块)中使用它时,它没有任何错误.但是当我使用时com.android.support:appcompat-v7:28,只是没有.+,它给了我一个错误:

无法解决:com.android.support:appcompat-v7:28.0

只是没有.+结束.我之前添加了maven但结果是一样的.有什么想法解决它吗?

android gradle

38
推荐指数
4
解决办法
9万
查看次数

检查RecyclerView是否可滚动

如何检查a RecyclerView是否可滚动,即可见区域下方/上方是否有项目

我在我的回收站视图中有一个下拉列表,它使用notifyItemRangeInserted()notifyItemRangeRemoved().每当发生任何这种情况时,我想检查它RecyclerView是否可滚动,因为我必须调整另一个视图,像报摊中的横幅一样

android android-recyclerview

21
推荐指数
3
解决办法
9306
查看次数

HTML5 Canvas - fillRect()vs rect()

在下面的代码中,第二个fillStyle覆盖第一个中指定的颜色,如果我使用rect()然后fill()在两个地方(即两个rects都是绿色)但按预期工作(即,第一个rect是蓝色,第二个是绿色)如果我改变第一个rect()fillRect().为什么会这样?我以为fillRect()只是rect(),然后fill(),对不对?

ctx.translate(canvas.width/2, canvas.height/2);

ctx.fillStyle = "#5A9BDC";
ctx.fillRect(0, 0, rectWidth, rectHeight);
// ctx.rect(0, 0, rectWidth, rectHeight);
// ctx.fill();    

ctx.translate(-canvas.width/2, -canvas.height/2);

ctx.fillStyle = "#31B131";
ctx.rect(0, 0, rectWidth, rectHeight);
ctx.fill();
Run Code Online (Sandbox Code Playgroud)

在Chrome中测试过 | 小提琴

javascript html5-canvas

19
推荐指数
2
解决办法
2万
查看次数

在Retrofit + RxJava中链接请求

我有2个API,我想按顺序请求并将它们的数据存储在SQLite中.

首先,我想向API发出请求A并将其数据存储在SQL表中a.然后请求API B并将其数据存储在表中,b并将一些数据存储在表中a_b.存储的数据a_b仅来自请求B.

我怎么能用RxJava做到这一点.我在这里读到了关于使用flatMap的地方,就像这样

apiService.A()
    // store in DB here? How? maybe use map()?
    .flatMap(modelA -> {
        // or maybe store modelA in DB here?
        return apiService.B().map(modelB -> {
            storeInDB()l // store B here ?
            return modelB;
        });
    });
Run Code Online (Sandbox Code Playgroud)

如果我没有使用lambda函数,这看起来就像普通的嵌套调用一样难看.这是一个更好的方法吗?

android rx-java retrofit2

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

OKHTTP 3跟踪分段上传进度

如何在OkHttp 3中跟踪上传的进度我可以找到v2但不是v3的答案,就像这样

来自OkHttp配方的示例Multipart请求

private static final String IMGUR_CLIENT_ID = "...";
private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");

private final OkHttpClient client = new OkHttpClient();

public void run() throws Exception {
    // Use the imgur image upload API as documented at https://api.imgur.com/endpoints/image
    RequestBody requestBody = new MultipartBody.Builder()
            .setType(MultipartBody.FORM)
            .addFormDataPart("title", "Square Logo")
            .addFormDataPart("image", "logo-square.png",
                    RequestBody.create(MEDIA_TYPE_PNG, new File("website/static/logo-square.png")))
            .build();

    Request request = new Request.Builder()
            .header("Authorization", "Client-ID " + IMGUR_CLIENT_ID)
            .url("https://api.imgur.com/3/image")
            .post(requestBody)
            .build();

    Response response = client.newCall(request).execute();
    if (!response.isSuccessful()) throw new IOException("Unexpected code …
Run Code Online (Sandbox Code Playgroud)

android okhttp3

12
推荐指数
2
解决办法
8417
查看次数

Mousemove事件处理文档而不是'body'

我试图使div看起来像一个关闭的灯,当鼠标移动时,灯会亮起.

我完成了鼠标移动打开灯的部分.看看这个小提琴.

jQuery代码:

$(document).mousemove(function() {
    $('div').addClass('glow');
});
Run Code Online (Sandbox Code Playgroud)

我有2个问题

  1. 如果我把'body'而不是文档,它不起作用,为什么?

  2. 如何检测鼠标停止?

jquery

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

如何同步两个CoordinatorLayout + AppBarLayout的滚动

我有一个XML活动.

就像是:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/primary"
                android:theme="@style/ToolbarStyle"
                android:gravity="center_vertical"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_scrollFlags="scroll|enterAlways|snap"
                style="@style/bold" />

            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/TabLayoutStyle"
                android:animateLayoutChanges="true"
                app:tabGravity="fill"
                app:tabMode="fixed"
                app:tabTextAppearance="@style/TabStyle"/>

        </android.support.design.widget.AppBarLayout>

        <com.wedmegood.planner.view.XViewPager
            android:id="@+id/main_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="fill_vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

        ...

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

FragmentViewPagerCoordinatorLayoutAppBarLayout+ CollapsingToolbarLayout.

Fragment的XML:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/primaryDark"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> …
Run Code Online (Sandbox Code Playgroud)

android android-coordinatorlayout android-collapsingtoolbarlayout android-appbarlayout

8
推荐指数
2
解决办法
2627
查看次数

CircleN上的ReactNative 0.59.x构建失败,退出值为137

在CircleCI上为v0.59.x构建应用程序时,出现以下错误(以前一直可以正常工作到v0.57.8):

[12:45:19]: ? Note: Some input files use or override a deprecated API.
[12:45:19]: ? Note: Recompile with -Xlint:deprecation for details.
[12:45:19]: ? > Task :react-native-svg:processReleaseJavaRes NO-SOURCE
[12:45:19]: ? > Task :react-native-svg:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease
[12:45:19]: ? > Task :app:javaPreCompileQa
[12:45:44]: ? > Task :app:bundleQaJsAndAssets
[12:45:44]: ? warning: the transform cache was reset.
[12:46:00]: ? Loading dependency graph, done.
[12:46:19]: ? > Task :app:bundleQaJsAndAssets FAILED
[12:46:19]: ? FAILURE: Build failed with an exception.
[12:46:19]: ? * What went wrong:
[12:46:19]: ? Execution failed …
Run Code Online (Sandbox Code Playgroud)

android circleci react-native

8
推荐指数
1
解决办法
766
查看次数

lunr.js添加有关索引记录的数据

lunr.js中,您可以使用该.ref()方法添加唯一引用,但我找不到任何方法来添加有关该特定记录的额外数据/信息.这是不可能的,还是我错过了一些非常明显的东西.

我甚至尝试将对象分配给ref,但它将其保存为字符串.

编辑 现在我将所有内容保存为JSON字符串.ref(),这可以使用,但是真的很难使用.

javascript lunrjs

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

Django - 自定义过滤器,用于检查文件是否存在

我制作了这个自定义过滤器来检查图像是否存在:

from django import template
from django.core.files.storage import default_storage

register = template.Library()

@register.filter(name='file_exists')
def file_exists(filepath):
    if default_storage.exists(filepath):
        return filepath
    else:
        index = filepath.rfind('/')
        new_filepath = filepath[:index] + '/image.png'
        return new_filepath
Run Code Online (Sandbox Code Playgroud)

我在模板中使用了这个:

<img src="{{ STATIC_URL }}images/{{ book.imageurl }}|file_exists" alt="{{book.title}} Cover Photo">
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我不明白为什么.

django django-templates django-models django-template-filters

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