小编Car*_*Gil的帖子

与Retrofit 2并行执行http请求

我想在Retrofit 2中实现多个并行请求.我有以下结构来发出3个请求:

HistoricalRApi.IStockChart service=HistoricalRApi.getMyApiService();
        //^BVSP,^DJI,^IXIC
        Call<HistoricalDataResponseTimestamp> call1= service.get1DHistoricalDataByStock("^IXIC");
        Call<HistoricalDataResponseTimestamp> call2= service.get1DHistoricalDataByStock("^DJI");
        Call<HistoricalDataResponseTimestamp> call3= service.get1DHistoricalDataByStock("^GSPC");
        call1.enqueue(retrofitCallbackAmerica());
        call2.enqueue(retrofitCallbackAmerica());
        call3.enqueue(retrofitCallbackAmerica());
}
Run Code Online (Sandbox Code Playgroud)

我已经在Retrofit1中看到,在定义其余适配器时,可以使用.setExecutor定义并行请求,如下所示:

RestAdapter adapter = new RestAdapter.Builder()
                .setEndpoint(END_POINT) 
                .setLogLevel(RestAdapter.LogLevel.FULL) 
                .setExecutors(Executors.newFixedThreadPool(3), null)
                .build(); 
Run Code Online (Sandbox Code Playgroud)

我的问题是如何在Retrofit 2中实现同样的目标?提前致谢

android retrofit2

13
推荐指数
1
解决办法
5227
查看次数

如何修复错误:添加Google Analytics时,global_tracker.xml的资源是否重复?

我正在尝试在我的应用中实施Google Analytics,但在编译时我收到以下错误:

错误:任务':app:mergeDebugResources'的执行失败.[xml/global_tracker] C:\ Users\Carlos\AndroidStudioProjects\Capstone\SP\Stocks Panel Lite\app\src\main\res\xml\global_tracker.xml [xml/global_tracker] C:\ Users\Carlos\AndroidStudioProjects\Capstone\SP\Stocks Panel Lite\app\build\generated\res\google-services\debug\xml\global_tracker.xml:错误:重复资源

我试图运行干净的项目,但我得到了同样的错误.如果我删除app/build,我也会得到同样的错误.

提前致谢.

更新:build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.carlos.capstone"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
    }

}
repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
}
dependencies {
    compile fileTree(include: …
Run Code Online (Sandbox Code Playgroud)

android android-resources google-play-services google-analytics-firebase

12
推荐指数
1
解决办法
7501
查看次数

RETROFIT 如何解析此响应

我正在尝试 使用 Retrofit解析此 json 响应yahoo yql,但问题是响应以以下字符开头(如您在上面的链接中所见):“finance_charts_json_callback(”。

因此,我收到以下错误: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

可以用 Retrofit 解析这个 json 文件吗?提前致谢

android gson retrofit

3
推荐指数
1
解决办法
1237
查看次数

Recyclerview和D-pad导航

我正在开发一个需要使用D-pad导航的应用程序RecyclerView.我的问题是虽然我设置android:focusable=trueitems.xml(news_items),但它似乎不起作用.

我的问题是:我应该如何实现D-pad导航RecyclerView

RecyclerView是以下布局内:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

         />
    <TextView
        android:id="@+id/emptyView"
        android:visibility="gone"
        tools:visibility="visible"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text=":( \n No news available"
        android:textSize="@dimen/fsn_emty_text"
        android:layout_gravity="center_vertical"
        android:gravity="center_horizontal"
        android:paddingEnd="@dimen/activity_horizontal_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingStart="@dimen/activity_horizontal_margin"
        />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

news_items.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/news_ripple"
    android:clickable="true"
    android:focusable="true"
    android:orientation="vertical"

    >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.15"
                android:background="?attr/colorAccent"

                />


            <LinearLayout

                android:layout_width="0dp" …
Run Code Online (Sandbox Code Playgroud)

android d-pad android-recyclerview

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

在 React 中悬停时缩放和更改 svg 的颜色

我有以下自定义图标组件:

import React from 'react';
import PropTypes from 'prop-types';

const Icon = (props: any) => {
  const styles = {
    svg: {
      display: 'inline-block',
      verticalAlign: 'middle',
    },
    path: {
       fill: props.color,
    },
  };

  return (

    <svg

      style={styles.svg}
      width={`${props.size}px`}
      height={`${props.size}px`}
      viewBox="0 0 1024 1024"
    >
       <path style={styles.path} d={props.icon} /> 
    </svg>
  );


};

Icon.propTypes = {
  icon: PropTypes.string.isRequired,
  size: PropTypes.number,
  color: PropTypes.string

};

Icon.defaultProps = {
  size: 16
};

export default Icon
Run Code Online (Sandbox Code Playgroud)

在另一个组件中,我使用以下语句实例化它:

<Icon
          icon={ICONS.TWITTER}
          color="#fff"
          size={30}
        />
Run Code Online (Sandbox Code Playgroud)

如何在悬停时更改大小和颜色?提前致谢!

svg reactjs

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