Commit f73d1994d65556171731b99f15ef8139590fd18d

Authored by 谷俊
1 parent 5c286530

添加原生demo,回调添加adId

app/build.gradle
... ... @@ -24,6 +24,8 @@ dependencies {
24 24 compile 'com.android.support:appcompat-v7:26.+'
25 25 compile 'com.google.code.gson:gson:2.8.2'
26 26 compile 'com.android.support.constraint:constraint-layout:1.0.2'
  27 + compile 'com.github.bumptech.glide:glide:4.3.1'
  28 + annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
27 29 //引入广告SDK
28 30 compile 'cn.vlion:vlion-ad:1.1.5'
29 31 }
... ...
app/src/main/AndroidManifest.xml
... ... @@ -49,6 +49,11 @@
49 49 android:configChanges="keyboardHidden|screenSize|orientation"
50 50 android:screenOrientation="portrait" />
51 51  
  52 + <activity
  53 + android:name="cn.vlion.simple.NativeFeedsDemoActivity"
  54 + android:configChanges="keyboardHidden|screenSize|orientation"
  55 + android:screenOrientation="portrait" />
  56 +
52 57 <!--使用瑞狮广告SDK需要配置以下信息-->
53 58 <!--广告SDK配置 Start-->
54 59 <receiver android:name="cn.vlion.ad.core.VLionReceiver">
... ...
app/src/main/java/cn/vlion/simple/BannerActivity.java
... ... @@ -33,35 +33,35 @@ public class BannerActivity extends AppCompatActivity {
33 33 //431 image
34 34 bannerView = BannerManager.getInstance().getBannerView(this, tagId, new BannerViewListener() {
35 35 @Override
36   - public void onRequestSuccess(int viewWidth, int viewHeight) {
37   - Log.e(TAG, "onRequestSuccess: " + viewWidth + "," + viewHeight);
  36 + public void onRequestSuccess(String adId, int viewWidth, int viewHeight) {
  37 + Log.e(TAG, "onRequestSuccess: " + "adId:" + adId + "," + viewWidth + "," + viewHeight);
38 38 bannerContainer.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
39 39 bannerContainer.getLayoutParams().height = ScreenUtil.getScreenWidth(BannerActivity.this) * viewHeight / viewWidth;
40 40 }
41 41  
42 42 @Override
43   - public void onRequestFailed(int code, String errorMsg) {
44   - Log.e(TAG, "onRequestFailed" + code + " : " + errorMsg);
  43 + public void onRequestFailed(String adId, int code, String errorMsg) {
  44 + Log.e(TAG, "onRequestFailed: " + "adId:" + adId + "," + code + " : " + errorMsg);
45 45 }
46 46  
47 47 @Override
48   - public void onShowSuccess() {
49   - Log.e(TAG, "onShowSuccess");
  48 + public void onShowSuccess(String adId) {
  49 + Log.e(TAG, "onShowSuccess: " + "adId:" + adId);
50 50 }
51 51  
52 52 @Override
53   - public void onSwitchBanner() {
54   - Log.e(TAG, "onSwitchBanner");
  53 + public void onSwitchBanner(String adId) {
  54 + Log.e(TAG, "onSwitchBanner: " + "adId:" + adId);
55 55 }
56 56  
57 57 @Override
58   - public void onShowFailed(int code, String msg) {
59   - Log.e(TAG, "onShowFailed: " + code + "," + msg);
  58 + public void onShowFailed(String adId, int code, String msg) {
  59 + Log.e(TAG, "onShowFailed: " + "adId:" + adId + "," + code + "," + msg);
60 60 }
61 61  
62 62 @Override
63   - public void onBannerClicked() {
64   - Log.e(TAG, "onBannerClicked");
  63 + public void onBannerClicked(String adId) {
  64 + Log.e(TAG, "onBannerClicked: " + "adId:" + adId);
65 65 }
66 66 });
67 67  
... ...
app/src/main/java/cn/vlion/simple/MainActivity.java
... ... @@ -17,7 +17,7 @@ public class MainActivity extends AppCompatActivity {
17 17 }
18 18  
19 19 public void bannerWebClick(View view) {
20   - startActivity(new Intent(MainActivity.this, BannerActivity.class).putExtra(TAG_ID, "430"));
  20 + startActivity(new Intent(MainActivity.this, BannerActivity.class).putExtra(TAG_ID, "469"));
21 21 }
22 22  
23 23 public void bannerImgClick(View view) {
... ...
app/src/main/java/cn/vlion/simple/NativeActivity.java
... ... @@ -42,13 +42,13 @@ public class NativeActivity extends AppCompatActivity {
42 42 NativeManager.getInstance().requestAppWall(this, adId_AppWall, new NativeListener<NativeAppWallData>() {
43 43 @Override
44 44 public void onRequestSuccess(NativeAppWallData data) {
45   - Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  45 + Log.e("DemoView", "数据获取成功 :" + "adId:" + data.getTagid() + "," + new Gson().toJson(data));
46 46 Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
47 47 }
48 48  
49 49 @Override
50   - public void onRequestFailed(int code, String message) {
51   - Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  50 + public void onRequestFailed(String adId, int code, String message) {
  51 + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message + ", adId:" + adId);
52 52 Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
53 53 }
54 54 });
... ... @@ -58,6 +58,7 @@ public class NativeActivity extends AppCompatActivity {
58 58 NativeManager.getInstance().requestCarousel(this, adId_Carousel, new NativeListener<NativeCarouselData>() {
59 59 @Override
60 60 public void onRequestSuccess(NativeCarouselData data) {
  61 + Log.e("DemoView", "数据获取成功 :" + "adId:" + data.getTagid() + "," + new Gson().toJson(data));
61 62 String ldp = data.getNativead().getLdp();
62 63 String download = data.getNativead().getAppDownloadurl();
63 64 Intent intent = new Intent(NativeActivity.this, VLionWebViewActivity.class);
... ... @@ -67,8 +68,8 @@ public class NativeActivity extends AppCompatActivity {
67 68 }
68 69  
69 70 @Override
70   - public void onRequestFailed(int code, String message) {
71   - Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  71 + public void onRequestFailed(String adId, int code, String message) {
  72 + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message + ", adId:" + adId);
72 73 Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
73 74 }
74 75 });
... ... @@ -78,13 +79,13 @@ public class NativeActivity extends AppCompatActivity {
78 79 NativeManager.getInstance().requestFeeds(this, adId_Feeds, new NativeListener<NativeFeedsData>() {
79 80 @Override
80 81 public void onRequestSuccess(NativeFeedsData data) {
81   - Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  82 + Log.e("DemoView", "数据获取成功 :" + "adId:" + data.getTagid() + "," + new Gson().toJson(data));
82 83 Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
83 84 }
84 85  
85 86 @Override
86   - public void onRequestFailed(int code, String message) {
87   - Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  87 + public void onRequestFailed(String adId, int code, String message) {
  88 + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message + ", adId:" + adId);
88 89 Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
89 90 }
90 91 });
... ... @@ -94,13 +95,13 @@ public class NativeActivity extends AppCompatActivity {
94 95 NativeManager.getInstance().requestNews(this, adId_News, new NativeListener<NativeNewsData>() {
95 96 @Override
96 97 public void onRequestSuccess(NativeNewsData data) {
97   - Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  98 + Log.e("DemoView", "数据获取成功 :" + "adId:" + data.getTagid() + "," + new Gson().toJson(data));
98 99 Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
99 100 }
100 101  
101 102 @Override
102   - public void onRequestFailed(int code, String message) {
103   - Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  103 + public void onRequestFailed(String adId, int code, String message) {
  104 + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message + ", adId:" + adId);
104 105 Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
105 106 }
106 107 });
... ... @@ -110,15 +111,19 @@ public class NativeActivity extends AppCompatActivity {
110 111 NativeManager.getInstance().requestWaterfall(this, adId_Waterfall, new NativeListener<NativeWaterfallData>() {
111 112 @Override
112 113 public void onRequestSuccess(NativeWaterfallData data) {
113   - Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  114 + Log.e("DemoView", "数据获取成功 :" + "adId:" + data.getTagid() + "," + new Gson().toJson(data));
114 115 Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
115 116 }
116 117  
117 118 @Override
118   - public void onRequestFailed(int code, String message) {
119   - Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  119 + public void onRequestFailed(String adId, int code, String message) {
  120 + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message + ", adId:" + adId);
120 121 Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
121 122 }
122 123 });
123 124 }
  125 +
  126 + public void showFeedsDemo(View view) {
  127 + startActivity(new Intent(this, NativeFeedsDemoActivity.class));
  128 + }
124 129 }
... ...
app/src/main/java/cn/vlion/simple/NativeFeedsDemoActivity.java 0 → 100644
  1 +package cn.vlion.simple;
  2 +
  3 +import android.content.Context;
  4 +import android.os.Bundle;
  5 +import android.support.annotation.Nullable;
  6 +import android.support.v7.app.AppCompatActivity;
  7 +import android.text.TextUtils;
  8 +import android.util.Log;
  9 +import android.util.TypedValue;
  10 +import android.view.View;
  11 +import android.widget.Button;
  12 +import android.widget.ImageView;
  13 +import android.widget.TextView;
  14 +
  15 +import com.bumptech.glide.Glide;
  16 +import com.google.gson.Gson;
  17 +
  18 +import java.util.List;
  19 +
  20 +import cn.vlion.ad.core.Config;
  21 +import cn.vlion.ad.moudle.natives.NativeAdStatusChangeListener;
  22 +import cn.vlion.ad.moudle.natives.NativeListener;
  23 +import cn.vlion.ad.moudle.natives.NativeManager;
  24 +import cn.vlion.ad.moudle.natives.model.NativeAdStateData;
  25 +import cn.vlion.ad.moudle.natives.model.NativeFeeds;
  26 +import cn.vlion.ad.moudle.natives.model.NativeFeedsData;
  27 +import cn.vlion.simple.util.ScreenUtil;
  28 +
  29 +/**
  30 + * Created by gujun on 2017/11/15.
  31 + */
  32 +
  33 +public class NativeFeedsDemoActivity extends AppCompatActivity {
  34 +
  35 + private static final String adId_Feeds = "357";
  36 + private static final String TAG = "NativeFeedsDemoActivity";
  37 +
  38 + private ImageView icon, image;
  39 + private TextView title, desc, rating;
  40 + private Button click;
  41 +
  42 + @Override
  43 + protected void onCreate(@Nullable Bundle savedInstanceState) {
  44 + super.onCreate(savedInstanceState);
  45 + setContentView(R.layout.activity_native_feeds_demo);
  46 + init();
  47 + loadFeeds();
  48 + }
  49 +
  50 + private void init() {
  51 + icon = findViewById(R.id.icon);
  52 + image = findViewById(R.id.image);
  53 + title = findViewById(R.id.title);
  54 + desc = findViewById(R.id.desc);
  55 + rating = findViewById(R.id.rating);
  56 + click = findViewById(R.id.click);
  57 + }
  58 +
  59 + public void loadFeeds() {
  60 + NativeManager.getInstance().requestFeeds(this, adId_Feeds, new NativeListener<NativeFeedsData>() {
  61 + @Override
  62 + public void onRequestSuccess(NativeFeedsData data) {
  63 + Log.e("DemoView", "数据获取成功 " + "adId:" + data.getTagid() + "," + new Gson().toJson(data));
  64 + addData(data);
  65 + }
  66 +
  67 + @Override
  68 + public void onRequestFailed(String adId, int code, String message) {
  69 + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message + "," + "adId:" + adId);
  70 + }
  71 + });
  72 + }
  73 +
  74 + private void addData(final NativeFeedsData data) {
  75 + if (data == null || data.getNativead() == null) return;
  76 +
  77 + List<NativeFeeds.IconBean> icons = data.getNativead().getIcon();
  78 + String iconUrl = icons == null || icons.size() <= 0 ? "" : icons.get(0).getUrl();
  79 + if (!TextUtils.isEmpty(iconUrl))
  80 + Glide.with(this).load(iconUrl).into(icon);
  81 +
  82 + List<NativeFeeds.ImgBean> images = data.getNativead().getImg();
  83 + String imageUrl = images == null || images.size() <= 0 ? "" : images.get(0).getUrl();
  84 + if (!TextUtils.isEmpty(imageUrl))
  85 + Glide.with(this).load(imageUrl).into(image);
  86 + int imageHeight = Integer.valueOf(images.get(0).getH());
  87 + int imageWidth = Integer.valueOf(images.get(0).getW());
  88 + int imageRealWidth = ScreenUtil.getScreenWidth(this) - dp2px(this, 20);
  89 + image.getLayoutParams().width = imageRealWidth;
  90 + image.getLayoutParams().height = imageRealWidth * imageHeight / imageWidth;
  91 +
  92 + title.setText(data.getNativead().getTitle());
  93 + desc.setText(data.getNativead().getDesc());
  94 + rating.setText(data.getNativead().getRating() == null ? "0分" : data.getNativead().getRating() + "分");
  95 + click.setText(data.getNativead().getButton() == null ? "ad click" : data.getNativead().getButton());
  96 + click.setOnClickListener(new View.OnClickListener() {
  97 + @Override
  98 + public void onClick(View v) {
  99 + //点击的调用
  100 + boolean clickSuccess = NativeManager.getInstance().onClick(NativeFeedsDemoActivity.this, data, statusChangeListener);
  101 + Log.e(TAG, "onClick: " + clickSuccess);
  102 + }
  103 + });
  104 +
  105 + //曝光的调用
  106 + NativeManager.getInstance().onExposure(data);
  107 + }
  108 +
  109 + public static int dp2px(Context context, float dpVal) {
  110 + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
  111 + dpVal, context.getResources().getDisplayMetrics());
  112 + }
  113 +
  114 + private NativeAdStatusChangeListener statusChangeListener = new NativeAdStatusChangeListener() {
  115 + @Override
  116 + public void onAdStatusChange(NativeAdStateData stateData) {
  117 + switch (stateData.getDownloadType()) {
  118 + case Config.NATIVE_AD_CLICK_TYPE_DOWNLOAD_START:
  119 + Log.e(TAG, "onAdStatusChange: adId:" + stateData.getAdId() + ",等待下载" + stateData.getDownloadProgress());
  120 + break;
  121 + case Config.NATIVE_AD_CLICK_TYPE_DOWNLOAD_RUNNING:
  122 + Log.e(TAG, "onAdStatusChange: adId:" + stateData.getAdId() + ",正在下载" + stateData.getDownloadProgress());
  123 + break;
  124 + case Config.NATIVE_AD_CLICK_TYPE_DOWNLOAD_FAILED:
  125 + Log.e(TAG, "onAdStatusChange: adId:" + stateData.getAdId() + ",下载失败" + stateData.getDownloadProgress());
  126 + break;
  127 + case Config.NATIVE_AD_CLICK_TYPE_DOWNLOAD_SUCCESS:
  128 + Log.e(TAG, "onAdStatusChange: adId:" + stateData.getAdId() + ",成功" + stateData.getDownloadProgress());
  129 + break;
  130 + case Config.NATIVE_AD_CLICK_TYPE_DOWNLOAD_PAUSED:
  131 + Log.e(TAG, "onAdStatusChange: adId:" + stateData.getAdId() + ",暂停" + stateData.getDownloadProgress());
  132 + break;
  133 + }
  134 + }
  135 + };
  136 +}
... ...
app/src/main/java/cn/vlion/simple/SplashActivity.java
... ... @@ -77,42 +77,42 @@ public class SplashActivity extends AppCompatActivity {
77 77 SplashManager.getInstance().showSplash(this, "432", new SplashViewListener() {
78 78  
79 79 @Override
80   - public void onRequestSuccess(int viewWidth, int viewHeight) {
81   - Log.e(TAG, "onRequestSuccess: " + viewWidth + "," + viewHeight);
  80 + public void onRequestSuccess(String adId, int viewWidth, int viewHeight) {
  81 + Log.e(TAG, "onRequestSuccess: " + "adId:" + adId + "," + viewWidth + "," + viewHeight);
82 82 splashAdContainer.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
83 83 splashAdContainer.getLayoutParams().height = ScreenUtil.getScreenWidth(SplashActivity.this) * viewHeight / viewWidth;
84 84 }
85 85  
86 86 @Override
87   - public void onRequestFailed(int code, String errorMsg) {
88   - Log.e(TAG, "onRequestFailed: " + code + "," + errorMsg);
  87 + public void onRequestFailed(String adId, int code, String errorMsg) {
  88 + Log.e(TAG, "onRequestFailed: " + "adId:" + adId + "," + code + "," + errorMsg);
89 89 }
90 90  
91 91 @Override
92   - public void onShowSuccess() {
93   - Log.e(TAG, "onShowSuccess: ");
  92 + public void onShowSuccess(String adId) {
  93 + Log.e(TAG, "onShowSuccess: " + "adId:" + adId);
94 94 defaultLayout.setVisibility(View.GONE);
95 95 adLayout.setVisibility(View.VISIBLE);
96 96 }
97 97  
98 98 @Override
99   - public void onShowFailed(int code, String msg) {
100   - Log.e(TAG, "onShowFailed: " + code + "," + msg);
  99 + public void onShowFailed(String adId, int code, String msg) {
  100 + Log.e(TAG, "onShowFailed: " + "adId:" + adId + "," + code + "," + msg);
101 101 }
102 102  
103 103 @Override
104   - public void onSplashClicked() {
105   - Log.e(TAG, "onSplashClicked: ");
  104 + public void onSplashClicked(String adId) {
  105 + Log.e(TAG, "onSplashClicked: " + "adId:" + adId);
106 106 }
107 107  
108 108 @Override
109   - public void onSplashClosed() {
110   - Log.e(TAG, "onSplashClosed: ");
  109 + public void onSplashClosed(String adId) {
  110 + Log.e(TAG, "onSplashClosed: " + "adId:" + adId);
111 111 }
112 112  
113 113 @Override
114   - public void onSwitchSplash() {
115   - Log.e(TAG, "onSwitchSplash: ");
  114 + public void onSwitchSplash(String adId) {
  115 + Log.e(TAG, "onSwitchSplash: " + "adId:" + adId);
116 116 }
117 117 });
118 118 }
... ...
app/src/main/java/cn/vlion/simple/SpotActivity.java
... ... @@ -44,44 +44,44 @@ public class SpotActivity extends AppCompatActivity {
44 44 SpotManager.getInstance().showSpot(this, tagId, new SpotViewListener() {
45 45  
46 46 @Override
47   - public void onRequestSuccess(int viewWidth, int viewHeight, int closeViewHeight) {
48   - Log.e(TAG, "onRequestSuccess: " + viewWidth + "," + viewHeight);
  47 + public void onRequestSuccess(String adId, int viewWidth, int viewHeight, int closeViewHeight) {
  48 + Log.e(TAG, "onRequestSuccess: " + "adId:" + adId + "," + viewWidth + "," + viewHeight);
49 49 spotAdContainer.getLayoutParams().width = 720;
50 50 spotAdContainer.getLayoutParams().height = 720 * viewHeight / viewWidth + closeViewHeight;
51 51 }
52 52  
53 53 @Override
54   - public void onRequestFailed(int code, String errorMsg) {
55   - Log.e(TAG, "onRequestFailed: " + code + "," + errorMsg);
  54 + public void onRequestFailed(String adId, int code, String errorMsg) {
  55 + Log.e(TAG, "onRequestFailed: " + "adId:" + adId + "," + code + "," + errorMsg);
56 56 Toast.makeText(SpotActivity.this, "onRequestFailed: " + code + "," + errorMsg, Toast.LENGTH_SHORT).show();
57 57 }
58 58  
59 59 @Override
60   - public void onShowSuccess() {
61   - Log.e(TAG, "onShowSuccess: ");
  60 + public void onShowSuccess(String adId) {
  61 + Log.e(TAG, "onShowSuccess: " + "adId:" + adId);
62 62 adLayout.setVisibility(View.VISIBLE);
63 63 }
64 64  
65 65 @Override
66   - public void onShowFailed(int code, String msg) {
67   - Log.e(TAG, "onShowFailed: " + code + "," + msg);
  66 + public void onShowFailed(String adId, int code, String msg) {
  67 + Log.e(TAG, "onShowFailed: " + "adId:" + adId + "," + code + "," + msg);
68 68 }
69 69  
70 70 @Override
71   - public void onSpotClicked() {
72   - Log.e(TAG, "onSplashClicked: ");
  71 + public void onSpotClicked(String adId) {
  72 + Log.e(TAG, "onSplashClicked: " + "adId:" + adId);
73 73 adLayout.setVisibility(View.GONE);
74 74 }
75 75  
76 76 @Override
77   - public void onSpotClosed() {
78   - Log.e(TAG, "onSplashClosed: ");
  77 + public void onSpotClosed(String adId) {
  78 + Log.e(TAG, "onSplashClosed: " + "adId:" + adId);
79 79 adLayout.setVisibility(View.GONE);
80 80 }
81 81  
82 82 @Override
83   - public void onSwitchSpot() {
84   - Log.e(TAG, "onSwitchSpot: ");
  83 + public void onSwitchSpot(String adId) {
  84 + Log.e(TAG, "onSwitchSpot: " + "adId:" + adId);
85 85 }
86 86 });
87 87 }
... ...
app/src/main/res/layout/activity_native.xml
... ... @@ -51,4 +51,13 @@
51 51 android:layout_marginTop="16dp"
52 52 android:onClick="loadWaterfall"
53 53 android:text="@string/loadWaterfall" />
  54 +
  55 + <Button
  56 + android:id="@+id/feedsDemo"
  57 + style="@style/buttonTheme"
  58 + android:layout_width="200dp"
  59 + android:layout_height="wrap_content"
  60 + android:text="@string/showFeedsDemo"
  61 + android:layout_marginTop="16dp"
  62 + android:onClick="showFeedsDemo"/>
54 63 </LinearLayout>
55 64 \ No newline at end of file
... ...
app/src/main/res/layout/activity_native_feeds_demo.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="wrap_content"
  5 + android:padding="10dp">
  6 +
  7 + <RelativeLayout
  8 + android:id="@+id/topLayout"
  9 + android:layout_width="match_parent"
  10 + android:layout_height="wrap_content">
  11 +
  12 + <ImageView
  13 + android:id="@+id/icon"
  14 + android:layout_width="50dp"
  15 + android:layout_height="50dp"
  16 + android:layout_marginRight="10dp"
  17 + android:scaleType="centerCrop" />
  18 +
  19 + <TextView
  20 + android:id="@+id/title"
  21 + android:layout_width="wrap_content"
  22 + android:layout_height="wrap_content"
  23 + android:layout_toRightOf="@+id/icon"
  24 + android:singleLine="true"
  25 + android:textColor="@android:color/black" />
  26 +
  27 + <TextView
  28 + android:id="@+id/rating"
  29 + android:layout_width="wrap_content"
  30 + android:layout_height="wrap_content"
  31 + android:layout_below="@+id/title"
  32 + android:layout_marginTop="5dp"
  33 + android:layout_toRightOf="@+id/icon"
  34 + android:textColor="@android:color/darker_gray" />
  35 +
  36 + </RelativeLayout>
  37 +
  38 + <ImageView
  39 + android:id="@+id/image"
  40 + android:layout_width="match_parent"
  41 + android:layout_height="100dp"
  42 + android:layout_below="@+id/topLayout"
  43 + android:layout_marginBottom="10dp"
  44 + android:layout_marginTop="10dp"
  45 + android:scaleType="centerCrop" />
  46 +
  47 + <LinearLayout
  48 + android:layout_width="match_parent"
  49 + android:layout_height="wrap_content"
  50 + android:layout_below="@+id/image"
  51 + android:gravity="center_vertical">
  52 +
  53 + <TextView
  54 + android:id="@+id/desc"
  55 + android:layout_width="0dp"
  56 + android:layout_height="wrap_content"
  57 + android:layout_weight="1" />
  58 +
  59 + <Button
  60 + android:id="@+id/click"
  61 + android:layout_width="wrap_content"
  62 + android:layout_height="wrap_content"
  63 + android:text="ad click" />
  64 +
  65 + </LinearLayout>
  66 +
  67 +</RelativeLayout>
0 68 \ No newline at end of file
... ...
app/src/main/res/values/strings.xml
... ... @@ -5,4 +5,5 @@
5 5 <string name="loadFeeds">信息流数据</string>
6 6 <string name="loadNews">新闻放送数据</string>
7 7 <string name="loadWaterfall">瀑布流数据</string>
  8 + <string name="showFeedsDemo">展示信息流demo</string>
8 9 </resources>
... ...
build.gradle
... ... @@ -15,6 +15,8 @@ buildscript {
15 15 allprojects {
16 16 repositories {
17 17 jcenter()
  18 + mavenCentral()
  19 + maven { url 'https://maven.google.com' }
18 20 }
19 21 }
20 22  
... ...