Commit 95628cc590f79d909b437b085f720055badf408c
1 parent
a5be0051
添加demo
Showing
25 changed files
with
1088 additions
and
13 deletions
app/build.gradle
| ... | ... | @@ -25,6 +25,7 @@ dependencies { |
| 25 | 25 | exclude group: 'com.android.support', module: 'support-annotations' |
| 26 | 26 | }) |
| 27 | 27 | compile 'com.android.support:appcompat-v7:26.+' |
| 28 | + compile 'com.google.code.gson:gson:2.8.2' | |
| 28 | 29 | compile 'com.android.support.constraint:constraint-layout:1.0.2' |
| 29 | 30 | testCompile 'junit:junit:4.12' |
| 30 | 31 | } | ... | ... |
app/libs/vlionSdk1.0.jar
0 → 100644
No preview for this file type
app/src/main/AndroidManifest.xml
| ... | ... | @@ -2,20 +2,61 @@ |
| 2 | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | 3 | package="com.vlion.simple"> |
| 4 | 4 | |
| 5 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | |
| 6 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
| 7 | + <uses-permission android:name="android.permission.INTERNET" /> | |
| 8 | + <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | |
| 9 | + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | |
| 10 | + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
| 11 | + | |
| 5 | 12 | <application |
| 13 | + android:name=".application.VLionApplication" | |
| 6 | 14 | android:allowBackup="true" |
| 15 | + android:configChanges="keyboardHidden|screenSize|orientation" | |
| 7 | 16 | android:icon="@mipmap/ic_launcher" |
| 8 | 17 | android:label="@string/app_name" |
| 9 | 18 | android:roundIcon="@mipmap/ic_launcher_round" |
| 19 | + android:screenOrientation="portrait" | |
| 10 | 20 | android:supportsRtl="true" |
| 11 | 21 | android:theme="@style/AppTheme"> |
| 12 | - <activity android:name=".MainActivity"> | |
| 22 | + <activity android:name=".SplashActivity"> | |
| 13 | 23 | <intent-filter> |
| 14 | 24 | <action android:name="android.intent.action.MAIN" /> |
| 15 | 25 | |
| 16 | 26 | <category android:name="android.intent.category.LAUNCHER" /> |
| 17 | 27 | </intent-filter> |
| 18 | 28 | </activity> |
| 29 | + | |
| 30 | + <receiver android:name="com.vlion.ad.utils.apkdownload.DownloadCompleteReceiver"> | |
| 31 | + <intent-filter> | |
| 32 | + <action android:name="android.intent.action.DOWNLOAD_COMPLETE" /> | |
| 33 | + </intent-filter> | |
| 34 | + <intent-filter> | |
| 35 | + <action android:name="android.intent.action.PACKAGE_ADDED" /> | |
| 36 | + <data android:scheme="package" /> | |
| 37 | + </intent-filter> | |
| 38 | + </receiver> | |
| 39 | + | |
| 40 | + <activity | |
| 41 | + android:name=".BannerActivity" | |
| 42 | + android:configChanges="keyboardHidden|screenSize|orientation" | |
| 43 | + android:screenOrientation="portrait" /> | |
| 44 | + <activity | |
| 45 | + android:name=".SpotActivity" | |
| 46 | + android:configChanges="keyboardHidden|screenSize|orientation" | |
| 47 | + android:screenOrientation="portrait" /> | |
| 48 | + | |
| 49 | + <activity | |
| 50 | + android:name=".MainActivity" | |
| 51 | + android:configChanges="keyboardHidden|screenSize|orientation" | |
| 52 | + android:screenOrientation="portrait" /> | |
| 53 | + | |
| 54 | + <activity | |
| 55 | + android:name=".NativeActivity" | |
| 56 | + android:configChanges="keyboardHidden|screenSize|orientation" | |
| 57 | + android:screenOrientation="portrait" /> | |
| 58 | + | |
| 59 | + <activity android:name="com.vlion.ad.view.webview.VLionWebViewActivity" /> | |
| 19 | 60 | </application> |
| 20 | 61 | |
| 21 | 62 | </manifest> |
| 22 | 63 | \ No newline at end of file | ... | ... |
app/src/main/java/com/vlion/simple/BannerActivity.java
0 → 100644
| 1 | +package com.vlion.simple; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.support.v7.app.AppCompatActivity; | |
| 5 | +import android.util.Log; | |
| 6 | +import android.view.ViewGroup; | |
| 7 | +import android.widget.RelativeLayout; | |
| 8 | + | |
| 9 | +import com.vlion.ad.core.Config; | |
| 10 | +import com.vlion.ad.moudle.banner.BannerManager; | |
| 11 | +import com.vlion.ad.moudle.banner.BannerView; | |
| 12 | +import com.vlion.ad.moudle.banner.BannerViewListener; | |
| 13 | +import com.vlion.simple.util.ScreenUtil; | |
| 14 | + | |
| 15 | +public class BannerActivity extends AppCompatActivity { | |
| 16 | + | |
| 17 | + private static final String TAG = "BannerActivity"; | |
| 18 | + | |
| 19 | + private RelativeLayout bannerContainer; | |
| 20 | + private BannerView bannerView; | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + protected void onCreate(Bundle savedInstanceState) { | |
| 24 | + super.onCreate(savedInstanceState); | |
| 25 | + setContentView(R.layout.activity_banner); | |
| 26 | + bannerContainer = (RelativeLayout) findViewById(R.id.bannerContainer); | |
| 27 | + | |
| 28 | + BannerManager.getInstance().setAdScalingModel(Config.AD_SCALING_MODE_SCALE_TO_FIT); | |
| 29 | + | |
| 30 | + bannerView = BannerManager.getInstance().getBannerView(this, "350", R.mipmap.ic_launcher, new BannerViewListener() { | |
| 31 | + @Override | |
| 32 | + public void onRequestSuccess(int viewWidth, int viewHeight) { | |
| 33 | + Log.e(TAG, "onRequestSuccess: " + viewWidth + "," + viewHeight); | |
| 34 | + bannerContainer.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; | |
| 35 | + bannerContainer.getLayoutParams().height = ScreenUtil.getScreenWidth(BannerActivity.this) * viewHeight / viewWidth; | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + public void onRequestFailed(int code, String errorMsg) { | |
| 40 | + Log.e(TAG, "onRequestFailed" + code + " : " + errorMsg); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void onShowSuccess() { | |
| 45 | + Log.e(TAG, "onShowSuccess"); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void onSwitchBanner() { | |
| 50 | + Log.e(TAG, "onSwitchBanner"); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + public void onShowFailed(int code, String msg) { | |
| 55 | + Log.e(TAG, "onShowFailed: " + code + "," + msg); | |
| 56 | + } | |
| 57 | + | |
| 58 | + @Override | |
| 59 | + public void onBannerClicked() { | |
| 60 | + Log.e(TAG, "onBannerClicked"); | |
| 61 | + } | |
| 62 | + }); | |
| 63 | + | |
| 64 | +// bannerView.setLayoutParams(new RelativeLayout.LayoutParams(300, 300)); | |
| 65 | + bannerContainer.addView(bannerView); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + protected void onPause() { | |
| 70 | + super.onPause(); | |
| 71 | + if (bannerView != null) { | |
| 72 | + bannerView.onPause(); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + protected void onResume() { | |
| 78 | + super.onResume(); | |
| 79 | + if (bannerView != null) { | |
| 80 | + bannerView.onResume(); | |
| 81 | + } | |
| 82 | + } | |
| 83 | + | |
| 84 | + @Override | |
| 85 | + protected void onDestroy() { | |
| 86 | + super.onDestroy(); | |
| 87 | + if (bannerView != null) { | |
| 88 | + bannerView.onDestroy(); | |
| 89 | + } | |
| 90 | + } | |
| 91 | +} | ... | ... |
app/src/main/java/com/vlion/simple/MainActivity.java
| 1 | 1 | package com.vlion.simple; |
| 2 | 2 | |
| 3 | -import android.support.v7.app.AppCompatActivity; | |
| 3 | +import android.content.Intent; | |
| 4 | 4 | import android.os.Bundle; |
| 5 | +import android.support.v7.app.AppCompatActivity; | |
| 6 | +import android.view.View; | |
| 5 | 7 | |
| 6 | 8 | public class MainActivity extends AppCompatActivity { |
| 7 | 9 | |
| 10 | + private static final String TAG = "MainActivity"; | |
| 11 | + | |
| 8 | 12 | @Override |
| 9 | 13 | protected void onCreate(Bundle savedInstanceState) { |
| 10 | 14 | super.onCreate(savedInstanceState); |
| 11 | 15 | 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 | + }); | |
| 12 | 36 | } |
| 13 | 37 | } | ... | ... |
app/src/main/java/com/vlion/simple/NativeActivity.java
0 → 100644
| 1 | +package com.vlion.simple; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.support.annotation.Nullable; | |
| 5 | +import android.support.v7.app.AppCompatActivity; | |
| 6 | +import android.util.Log; | |
| 7 | +import android.view.View; | |
| 8 | + | |
| 9 | +import com.google.gson.Gson; | |
| 10 | +import com.vlion.ad.moudle.natives.NativeListener; | |
| 11 | +import com.vlion.ad.moudle.natives.NativeManager; | |
| 12 | +import com.vlion.ad.moudle.natives.model.NativeAppWallData; | |
| 13 | +import com.vlion.ad.moudle.natives.model.NativeCarouselData; | |
| 14 | +import com.vlion.ad.moudle.natives.model.NativeFeedsData; | |
| 15 | +import com.vlion.ad.moudle.natives.model.NativeNewsData; | |
| 16 | +import com.vlion.ad.moudle.natives.model.NativeWaterfallData; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * Created by xiansong on 2017/10/14. | |
| 20 | + */ | |
| 21 | + | |
| 22 | +public class NativeActivity extends AppCompatActivity { | |
| 23 | + | |
| 24 | + private static final String adId_AppWall = ""; | |
| 25 | + private static final String adId_Carousel = "359"; | |
| 26 | + private static final String adId_Feeds = "357"; | |
| 27 | + private static final String adId_News = ""; | |
| 28 | + private static final String adId_Waterfall = "358"; | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + protected void onCreate(@Nullable Bundle savedInstanceState) { | |
| 32 | + super.onCreate(savedInstanceState); | |
| 33 | + setContentView(R.layout.activity_native); | |
| 34 | + } | |
| 35 | + | |
| 36 | + public void loadAppWall(View view) { | |
| 37 | + NativeManager.getInstance().requestAppWall(this, adId_AppWall, new NativeListener<NativeAppWallData>() { | |
| 38 | + @Override | |
| 39 | + public void onRequestSuccess(NativeAppWallData data) { | |
| 40 | + Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data)); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void onRequestFailed(int code, String message) { | |
| 45 | + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message); | |
| 46 | + } | |
| 47 | + }); | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void loadCarousel(View view) { | |
| 51 | + NativeManager.getInstance().requestCarousel(this, adId_Carousel, new NativeListener<NativeCarouselData>() { | |
| 52 | + @Override | |
| 53 | + public void onRequestSuccess(NativeCarouselData data) { | |
| 54 | + Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data)); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + public void onRequestFailed(int code, String message) { | |
| 59 | + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message); | |
| 60 | + } | |
| 61 | + }); | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void loadFeeds(View view) { | |
| 65 | + NativeManager.getInstance().requestFeeds(this, adId_Feeds, new NativeListener<NativeFeedsData>() { | |
| 66 | + @Override | |
| 67 | + public void onRequestSuccess(NativeFeedsData data) { | |
| 68 | + Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data)); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public void onRequestFailed(int code, String message) { | |
| 73 | + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message); | |
| 74 | + } | |
| 75 | + }); | |
| 76 | + } | |
| 77 | + | |
| 78 | + public void loadNews(View view) { | |
| 79 | + NativeManager.getInstance().requestNews(this, adId_News, new NativeListener<NativeNewsData>() { | |
| 80 | + @Override | |
| 81 | + public void onRequestSuccess(NativeNewsData data) { | |
| 82 | + Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data)); | |
| 83 | + } | |
| 84 | + | |
| 85 | + @Override | |
| 86 | + public void onRequestFailed(int code, String message) { | |
| 87 | + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message); | |
| 88 | + } | |
| 89 | + }); | |
| 90 | + } | |
| 91 | + | |
| 92 | + public void loadWaterfall(View view) { | |
| 93 | + NativeManager.getInstance().requestWaterfall(this, adId_Waterfall, new NativeListener<NativeWaterfallData>() { | |
| 94 | + @Override | |
| 95 | + public void onRequestSuccess(NativeWaterfallData data) { | |
| 96 | + Log.e("DemoView", "数据获取成功 " + new Gson().toJson(data)); | |
| 97 | + } | |
| 98 | + | |
| 99 | + @Override | |
| 100 | + public void onRequestFailed(int code, String message) { | |
| 101 | + Log.e("DemoView", "数据加载失败 : code = " + code + " , message = " + message); | |
| 102 | + } | |
| 103 | + }); | |
| 104 | + } | |
| 105 | +} | ... | ... |
app/src/main/java/com/vlion/simple/SplashActivity.java
0 → 100644
| 1 | +package com.vlion.simple; | |
| 2 | + | |
| 3 | +import android.content.Intent; | |
| 4 | +import android.os.Build; | |
| 5 | +import android.os.Bundle; | |
| 6 | +import android.support.annotation.NonNull; | |
| 7 | +import android.support.v7.app.AppCompatActivity; | |
| 8 | +import android.util.Log; | |
| 9 | +import android.view.View; | |
| 10 | +import android.view.ViewGroup; | |
| 11 | +import android.widget.RelativeLayout; | |
| 12 | + | |
| 13 | +import com.vlion.ad.core.Config; | |
| 14 | +import com.vlion.ad.moudle.splash.SplashManager; | |
| 15 | +import com.vlion.ad.moudle.splash.SplashViewListener; | |
| 16 | +import com.vlion.simple.util.PermissionHelper; | |
| 17 | +import com.vlion.simple.util.ScreenUtil; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * Created by gujun on 2017/10/11. | |
| 21 | + */ | |
| 22 | + | |
| 23 | +public class SplashActivity extends AppCompatActivity { | |
| 24 | + | |
| 25 | + private static final String TAG = "SplashActivity"; | |
| 26 | + | |
| 27 | + private PermissionHelper mPermissionHelper; | |
| 28 | + | |
| 29 | + private View defaultLayout, adLayout; | |
| 30 | + private RelativeLayout splashAdContainer; | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + protected void onCreate(Bundle savedInstanceState) { | |
| 34 | + super.onCreate(savedInstanceState); | |
| 35 | + setContentView(R.layout.activity_splash); | |
| 36 | + defaultLayout = findViewById(R.id.defaultLayout); | |
| 37 | + adLayout = findViewById(R.id.adLayout); | |
| 38 | + splashAdContainer = (RelativeLayout) findViewById(R.id.splashAdContainer); | |
| 39 | + | |
| 40 | + // 当系统为6.0以上时,需要申请权限 | |
| 41 | + mPermissionHelper = new PermissionHelper(this); | |
| 42 | + mPermissionHelper.setOnApplyPermissionListener(new PermissionHelper.OnApplyPermissionListener() { | |
| 43 | + @Override | |
| 44 | + public void onAfterApplyAllPermission() { | |
| 45 | + Log.i(TAG, "All of requested permissions has been granted, so run app logic."); | |
| 46 | + startApp(); | |
| 47 | + } | |
| 48 | + }); | |
| 49 | + | |
| 50 | + if (Build.VERSION.SDK_INT < 23) { | |
| 51 | + // 如果系统版本低于23,直接跑应用的逻辑 | |
| 52 | + Log.d(TAG, "The api level of system is lower than 23, so run app logic directly."); | |
| 53 | + startApp(); | |
| 54 | + } else { | |
| 55 | + // 如果权限全部申请了,那就直接跑应用逻辑 | |
| 56 | + if (mPermissionHelper.isAllRequestedPermissionGranted()) { | |
| 57 | + Log.d(TAG, "All of requested permissions has been granted, so run app logic directly."); | |
| 58 | + startApp(); | |
| 59 | + } else { | |
| 60 | + // 如果还有权限为申请,而且系统版本大于23,执行申请权限逻辑 | |
| 61 | + Log.i(TAG, "Some of requested permissions hasn't been granted, so apply permissions first."); | |
| 62 | + mPermissionHelper.applyPermissions(); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + } | |
| 66 | + | |
| 67 | + private void startApp() { | |
| 68 | + defaultLayout.setVisibility(View.VISIBLE); | |
| 69 | + adLayout.setVisibility(View.GONE); | |
| 70 | + | |
| 71 | + SplashManager.getInstance().setTargetClass(MainActivity.class); | |
| 72 | + SplashManager.getInstance().setAutoJumpToTargetWhenShowFailed(true); | |
| 73 | + SplashManager.getInstance().setSplashViewContainer(splashAdContainer); | |
| 74 | + SplashManager.getInstance().setAdScalingModel(Config.AD_SCALING_MODE_SCALE_TO_FIT); | |
| 75 | + SplashManager.getInstance().showSplash(this, "353", R.mipmap.ic_launcher, new SplashViewListener() { | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public void onRequestSuccess(int viewWidth, int viewHeight) { | |
| 79 | + Log.e(TAG, "onRequestSuccess: " + viewWidth + "," + viewHeight); | |
| 80 | + splashAdContainer.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; | |
| 81 | + splashAdContainer.getLayoutParams().height = ScreenUtil.getScreenWidth(SplashActivity.this) * viewHeight / viewWidth; | |
| 82 | + } | |
| 83 | + | |
| 84 | + @Override | |
| 85 | + public void onRequestFailed(int code, String errorMsg) { | |
| 86 | + Log.e(TAG, "onRequestFailed: " + code + "," + errorMsg); | |
| 87 | + } | |
| 88 | + | |
| 89 | + @Override | |
| 90 | + public void onShowSuccess() { | |
| 91 | + Log.e(TAG, "onShowSuccess: "); | |
| 92 | + defaultLayout.setVisibility(View.GONE); | |
| 93 | + adLayout.setVisibility(View.VISIBLE); | |
| 94 | + } | |
| 95 | + | |
| 96 | + @Override | |
| 97 | + public void onShowFailed(int code, String msg) { | |
| 98 | + Log.e(TAG, "onShowFailed: " + code + "," + msg); | |
| 99 | + } | |
| 100 | + | |
| 101 | + @Override | |
| 102 | + public void onSplashClicked() { | |
| 103 | + Log.e(TAG, "onSplashClicked: "); | |
| 104 | + } | |
| 105 | + | |
| 106 | + @Override | |
| 107 | + public void onSplashClosed() { | |
| 108 | + Log.e(TAG, "onSplashClosed: "); | |
| 109 | + } | |
| 110 | + | |
| 111 | + @Override | |
| 112 | + public void onSwitchSplash() { | |
| 113 | + Log.e(TAG, "onSwitchSplash: "); | |
| 114 | + } | |
| 115 | + }); | |
| 116 | + } | |
| 117 | + | |
| 118 | + @Override | |
| 119 | + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |
| 120 | + super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
| 121 | + mPermissionHelper.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
| 122 | + } | |
| 123 | + | |
| 124 | + @Override | |
| 125 | + protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
| 126 | + super.onActivityResult(requestCode, resultCode, data); | |
| 127 | + mPermissionHelper.onActivityResult(requestCode, resultCode, data); | |
| 128 | + } | |
| 129 | + | |
| 130 | + @Override | |
| 131 | + protected void onResume() { | |
| 132 | + super.onResume(); | |
| 133 | + SplashManager.getInstance().onResume(); | |
| 134 | + } | |
| 135 | + | |
| 136 | + @Override | |
| 137 | + protected void onPause() { | |
| 138 | + super.onPause(); | |
| 139 | + SplashManager.getInstance().onPause(); | |
| 140 | + } | |
| 141 | + | |
| 142 | + @Override | |
| 143 | + protected void onDestroy() { | |
| 144 | + super.onDestroy(); | |
| 145 | + SplashManager.getInstance().onDestroy(); | |
| 146 | + } | |
| 147 | +} | ... | ... |
app/src/main/java/com/vlion/simple/SpotActivity.java
0 → 100644
| 1 | +package com.vlion.simple; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.support.annotation.Nullable; | |
| 5 | +import android.support.v7.app.AppCompatActivity; | |
| 6 | +import android.util.Log; | |
| 7 | +import android.view.View; | |
| 8 | +import android.view.ViewGroup; | |
| 9 | +import android.widget.RelativeLayout; | |
| 10 | + | |
| 11 | +import com.vlion.ad.core.Config; | |
| 12 | +import com.vlion.ad.moudle.spot.SpotManager; | |
| 13 | +import com.vlion.ad.moudle.spot.SpotViewListener; | |
| 14 | +import com.vlion.simple.util.ScreenUtil; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Created by gujun on 2017/10/12. | |
| 18 | + */ | |
| 19 | + | |
| 20 | +public class SpotActivity extends AppCompatActivity { | |
| 21 | + | |
| 22 | + private static final String TAG = "SpotActivity"; | |
| 23 | + private RelativeLayout spotAdContainer; | |
| 24 | + private RelativeLayout adLayout; | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + protected void onCreate(@Nullable Bundle savedInstanceState) { | |
| 28 | + super.onCreate(savedInstanceState); | |
| 29 | + setContentView(R.layout.activity_spot); | |
| 30 | + addSpotAd(); | |
| 31 | + } | |
| 32 | + | |
| 33 | + private void addSpotAd() { | |
| 34 | + spotAdContainer = (RelativeLayout) findViewById(R.id.spotAdContainer); | |
| 35 | + adLayout = (RelativeLayout) findViewById(R.id.adLayout); | |
| 36 | + | |
| 37 | + SpotManager.getInstance().setSpotViewContainer(spotAdContainer); | |
| 38 | +// SpotManager.getInstance().setSplashViewContainerAndLayoutParams(splashContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 600)); | |
| 39 | + SpotManager.getInstance().setAdScalingModel(Config.AD_SCALING_MODE_SCALE_TO_FIT); | |
| 40 | + SpotManager.getInstance().showSpot(this, "355", R.mipmap.ic_launcher, new SpotViewListener() { | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public void onRequestSuccess(int viewWidth, int viewHeight, int closeViewHeight) { | |
| 44 | + Log.e(TAG, "onRequestSuccess: " + viewWidth + "," + viewHeight); | |
| 45 | + spotAdContainer.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; | |
| 46 | + spotAdContainer.getLayoutParams().height = ScreenUtil.getScreenWidth(SpotActivity.this) * viewHeight / viewWidth + closeViewHeight; | |
| 47 | + } | |
| 48 | + | |
| 49 | + @Override | |
| 50 | + public void onRequestFailed(int code, String errorMsg) { | |
| 51 | + Log.e(TAG, "onRequestFailed: " + code + "," + errorMsg); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @Override | |
| 55 | + public void onShowSuccess() { | |
| 56 | + Log.e(TAG, "onShowSuccess: "); | |
| 57 | + adLayout.setVisibility(View.VISIBLE); | |
| 58 | + } | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + public void onShowFailed(int code, String msg) { | |
| 62 | + Log.e(TAG, "onShowFailed: " + code + "," + msg); | |
| 63 | + } | |
| 64 | + | |
| 65 | + @Override | |
| 66 | + public void onSpotClicked() { | |
| 67 | + Log.e(TAG, "onSplashClicked: "); | |
| 68 | + adLayout.setVisibility(View.GONE); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public void onSpotClosed() { | |
| 73 | + Log.e(TAG, "onSplashClosed: "); | |
| 74 | + adLayout.setVisibility(View.GONE); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public void onSwitchSpot() { | |
| 79 | + Log.e(TAG, "onSwitchSpot: "); | |
| 80 | + } | |
| 81 | + }); | |
| 82 | + } | |
| 83 | + | |
| 84 | + @Override | |
| 85 | + protected void onResume() { | |
| 86 | + super.onResume(); | |
| 87 | + SpotManager.getInstance().onResume(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @Override | |
| 91 | + protected void onPause() { | |
| 92 | + super.onPause(); | |
| 93 | + SpotManager.getInstance().onPause(); | |
| 94 | + } | |
| 95 | + | |
| 96 | + @Override | |
| 97 | + protected void onDestroy() { | |
| 98 | + super.onDestroy(); | |
| 99 | + SpotManager.getInstance().onDestroy(); | |
| 100 | + } | |
| 101 | +} | ... | ... |
app/src/main/java/com/vlion/simple/application/VLionApplication.java
0 → 100644
| 1 | +package com.vlion.simple.application; | |
| 2 | + | |
| 3 | +import android.app.Application; | |
| 4 | + | |
| 5 | +import com.vlion.ad.core.ADManager; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Created by xiansong on 2017/9/29. | |
| 9 | + */ | |
| 10 | + | |
| 11 | +public class VLionApplication extends Application { | |
| 12 | + | |
| 13 | + private static final String vlionAppId = "173"; | |
| 14 | + | |
| 15 | + @Override | |
| 16 | + public void onCreate() { | |
| 17 | + super.onCreate(); | |
| 18 | + | |
| 19 | + ADManager.init(this, vlionAppId); | |
| 20 | + } | |
| 21 | +} | ... | ... |
app/src/main/java/com/vlion/simple/util/PermissionHelper.java
0 → 100644
| 1 | +package com.vlion.simple.util; | |
| 2 | + | |
| 3 | +import android.Manifest; | |
| 4 | +import android.app.Activity; | |
| 5 | +import android.app.AlertDialog; | |
| 6 | +import android.content.DialogInterface; | |
| 7 | +import android.content.Intent; | |
| 8 | +import android.content.pm.PackageManager; | |
| 9 | +import android.net.Uri; | |
| 10 | +import android.provider.Settings; | |
| 11 | +import android.support.v4.app.ActivityCompat; | |
| 12 | +import android.support.v4.content.ContextCompat; | |
| 13 | +import android.util.Log; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * Android 6.0 上权限分为<b>正常</b>和<b>危险</b>级别 | |
| 17 | + * <ul> | |
| 18 | + * <li>正常级别权限:开发者仅仅需要在AndroidManifext.xml上声明,那么应用就会被允许拥有该权限,如:android.permission.INTERNET</li> | |
| 19 | + * <li>危险级别权限:开发者需要在AndroidManifext.xml上声明,并且在运行时进行申请,而且用户允许了,应用才会被允许拥有该权限,如:android.permission.WRITE_EXTERNAL_STORAGE</li> | |
| 20 | + * </ul> | |
| 21 | + * 有米的以下权限需要在Android6.0上被允许,有米广告sdk才能正常工作,开发者需要在调用有米的任何代码之前,提前让用户允许权限 | |
| 22 | + * <ul> | |
| 23 | + * <li>必须申请的权限 | |
| 24 | + * <ul> | |
| 25 | + * <li>android.permission.READ_PHONE_STATE</li> | |
| 26 | + * <li>android.permission.WRITE_EXTERNAL_STORAGE</li> | |
| 27 | + * </ul> | |
| 28 | + * </li> | |
| 29 | + * <li>可选申请的权限 | |
| 30 | + * <ul> | |
| 31 | + * <li>android.permission.ACCESS_FINE_LOCATION</li> | |
| 32 | + * </ul> | |
| 33 | + * </li> | |
| 34 | + * </ul> | |
| 35 | + * Android 6.0+ 权限申请助手 | |
| 36 | + * | |
| 37 | + * @since 2016-01-12 | |
| 38 | + */ | |
| 39 | +public class PermissionHelper { | |
| 40 | + | |
| 41 | + private static final String TAG = "PermissionHelper"; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 小tips:这里的int数值不能太大,否则不会弹出请求权限提示,测试的时候,改到1000就不会弹出请求了 | |
| 45 | + */ | |
| 46 | + private final static int READ_PHONE_STATE_CODE = 101; | |
| 47 | + | |
| 48 | + private final static int WRITE_EXTERNAL_STORAGE_CODE = 102; | |
| 49 | + | |
| 50 | + private final static int REQUEST_OPEN_APPLICATION_SETTINGS_CODE = 12345; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 有米 Android SDK 所需要向用户申请的权限列表 | |
| 54 | + */ | |
| 55 | + private PermissionModel[] mPermissionModels = new PermissionModel[] { | |
| 56 | + new PermissionModel("电话", Manifest.permission.READ_PHONE_STATE, "我们需要读取手机信息的权限来标识您的身份", READ_PHONE_STATE_CODE), | |
| 57 | + new PermissionModel( | |
| 58 | + "存储空间", | |
| 59 | + Manifest.permission.WRITE_EXTERNAL_STORAGE, | |
| 60 | + "我们需要您允许我们读写你的存储卡,以方便我们临时保存一些数据", | |
| 61 | + WRITE_EXTERNAL_STORAGE_CODE | |
| 62 | + ) | |
| 63 | + }; | |
| 64 | + | |
| 65 | + private Activity mActivity; | |
| 66 | + | |
| 67 | + private OnApplyPermissionListener mOnApplyPermissionListener; | |
| 68 | + | |
| 69 | + public PermissionHelper(Activity activity) { | |
| 70 | + mActivity = activity; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setOnApplyPermissionListener(OnApplyPermissionListener onApplyPermissionListener) { | |
| 74 | + mOnApplyPermissionListener = onApplyPermissionListener; | |
| 75 | + } | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * 这里我们演示如何在Android 6.0+上运行时申请权限 | |
| 79 | + */ | |
| 80 | + public void applyPermissions() { | |
| 81 | + try { | |
| 82 | + for (final PermissionModel model : mPermissionModels) { | |
| 83 | + if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(mActivity, model.permission)) { | |
| 84 | + ActivityCompat.requestPermissions(mActivity, new String[] { model.permission }, model.requestCode); | |
| 85 | + return; | |
| 86 | + } | |
| 87 | + } | |
| 88 | + if (mOnApplyPermissionListener != null) { | |
| 89 | + mOnApplyPermissionListener.onAfterApplyAllPermission(); | |
| 90 | + } | |
| 91 | + } catch (Throwable e) { | |
| 92 | + Log.e(TAG, "", e); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * 对应Activity的 {@code onRequestPermissionsResult(...)} 方法 | |
| 98 | + * | |
| 99 | + * @param requestCode | |
| 100 | + * @param permissions | |
| 101 | + * @param grantResults | |
| 102 | + */ | |
| 103 | + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | |
| 104 | + switch (requestCode) { | |
| 105 | + case READ_PHONE_STATE_CODE: | |
| 106 | + case WRITE_EXTERNAL_STORAGE_CODE: | |
| 107 | + // 如果用户不允许,我们视情况发起二次请求或者引导用户到应用页面手动打开 | |
| 108 | + if (PackageManager.PERMISSION_GRANTED != grantResults[0]) { | |
| 109 | + | |
| 110 | + // 二次请求,表现为:以前请求过这个权限,但是用户拒接了 | |
| 111 | + // 在二次请求的时候,会有一个“不再提示的”checkbox | |
| 112 | + // 因此这里需要给用户解释一下我们为什么需要这个权限,否则用户可能会永久不在激活这个申请 | |
| 113 | + // 方便用户理解我们为什么需要这个权限 | |
| 114 | + if (ActivityCompat.shouldShowRequestPermissionRationale(mActivity, permissions[0])) { | |
| 115 | + AlertDialog.Builder builder = new AlertDialog.Builder(mActivity).setTitle("权限申请") | |
| 116 | + .setMessage(findPermissionExplain | |
| 117 | + (permissions[0])).setPositiveButton( | |
| 118 | + "确定", | |
| 119 | + new DialogInterface.OnClickListener | |
| 120 | + () { | |
| 121 | + | |
| 122 | + @Override | |
| 123 | + public void onClick( | |
| 124 | + DialogInterface dialog, | |
| 125 | + int which) { | |
| 126 | + applyPermissions(); | |
| 127 | + } | |
| 128 | + } | |
| 129 | + ); | |
| 130 | + builder.setCancelable(false); | |
| 131 | + builder.show(); | |
| 132 | + } | |
| 133 | + // 到这里就表示已经是第3+次请求,而且此时用户已经永久拒绝了,这个时候,我们引导用户到应用权限页面,让用户自己手动打开 | |
| 134 | + else { | |
| 135 | + AlertDialog.Builder builder = new AlertDialog.Builder(mActivity).setTitle("权限申请") | |
| 136 | + .setMessage("请在打开的窗口的权限中开启" + | |
| 137 | + findPermissionName | |
| 138 | + (permissions[0]) + | |
| 139 | + "权限,以正常使用本应用") | |
| 140 | + .setPositiveButton( | |
| 141 | + "去设置", | |
| 142 | + new DialogInterface.OnClickListener | |
| 143 | + () { | |
| 144 | + | |
| 145 | + @Override | |
| 146 | + public void onClick( | |
| 147 | + DialogInterface dialog, | |
| 148 | + int which) { | |
| 149 | + openApplicationSettings( | |
| 150 | + REQUEST_OPEN_APPLICATION_SETTINGS_CODE); | |
| 151 | + } | |
| 152 | + } | |
| 153 | + ) | |
| 154 | + .setNegativeButton( | |
| 155 | + "取消", | |
| 156 | + new DialogInterface.OnClickListener | |
| 157 | + () { | |
| 158 | + @Override | |
| 159 | + public void onClick( | |
| 160 | + DialogInterface dialog, | |
| 161 | + int which) { | |
| 162 | + mActivity.finish(); | |
| 163 | + } | |
| 164 | + } | |
| 165 | + ); | |
| 166 | + builder.setCancelable(false); | |
| 167 | + builder.show(); | |
| 168 | + } | |
| 169 | + return; | |
| 170 | + } | |
| 171 | + | |
| 172 | + // 到这里就表示用户允许了本次请求,我们继续检查是否还有待申请的权限没有申请 | |
| 173 | + if (isAllRequestedPermissionGranted()) { | |
| 174 | + if (mOnApplyPermissionListener != null) { | |
| 175 | + mOnApplyPermissionListener.onAfterApplyAllPermission(); | |
| 176 | + } | |
| 177 | + } else { | |
| 178 | + applyPermissions(); | |
| 179 | + } | |
| 180 | + break; | |
| 181 | + } | |
| 182 | + } | |
| 183 | + | |
| 184 | + /** | |
| 185 | + * 对应Activity的 {@code onActivityResult(...)} 方法 | |
| 186 | + * | |
| 187 | + * @param requestCode | |
| 188 | + * @param resultCode | |
| 189 | + * @param data | |
| 190 | + */ | |
| 191 | + public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
| 192 | + switch (requestCode) { | |
| 193 | + case REQUEST_OPEN_APPLICATION_SETTINGS_CODE: | |
| 194 | + if (isAllRequestedPermissionGranted()) { | |
| 195 | + if (mOnApplyPermissionListener != null) { | |
| 196 | + mOnApplyPermissionListener.onAfterApplyAllPermission(); | |
| 197 | + } | |
| 198 | + } else { | |
| 199 | + mActivity.finish(); | |
| 200 | + } | |
| 201 | + break; | |
| 202 | + } | |
| 203 | + } | |
| 204 | + | |
| 205 | + /** | |
| 206 | + * 判断是否所有的权限都被授权了 | |
| 207 | + * | |
| 208 | + * @return | |
| 209 | + */ | |
| 210 | + public boolean isAllRequestedPermissionGranted() { | |
| 211 | + for (PermissionModel model : mPermissionModels) { | |
| 212 | + if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(mActivity, model.permission)) { | |
| 213 | + return false; | |
| 214 | + } | |
| 215 | + } | |
| 216 | + return true; | |
| 217 | + } | |
| 218 | + | |
| 219 | + /** | |
| 220 | + * 打开应用设置界面 | |
| 221 | + * | |
| 222 | + * @param requestCode 请求码 | |
| 223 | + * | |
| 224 | + * @return | |
| 225 | + */ | |
| 226 | + private boolean openApplicationSettings(int requestCode) { | |
| 227 | + try { | |
| 228 | + Intent intent = | |
| 229 | + new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + mActivity.getPackageName())); | |
| 230 | + intent.addCategory(Intent.CATEGORY_DEFAULT); | |
| 231 | + | |
| 232 | + // Android L 之后Activity的启动模式发生了一些变化 | |
| 233 | + // 如果用了下面的 Intent.FLAG_ACTIVITY_NEW_TASK ,并且是 startActivityForResult | |
| 234 | + // 那么会在打开新的activity的时候就会立即回调 onActivityResult | |
| 235 | + // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
| 236 | + mActivity.startActivityForResult(intent, requestCode); | |
| 237 | + return true; | |
| 238 | + } catch (Throwable e) { | |
| 239 | + Log.e(TAG, "", e); | |
| 240 | + } | |
| 241 | + return false; | |
| 242 | + } | |
| 243 | + | |
| 244 | + /** | |
| 245 | + * 查找申请权限的解释短语 | |
| 246 | + * | |
| 247 | + * @param permission 权限 | |
| 248 | + * | |
| 249 | + * @return | |
| 250 | + */ | |
| 251 | + private String findPermissionExplain(String permission) { | |
| 252 | + if (mPermissionModels != null) { | |
| 253 | + for (PermissionModel model : mPermissionModels) { | |
| 254 | + if (model != null && model.permission != null && model.permission.equals(permission)) { | |
| 255 | + return model.explain; | |
| 256 | + } | |
| 257 | + } | |
| 258 | + } | |
| 259 | + return null; | |
| 260 | + } | |
| 261 | + | |
| 262 | + /** | |
| 263 | + * 查找申请权限的名称 | |
| 264 | + * | |
| 265 | + * @param permission 权限 | |
| 266 | + * | |
| 267 | + * @return | |
| 268 | + */ | |
| 269 | + private String findPermissionName(String permission) { | |
| 270 | + if (mPermissionModels != null) { | |
| 271 | + for (PermissionModel model : mPermissionModels) { | |
| 272 | + if (model != null && model.permission != null && model.permission.equals(permission)) { | |
| 273 | + return model.name; | |
| 274 | + } | |
| 275 | + } | |
| 276 | + } | |
| 277 | + return null; | |
| 278 | + } | |
| 279 | + | |
| 280 | + private static class PermissionModel { | |
| 281 | + | |
| 282 | + /** | |
| 283 | + * 权限名称 | |
| 284 | + */ | |
| 285 | + public String name; | |
| 286 | + | |
| 287 | + /** | |
| 288 | + * 请求的权限 | |
| 289 | + */ | |
| 290 | + public String permission; | |
| 291 | + | |
| 292 | + /** | |
| 293 | + * 解析为什么请求这个权限 | |
| 294 | + */ | |
| 295 | + public String explain; | |
| 296 | + | |
| 297 | + /** | |
| 298 | + * 请求代码 | |
| 299 | + */ | |
| 300 | + public int requestCode; | |
| 301 | + | |
| 302 | + public PermissionModel(String name, String permission, String explain, int requestCode) { | |
| 303 | + this.name = name; | |
| 304 | + this.permission = permission; | |
| 305 | + this.explain = explain; | |
| 306 | + this.requestCode = requestCode; | |
| 307 | + } | |
| 308 | + } | |
| 309 | + | |
| 310 | + /** | |
| 311 | + * 权限申请事件监听 | |
| 312 | + */ | |
| 313 | + public interface OnApplyPermissionListener { | |
| 314 | + | |
| 315 | + /** | |
| 316 | + * 申请所有权限之后的逻辑 | |
| 317 | + */ | |
| 318 | + void onAfterApplyAllPermission(); | |
| 319 | + } | |
| 320 | + | |
| 321 | +} | ... | ... |
app/src/main/java/com/vlion/simple/util/ScreenUtil.java
0 → 100644
| 1 | +package com.vlion.simple.util; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.view.WindowManager; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * Created by gujun on 2017/10/14. | |
| 8 | + */ | |
| 9 | + | |
| 10 | +public class ScreenUtil { | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * 获取手机宽度的分辨率 | |
| 14 | + * @param context | |
| 15 | + * @return | |
| 16 | + */ | |
| 17 | + public static int getScreenWidth(Context context) { | |
| 18 | + WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | |
| 19 | + int screenWidth = wm.getDefaultDisplay().getWidth(); | |
| 20 | + return screenWidth; | |
| 21 | + } | |
| 22 | +} | ... | ... |
app/src/main/res/drawable/back.png
0 → 100644
700 Bytes
app/src/main/res/drawable/load_error.png
0 → 100644
1.34 KB
app/src/main/res/drawable/vlion_ad_close.xml
0 → 100644
| 1 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | + android:width="24dp" | |
| 3 | + android:height="24dp" | |
| 4 | + android:viewportWidth="24.0" | |
| 5 | + android:viewportHeight="24.0"> | |
| 6 | + <path | |
| 7 | + android:fillColor="#FFffffff" | |
| 8 | + android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> | |
| 9 | +</vector> | ... | ... |
app/src/main/res/drawable/vlion_ad_close_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="oval" | |
| 4 | + android:useLevel="false"> | |
| 5 | + <solid android:color="#2F000000" /> | |
| 6 | + <stroke | |
| 7 | + android:width="1dp" | |
| 8 | + android:color="@android:color/white" /> | |
| 9 | + <corners android:radius="20dp" /> | |
| 10 | + <padding | |
| 11 | + android:bottom="4dp" | |
| 12 | + android:left="4dp" | |
| 13 | + android:right="4dp" | |
| 14 | + android:top="4dp" /> | |
| 15 | +</shape> | |
| 0 | 16 | \ No newline at end of file | ... | ... |
app/src/main/res/drawable/vlion_bg_jump.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 | + <solid android:color="#66000000" /> | |
| 6 | + <corners | |
| 7 | + android:bottomLeftRadius="10dp" | |
| 8 | + android:bottomRightRadius="10dp" | |
| 9 | + android:topLeftRadius="10dp" | |
| 10 | + android:topRightRadius="10dp" /> <!-- 设置四个角的半径 --> | |
| 11 | + | |
| 12 | +</shape> | |
| 0 | 13 | \ No newline at end of file | ... | ... |
app/src/main/res/drawable/vlion_bg_video_volume.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + <item android:drawable="@drawable/vlion_volume_open" android:state_checked="true" /> | |
| 4 | + <item android:drawable="@drawable/vlion_volume_close" android:state_checked="false" /> | |
| 5 | +</selector> | ... | ... |
app/src/main/res/drawable/vlion_volume_close.xml
0 → 100644
| 1 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | + android:width="24dp" | |
| 3 | + android:height="24dp" | |
| 4 | + android:viewportWidth="24.0" | |
| 5 | + android:viewportHeight="24.0"> | |
| 6 | + <path | |
| 7 | + android:fillColor="#FFffffff" | |
| 8 | + android:pathData="M16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v2.21l2.45,2.45c0.03,-0.2 0.05,-0.41 0.05,-0.63zM19,12c0,0.94 -0.2,1.82 -0.54,2.64l1.51,1.51C20.63,14.91 21,13.5 21,12c0,-4.28 -2.99,-7.86 -7,-8.77v2.06c2.89,0.86 5,3.54 5,6.71zM4.27,3L3,4.27 7.73,9L3,9v6h4l5,5v-6.73l4.25,4.25c-0.67,0.52 -1.42,0.93 -2.25,1.18v2.06c1.38,-0.31 2.63,-0.95 3.69,-1.81L19.73,21 21,19.73l-9,-9L4.27,3zM12,4L9.91,6.09 12,8.18L12,4z"/> | |
| 9 | +</vector> | ... | ... |
app/src/main/res/drawable/vlion_volume_open.xml
0 → 100644
| 1 | +<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | + android:width="24dp" | |
| 3 | + android:height="24dp" | |
| 4 | + android:viewportWidth="24.0" | |
| 5 | + android:viewportHeight="24.0"> | |
| 6 | + <path | |
| 7 | + android:fillColor="#FFffffff" | |
| 8 | + android:pathData="M3,9v6h4l5,5L12,4L7,9L3,9zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z"/> | |
| 9 | +</vector> | ... | ... |
app/src/main/res/layout/activity_banner.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:tools="http://schemas.android.com/tools" | |
| 4 | + android:layout_width="match_parent" | |
| 5 | + android:layout_height="match_parent" | |
| 6 | + tools:context="com.vlion.simple.BannerActivity"> | |
| 7 | + | |
| 8 | + <RelativeLayout | |
| 9 | + android:id="@+id/bannerContainer" | |
| 10 | + android:layout_width="wrap_content" | |
| 11 | + android:layout_height="wrap_content"/> | |
| 12 | + | |
| 13 | +</RelativeLayout> | ... | ... |
app/src/main/res/layout/activity_main.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | -<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | - xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | 3 | xmlns:tools="http://schemas.android.com/tools" |
| 5 | 4 | android:layout_width="match_parent" |
| 6 | 5 | android:layout_height="match_parent" |
| 6 | + android:orientation="vertical" | |
| 7 | 7 | tools:context="com.vlion.simple.MainActivity"> |
| 8 | 8 | |
| 9 | - <TextView | |
| 10 | - android:layout_width="wrap_content" | |
| 9 | + <Button | |
| 10 | + android:id="@+id/bannerBtn" | |
| 11 | + android:layout_width="200dp" | |
| 11 | 12 | android:layout_height="wrap_content" |
| 12 | - android:text="Hello World!" | |
| 13 | - app:layout_constraintBottom_toBottomOf="parent" | |
| 14 | - app:layout_constraintLeft_toLeftOf="parent" | |
| 15 | - app:layout_constraintRight_toRightOf="parent" | |
| 16 | - app:layout_constraintTop_toTopOf="parent" /> | |
| 13 | + android:layout_alignParentBottom="true" | |
| 14 | + android:layout_centerHorizontal="true" | |
| 15 | + android:text="横幅广告" /> | |
| 17 | 16 | |
| 18 | -</android.support.constraint.ConstraintLayout> | |
| 17 | + <Button | |
| 18 | + android:id="@+id/spotBtn" | |
| 19 | + android:layout_width="200dp" | |
| 20 | + android:layout_height="wrap_content" | |
| 21 | + android:layout_alignParentBottom="true" | |
| 22 | + android:layout_centerHorizontal="true" | |
| 23 | + android:text="插屏广告广告" /> | |
| 24 | + | |
| 25 | + <Button | |
| 26 | + android:id="@+id/nativeBtn" | |
| 27 | + android:layout_width="200dp" | |
| 28 | + android:layout_height="wrap_content" | |
| 29 | + android:layout_alignParentBottom="true" | |
| 30 | + android:layout_centerHorizontal="true" | |
| 31 | + android:text="原生广告" /> | |
| 32 | +</LinearLayout> | ... | ... |
app/src/main/res/layout/activity_native.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + xmlns:tools="http://schemas.android.com/tools" | |
| 4 | + android:layout_width="match_parent" | |
| 5 | + android:layout_height="match_parent" | |
| 6 | + android:orientation="vertical" | |
| 7 | + tools:context="com.vlion.simple.NativeActivity" | |
| 8 | + android:gravity="center"> | |
| 9 | + | |
| 10 | + <Button | |
| 11 | + android:id="@+id/loadAppWall" | |
| 12 | + android:layout_width="200dp" | |
| 13 | + android:layout_height="wrap_content" | |
| 14 | + android:text="@string/loadAppWall" | |
| 15 | + android:onClick="loadAppWall"/> | |
| 16 | + | |
| 17 | + <Button | |
| 18 | + android:id="@+id/loadCarousel" | |
| 19 | + android:layout_width="200dp" | |
| 20 | + android:layout_height="wrap_content" | |
| 21 | + android:text="@string/loadCarousel" | |
| 22 | + android:layout_marginTop="16dp" | |
| 23 | + android:onClick="loadCarousel"/> | |
| 24 | + | |
| 25 | + <Button | |
| 26 | + android:id="@+id/loadFeeds" | |
| 27 | + android:layout_width="200dp" | |
| 28 | + android:layout_height="wrap_content" | |
| 29 | + android:text="@string/loadFeeds" | |
| 30 | + android:layout_marginTop="16dp" | |
| 31 | + android:onClick="loadFeeds"/> | |
| 32 | + | |
| 33 | + <Button | |
| 34 | + android:id="@+id/loadNews" | |
| 35 | + android:layout_width="200dp" | |
| 36 | + android:layout_height="wrap_content" | |
| 37 | + android:text="@string/loadNews" | |
| 38 | + android:layout_marginTop="16dp" | |
| 39 | + android:onClick="loadNews"/> | |
| 40 | + | |
| 41 | + <Button | |
| 42 | + android:id="@+id/loadWaterfall" | |
| 43 | + android:layout_width="200dp" | |
| 44 | + android:layout_height="wrap_content" | |
| 45 | + android:text="@string/loadWaterfall" | |
| 46 | + android:layout_marginTop="16dp" | |
| 47 | + android:onClick="loadWaterfall"/> | |
| 48 | +</LinearLayout> | |
| 0 | 49 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/activity_splash.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="match_parent"> | |
| 5 | + | |
| 6 | + <RelativeLayout | |
| 7 | + android:id="@+id/defaultLayout" | |
| 8 | + android:layout_width="match_parent" | |
| 9 | + android:layout_height="match_parent" | |
| 10 | + android:background="@mipmap/ic_launcher"/> | |
| 11 | + | |
| 12 | + <RelativeLayout | |
| 13 | + android:id="@+id/adLayout" | |
| 14 | + android:layout_width="match_parent" | |
| 15 | + android:layout_height="match_parent" | |
| 16 | + android:visibility="gone"> | |
| 17 | + | |
| 18 | + <RelativeLayout | |
| 19 | + android:id="@+id/splashAdContainer" | |
| 20 | + android:layout_width="match_parent" | |
| 21 | + android:layout_height="match_parent"/> | |
| 22 | + | |
| 23 | + <ImageView | |
| 24 | + android:id="@+id/logo" | |
| 25 | + android:layout_width="100dp" | |
| 26 | + android:layout_height="100dp" | |
| 27 | + android:src="@mipmap/ic_launcher" | |
| 28 | + android:layout_alignParentBottom="true"/> | |
| 29 | + | |
| 30 | + </RelativeLayout> | |
| 31 | + | |
| 32 | +</RelativeLayout> | |
| 0 | 33 | \ No newline at end of file | ... | ... |
app/src/main/res/layout/activity_spot.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="match_parent"> | |
| 5 | + | |
| 6 | + <TextView | |
| 7 | + android:layout_width="match_parent" | |
| 8 | + android:layout_height="match_parent" | |
| 9 | + android:gravity="center" | |
| 10 | + android:text="page content" | |
| 11 | + android:textColor="@android:color/black" | |
| 12 | + android:textSize="18sp" /> | |
| 13 | + | |
| 14 | + <RelativeLayout | |
| 15 | + android:id="@+id/adLayout" | |
| 16 | + android:layout_width="match_parent" | |
| 17 | + android:layout_height="match_parent" | |
| 18 | + android:background="#66000000" | |
| 19 | + android:visibility="gone"> | |
| 20 | + | |
| 21 | + <RelativeLayout | |
| 22 | + android:id="@+id/spotAdContainer" | |
| 23 | + android:layout_width="match_parent" | |
| 24 | + android:layout_height="match_parent" | |
| 25 | + android:layout_centerInParent="true"/> | |
| 26 | + | |
| 27 | + </RelativeLayout> | |
| 28 | + | |
| 29 | + | |
| 30 | +</RelativeLayout> | |
| 0 | 31 | \ No newline at end of file | ... | ... |
app/src/main/res/values/strings.xml
| 1 | 1 | <resources> |
| 2 | - <string name="app_name">VLionSimple</string> | |
| 2 | + <string name="app_name">VLionSDK</string> | |
| 3 | + <string name="loadAppWall">应用墙数据</string> | |
| 4 | + <string name="loadCarousel">轮播图数据</string> | |
| 5 | + <string name="loadFeeds">信息流数据</string> | |
| 6 | + <string name="loadNews">新闻放送数据</string> | |
| 7 | + <string name="loadWaterfall">瀑布流数据</string> | |
| 3 | 8 | </resources> | ... | ... |