├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── AdsView
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── xwj
│ │ └── adsview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── xwj
│ │ │ └── adsview
│ │ │ ├── bean
│ │ │ ├── AdsInfo.java
│ │ │ ├── Constant.java
│ │ │ └── ResponseData.java
│ │ │ ├── exception
│ │ │ └── ParseResponseException.java
│ │ │ ├── fragment
│ │ │ ├── AdsFragment.java
│ │ │ ├── BannerFragment.java
│ │ │ └── VideoFragment.java
│ │ │ ├── utils
│ │ │ └── HttpUtils.java
│ │ │ └── view
│ │ │ └── AdsView.java
│ └── res
│ │ ├── layout
│ │ ├── error.xml
│ │ ├── fragment_banner.xml
│ │ ├── progress_bar.xml
│ │ ├── video.xml
│ │ └── welcome_progress_bar.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── xwj
│ └── adsview
│ └── ExampleUnitTest.java
├── README.md
├── aikangti2.jks
├── app
├── .gitignore
├── app-release.apk
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── xwj
│ │ └── adsplayer
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── xwj
│ │ │ └── adsplayer
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── xwj
│ └── adsplayer
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── screenshots
├── 1.png
└── 2.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AdsView/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/AdsView/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'me.tatarka.retrolambda'
3 |
4 | android {
5 | compileSdkVersion 23
6 | buildToolsVersion "23.0.3"
7 |
8 | defaultConfig {
9 | minSdkVersion 16
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | compileOptions {
24 | targetCompatibility 1.8
25 | sourceCompatibility 1.8
26 | }
27 | }
28 |
29 | dependencies {
30 | compile fileTree(dir: 'libs', include: ['*.jar'])
31 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
32 | exclude group: 'com.android.support', module: 'support-annotations'
33 | })
34 | compile 'com.android.support:appcompat-v7:23.4.0'
35 | testCompile 'junit:junit:4.12'
36 |
37 | //fastjson
38 | compile 'com.alibaba:fastjson:1.2.9'
39 |
40 | //图片加载
41 | compile 'com.github.bumptech.glide:glide:3.7.0'
42 |
43 | //网络请求
44 | compile 'com.loopj.android:android-async-http:1.4.9'
45 |
46 | //图片banner
47 | compile 'com.youth.banner:banner:1.4.6'
48 |
49 | //进度条
50 | compile 'com.daimajia.numberprogressbar:library:1.4@aar'
51 | }
52 |
--------------------------------------------------------------------------------
/AdsView/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/AdsView/src/androidTest/java/com/xwj/adsview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.xwj.adsplayer.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/AdsView/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/bean/AdsInfo.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.bean;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by Xu Wenjian on 2017/5/8.
7 | */
8 |
9 | public class AdsInfo {
10 |
11 | private static AdsInfo adsInfo;
12 |
13 | public AdsInfo() {}
14 |
15 | /**
16 | * 获取当前广告信息的实例
17 | * @return
18 | */
19 | public static AdsInfo getAdsInfo() {
20 | return adsInfo;
21 | }
22 |
23 | /**
24 | * 将当前的adsInfo与传入的参数进行比较,若内容相同,则返回true,否则返回false,并将传入的参数变成当前的adsInfo
25 | * @param adsInfo
26 | * @return
27 | */
28 | public static boolean compareAndSet(AdsInfo adsInfo) {
29 | if (AdsInfo.adsInfo == null) {
30 | AdsInfo.adsInfo = adsInfo;
31 | return false;
32 | }
33 | if (AdsInfo.adsInfo.equals(adsInfo)) return true;
34 | AdsInfo.adsInfo = adsInfo;
35 | return false;
36 | }
37 |
38 | @Override
39 | public boolean equals(Object o) {
40 | if (this == o) return true;
41 | if (o == null || getClass() != o.getClass()) return false;
42 |
43 | AdsInfo adsInfo = (AdsInfo) o;
44 |
45 |
46 | if (partNum != adsInfo.partNum) return false;
47 | return content != null ? content.equals(adsInfo.content) : adsInfo.content == null;
48 |
49 | }
50 |
51 | private int partNum;
52 | public class Content {
53 | private int partIndex;
54 | private List videoUrls;
55 | private List picUrls;
56 |
57 | public int getPartIndex() {
58 | return partIndex;
59 | }
60 |
61 | public void setPartIndex(int partIndex) {
62 | this.partIndex = partIndex;
63 | }
64 |
65 | public List getPicUrls() {
66 | return picUrls;
67 | }
68 |
69 | public void setPicUrls(List picUrls) {
70 | this.picUrls = picUrls;
71 | }
72 |
73 | public List getVideoUrls() {
74 | return videoUrls;
75 | }
76 |
77 | public void setVideoUrls(List videoUrls) {
78 | this.videoUrls = videoUrls;
79 | }
80 |
81 | @Override
82 | public boolean equals(Object o) {
83 | if (this == o) return true;
84 | if (o == null || getClass() != o.getClass()) return false;
85 |
86 | Content content = (Content) o;
87 |
88 | if (partIndex != content.partIndex) return false;
89 | if (videoUrls != null ? !videoUrls.equals(content.videoUrls) : content.videoUrls != null)
90 | return false;
91 | return picUrls != null ? picUrls.equals(content.picUrls) : content.picUrls == null;
92 |
93 | }
94 |
95 | @Override
96 | public int hashCode() {
97 | int result = partIndex;
98 | result = 31 * result + (videoUrls != null ? videoUrls.hashCode() : 0);
99 | result = 31 * result + (picUrls != null ? picUrls.hashCode() : 0);
100 | return result;
101 | }
102 | }
103 | private List content;
104 |
105 | public List getContent() {
106 | return content;
107 | }
108 |
109 | public void setContent(List content) {
110 | this.content = content;
111 | }
112 |
113 |
114 | public int getPartNum() {
115 | return partNum;
116 | }
117 |
118 | public void setPartNum(int partNum) {
119 | this.partNum = partNum;
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/bean/Constant.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.bean;
2 |
3 | import android.os.Environment;
4 |
5 | /**
6 | * Created by Xu Wenjian on 2017/5/10.
7 | */
8 |
9 | public interface Constant {
10 | String BASE_URL = "https://icontinua.com";
11 |
12 | /** sd卡存储路径 */
13 | String DATA_PATH = Environment.getExternalStorageDirectory() + "/adsplayer/";
14 |
15 | /**
16 | * 刷新数据的时间间隔
17 | * 毫秒
18 | */
19 | long interval = 60 * 5 * 1000;
20 | }
21 |
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/bean/ResponseData.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.bean;
2 |
3 | import com.alibaba.fastjson.JSONObject;
4 | import com.xwj.adsview.exception.ParseResponseException;
5 |
6 | /**
7 | * Created by Xu Wenjian on 2017/5/8.
8 | */
9 |
10 | public class ResponseData {
11 | private int status;
12 | private long timestamp;
13 | private Object data;
14 | private int errno;
15 |
16 | public int getStatus() {
17 | return status;
18 | }
19 |
20 | public void setStatus(int status) {
21 | this.status = status;
22 | }
23 |
24 | public long getTimestamp() {
25 | return timestamp;
26 | }
27 |
28 | public void setTimestamp(long timestamp) {
29 | this.timestamp = timestamp;
30 | }
31 |
32 | public Object getData() {
33 | return data;
34 | }
35 |
36 | public void setData(Object data) {
37 | this.data = data;
38 | }
39 |
40 | public int getErrno() {
41 | return errno;
42 | }
43 |
44 | public void setErrno(int errno) {
45 | this.errno = errno;
46 | }
47 |
48 | public static ResponseData parse(String text) throws ParseResponseException {
49 | try {
50 | return JSONObject.parseObject(text, ResponseData.class);
51 | } catch (Exception e) {
52 | throw new ParseResponseException("数据格式错误", e);
53 | }
54 | }
55 |
56 | public static ResponseData parse(byte[] byteArray) throws ParseResponseException {
57 | try {
58 | return parse(new String(byteArray));
59 | } catch (NullPointerException e) {
60 | throw new ParseResponseException("数据为空", e);
61 | }
62 | }
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/exception/ParseResponseException.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.exception;
2 |
3 | /**
4 | * Created by Xu Wenjian on 2017/5/8.
5 | */
6 |
7 | public class ParseResponseException extends Exception {
8 | private String errorMessage;
9 |
10 | public ParseResponseException() {
11 | super();
12 | }
13 |
14 | public ParseResponseException(String detailMessage) {
15 | super(detailMessage);
16 | this.errorMessage = detailMessage;
17 | }
18 |
19 | public ParseResponseException(String detailMessage, Throwable throwable) {
20 | super(detailMessage, throwable);
21 | this.errorMessage = detailMessage;
22 | }
23 |
24 | public ParseResponseException(Throwable throwable) {
25 | super(throwable);
26 | }
27 |
28 | public String getErrorMessage() {
29 | return errorMessage;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/fragment/AdsFragment.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.fragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | /**
12 | * Created by Xu Wenjian on 2017/5/8.
13 | */
14 |
15 | public abstract class AdsFragment extends Fragment {
16 |
17 | private View mView;
18 | private int layoutId;
19 |
20 | public AdsFragment(int layoutId) {
21 | // Required empty public constructor
22 | this.layoutId = layoutId;
23 | }
24 |
25 | protected abstract View onCreate(View view);
26 |
27 | @Nullable
28 | @Override
29 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
30 | if(mView == null) {
31 | mView = inflater.inflate(layoutId, container, false);
32 | mView = onCreate(mView);
33 | }
34 |
35 | ViewGroup parent = (ViewGroup) mView.getParent();
36 | if (parent != null) {
37 | parent.removeView(mView);
38 | }
39 |
40 | return mView;
41 | }
42 | protected View findViewById(int id) {
43 | return mView.findViewById(id);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/fragment/BannerFragment.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.fragment;
2 |
3 | import android.content.Context;
4 | import android.view.Gravity;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.FrameLayout;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.bumptech.glide.Glide;
12 | import com.xwj.adsview.R;
13 | import com.xwj.adsview.view.AdsView;
14 | import com.youth.banner.Banner;
15 | import com.youth.banner.loader.ImageLoader;
16 |
17 | import java.util.List;
18 |
19 | /**
20 | * Created by Xu Wenjian on 2017/5/8.
21 | */
22 |
23 | public class BannerFragment extends AdsFragment {
24 |
25 | public static final String KEY_IMAGE_URLS = "KEY_IMAGE_URLS";
26 | public static final String KEY_HEIGHT = "KEY_HEIGHT";
27 |
28 | private FrameLayout frameLayout;
29 | private Banner banner;
30 | private List bannerImageUrls;
31 | private int height;
32 |
33 | public BannerFragment() {
34 | super(R.layout.fragment_banner);
35 | }
36 |
37 | @Override
38 | protected View onCreate(View view) {
39 | frameLayout = (FrameLayout) view;
40 | banner = (Banner) findViewById(R.id.banner);
41 | height = getArguments().getInt(KEY_HEIGHT);
42 | frameLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height));
43 | //banner.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height));
44 | banner.setImageLoader(new ImageLoader() {
45 | @Override
46 | public void displayImage(Context context, Object path, ImageView imageView) {
47 | imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
48 | Glide.with(getContext()).load((String) path).into(imageView);
49 | }
50 | });
51 | bannerImageUrls = getArguments().getStringArrayList(KEY_IMAGE_URLS);
52 |
53 | AdsView.countDownLatch.countDown();
54 |
55 | if (bannerImageUrls != null && !bannerImageUrls.isEmpty()) {
56 | banner.setImages(bannerImageUrls);
57 | banner.start();
58 | return view;
59 | }
60 | else {
61 | TextView emptyView = new TextView(getActivity());
62 | emptyView.setLayoutParams(new ViewGroup.LayoutParams(height, ViewGroup.LayoutParams.MATCH_PARENT));
63 | emptyView.setGravity(Gravity.CENTER);
64 | emptyView.setText("资源为空!");
65 | return emptyView;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/fragment/VideoFragment.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.fragment;
2 |
3 | import android.media.MediaPlayer;
4 | import android.util.Log;
5 | import android.view.Gravity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.FrameLayout;
10 | import android.widget.TextView;
11 | import android.widget.VideoView;
12 |
13 | import com.daimajia.numberprogressbar.NumberProgressBar;
14 | import com.loopj.android.http.FileAsyncHttpResponseHandler;
15 | import com.xwj.adsview.R;
16 | import com.xwj.adsview.bean.Constant;
17 | import com.xwj.adsview.utils.HttpUtils;
18 | import com.xwj.adsview.view.AdsView;
19 |
20 | import java.io.File;
21 | import java.util.ArrayList;
22 | import java.util.Arrays;
23 | import java.util.HashSet;
24 | import java.util.List;
25 | import java.util.Set;
26 |
27 | import cz.msebera.android.httpclient.Header;
28 | import cz.msebera.android.httpclient.io.SessionOutputBuffer;
29 |
30 | /**
31 | * Created by Xu Wenjian on 2017/5/8.
32 | */
33 |
34 | public class VideoFragment extends AdsFragment {
35 |
36 | public static final String KEY_VIDEO_URLS = "KEY_VIDEO_URLS";
37 | public static final String KEY_HEIGHT = "KEY_HEIGHT";
38 |
39 | private FrameLayout frameLayout;
40 | private VideoView videoView;
41 | private NumberProgressBar progressBar;
42 | private TextView progressText;
43 | private FrameLayout progressLayout;
44 | private List videoUrls;
45 | private int height;
46 |
47 | private View errorView;
48 | private TextView errorText;
49 |
50 | /** 当前播放的是第几个视频 */
51 | private int index;
52 |
53 | /** 本地的视频文件路径列表 */
54 | private List localPathList = new ArrayList<>();
55 |
56 | public VideoFragment() {
57 | super(R.layout.video);
58 | }
59 |
60 | @Override
61 | protected View onCreate(View view) {
62 | frameLayout = (FrameLayout) view;
63 |
64 | errorView = LayoutInflater.from(getContext()).inflate(R.layout.error, null);
65 | errorText = (TextView) errorView.findViewById(R.id.error_text);
66 |
67 | videoView = (VideoView) findViewById(R.id.video_view);
68 | videoView.setClickable(false);
69 | progressLayout = (FrameLayout) findViewById(R.id.progress_layout);
70 | progressBar = (NumberProgressBar) findViewById(R.id.progress_bar);
71 | progressText = (TextView) findViewById(R.id.progress_text);
72 |
73 | height = getArguments().getInt(KEY_HEIGHT);
74 | frameLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height));
75 |
76 | videoUrls = getArguments().getStringArrayList(KEY_VIDEO_URLS);
77 | if (videoUrls != null && !videoUrls.isEmpty()) {
78 | List downloadUrlList = filterDownloadUrls(videoUrls);
79 | if (downloadUrlList.isEmpty()) {
80 | play();
81 | }
82 | else {
83 | refreshVideos(downloadUrlList, 0);
84 | }
85 |
86 | return view;
87 | }
88 | else {
89 | TextView emptyView = new TextView(getActivity());
90 | emptyView.setLayoutParams(new ViewGroup.LayoutParams(height, ViewGroup.LayoutParams.MATCH_PARENT));
91 | emptyView.setGravity(Gravity.CENTER);
92 | emptyView.setText("资源为空!");
93 | return emptyView;
94 | }
95 | }
96 |
97 | /**
98 | * 根据给定的url过滤出需要更新的url,并更新至localPathList
99 | * @param videoUrls
100 | * @return
101 | */
102 | private List filterDownloadUrls(List videoUrls) {
103 | String videoPath = Constant.DATA_PATH + "videos/";
104 | File videoPathFile = new File(videoPath);
105 | if (!videoPathFile.exists()) videoPathFile.mkdirs();
106 | //获取该目录下的文件名集合
107 | Set videoFileSet = new HashSet<>(Arrays.asList(videoPathFile.list()));
108 |
109 | List downloadUrls = new ArrayList<>();
110 | localPathList.clear();
111 | for (String url : videoUrls) {
112 | String filename = url.substring(url.lastIndexOf('/') + 1);
113 | if (!videoFileSet.contains(filename)) {
114 | downloadUrls.add(url);
115 | }
116 | localPathList.add(videoPath + filename);
117 | }
118 | return downloadUrls;
119 | }
120 |
121 | /**
122 | * 下载视频
123 | * @param downloadUrlList 需要下载的url列表
124 | * @param index 当前下载的是第几个url
125 | */
126 | private void refreshVideos(List downloadUrlList, int index) {
127 | if (index >= downloadUrlList.size()) return;
128 |
129 | progressText.setText(index + "/" + downloadUrlList.size());
130 |
131 | File file = new File(Constant.DATA_PATH + "videos/");
132 | if (!file.exists()) file.mkdirs();
133 | HttpUtils.get(getContext(), downloadUrlList.get(index), new FileAsyncHttpResponseHandler(file) {
134 | @Override
135 | public void onFailure(int statusCode, Header[] headers, Throwable throwable, File file) {
136 | Log.e("refreshVideos", "下载出错");
137 | frameLayout.removeAllViews();
138 | errorText.setText("视频加载出错!");
139 | frameLayout.addView(errorView);
140 | }
141 |
142 | @Override
143 | public void onProgress(long bytesWritten, long totalSize) {
144 | int percent = (int) ((bytesWritten * 1.0 / totalSize) * 100);
145 | progressBar.setProgress(percent);
146 | super.onProgress(bytesWritten, totalSize);
147 | }
148 |
149 | @Override
150 | public void onSuccess(int statusCode, Header[] headers, File file) {
151 | if (index == downloadUrlList.size() - 1) {
152 | progressLayout.setVisibility(View.GONE);
153 | videoView.setVisibility(View.VISIBLE);
154 |
155 | AdsView.countDownLatch.countDown();
156 |
157 | play();
158 | }
159 | else {
160 | refreshVideos(downloadUrlList, index + 1);
161 | }
162 | }
163 | });
164 | }
165 |
166 | private void play() {
167 | progressLayout.setVisibility(View.GONE);
168 | videoView.setVisibility(View.VISIBLE);
169 | doPlay();
170 | }
171 |
172 | /**
173 | * 播放视频
174 | */
175 | private void doPlay() {
176 | videoView.setVideoPath(localPathList.get(index++));
177 | videoView.start();
178 |
179 | videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
180 | @Override
181 | public void onPrepared(MediaPlayer mp) {
182 | mp.start();
183 | }
184 | });
185 |
186 | videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
187 | @Override
188 | public void onCompletion(MediaPlayer mp) {
189 | index %= videoUrls.size();
190 | doPlay();
191 | }
192 | });
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/utils/HttpUtils.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.utils;
2 |
3 | import android.content.Context;
4 |
5 | import com.alibaba.fastjson.JSONObject;
6 | import com.loopj.android.http.AsyncHttpClient;
7 | import com.loopj.android.http.AsyncHttpResponseHandler;
8 | import com.loopj.android.http.BinaryHttpResponseHandler;
9 | import com.loopj.android.http.JsonHttpResponseHandler;
10 | import com.loopj.android.http.PersistentCookieStore;
11 | import com.loopj.android.http.RequestParams;
12 | import com.loopj.android.http.SyncHttpClient;
13 |
14 | import java.util.List;
15 | import java.util.Map;
16 |
17 | import cz.msebera.android.httpclient.Consts;
18 | import cz.msebera.android.httpclient.HttpEntity;
19 | import cz.msebera.android.httpclient.cookie.Cookie;
20 | import cz.msebera.android.httpclient.entity.ByteArrayEntity;
21 | import cz.msebera.android.httpclient.entity.ContentType;
22 | import cz.msebera.android.httpclient.entity.StringEntity;
23 | import cz.msebera.android.httpclient.impl.cookie.BasicClientCookie;
24 | import cz.msebera.android.httpclient.message.BasicHeader;
25 | import cz.msebera.android.httpclient.protocol.HTTP;
26 |
27 |
28 | public class HttpUtils {
29 |
30 | /**
31 | * Single instance
32 | */
33 | private static AsyncHttpClient client = new AsyncHttpClient();
34 |
35 | private static SyncHttpClient syncHttpClient = new SyncHttpClient();
36 |
37 | public static AsyncHttpClient getClient() {
38 | return client;
39 | }
40 |
41 | public static SyncHttpClient getSyncHttpClient() {
42 | return syncHttpClient;
43 | }
44 |
45 | /**
46 | * while you create StringEntity yourself, please do : entity.setContentType(basicHeader)
47 | * but you need not do this by use static method createEntity
48 | */
49 | public static BasicHeader basicHeader = new BasicHeader(HTTP.CONTENT_TYPE, "application/json; charset=UTF-8");
50 |
51 | private static PersistentCookieStore persistentCookieStore;
52 | public static void addCookie(Context context, String value) {
53 | if (persistentCookieStore == null) persistentCookieStore = new PersistentCookieStore(context);
54 | BasicClientCookie cookie = new BasicClientCookie("Set-Cookie", value);
55 | persistentCookieStore.addCookie(cookie);
56 | }
57 |
58 | public static List getCookie() {
59 | List cookieList = persistentCookieStore.getCookies();
60 | return cookieList;
61 | }
62 |
63 | public static void clearCookies(Context context) {
64 | if (persistentCookieStore == null) persistentCookieStore = new PersistentCookieStore(context);
65 | persistentCookieStore.clear();
66 | }
67 |
68 | public static void addHeaders(Context context) {
69 | client.addHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
70 | client.addHeader("Accept", ContentType.APPLICATION_JSON.toString());
71 | if (persistentCookieStore == null) persistentCookieStore = new PersistentCookieStore(context);
72 | client.setCookieStore(persistentCookieStore);
73 | }
74 |
75 | public static void addFormHeaders(Context context) {
76 | client.addHeader(HTTP.CONTENT_TYPE, ContentType.create(
77 | "application/x-www-form-urlencoded", Consts.UTF_8).toString());
78 | if (persistentCookieStore == null) persistentCookieStore = new PersistentCookieStore(context);
79 | client.setCookieStore(persistentCookieStore);
80 | }
81 |
82 | public static void addSyncFormHeaders(Context context) {
83 | syncHttpClient.addHeader(HTTP.CONTENT_TYPE, ContentType.create(
84 | "application/x-www-form-urlencoded", Consts.UTF_8).toString());
85 | if (persistentCookieStore == null) persistentCookieStore = new PersistentCookieStore(context);
86 | syncHttpClient.setCookieStore(persistentCookieStore);
87 | }
88 |
89 | public static void addSyncJsonHeaders(Context context) {
90 | syncHttpClient.addHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
91 | syncHttpClient.addHeader("Accept", ContentType.APPLICATION_JSON.toString());
92 | if (persistentCookieStore == null) persistentCookieStore = new PersistentCookieStore(context);
93 | syncHttpClient.setCookieStore(persistentCookieStore);
94 | }
95 |
96 | /**
97 | * create StringEntity with ContentType: application/json; charset=UTF-8
98 | * @param string entity string
99 | * @return StringEntity
100 | */
101 | public static StringEntity createEntity(String string) {
102 | return new StringEntity(string, ContentType.APPLICATION_JSON);
103 | }
104 |
105 | /**
106 | * create StringEntity with ContentType: application/json; charset=UTF-8
107 | * @param jsonObject entity jsonObject
108 | * @return StringEntity
109 | */
110 | public static StringEntity createEntity(JSONObject jsonObject) {
111 | return new StringEntity(jsonObject.toJSONString(), ContentType.APPLICATION_JSON);
112 | }
113 |
114 | /**
115 | * create StringEntity with ContentType: application/json; charset=UTF-8
116 | * @param map entity map
117 | * @return StringEntity
118 | */
119 | public static StringEntity createEntity(Map map) {
120 | return new StringEntity(map.toString(), ContentType.APPLICATION_JSON);
121 | }
122 |
123 | public static HttpEntity createByteArrayEntity(byte[] binaryBody) {
124 | return new ByteArrayEntity(binaryBody);
125 | }
126 |
127 | /**
128 | * GET 方法 用一个完整url获取一个string对象
129 | * @param url 请求url
130 | * @param res AsyncHttpResponseHandler
131 | */
132 | public static void get(Context context, String url, AsyncHttpResponseHandler res) {
133 | addHeaders(context);
134 | client.get(url, res);
135 | }
136 |
137 | /**
138 | * GET 方法 用一个带参数的url获取一个string对象
139 | * @param url 请求的url
140 | * @param params 请求参数
141 | * @param res AsyncHttpResponseHandler
142 | */
143 | public static void get(Context context, String url, RequestParams params, AsyncHttpResponseHandler res) {
144 | addHeaders(context);
145 | client.get(url, params, res);
146 | }
147 |
148 | /**
149 | * GET 方法 用一个带参数的url获取一个string对象
150 | * @param url 请求的url
151 | * @param entity StringEntity body字符串
152 | * @param res AsyncHttpResponseHandler
153 | */
154 | public static void get(Context context, String url, StringEntity entity, AsyncHttpResponseHandler res) {
155 | addHeaders(context);
156 | client.get(context, url, entity, "application/json", res);
157 | }
158 |
159 | /**
160 | * GET 方法 不带参数,获取json对象或者数组
161 | * @param url 请求的url
162 | * @param res JsonHttpResponseHandler
163 | */
164 | public static void get(Context context, String url, JsonHttpResponseHandler res) {
165 | addHeaders(context);
166 | client.get(url, res);
167 | }
168 |
169 | /**
170 | * GET 方法 不带参数,获取json对象或者数组
171 | * @param url 请求的url
172 | * @param params 请求参数
173 | * @param res JsonHttpResponseHandler
174 | */
175 | public static void get(Context context, String url, RequestParams params, JsonHttpResponseHandler res) {
176 | addHeaders(context);
177 | client.get(url, params, res);
178 | }
179 |
180 | /**
181 | * GET 方法 用一个带参数的url获取一个string对象
182 | * @param url 请求的url
183 | * @param entity StringEntity body字符串
184 | * @param res JsonHttpResponseHandler
185 | */
186 | public static void get(Context context, String url, StringEntity entity, JsonHttpResponseHandler res) {
187 | addHeaders(context);
188 | client.get(context, url, entity, "application/json", res);
189 | }
190 |
191 | /**
192 | * GET 方法 不带参数 下载数据使用,会返回byte数据
193 | * @param url 请求的url
194 | * @param res BinaryHttpResponseHandler
195 | */
196 | public static void get(Context context, String url, BinaryHttpResponseHandler res) {
197 | addHeaders(context);
198 | client.get(url, res);
199 | }
200 |
201 | public static void getSync(Context context, String url, AsyncHttpResponseHandler res) {
202 | addSyncJsonHeaders(context);
203 | syncHttpClient.get(url, res);
204 | }
205 |
206 |
207 | public static void post(Context context, String url, HttpEntity httpEntity, AsyncHttpResponseHandler res) {
208 | addHeaders(context);
209 | client.post(context, url, httpEntity, null, res);
210 | }
211 |
212 |
213 | /**
214 | * POST 方法 用一个完整url获取一个string对象
215 | * @param url 请求url
216 | * @param res AsyncHttpResponseHandler
217 | */
218 | public static void post(Context context, String url, AsyncHttpResponseHandler res) {
219 | addHeaders(context);
220 | client.post(url, res);
221 | }
222 |
223 | /**
224 | * POST 方法 用一个带参数的url获取一个string对象
225 | * @param url 请求的url
226 | * @param params 请求参数
227 | * @param res AsyncHttpResponseHandler
228 | */
229 | public static void post(Context context, String url, RequestParams params, AsyncHttpResponseHandler res) {
230 | addFormHeaders(context);
231 | client.post(url, params, res);
232 | }
233 |
234 | public static void postSync(Context context, String url, RequestParams params, AsyncHttpResponseHandler res) {
235 | addSyncFormHeaders(context);
236 | syncHttpClient.post(url, params, res);
237 | }
238 |
239 | public static void postSync(Context context, String url, HttpEntity entity, AsyncHttpResponseHandler res) {
240 | syncHttpClient.addHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_OCTET_STREAM.toString());
241 | if (persistentCookieStore == null) persistentCookieStore = new PersistentCookieStore(context);
242 | syncHttpClient.setCookieStore(persistentCookieStore);
243 | syncHttpClient.post(context, url, entity, null, res);
244 | }
245 |
246 | /**
247 | * POST 方法 用一个带参数的url获取一个string对象
248 | * @param url 请求的url
249 | * @param entity StringEntity body字符串
250 | * @param res AsyncHttpResponseHandler
251 | */
252 | public static void post(Context context, String url, StringEntity entity, AsyncHttpResponseHandler res) {
253 | addHeaders(context);
254 | client.post(context, url, entity, "application/json", res);
255 | }
256 |
257 | /**
258 | * POST 方法 不带参数,获取json对象或者数组
259 | * @param url 请求的url
260 | * @param res JsonHttpResponseHandler
261 | */
262 | public static void post(Context context, String url, JsonHttpResponseHandler res) {
263 | addHeaders(context);
264 | client.post(url, res);
265 | }
266 |
267 | /**
268 | * POST 方法 不带参数,获取json对象或者数组
269 | * @param url 请求的url
270 | * @param params 请求参数
271 | * @param res JsonHttpResponseHandler
272 | */
273 | public static void post(Context context, String url, RequestParams params, JsonHttpResponseHandler res) {
274 | addHeaders(context);
275 | client.post(url, params, res);
276 | }
277 |
278 | /**
279 | * POST 方法 用一个带参数的url获取一个string对象
280 | * @param url 请求的url
281 | * @param entity StringEntity body字符串
282 | * @param res JsonHttpResponseHandler
283 | */
284 | public static void post(Context context, String url, StringEntity entity, JsonHttpResponseHandler res) {
285 | addHeaders(context);
286 | client.post(context, url, entity, "application/json", res);
287 | }
288 |
289 | /**
290 | * POST 方法 不带参数 下载数据使用,会返回byte数据
291 | * @param url 请求的url
292 | * @param res BinaryHttpResponseHandler
293 | */
294 | public static void post(Context context, String url, BinaryHttpResponseHandler res) {
295 | addHeaders(context);
296 | client.post(url, res);
297 | }
298 |
299 | /**
300 | * PUT 方法 用一个完整url获取一个string对象
301 | * @param url 请求url
302 | * @param res AsyncHttpResponseHandler
303 | */
304 | public static void put(String url, AsyncHttpResponseHandler res) {
305 | client.put(url, res);
306 | }
307 |
308 |
309 | }
--------------------------------------------------------------------------------
/AdsView/src/main/java/com/xwj/adsview/view/AdsView.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview.view;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.os.Message;
8 | import android.support.v4.app.FragmentManager;
9 | import android.support.v4.app.FragmentTransaction;
10 | import android.util.AttributeSet;
11 | import android.util.DisplayMetrics;
12 | import android.view.LayoutInflater;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.LinearLayout;
16 | import android.widget.TextView;
17 |
18 | import com.alibaba.fastjson.JSON;
19 | import com.loopj.android.http.AsyncHttpResponseHandler;
20 | import com.xwj.adsview.R;
21 | import com.xwj.adsview.bean.AdsInfo;
22 | import com.xwj.adsview.bean.Constant;
23 | import com.xwj.adsview.bean.ResponseData;
24 | import com.xwj.adsview.exception.ParseResponseException;
25 | import com.xwj.adsview.fragment.BannerFragment;
26 | import com.xwj.adsview.fragment.VideoFragment;
27 | import com.xwj.adsview.utils.HttpUtils;
28 |
29 | import java.util.ArrayList;
30 | import java.util.List;
31 | import java.util.Timer;
32 | import java.util.TimerTask;
33 | import java.util.concurrent.CountDownLatch;
34 |
35 | import cz.msebera.android.httpclient.Header;
36 |
37 | /**
38 | * Created by Xu Wenjian on 2017/5/9.
39 | */
40 |
41 | public class AdsView extends LinearLayout {
42 |
43 | private FragmentManager fragmentManager;
44 | private View progressBarView;
45 | private View errorView;
46 | private TextView errorText;
47 | private Timer timer;
48 | private Context context;
49 |
50 | public static CountDownLatch countDownLatch;
51 |
52 | private static final int INIT = 0;
53 | private static final int REFRESH = 1;
54 | private static final int ERROR_DATA = 2;
55 | private static final int ERROR_SERVER = 3;
56 |
57 | private Handler handler = new Handler() {
58 | @Override
59 | public void handleMessage(Message msg) {
60 | super.handleMessage(msg);
61 | switch (msg.what) {
62 | case INIT:
63 | showProgressBar();
64 | break;
65 | case REFRESH:
66 | refreshView(context);
67 | break;
68 | case ERROR_DATA:
69 | removeAllViews();
70 | errorText.setText("数据解析错误!");
71 | addView(errorView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
72 | break;
73 | case ERROR_SERVER:
74 | removeAllViews();
75 | errorText.setText("服务器出错!");
76 | addView(errorView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
77 | break;
78 | }
79 |
80 | }
81 | };
82 |
83 | public AdsView(Context context) {
84 | super(context);
85 | init(context);
86 | }
87 |
88 | public AdsView(Context context, AttributeSet attrs) {
89 | super(context, attrs);
90 | init(context);
91 | }
92 |
93 | public AdsView(Context context, AttributeSet attrs, int defStyleAttr) {
94 | super(context, attrs, defStyleAttr);
95 | init(context);
96 | }
97 |
98 | private void init(Context context) {
99 | this.context = context;
100 | setOrientation(VERTICAL);
101 |
102 | errorView = LayoutInflater.from(context).inflate(R.layout.error, null);
103 | errorText = (TextView) errorView.findViewById(R.id.error_text);
104 |
105 | //默认显示环形进度条
106 | progressBarView = LayoutInflater.from(context).inflate(R.layout.welcome_progress_bar, null);
107 | showProgressBar();
108 |
109 | schedule();
110 | }
111 |
112 | private void schedule() {
113 | timer = new Timer();
114 | timer.schedule(new TimerTask() {
115 | @Override
116 | public void run() {
117 | HttpUtils.getSync(context, Constant.BASE_URL + "/api/ads/apkads", new AsyncHttpResponseHandler() {
118 | @Override
119 | public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
120 | ResponseData responseData = null;
121 | try {
122 | responseData = ResponseData.parse(responseBody);
123 | AdsInfo refreshAdsInfo = JSON.parseObject(responseData.getData().toString(), AdsInfo.class);
124 | //如果adsInfo有更新,则更新UI
125 | if (!AdsInfo.compareAndSet(refreshAdsInfo)) {
126 | timer.cancel();
127 | countDownLatch = new CountDownLatch(refreshAdsInfo.getPartNum());
128 | handler.sendEmptyMessage(REFRESH);
129 |
130 | countDownLatch.await();
131 | schedule();
132 | }
133 | } catch (ParseResponseException e) {
134 | handler.sendEmptyMessage(ERROR_DATA);
135 | } catch (InterruptedException e) {
136 | e.printStackTrace();
137 | }
138 |
139 | }
140 |
141 | @Override
142 | public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
143 | handler.sendEmptyMessage(ERROR_SERVER);
144 | }
145 | });
146 | }
147 | }, 0, Constant.interval);
148 | }
149 |
150 | /**
151 | * 显示进度条
152 | */
153 | private void showProgressBar() {
154 | removeAllViews();
155 | addView(progressBarView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
156 | }
157 |
158 | /**
159 | * 更新界面
160 | */
161 | public void refreshView(Context context) {
162 | if (fragmentManager == null) return;
163 |
164 | int parts = AdsInfo.getAdsInfo().getPartNum();
165 | int height = getFragmentHeight(context, parts);
166 | List contentList = AdsInfo.getAdsInfo().getContent();
167 | if (contentList != null && !contentList.isEmpty()) {
168 | //清除所有view
169 | removeAllViews();
170 |
171 | FragmentTransaction transaction = fragmentManager.beginTransaction();
172 | for (AdsInfo.Content content : contentList) {
173 | if (content.getPicUrls() != null && !content.getPicUrls().isEmpty()) {
174 | System.out.println("picUrls:" + content.getPicUrls());
175 | BannerFragment bannerFragment = new BannerFragment();
176 | Bundle bundle = new Bundle();
177 | bundle.putStringArrayList(BannerFragment.KEY_IMAGE_URLS, (ArrayList) content.getPicUrls());
178 | bundle.putInt(BannerFragment.KEY_HEIGHT, height);
179 | bannerFragment.setArguments(bundle);
180 |
181 | transaction.add(getId(), bannerFragment);
182 | }
183 | else if (content.getVideoUrls() != null && !content.getVideoUrls().isEmpty()) {
184 | VideoFragment videoFragment = new VideoFragment();
185 | Bundle bundle = new Bundle();
186 | bundle.putStringArrayList(VideoFragment.KEY_VIDEO_URLS, (ArrayList) content.getVideoUrls());
187 | bundle.putInt(VideoFragment.KEY_HEIGHT, height);
188 | videoFragment.setArguments(bundle);
189 |
190 | transaction.add(getId(), videoFragment);
191 | }
192 | }
193 | transaction.commit();
194 |
195 | }
196 | }
197 |
198 | /**
199 | * 根据parts的个数按比例分屏
200 | * @param context
201 | * @param parts
202 | * @return 每屏的高度
203 | */
204 | private int getFragmentHeight(Context context, int parts) {
205 | DisplayMetrics metric = new DisplayMetrics();
206 | ((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(metric);
207 | int height = metric.heightPixels;
208 | return height / parts;
209 | }
210 |
211 | /**
212 | * 设置FragmentManager
213 | * @param fragmentManager
214 | */
215 | public void setFragmentManager(FragmentManager fragmentManager) {
216 | this.fragmentManager = fragmentManager;
217 | }
218 |
219 | @Override
220 | protected void onDetachedFromWindow() {
221 | if (timer != null) {
222 | timer.cancel();
223 | }
224 | super.onDetachedFromWindow();
225 | }
226 | }
227 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/layout/error.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/layout/fragment_banner.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/layout/progress_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
12 |
17 |
21 |
26 |
27 |
32 |
33 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/layout/video.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
14 |
15 |
20 |
26 |
31 |
35 |
40 |
41 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/layout/welcome_progress_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #12C9B7
4 | #0e9c8e
5 | #12C9B7
6 | #f2f2f2
7 | #ffffff
8 | #000000
9 | #f0f0f0
10 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 5dp
4 | 6dp
5 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 爱康体广告播放器
3 |
4 |
--------------------------------------------------------------------------------
/AdsView/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/AdsView/src/test/java/com/xwj/adsview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AdsView 分屏的广告播放器
2 |
3 | #### 支持大屏幕多屏播放
4 | #### 支持滚动图片和视频轮播两种播放形式
5 | #### 支持后台动态配置播放内容
6 |
7 | # 效果展示
8 |
9 |

10 |

11 |
12 |
13 | # 使用方式
14 |
15 | ## 在布局文件中使用AdsView
16 |
17 | ```xml
18 |
22 | ```
23 | ## 给AdsView设置FragmentManager
24 |
25 | ```java
26 | adsView = (AdsView) findViewById(R.id.ads_view);
27 | adsView.setFragmentManager(getSupportFragmentManager());
28 | ```
29 |
30 | ## 若想添加自定义功能,请直接fork项目
31 |
32 | #### 若有任何疑问,可邮件联系wenjian881314@163.com
33 |
--------------------------------------------------------------------------------
/aikangti2.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/aikangti2.jks
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/app/app-release.apk
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 | defaultConfig {
7 | applicationId "com.xwj.adsplayer"
8 | minSdkVersion 16
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:23.4.0'
28 | testCompile 'junit:junit:4.12'
29 | compile project(path: ':AdsView')
30 | }
31 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/xwj/adsplayer/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsplayer;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.xwj.adsplayer", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/xwj/adsplayer/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsplayer;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 |
6 | import com.xwj.adsview.view.AdsView;
7 |
8 |
9 | public class MainActivity extends AppCompatActivity {
10 |
11 | private AdsView adsView;
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_main);
17 |
18 | adsView = (AdsView) findViewById(R.id.ads_view);
19 | adsView.setFragmentManager(getSupportFragmentManager());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #12C9B7
4 | #0e9c8e
5 | #12C9B7
6 | #f2f2f2
7 | #ffffff
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 爱康体广告播放器
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/test/java/com/xwj/adsplayer/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.xwj.adsplayer;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | //jcenter()
6 | maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.2.0'
10 | classpath 'me.tatarka:gradle-retrolambda:3.2.4'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | //jcenter()
20 | maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
21 | maven { url "https://jitpack.io" }
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/screenshots/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/screenshots/1.png
--------------------------------------------------------------------------------
/screenshots/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wenjian1314/AdsView/19b02fd2c15a7ad609f5158479e28d333f4a6bef/screenshots/2.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':AdsView'
2 |
--------------------------------------------------------------------------------