Commit e32d8fa94456119a1e808dbb3065d6b2275bc30d

Authored by 王琳
1 parent 37a8ffe7

更新demo样式

app/src/main/java/cn/vlion/simple/BannerActivity.java
... ... @@ -12,6 +12,8 @@ import cn.vlion.ad.moudle.banner.BannerView;
12 12 import cn.vlion.ad.moudle.banner.BannerViewListener;
13 13 import cn.vlion.simple.util.ScreenUtil;
14 14  
  15 +import static cn.vlion.simple.MainActivity.TAG_ID;
  16 +
15 17 public class BannerActivity extends AppCompatActivity {
16 18  
17 19 private static final String TAG = "BannerActivity";
... ... @@ -24,11 +26,12 @@ public class BannerActivity extends AppCompatActivity {
24 26 super.onCreate(savedInstanceState);
25 27 setContentView(R.layout.activity_banner);
26 28 bannerContainer = (RelativeLayout) findViewById(R.id.bannerContainer);
  29 + String tagId = getIntent().getStringExtra(TAG_ID);
27 30  
28 31 BannerManager.getInstance().setAdScalingModel(Config.AD_SCALING_MODE_SCALE_TO_FIT);
29 32 //430 h5
30 33 //431 image
31   - bannerView = BannerManager.getInstance().getBannerView(this, "430", new BannerViewListener() {
  34 + bannerView = BannerManager.getInstance().getBannerView(this, tagId, new BannerViewListener() {
32 35 @Override
33 36 public void onRequestSuccess(int viewWidth, int viewHeight) {
34 37 Log.e(TAG, "onRequestSuccess: " + viewWidth + "," + viewHeight);
... ...
app/src/main/java/cn/vlion/simple/MainActivity.java
... ... @@ -8,30 +8,31 @@ import android.view.View;
8 8 public class MainActivity extends AppCompatActivity {
9 9  
10 10 private static final String TAG = "MainActivity";
  11 + public static final String TAG_ID = "tagId";
11 12  
12 13 @Override
13 14 protected void onCreate(Bundle savedInstanceState) {
14 15 super.onCreate(savedInstanceState);
15 16 setContentView(R.layout.activity_main);
16   - findViewById(R.id.bannerBtn).setOnClickListener(new View.OnClickListener() {
17   - @Override
18   - public void onClick(View view) {
19   - startActivity(new Intent(MainActivity.this, BannerActivity.class));
20   - }
21   - });
22   -
23   - findViewById(R.id.spotBtn).setOnClickListener(new View.OnClickListener() {
24   - @Override
25   - public void onClick(View view) {
26   - startActivity(new Intent(MainActivity.this, SpotActivity.class));
27   - }
28   - });
29   -
30   - findViewById(R.id.nativeBtn).setOnClickListener(new View.OnClickListener() {
31   - @Override
32   - public void onClick(View v) {
33   - startActivity(new Intent(MainActivity.this, NativeActivity.class));
34   - }
35   - });
  17 + }
  18 +
  19 + public void bannerWebClick(View view) {
  20 + startActivity(new Intent(MainActivity.this, BannerActivity.class).putExtra(TAG_ID, "430"));
  21 + }
  22 +
  23 + public void bannerImgClick(View view) {
  24 + startActivity(new Intent(MainActivity.this, BannerActivity.class).putExtra(TAG_ID, "431"));
  25 + }
  26 +
  27 + public void spotWebClick(View view) {
  28 + startActivity(new Intent(MainActivity.this, SpotActivity.class).putExtra(TAG_ID, "434"));
  29 + }
  30 +
  31 + public void spotImgClick(View view) {
  32 + startActivity(new Intent(MainActivity.this, SpotActivity.class).putExtra(TAG_ID, "438"));
  33 + }
  34 +
  35 + public void nativeClick(View view) {
  36 + startActivity(new Intent(MainActivity.this, NativeActivity.class));
36 37 }
37 38 }
... ...
app/src/main/java/cn/vlion/simple/NativeActivity.java
... ... @@ -5,6 +5,7 @@ import android.support.annotation.Nullable;
5 5 import android.support.v7.app.AppCompatActivity;
6 6 import android.util.Log;
7 7 import android.view.View;
  8 +import android.widget.Toast;
8 9  
9 10 import com.google.gson.Gson;
10 11  
... ... @@ -24,7 +25,7 @@ public class NativeActivity extends AppCompatActivity {
24 25  
25 26 private static final String adId_AppWall = "";
26 27 private static final String adId_Carousel = "359";
27   - private static final String adId_Feeds = "357";
  28 + private static final String adId_Feeds = "440";
28 29 private static final String adId_News = "";
29 30 private static final String adId_Waterfall = "358";
30 31  
... ... @@ -39,11 +40,13 @@ public class NativeActivity extends AppCompatActivity {
39 40 @Override
40 41 public void onRequestSuccess(NativeAppWallData data) {
41 42 Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  43 + Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
42 44 }
43 45  
44 46 @Override
45 47 public void onRequestFailed(int code, String message) {
46 48 Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  49 + Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
47 50 }
48 51 });
49 52 }
... ... @@ -53,11 +56,13 @@ public class NativeActivity extends AppCompatActivity {
53 56 @Override
54 57 public void onRequestSuccess(NativeCarouselData data) {
55 58 Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  59 + Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
56 60 }
57 61  
58 62 @Override
59 63 public void onRequestFailed(int code, String message) {
60 64 Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  65 + Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
61 66 }
62 67 });
63 68 }
... ... @@ -67,11 +72,13 @@ public class NativeActivity extends AppCompatActivity {
67 72 @Override
68 73 public void onRequestSuccess(NativeFeedsData data) {
69 74 Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  75 + Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
70 76 }
71 77  
72 78 @Override
73 79 public void onRequestFailed(int code, String message) {
74 80 Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  81 + Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
75 82 }
76 83 });
77 84 }
... ... @@ -81,11 +88,13 @@ public class NativeActivity extends AppCompatActivity {
81 88 @Override
82 89 public void onRequestSuccess(NativeNewsData data) {
83 90 Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  91 + Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
84 92 }
85 93  
86 94 @Override
87 95 public void onRequestFailed(int code, String message) {
88 96 Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  97 + Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
89 98 }
90 99 });
91 100 }
... ... @@ -95,11 +104,13 @@ public class NativeActivity extends AppCompatActivity {
95 104 @Override
96 105 public void onRequestSuccess(NativeWaterfallData data) {
97 106 Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data));
  107 + Toast.makeText(NativeActivity.this, "数据获取成功 " + new Gson().toJson(data), Toast.LENGTH_SHORT).show();
98 108 }
99 109  
100 110 @Override
101 111 public void onRequestFailed(int code, String message) {
102 112 Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message);
  113 + Toast.makeText(NativeActivity.this, "数据加载失败 : code = " + code + " , message = " + message, Toast.LENGTH_SHORT).show();
103 114 }
104 115 });
105 116 }
... ...
app/src/main/java/cn/vlion/simple/SplashActivity.java
... ... @@ -74,7 +74,7 @@ public class SplashActivity extends AppCompatActivity {
74 74 SplashManager.getInstance().setAdScalingModel(Config.AD_SCALING_MODE_SCALE_TO_FIT);
75 75 //432 h5
76 76 //433 image
77   - SplashManager.getInstance().showSplash(this, "432", new SplashViewListener() {
  77 + SplashManager.getInstance().showSplash(this, "433", new SplashViewListener() {
78 78  
79 79 @Override
80 80 public void onRequestSuccess(int viewWidth, int viewHeight) {
... ...
app/src/main/java/cn/vlion/simple/SpotActivity.java
... ... @@ -7,6 +7,7 @@ import android.util.Log;
7 7 import android.view.View;
8 8 import android.view.ViewGroup;
9 9 import android.widget.RelativeLayout;
  10 +import android.widget.Toast;
10 11  
11 12 import cn.vlion.ad.core.Config;
12 13 import cn.vlion.ad.moudle.spot.SpotManager;
... ... @@ -14,6 +15,8 @@ import cn.vlion.ad.moudle.spot.SpotViewListener;
14 15  
15 16 import cn.vlion.simple.util.ScreenUtil;
16 17  
  18 +import static cn.vlion.simple.MainActivity.TAG_ID;
  19 +
17 20 /**
18 21 * Created by gujun on 2017/10/12.
19 22 */
... ... @@ -23,11 +26,13 @@ public class SpotActivity extends AppCompatActivity {
23 26 private static final String TAG = "SpotActivity";
24 27 private RelativeLayout spotAdContainer;
25 28 private RelativeLayout adLayout;
  29 + private String tagId;
26 30  
27 31 @Override
28 32 protected void onCreate(@Nullable Bundle savedInstanceState) {
29 33 super.onCreate(savedInstanceState);
30 34 setContentView(R.layout.activity_spot);
  35 + tagId = getIntent().getStringExtra(TAG_ID);
31 36 addSpotAd();
32 37 }
33 38  
... ... @@ -39,7 +44,7 @@ public class SpotActivity extends AppCompatActivity {
39 44 SpotManager.getInstance().setAdScalingModel(Config.AD_SCALING_MODE_SCALE_TO_FIT);
40 45 //434 h5
41 46 //438 image
42   - SpotManager.getInstance().showSpot(this, "438", new SpotViewListener() {
  47 + SpotManager.getInstance().showSpot(this, tagId, new SpotViewListener() {
43 48  
44 49 @Override
45 50 public void onRequestSuccess(int viewWidth, int viewHeight, int closeViewHeight) {
... ... @@ -51,6 +56,7 @@ public class SpotActivity extends AppCompatActivity {
51 56 @Override
52 57 public void onRequestFailed(int code, String errorMsg) {
53 58 Log.e(TAG, "onRequestFailed: " + code + "," + errorMsg);
  59 + Toast.makeText(SpotActivity.this, "onRequestFailed: " + code + "," + errorMsg, Toast.LENGTH_SHORT).show();
54 60 }
55 61  
56 62 @Override
... ...
app/src/main/res/drawable/back.png

700 Bytes | W: | H:

438 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin
app/src/main/res/drawable/btn_bg.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:shape="rectangle"
  4 + android:useLevel="false">
  5 +
  6 + <solid android:color="@color/colorAccent" />
  7 +
  8 + <corners
  9 + android:bottomLeftRadius="20dp"
  10 + android:bottomRightRadius="20dp"
  11 + android:topLeftRadius="20dp"
  12 + android:topRightRadius="20dp" />
  13 +
  14 +</shape>
0 15 \ No newline at end of file
... ...
app/src/main/res/layout/activity_main.xml
... ... @@ -7,26 +7,42 @@
7 7 tools:context="cn.vlion.simple.MainActivity">
8 8  
9 9 <Button
10   - android:id="@+id/bannerBtn"
  10 + android:id="@+id/bannerWebBtn"
  11 + style="@style/buttonTheme"
11 12 android:layout_width="200dp"
12 13 android:layout_height="wrap_content"
13   - android:layout_alignParentBottom="true"
14   - android:layout_centerHorizontal="true"
15   - android:text="横幅广告" />
  14 + android:onClick="bannerWebClick"
  15 + android:text="横幅广告(web)" />
16 16  
17 17 <Button
18   - android:id="@+id/spotBtn"
  18 + android:id="@+id/bannerImgBtn"
  19 + style="@style/buttonTheme"
19 20 android:layout_width="200dp"
20 21 android:layout_height="wrap_content"
21   - android:layout_alignParentBottom="true"
22   - android:layout_centerHorizontal="true"
23   - android:text="插屏广告广告" />
  22 + android:onClick="bannerImgClick"
  23 + android:text="横幅广告(img)" />
  24 +
  25 + <Button
  26 + android:id="@+id/spotWebBtn"
  27 + style="@style/buttonTheme"
  28 + android:layout_width="200dp"
  29 + android:layout_height="wrap_content"
  30 + android:onClick="spotWebClick"
  31 + android:text="插屏广告(web)" />
  32 +
  33 + <Button
  34 + android:id="@+id/spotImgBtn"
  35 + style="@style/buttonTheme"
  36 + android:layout_width="200dp"
  37 + android:layout_height="wrap_content"
  38 + android:onClick="spotImgClick"
  39 + android:text="插屏广告(img)" />
24 40  
25 41 <Button
26 42 android:id="@+id/nativeBtn"
  43 + style="@style/buttonTheme"
27 44 android:layout_width="200dp"
28 45 android:layout_height="wrap_content"
29   - android:layout_alignParentBottom="true"
30   - android:layout_centerHorizontal="true"
  46 + android:onClick="nativeClick"
31 47 android:text="原生广告" />
32 48 </LinearLayout>
... ...
app/src/main/res/layout/activity_native.xml
... ... @@ -3,46 +3,51 @@
3 3 xmlns:tools="http://schemas.android.com/tools"
4 4 android:layout_width="match_parent"
5 5 android:layout_height="match_parent"
  6 + android:gravity="center"
6 7 android:orientation="vertical"
7   - tools:context="cn.vlion.simple.NativeActivity"
8   - android:gravity="center">
  8 + tools:context="cn.vlion.simple.NativeActivity">
9 9  
10 10 <Button
11 11 android:id="@+id/loadAppWall"
  12 + style="@style/buttonTheme"
12 13 android:layout_width="200dp"
13 14 android:layout_height="wrap_content"
14   - android:text="@string/loadAppWall"
15   - android:onClick="loadAppWall"/>
  15 + android:onClick="loadAppWall"
  16 + android:text="@string/loadAppWall" />
16 17  
17 18 <Button
18 19 android:id="@+id/loadCarousel"
  20 + style="@style/buttonTheme"
19 21 android:layout_width="200dp"
20 22 android:layout_height="wrap_content"
21   - android:text="@string/loadCarousel"
22 23 android:layout_marginTop="16dp"
23   - android:onClick="loadCarousel"/>
  24 + android:onClick="loadCarousel"
  25 + android:text="@string/loadCarousel" />
24 26  
25 27 <Button
26 28 android:id="@+id/loadFeeds"
  29 + style="@style/buttonTheme"
27 30 android:layout_width="200dp"
28 31 android:layout_height="wrap_content"
29   - android:text="@string/loadFeeds"
30 32 android:layout_marginTop="16dp"
31   - android:onClick="loadFeeds"/>
  33 + android:onClick="loadFeeds"
  34 + android:text="@string/loadFeeds" />
32 35  
33 36 <Button
34 37 android:id="@+id/loadNews"
  38 + style="@style/buttonTheme"
35 39 android:layout_width="200dp"
36 40 android:layout_height="wrap_content"
37   - android:text="@string/loadNews"
38 41 android:layout_marginTop="16dp"
39   - android:onClick="loadNews"/>
  42 + android:onClick="loadNews"
  43 + android:text="@string/loadNews" />
40 44  
41 45 <Button
42 46 android:id="@+id/loadWaterfall"
  47 + style="@style/buttonTheme"
43 48 android:layout_width="200dp"
44 49 android:layout_height="wrap_content"
45   - android:text="@string/loadWaterfall"
46 50 android:layout_marginTop="16dp"
47   - android:onClick="loadWaterfall"/>
  51 + android:onClick="loadWaterfall"
  52 + android:text="@string/loadWaterfall" />
48 53 </LinearLayout>
49 54 \ No newline at end of file
... ...
app/src/main/res/values/colors.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <resources>
3   - <color name="colorPrimary">#3F51B5</color>
4   - <color name="colorPrimaryDark">#303F9F</color>
5   - <color name="colorAccent">#FF4081</color>
  3 + <color name="colorPrimary">#4685CA</color>
  4 + <color name="colorPrimaryDark">#25609E</color>
  5 + <color name="colorAccent">#5892D0</color>
6 6 </resources>
... ...
app/src/main/res/values/styles.xml
... ... @@ -8,4 +8,11 @@
8 8 <item name="colorAccent">@color/colorAccent</item>
9 9 </style>
10 10  
  11 + <style name="buttonTheme">
  12 + <item name="android:background">@drawable/btn_bg</item>
  13 + <item name="android:textColor">@android:color/white</item>
  14 + <item name="android:layout_gravity">center_horizontal</item>
  15 + <item name="android:layout_marginTop">20dp</item>
  16 + </style>
  17 +
11 18 </resources>
... ...