├── app
├── .gitignore
├── release
│ ├── app-release.apk
│ └── output.json
├── src
│ └── main
│ │ ├── res
│ │ ├── drawable
│ │ │ ├── vip.png
│ │ │ ├── close.png
│ │ │ ├── play.png
│ │ │ ├── splash.jpg
│ │ │ ├── download_qrcode.png
│ │ │ ├── filled_green_circle.png
│ │ │ ├── button_textview.xml
│ │ │ └── ic_launcher_background.xml
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── values
│ │ │ ├── dimens.xml
│ │ │ ├── colors.xml
│ │ │ ├── adurls.xml
│ │ │ ├── strings.xml
│ │ │ ├── styles.xml
│ │ │ └── attrs.xml
│ │ ├── menu
│ │ │ └── menu_setting.xml
│ │ ├── layout
│ │ │ ├── vip_code_dialog.xml
│ │ │ ├── vparser_dialog.xml
│ │ │ ├── activity_player.xml
│ │ │ ├── activity_web_play.xml
│ │ │ ├── activity_start.xml
│ │ │ ├── icon_text_view.xml
│ │ │ ├── fragment_main.xml
│ │ │ ├── setting_item_view.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── activity_web_view.xml
│ │ │ ├── activity_registe.xml
│ │ │ ├── fragment_mine.xml
│ │ │ ├── activity_login.xml
│ │ │ └── activity_change_password.xml
│ │ └── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ └── com
│ │ │ └── novip
│ │ │ ├── model
│ │ │ ├── VipCode.java
│ │ │ ├── AdUrl.java
│ │ │ ├── BaseResponse.java
│ │ │ ├── Ad.java
│ │ │ ├── User.java
│ │ │ ├── Platform.java
│ │ │ ├── Version.java
│ │ │ ├── Novip.java
│ │ │ └── VParser.java
│ │ │ ├── view
│ │ │ ├── VParserDialog.java
│ │ │ ├── SettingItemView.java
│ │ │ ├── IconTextView.java
│ │ │ ├── VipCodeDialog.java
│ │ │ └── CountDownView.java
│ │ │ ├── app
│ │ │ ├── VipChannel.java
│ │ │ ├── BaseActivity.java
│ │ │ ├── OnFragmentInteractionListener.java
│ │ │ ├── BannerADImageLoader.java
│ │ │ ├── RegisteActivity.java
│ │ │ ├── ChangePasswordActivity.java
│ │ │ ├── StartActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── LoginActivity.java
│ │ │ ├── MainFragment.java
│ │ │ └── MineFragment.java
│ │ │ ├── utils
│ │ │ ├── LogUtils.java
│ │ │ ├── PlatformUtil.java
│ │ │ ├── DensityUtils.java
│ │ │ ├── SharedPrefernceUtils.java
│ │ │ ├── ShareUtils.java
│ │ │ └── DeviceUtils.java
│ │ │ ├── web
│ │ │ ├── NoADWebViewClent.java
│ │ │ ├── AdFilterTool.java
│ │ │ ├── JSInterface.java
│ │ │ ├── WebPlayActivity.java
│ │ │ └── WebViewActivity.java
│ │ │ ├── VipCheck.java
│ │ │ ├── AppApplication.java
│ │ │ ├── Http.java
│ │ │ └── AppPrepare.java
│ │ ├── cpp
│ │ └── com_novip_novip_Native.h
│ │ └── AndroidManifest.xml
├── build.gradle
├── CMakeLists.txt
└── proguard-rules.pro
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── caches
│ └── build_file_checksums.ser
├── markdown-navigator
│ └── profiles_settings.xml
├── vcs.xml
├── runConfigurations.xml
├── gradle.xml
├── codeStyles
│ └── Project.xml
├── misc.xml
└── markdown-navigator.xml
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/src/main/res/drawable/vip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/src/main/res/drawable/vip.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/model/VipCode.java:
--------------------------------------------------------------------------------
1 | package com.novip.model;
2 |
3 |
4 |
5 | public class VipCode {
6 | }
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/src/main/res/drawable/close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/src/main/res/drawable/play.png
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/app/src/main/res/drawable/splash.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/src/main/res/drawable/splash.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/download_qrcode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/src/main/res/drawable/download_qrcode.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/filled_green_circle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/src/main/res/drawable/filled_green_circle.png
--------------------------------------------------------------------------------
/.idea/markdown-navigator/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JefferyBoy/NoVIP/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/libraries
5 | /.idea/modules.xml
6 | /.idea/workspace.xml
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 | *.jks
12 |
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":8,"versionName":"1.7","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | /* Header for class com_novip_novip_Native */
4 |
5 | #ifndef _Included_com_novip_novip_Native
6 | #define _Included_com_novip_novip_Native
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: com_novip_novip_Native
12 | * Method: verifyVip
13 | * Signature: (Ljava/lang/String;)Z
14 | */
15 | JNIEXPORT jboolean JNICALL Java_com_novip_novip_Native_verifyVip
16 | (JNIEnv *, jobject, jstring);
17 |
18 | #ifdef __cplusplus
19 | }
20 | #endif
21 | #endif
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/vparser_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_player.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/model/BaseResponse.java:
--------------------------------------------------------------------------------
1 | package com.novip.model;
2 |
3 | public class BaseResponse {
4 |
5 | private boolean success = true;
6 | private String note = "success";
7 |
8 | public BaseResponse() {
9 |
10 | }
11 | public BaseResponse(boolean success,String note) {
12 | this.success = success;
13 | this.note = note;
14 | }
15 |
16 | public boolean isSuccess() {
17 | return success;
18 | }
19 | public void setSuccess(boolean success) {
20 | this.success = success;
21 | }
22 | public String getNote() {
23 | return note;
24 | }
25 | public void setNote(String note) {
26 | this.note = note;
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/app/OnFragmentInteractionListener.java:
--------------------------------------------------------------------------------
1 | package com.novip.app;
2 |
3 | import android.net.Uri;
4 |
5 | /**
6 | * This interface must be implemented by activities that contain this
7 | * fragment to allow an interaction in this fragment to be communicated
8 | * to the activity and potentially other fragments contained in that
9 | * activity.
10 | *
11 | * See the Android Training lesson Communicating with Other Fragments for more information.
14 | */
15 | public interface OnFragmentInteractionListener {
16 | // TODO: Cloud argument type and name
17 | void onFragmentInteraction(Uri uri);
18 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/web/NoADWebViewClent.java:
--------------------------------------------------------------------------------
1 | package com.novip.web;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.webkit.WebResourceRequest;
5 | import android.webkit.WebResourceResponse;
6 | import android.webkit.WebView;
7 | import android.webkit.WebViewClient;
8 |
9 | public class NoADWebViewClent extends WebViewClient{
10 | @Nullable
11 | @Override
12 | public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
13 | //判断是否是广告相关的资源链接
14 | if (!AdFilterTool.isAd(view.getContext(), request.getUrl().toString())) {
15 | //这里是不做处理的数据
16 | return super.shouldInterceptRequest(view, request);
17 | } else {
18 | //有广告的请求数据,我们直接返回空数据,注:不能直接返回null
19 | return new WebResourceResponse(null, null, null);
20 | }
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
15 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/model/Ad.java:
--------------------------------------------------------------------------------
1 | package com.novip.model;
2 |
3 | public class Ad {
4 | private int id;
5 | private String picture_url;
6 | private String action_url;
7 | private String name;
8 |
9 | public int getId() {
10 | return id;
11 | }
12 |
13 | public void setId(int id) {
14 | this.id = id;
15 | }
16 |
17 | public String getPicture_url() {
18 | return picture_url;
19 | }
20 |
21 | public void setPicture_url(String picture_url) {
22 | this.picture_url = picture_url;
23 | }
24 |
25 | public String getAction_url() {
26 | return action_url;
27 | }
28 |
29 | public void setAction_url(String action_url) {
30 | this.action_url = action_url;
31 | }
32 |
33 | public String getName() {
34 | return name;
35 | }
36 |
37 | public void setName(String name) {
38 | this.name = name;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/model/User.java:
--------------------------------------------------------------------------------
1 | package com.novip.model;
2 |
3 | import java.util.Date;
4 |
5 | public class User{
6 |
7 | private String phone;
8 | private String password;
9 | private Date vip_end;
10 | private int id;
11 |
12 | public String getPhone() {
13 | return phone;
14 | }
15 |
16 | public void setPhone(String phone) {
17 | this.phone = phone;
18 | }
19 |
20 | public String getPassword() {
21 | return password;
22 | }
23 |
24 | public void setPassword(String password) {
25 | this.password = password;
26 | }
27 |
28 | public Date getVip_end() {
29 | return vip_end;
30 | }
31 |
32 | public void setVip_end(Date vip_end) {
33 | this.vip_end = vip_end;
34 | }
35 |
36 | public int getId() {
37 | return id;
38 | }
39 |
40 | public void setId(int id) {
41 | this.id = id;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_start.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/model/Platform.java:
--------------------------------------------------------------------------------
1 | package com.novip.model;
2 |
3 | import java.util.List;
4 |
5 | public class Platform {
6 |
7 | private int id;
8 | private String picture_url;
9 | private String action_url;
10 | private String name;
11 |
12 | public int getId() {
13 | return id;
14 | }
15 |
16 | public void setId(int id) {
17 | this.id = id;
18 | }
19 |
20 | public String getPicture_url() {
21 | return picture_url;
22 | }
23 |
24 | public void setPicture_url(String picture_url) {
25 | this.picture_url = picture_url;
26 | }
27 |
28 | public String getAction_url() {
29 | return action_url;
30 | }
31 |
32 | public void setAction_url(String action_url) {
33 | this.action_url = action_url;
34 | }
35 |
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/model/Version.java:
--------------------------------------------------------------------------------
1 | package com.novip.model;
2 |
3 |
4 | import org.jsoup.helper.StringUtil;
5 |
6 | public class Version {
7 | private int version_code;
8 | private String version_name;
9 | private String note;
10 | private String url;
11 |
12 | public String getUrl() {
13 | return url;
14 | }
15 |
16 | public void setUrl(String url) {
17 | this.url = url;
18 | }
19 |
20 | public int getVersion_code() {
21 | return version_code;
22 | }
23 |
24 | public void setVersion_code(int version_code) {
25 | this.version_code = version_code;
26 | }
27 |
28 | public String getVersion_name() {
29 | return version_name;
30 | }
31 |
32 | public void setVersion_name(String version_name) {
33 | this.version_name = version_name;
34 | }
35 |
36 | public String getNote() {
37 | return note;
38 | }
39 |
40 | public void setNote(String note) {
41 | this.note = note;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/web/AdFilterTool.java:
--------------------------------------------------------------------------------
1 | package com.novip.web;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 |
6 | import com.alibaba.fastjson.JSON;
7 | import com.novip.AppApplication;
8 | import com.novip.Http;
9 | import com.novip.R;
10 | import com.novip.model.AdUrl;
11 | import com.novip.model.Platform;
12 |
13 | import java.io.IOException;
14 | import java.util.List;
15 |
16 | import okhttp3.Call;
17 | import okhttp3.Callback;
18 | import okhttp3.Response;
19 |
20 | /*
21 | * 广告过滤规则,参考360过滤:http://rules.wd.360.cn/
22 | * */
23 | public class AdFilterTool {
24 |
25 | public static boolean isAd(Context context, String url) {
26 | if(AppApplication.getInstance().getFilterUrls() != null && AppApplication.getInstance().getFilterUrls().length>0){
27 | for (String adUrl : AppApplication.getInstance().getFilterUrls() ) {
28 | if (url.contains(adUrl)) {
29 | return true;
30 | }
31 | }
32 | }
33 | return false;
34 | }
35 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/app/BannerADImageLoader.java:
--------------------------------------------------------------------------------
1 | package com.novip.app;
2 |
3 | import android.content.Context;
4 | import android.widget.ImageView;
5 |
6 | import com.bumptech.glide.Glide;
7 | import com.youth.banner.loader.ImageLoader;
8 |
9 | public class BannerADImageLoader extends ImageLoader {
10 | @Override
11 | public void displayImage(Context context, Object path, ImageView imageView) {
12 | /**
13 | 注意:
14 | 1.图片加载器由自己选择,这里不限制,只是提供几种使用方法
15 | 2.返回的图片路径为Object类型,由于不能确定你到底使用的那种图片加载器,
16 | 传输的到的是什么格式,那么这种就使用Object接收和返回,你只需要强转成你传输的类型就行,
17 | 切记不要胡乱强转!
18 | */
19 | //Glide 加载图片简单用法
20 | Glide.with(context).load(path).into(imageView);
21 | }
22 |
23 | //提供createImageView 方法,如果不用可以不重写这个方法,主要是方便自定义ImageView的创建
24 | @Override
25 | public ImageView createImageView(Context context) {
26 | //使用fresco,需要创建它提供的ImageView,当然你也可以用自己自定义的具有图片加载功能的ImageView
27 | ImageView simpleDraweeView=new ImageView(context);
28 | return simpleDraweeView;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/icon_text_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
17 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/utils/PlatformUtil.java:
--------------------------------------------------------------------------------
1 | package com.novip.utils;
2 |
3 | import android.content.Context;
4 | import android.content.pm.PackageInfo;
5 | import android.content.pm.PackageManager;
6 |
7 | import java.util.List;
8 |
9 | public class PlatformUtil {
10 | public static final String PACKAGE_WECHAT = "com.tencent.mm";
11 | public static final String PACKAGE_MOBILE_QQ = "com.tencent.mobileqq";
12 | public static final String PACKAGE_QZONE = "com.qzone";
13 | public static final String PACKAGE_SINA = "com.sina.weibo";
14 |
15 | // 判断是否安装指定app
16 | public static boolean isInstallApp(Context context, String app_package){
17 | final PackageManager packageManager = context.getPackageManager();
18 | List pInfo = packageManager.getInstalledPackages(0);
19 | if (pInfo != null) {
20 | for (int i = 0; i < pInfo.size(); i++) {
21 | String pn = pInfo.get(i).packageName;
22 | if (app_package.equals(pn)) {
23 | return true;
24 | }
25 | }
26 | }
27 | return false;
28 | }
29 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/model/Novip.java:
--------------------------------------------------------------------------------
1 | package com.novip.model;
2 |
3 | public class Novip {
4 |
5 | private String host;
6 | private int port;
7 | private String admin_qq;
8 | private String qq_group;
9 | private String buy_url;
10 |
11 | public String getHost() {
12 | return host;
13 | }
14 |
15 | public void setHost(String host) {
16 | this.host = host;
17 | }
18 |
19 | public int getPort() {
20 | return port;
21 | }
22 |
23 | public void setPort(int port) {
24 | this.port = port;
25 | }
26 |
27 | public String getAdmin_qq() {
28 | return admin_qq;
29 | }
30 |
31 | public void setAdmin_qq(String admin_qq) {
32 | this.admin_qq = admin_qq;
33 | }
34 |
35 | public String getQq_group() {
36 | return qq_group;
37 | }
38 |
39 | public void setQq_group(String qq_group) {
40 | this.qq_group = qq_group;
41 | }
42 |
43 | public String getBuy_url() {
44 | return buy_url;
45 | }
46 |
47 | public void setBuy_url(String buy_url) {
48 | this.buy_url = buy_url;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
22 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/setting_item_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
17 |
25 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/model/VParser.java:
--------------------------------------------------------------------------------
1 | package com.novip.model;
2 |
3 |
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | public class VParser {
8 | private String name;
9 | private String nick_name;
10 | private String url;
11 | private String note;
12 | private Date date;
13 | private String platform_ids;
14 |
15 | public String getNick_name() {
16 | return nick_name;
17 | }
18 |
19 | public void setNick_name(String nick_name) {
20 | this.nick_name = nick_name;
21 | }
22 |
23 | public String getName() {
24 | return name;
25 | }
26 |
27 | public void setName(String name) {
28 | this.name = name;
29 | }
30 |
31 | public String getUrl() {
32 | return url;
33 | }
34 |
35 | public void setUrl(String url) {
36 | this.url = url;
37 | }
38 |
39 | public String getNote() {
40 | return note;
41 | }
42 |
43 | public void setNote(String note) {
44 | this.note = note;
45 | }
46 |
47 | public Date getDate() {
48 | return date;
49 | }
50 |
51 | public void setDate(Date date) {
52 | this.date = date;
53 | }
54 |
55 | public String getPlatform_ids() {
56 | return platform_ids;
57 | }
58 |
59 | public void setPlatform_ids(String platform_ids) {
60 | this.platform_ids = platform_ids;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/view/SettingItemView.java:
--------------------------------------------------------------------------------
1 | package com.novip.view;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.util.AttributeSet;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.FrameLayout;
10 | import android.widget.TextView;
11 |
12 | import com.novip.R;
13 |
14 | public class SettingItemView extends FrameLayout {
15 |
16 | private TextView title,sub;
17 |
18 |
19 | public SettingItemView(@NonNull Context context) {
20 | this(context,null);
21 | }
22 |
23 | public SettingItemView(@NonNull Context context, @Nullable AttributeSet attrs) {
24 | this(context, attrs,0);
25 | }
26 |
27 | public SettingItemView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
28 | this(context, attrs, defStyleAttr,0);
29 | }
30 |
31 | public SettingItemView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
32 | super(context, attrs, defStyleAttr, defStyleRes);
33 | View view = LayoutInflater.from(context).inflate(R.layout.setting_item_view,this,false);
34 | title = view.findViewById(R.id.title);
35 | sub = view.findViewById(R.id.sub);
36 | addView(view);
37 | }
38 |
39 | public void setText(CharSequence title,CharSequence sub){
40 | this.title.setText(title);
41 | this.sub.setText(sub);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.novip"
7 | minSdkVersion 21
8 | targetSdkVersion 28
9 | versionCode 8
10 | versionName "1.7"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
24 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25 | implementation 'com.android.support:design:28.0.0'
26 | testImplementation 'junit:junit:4.12'
27 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
28 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
29 | implementation 'com.android.support:support-v4:28.0.0-rc02'
30 | implementation 'com.github.bumptech.glide:glide:4.8.0'
31 | implementation 'com.squareup.okhttp3:okhttp:3.11.0'
32 | implementation 'com.alibaba:fastjson:1.2.49'
33 | implementation 'com.youth.banner:banner:1.4.10'
34 | //implementation 'cn.jzvd:jiaozivideoplayer:6.3.1'
35 | implementation 'org.jsoup:jsoup:1.11.3'
36 |
37 | implementation 'com.umeng.sdk:common:1.5.0'
38 | implementation 'com.umeng.sdk:analytics:7.5.0'
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/utils/DensityUtils.java:
--------------------------------------------------------------------------------
1 | package com.novip.utils;
2 |
3 | import android.content.Context;
4 | import android.util.TypedValue;
5 |
6 | /**
7 | * 常用单位转换的辅助类
8 | */
9 | public class DensityUtils {
10 | private DensityUtils() {
11 | /* cannot be instantiated */
12 | throw new UnsupportedOperationException("cannot be instantiated");
13 | }
14 |
15 | /**
16 | * dp转px
17 | *
18 | * @param context
19 | * @return
20 | */
21 | public static int dp2px(Context context, float dpVal) {
22 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
23 | dpVal, context.getResources().getDisplayMetrics());
24 | }
25 |
26 | /**
27 | * sp转px
28 | *
29 | * @param context
30 | * @return
31 | */
32 | public static int sp2px(Context context, float spVal) {
33 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
34 | spVal, context.getResources().getDisplayMetrics());
35 | }
36 |
37 | /**
38 | * px转dp
39 | *
40 | * @param context
41 | * @param pxVal
42 | * @return
43 | */
44 | public static float px2dp(Context context, float pxVal) {
45 | final float scale = context.getResources().getDisplayMetrics().density;
46 | return (pxVal / scale);
47 | }
48 |
49 | /**
50 | * px转sp
51 | *
52 | * @param pxVal
53 | * @return
54 | */
55 | public static float px2sp(Context context, float pxVal) {
56 | return (pxVal / context.getResources().getDisplayMetrics().scaledDensity);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/web/JSInterface.java:
--------------------------------------------------------------------------------
1 | package com.novip.web;
2 |
3 | import android.util.Log;
4 | import android.webkit.JavascriptInterface;
5 |
6 | import com.novip.utils.FileUtils;
7 |
8 | import org.jsoup.Jsoup;
9 | import org.jsoup.nodes.DataNode;
10 | import org.jsoup.nodes.Element;
11 | import org.jsoup.select.Elements;
12 |
13 | public class JSInterface {
14 |
15 | @JavascriptInterface
16 | public void showSource(String html) {
17 | Log.d("HTML", html);
18 | Element body = Jsoup.parse(html).body();
19 | Elements elements = body.getElementsByAttribute("src");
20 | for(Element e: elements){
21 | if(e.tagName().equals("video")){
22 | for(DataNode node : e.dataNodes()){
23 | if(node.nodeName().equals("src")){
24 |
25 | Log.d("JSInterface",node.getWholeData());
26 | }
27 | }
28 | }
29 | Log.d("JSInterface",e.toString());
30 | }
31 | /*Elements elements = body.getElementsByTag("body");
32 | if(elements != null && !elements.isEmpty()){
33 | elements = elements.get(0).getElementsByTag("video");
34 | if(elements != null && !elements.isEmpty()){
35 | Log.d("JSInterface",elements.get(0).toString());
36 | elements = elements.get(0).getElementsByAttribute("src");
37 | if(elements != null && !elements.isEmpty()){
38 | Log.d("JSInterface",elements.get(0).toString());
39 | }
40 | }
41 | }else {
42 | Log.d("JSInterface","没有Video");
43 | }*/
44 | FileUtils.saveFile("video.html",html);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.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 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - 线路1
6 | - 线路2
7 | - 线路3
8 | - 线路4
9 | - 线路5
10 | - 线路6
11 | - 线路7
12 | - 线路8
13 | - 线路9
14 | - 线路10
15 | - 线路11
16 | - 线路13
17 | - 线路14
18 | - 线路15
19 | - 线路16
20 | - 线路17
21 | - 线路18
22 | - 线路19
23 |
24 |
25 |
26 | - http://jx.618g.com/?url=
27 | - http://api.baiyug.vip/index.php?url=
28 | - http://www.wocao.xyz/index.php?url=
29 | - https://vip.hackmg.com/jx/index.php?url=
30 | - http://www.lan8888.cn/jx.php?url=
31 | - http://jiexi.92fz.cn/player/vip.php?url=
32 | - http://api.xcq91.top/?url=
33 | - http://aikan-tv.com/?url=
34 | - http://jx.jfysz.cn/jx.php/?url=
35 | - http://api.bbbbbb.me/yunjx/?url=
36 | - https://jiexi.071811.cc/jx.php?url=
37 | - http://yun.baiyug.cn/vip/index.php?url=
38 | - http://aikan-tv.com/?url=
39 | - http://api.pucms.com/?url=
40 | - http://xlyy100.com/xlyy.php?url=
41 | - http://www.a305.org/flv.php?url=
42 | - http://000o.cc/jx/ty.php?url=
43 | - http://www.82190555.com/video.php?url=
44 | - http://jx.598110.com/zuida.php?url=
45 |
46 |
--------------------------------------------------------------------------------
/app/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # For more information about using CMake with Android Studio, read the
2 | # documentation: https://d.android.com/studio/projects/add-native-code.html
3 |
4 | # Sets the minimum version of CMake required to build the native library.
5 |
6 | cmake_minimum_required(VERSION 3.4.1)
7 |
8 | # Creates and names a library, sets it as either STATIC
9 | # or SHARED, and provides the relative paths to its source code.
10 | # You can define multiple libraries, and CMake builds them for you.
11 | # Gradle automatically packages shared libraries with your APK.
12 |
13 | add_library( # Sets the name of the library.
14 | native-lib
15 |
16 | # Sets the library as a shared library.
17 | SHARED
18 |
19 | # Provides a relative path to your source file(s).
20 | src/main/cpp/native-lib.cpp )
21 |
22 | # Searches for a specified prebuilt library and stores the path as a
23 | # variable. Because CMake includes system libraries in the search path by
24 | # default, you only need to specify the name of the public NDK library
25 | # you want to add. CMake verifies that the library exists before
26 | # completing its build.
27 |
28 | find_library( # Sets the name of the path variable.
29 | log-lib
30 |
31 | # Specifies the name of the NDK library that
32 | # you want CMake to locate.
33 | log )
34 |
35 | # Specifies libraries CMake should link to your target library. You
36 | # can link multiple libraries, such as libraries you define in this
37 | # build script, prebuilt third-party libraries, or system libraries.
38 |
39 | target_link_libraries( # Specifies the target library.
40 | native-lib
41 |
42 | # Links the target library to the log library
43 | # included in the NDK.
44 | ${log-lib} )
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/utils/SharedPrefernceUtils.java:
--------------------------------------------------------------------------------
1 | package com.novip.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | public class SharedPrefernceUtils {
7 |
8 | private static SharedPrefernceUtils sp;
9 |
10 | private static SharedPreferences sharedPreferences;
11 |
12 | public static final String KEY_CHANNEL = "channel";
13 |
14 | public static final String TEST = "test";
15 |
16 | public static final String VIP_CODE = "VIP_CODE";
17 |
18 | public static final String PHONE = "phone";
19 | public static final String PS = "ps";
20 |
21 | private SharedPrefernceUtils(){}
22 |
23 | public static SharedPrefernceUtils getInstance(Context context){
24 | if(sp == null){
25 | sp = new SharedPrefernceUtils();
26 | sharedPreferences = context.getSharedPreferences("novip",Context.MODE_PRIVATE);
27 | }
28 | return sp;
29 | }
30 |
31 | public void putInt(String key,int value){
32 | SharedPreferences.Editor editor = sharedPreferences.edit();
33 | editor.putInt(key,value);
34 | editor.commit();
35 | }
36 |
37 | public int getInt(String key){
38 | return sharedPreferences.getInt(key,0);
39 | }
40 |
41 | public void putBoolean(String key,boolean value){
42 | SharedPreferences.Editor editor = sharedPreferences.edit();
43 | editor.putBoolean(key,value);
44 | editor.commit();
45 | }
46 |
47 | public boolean getBoolean(String key){
48 | return sharedPreferences.getBoolean(key,false);
49 | }
50 |
51 | public void putString(String key,String value){
52 | SharedPreferences.Editor editor = sharedPreferences.edit();
53 | editor.putString(key,value);
54 | editor.commit();
55 | }
56 |
57 | public String getString(String key){
58 | return sharedPreferences.getString(key,"");
59 | }
60 |
61 | public void putLong(String key,long value){
62 | SharedPreferences.Editor editor = sharedPreferences.edit();
63 | editor.putLong(key,value);
64 | editor.commit();
65 | }
66 |
67 | public long getLong(String key){
68 | return sharedPreferences.getLong(key,0l);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/app/RegisteActivity.java:
--------------------------------------------------------------------------------
1 | package com.novip.app;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import com.novip.Http;
13 | import com.novip.R;
14 | import com.novip.utils.DeviceUtils;
15 |
16 | import java.io.IOException;
17 |
18 | import okhttp3.Call;
19 | import okhttp3.Callback;
20 | import okhttp3.Response;
21 |
22 | public class RegisteActivity extends BaseActivity implements View.OnClickListener {
23 |
24 | private EditText phone,password;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_registe);
30 | phone = findViewById(R.id.email);
31 | password = findViewById(R.id.password);
32 | findViewById(R.id.email_sign_in_button).setOnClickListener(this);
33 | }
34 |
35 | @Override
36 | public void onClick(View v) {
37 | String ph = phone.getText().toString().trim();
38 | String pass = password.getText().toString().trim();
39 | if(ph.length() != 11){
40 | Toast.makeText(this,"手机号格式不对",Toast.LENGTH_SHORT).show();
41 | return;
42 | }
43 | if(pass.length() < 4){
44 | Toast.makeText(this,"密码长度要大于4",Toast.LENGTH_SHORT).show();
45 | return;
46 | }
47 |
48 | Http.registe(ph, pass,DeviceUtils.getUniqueId(this), new Callback() {
49 | @Override
50 | public void onFailure(Call call, IOException e) {
51 |
52 | }
53 |
54 | @Override
55 | public void onResponse(Call call, final Response response) throws IOException {
56 | runOnUiThread(new Runnable() {
57 | @Override
58 | public void run() {
59 | if(response.code() == 200){
60 | Toast.makeText(RegisteActivity.this,"注册成功",Toast.LENGTH_SHORT).show();
61 | startActivity(new Intent(RegisteActivity.this, LoginActivity.class));
62 | finish();
63 | }
64 | }
65 | });
66 |
67 | }
68 | });
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
38 |
39 |
43 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/app/ChangePasswordActivity.java:
--------------------------------------------------------------------------------
1 | package com.novip.app;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.EditText;
8 | import android.widget.Toast;
9 |
10 | import com.novip.Http;
11 | import com.novip.R;
12 |
13 | import org.jsoup.helper.StringUtil;
14 |
15 | import java.io.IOException;
16 |
17 | import okhttp3.Call;
18 | import okhttp3.Callback;
19 | import okhttp3.Response;
20 |
21 | public class ChangePasswordActivity extends AppCompatActivity implements View.OnClickListener {
22 |
23 | private EditText phone,password,new_password;
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_change_password);
28 | phone = findViewById(R.id.email);
29 | password = findViewById(R.id.password);
30 | new_password = findViewById(R.id.new_password);
31 | findViewById(R.id.email_sign_in_button).setOnClickListener(this);
32 | }
33 |
34 | @Override
35 | public void onClick(View v) {
36 | String phone_s = phone.getText().toString().trim();
37 | String password_s = password.getText().toString().trim();
38 | String newPassword_s = new_password.getText().toString().trim();
39 | if(StringUtil.isBlank(phone_s) || StringUtil.isBlank(password_s)||StringUtil.isBlank(newPassword_s)){
40 | Toast.makeText(this,"输入内容不能为空",Toast.LENGTH_SHORT).show();
41 | }else {
42 | Http.changePassword(phone_s, password_s, newPassword_s, new Callback() {
43 | @Override
44 | public void onFailure(Call call, IOException e) {
45 |
46 | }
47 |
48 | @Override
49 | public void onResponse(Call call, Response response) throws IOException {
50 | if(response.code() == 200){
51 | runOnUiThread(new Runnable() {
52 | @Override
53 | public void run() {
54 | Toast.makeText(ChangePasswordActivity.this,"成功",Toast.LENGTH_SHORT).show();
55 | startActivity(new Intent(ChangePasswordActivity.this,LoginActivity.class));
56 | finish();
57 | }
58 | });
59 | }
60 | }
61 | });
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/VipCheck.java:
--------------------------------------------------------------------------------
1 | package com.novip;
2 |
3 | import android.content.Context;
4 |
5 | import com.novip.utils.SharedPrefernceUtils;
6 |
7 | public class VipCheck {
8 |
9 | public static long getVipEnd(Context context){
10 | long v = SharedPrefernceUtils.getInstance(context).getLong("v_end");
11 | if(v == 0){
12 | long d = System.currentTimeMillis()+24*60*60*1000l;
13 | SharedPrefernceUtils.getInstance(context).putLong("v_end",d);
14 | return d;
15 | }else {
16 | return v;
17 | }
18 | }
19 |
20 | public static void addVipEnd(Context context,int days){
21 | long d = System.currentTimeMillis()+days*24*60*60*1000l;
22 | SharedPrefernceUtils.getInstance(context).putLong("v_end",d);
23 | }
24 |
25 | //14个字符长度,13个是时间戳,还有一个是VIP时间(1一周,2一个月,3永久)
26 | public static String encode(String str) {
27 | char[] data = str.toCharArray();
28 | int len = data.length;
29 | for(int i=0;i out_t){
52 | //过期了
53 | state = false;
54 | }else {
55 | switch (p){
56 | case 1:
57 | addVipEnd(context,7);
58 | state = true;
59 | break;
60 | case 2:
61 | addVipEnd(context,30);
62 | state = true;
63 | break;
64 | case 3:
65 | addVipEnd(context,9999);
66 | state = true;
67 | break;
68 | }
69 | }
70 |
71 | }catch (Exception e){
72 | return false;
73 | }
74 |
75 | return state;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/view/IconTextView.java:
--------------------------------------------------------------------------------
1 | package com.novip.view;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.DrawableRes;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.annotation.StringRes;
8 | import android.util.AttributeSet;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.widget.FrameLayout;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 |
15 | import com.bumptech.glide.Glide;
16 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
17 | import com.bumptech.glide.request.RequestOptions;
18 | import com.novip.R;
19 |
20 | public class IconTextView extends FrameLayout {
21 |
22 | private ImageView imageView;
23 | private TextView textView;
24 | public IconTextView(@NonNull Context context) {
25 | this(context,null);
26 | }
27 |
28 | public IconTextView(@NonNull Context context, @Nullable AttributeSet attrs) {
29 | this(context, attrs,0);
30 | }
31 |
32 | public IconTextView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
33 | this(context, attrs, defStyleAttr,0);
34 | }
35 |
36 | public IconTextView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
37 | super(context, attrs, defStyleAttr, defStyleRes);
38 | View view = LayoutInflater.from(context).inflate(R.layout.icon_text_view,this,false);
39 | imageView = view.findViewById(R.id.image);
40 | textView = view.findViewById(R.id.text);
41 | addView(view);
42 | }
43 |
44 | public void setImage(@DrawableRes int id){
45 |
46 | RequestOptions mRequestOptions = RequestOptions.circleCropTransform()
47 | .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)//磁盘缓存
48 | .skipMemoryCache(true);
49 | Glide.with(this).load(id).apply(mRequestOptions).into(imageView);
50 | }
51 |
52 | public void setText(@StringRes int sid){
53 | textView.setText(sid);
54 | }
55 |
56 | public void setImageText(@DrawableRes int id, @StringRes int sid){
57 | setImage(id);
58 | setText(sid);
59 | }
60 |
61 | public void setImageText(CharSequence imgUrl,CharSequence text){
62 | RequestOptions mRequestOptions = RequestOptions.circleCropTransform()
63 | .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)//磁盘缓存
64 | .skipMemoryCache(true);
65 | Glide.with(this).load(imgUrl).apply(mRequestOptions).into(imageView);
66 | textView.setText(text);
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
38 |
48 |
58 |
59 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
22 |
32 |
33 |
34 |
40 |
49 |
56 |
62 |
63 |
64 |
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/view/VipCodeDialog.java:
--------------------------------------------------------------------------------
1 | package com.novip.view;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.support.annotation.NonNull;
7 | import android.support.v7.app.AlertDialog;
8 | import android.view.Gravity;
9 | import android.view.ViewGroup;
10 | import android.widget.EditText;
11 | import android.widget.Toast;
12 |
13 | import com.novip.AppApplication;
14 | import com.novip.Http;
15 | import com.novip.VipCheck;
16 | import com.novip.app.ChangePasswordActivity;
17 |
18 | import java.io.IOException;
19 |
20 | import okhttp3.Call;
21 | import okhttp3.Callback;
22 | import okhttp3.Response;
23 |
24 | public class VipCodeDialog implements Callback {
25 | private AlertDialog dialog;
26 | private VerifyListener listener;
27 | public VipCodeDialog(@NonNull final Context context, final VerifyListener listener) {
28 | final EditText editText = new EditText(context);
29 | this.listener = listener;
30 | editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
31 | editText.setHint("授权码");
32 | editText.setGravity(Gravity.CENTER_HORIZONTAL);
33 | editText.setPadding(0,30,0,30);
34 | dialog = new AlertDialog.Builder(context)
35 | .setTitle("输入授权码")
36 | .setView(editText)
37 | .setPositiveButton("确定", new DialogInterface.OnClickListener() {
38 | @Override
39 | public void onClick(DialogInterface dialog, int which) {
40 | if(AppApplication.getInstance().getUser() == null){
41 | Toast.makeText(context,"请登陆后操作",Toast.LENGTH_SHORT).show();
42 | }else {
43 | Http.checkCode(AppApplication.getInstance().getUser().getPhone(),editText.getText().toString().trim(),VipCodeDialog.this);
44 | }
45 | }
46 | })
47 | .setNegativeButton("取消",null)
48 | .create();
49 | }
50 |
51 | public void show(){
52 | if(dialog != null){
53 | dialog.show();
54 | }
55 | }
56 |
57 | @Override
58 | public void onFailure(Call call, IOException e) {
59 |
60 | if(listener != null){
61 | listener.verify(false);
62 | }
63 | }
64 |
65 | @Override
66 | public void onResponse(Call call, Response response) throws IOException {
67 | if(response.code() == 200){
68 | if(listener != null){
69 | listener.verify(true);
70 | }
71 | }else {
72 | if(listener != null){
73 | listener.verify(false);
74 | }
75 | }
76 | }
77 |
78 | public interface VerifyListener{
79 | void verify(boolean b);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/app/StartActivity.java:
--------------------------------------------------------------------------------
1 | package com.novip.app;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.net.Uri;
7 | import android.os.Process;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.os.Bundle;
10 | import android.widget.Toast;
11 |
12 | import com.alibaba.fastjson.JSON;
13 | import com.novip.AppApplication;
14 | import com.novip.AppPrepare;
15 | import com.novip.Http;
16 | import com.novip.R;
17 | import com.novip.model.Novip;
18 | import com.novip.model.Platform;
19 | import com.novip.model.User;
20 | import com.novip.model.VParser;
21 | import com.novip.model.Version;
22 | import com.novip.utils.DeviceUtils;
23 | import com.novip.utils.LogUtils;
24 | import com.novip.utils.SharedPrefernceUtils;
25 | import com.novip.view.CountDownView;
26 | import com.umeng.analytics.MobclickAgent;
27 |
28 | import org.jsoup.Connection;
29 | import org.jsoup.Jsoup;
30 | import org.jsoup.helper.StringUtil;
31 |
32 | import java.io.IOException;
33 | import java.util.List;
34 |
35 | import okhttp3.Call;
36 | import okhttp3.Callback;
37 | import okhttp3.Response;
38 |
39 | /*
40 | * APP准备工作:
41 | * 1.获取主机IP,端口等基本信息
42 | * 2.检查更新(有更新时强制更新,无更新时到第3步)
43 | * 3.登陆(成功到4,失败到登陆界面)
44 | * 4.获取APP中需要使用到的数据(平台信息、解析线路等)
45 | *
46 | * */
47 | public class StartActivity extends AppCompatActivity implements CountDownView.OnCountDownFinishListener, AppPrepare.AppPrepareCallback {
48 |
49 | private CountDownView countDownView;
50 | private boolean appPrepared = false;
51 | private boolean countDownFinished =false;
52 | @Override
53 | protected void onCreate(Bundle savedInstanceState) {
54 | super.onCreate(savedInstanceState);
55 | setContentView(R.layout.activity_start);
56 | countDownView = findViewById(R.id.cdv);
57 | countDownView.setAddCountDownListener(this);
58 | countDownView.startCountDown();
59 | }
60 |
61 | private void toast(){
62 | runOnUiThread(new Runnable() {
63 | @Override
64 | public void run() {
65 | Toast.makeText(getBaseContext(),"无法连接到服务器",Toast.LENGTH_SHORT).show();
66 | //finish();
67 | }
68 | });
69 |
70 | }
71 | @Override
72 | protected void onStart() {
73 | super.onStart();
74 | new AppPrepare().start(this,this);
75 | }
76 |
77 | @Override
78 | public void countDownFinished() {
79 | countDownFinished = true;
80 | if(appPrepared && countDownFinished){
81 | startActivity(new Intent(this,MainActivity.class));
82 | finish();
83 | }
84 | }
85 |
86 | @Override
87 | public void onPrepared() {
88 | appPrepared = true;
89 | if(appPrepared && countDownFinished){
90 | startActivity(new Intent(this,MainActivity.class));
91 | finish();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/utils/ShareUtils.java:
--------------------------------------------------------------------------------
1 | package com.novip.utils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.os.Environment;
7 | import android.view.View;
8 |
9 | import java.io.File;
10 | import java.util.ArrayList;
11 |
12 | public class ShareUtils {
13 | /**
14 | * 分享文字内容
15 | *
16 | * @param dlgTitle
17 | * 分享对话框标题
18 | * @param subject
19 | * 主题
20 | * @param content
21 | * 分享内容(文字)
22 | */
23 | public static void shareText(Context context,String dlgTitle, String subject, String content) {
24 | if (content == null || "".equals(content)) {
25 | return;
26 | }
27 | Intent intent = new Intent(Intent.ACTION_SEND);
28 | intent.setType("text/plain");
29 | if (subject != null && !"".equals(subject)) {
30 | intent.putExtra(Intent.EXTRA_SUBJECT, subject);
31 | }
32 |
33 | intent.putExtra(Intent.EXTRA_TEXT, content);
34 |
35 | // 设置弹出框标题
36 | if (dlgTitle != null && !"".equals(dlgTitle)) { // 自定义标题
37 | context.startActivity(Intent.createChooser(intent, dlgTitle));
38 | } else { // 系统默认标题
39 | context.startActivity(intent);
40 | }
41 | }
42 |
43 | /**
44 | * 分享图片和文字内容
45 | *
46 | * @param dlgTitle
47 | * 分享对话框标题
48 | * @param subject
49 | * 主题
50 | * @param content
51 | * 分享内容(文字)
52 | * @param uri
53 | * 图片资源URI
54 | */
55 | public static void shareImg(Context context,String dlgTitle, String subject, String content,
56 | Uri uri) {
57 | if (uri == null) {
58 | return;
59 | }
60 | Intent intent = new Intent(Intent.ACTION_SEND);
61 | intent.setType("image/*");
62 | intent.putExtra(Intent.EXTRA_STREAM, uri);
63 | if (subject != null && !"".equals(subject)) {
64 | intent.putExtra(Intent.EXTRA_SUBJECT, subject);
65 | }
66 | if (content != null && !"".equals(content)) {
67 | intent.putExtra(Intent.EXTRA_TEXT, content);
68 | }
69 |
70 | // 设置弹出框标题
71 | if (dlgTitle != null && !"".equals(dlgTitle)) { // 自定义标题
72 | context.startActivity(Intent.createChooser(intent, dlgTitle));
73 | } else { // 系统默认标题
74 | context.startActivity(intent);
75 | }
76 | }
77 |
78 | //分享多张图片
79 | public static void shareMultipleImage(Context context,View view) {
80 | ArrayList uriList = new ArrayList<>();
81 |
82 | String path = Environment.getExternalStorageDirectory() + File.separator;
83 | uriList.add(Uri.fromFile(new File(path+"australia_1.jpg")));
84 | uriList.add(Uri.fromFile(new File(path+"australia_2.jpg")));
85 | uriList.add(Uri.fromFile(new File(path+"australia_3.jpg")));
86 |
87 | Intent shareIntent = new Intent();
88 | shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
89 | shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
90 | shareIntent.setType("image/*");
91 | context.startActivity(Intent.createChooser(shareIntent, "分享到"));
92 | }
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | @[TOC](Android的NoVIP视频解析APP开发完整过程)
2 |
3 | # 开发灵感
4 | 国内现在视频类知名网站主要有:爱奇艺、优酷、腾讯视频、搜狐视频、乐视视频、芒果TV、Bilibili等。这些网站都有各自的付费VIP视频,我虽然很少去看这些视频啦,我主要是看一些新闻类的,这些都是免费的。但是,生活中很多同事、朋友都在追剧,在办公室在学校经常会听到某某有没有XX视频的VIP账号?生活中其实很多人都开通了这些视频网站的VIP。然而,依旧问题严重,因为很多电影&电视剧是版权独家的,只有某个视频站才能观看,那么买的其他站的VIP那不就是无效了吗?当然,对于开发者来说,网上很多浏览器插件可以解决这个问题,比如**Greasy Fork**插件就牛的一逼,各种VIP视频、网盘资源等都不在话下。对于某部分人来说,上班偷偷看看手机不方便看电脑、回家路上看手机,但是手机端并没有这些插件呀。于是,笔者想设计一个APP,让手机端可以方便的查看各种视频,正式这个原因,着手开发了,花了两天时间把APP做出来了,测试能够播放各个站点的VIP视频。下面是APP的源码:
5 |
6 | [Github源代码](https://github.com/JafferLei/NoVIP)
7 |
8 | # 功能需求设计
9 | 1. 解析播放各大站点的VIP视频是核心,对于视频解析来说,整个过程是比较复杂的,笔者查看很多相关资料,各大战点都做了多层的视频链接加密,还做了视频分段处理。笔者也就懒得去做了,直接调用了其他站点的解析地址。
10 | 
11 | 下面是视频解析播放的方法,在进入视频播放也后选择播放线路(部分播放线路可能被和谐了播放不了,可以选择其他的线路),然后点击右下角播放图片按钮会跳转到视频解析播放的页面(笔者就偷懒了,自己不做这部分了,调用的别人现成的)。
12 | 
13 | 2. 界面设计优雅整洁,设计APP时间脚本,各种的图片资源都是网上直接找的,界面设计也用了第三方库,可以加快开发过程。下面两个Material Design资源的网站,大家可以去找到各种精美的界面、图标设计等。
14 | [Material Design图标](https://www.flaticon.com/packs/material-design)
15 | [Material Design综合大站](https://www.uplabs.com/posts/c/android/resources)
16 | 3. 为了丰富功能,添加了广告投放和APP授权功能。另外、还有加入QQ群、分析APP等功能。当然,APP是免费给大家用的,授权码只是给开发者有兴趣的去改进而已。授权码:**1234**
17 | 
18 |
19 | # 代码编写
20 | APP功能需求准备好了,下面就要开始着手编程实现了。
21 | ## 框架搭建
22 | 对于一个APP来说,框架设计占有极其重要的部分,一个APP的编程框架设计好了,以后的开发可以避免很多弯路,也能节省很多的开发时间。很多程序员之所以会是程序猿就是因为在走很多弯路,浪费了大量的时间,导致经常加班加点的工作。在我看来,程序是用来设计的,不是用来干苦力的。在本APP中,为了节省开发周期,很多的工作都没有做,比如网络请求、注解、MVP、MVVM等。只用简单的原生API快速完成功能,代码中的字符串也都是写死的,没有使用xml去配置,在企业的APP是不能这么写的。所以本APP基本是没有框架的,整个APP的代码文件也不超过十个,总代码量不超过2000行,实在是精简的不能再说了。
23 | ## 第三方库引入
24 | 程序中使用部分第三方库,都是行业比较成熟的,经过市场的认证,不用担心出什么问题。下面是gradle中的配置:
25 |
26 | ```
27 | dependencies {
28 | implementation fileTree(include: ['*.jar'], dir: 'libs')
29 | implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
30 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
31 | testImplementation 'junit:junit:4.12'
32 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
34 | implementation 'com.android.support:support-v4:28.0.0-rc02'
35 | implementation 'com.github.bumptech.glide:glide:4.8.0'
36 | implementation 'com.squareup.okhttp3:okhttp:3.11.0'
37 | implementation 'eu.the4thfloor.volley:com.android.volley:2015.05.28'
38 | implementation 'com.alibaba:fastjson:1.2.49'
39 | implementation 'com.youth.banner:banner:1.4.10'
40 | }
41 | ```
42 |
43 | ## 代码编写
44 | 编程过程就不说了,太简单了,Android开发入门的人都能很清晰的看懂代码。这里说一下,对于授权码部分,调用了一个native层函数,用C++编写的,只是为了说明为了安全,部分重要的数据是需要放到C++中做的,不说了,太简单了。下面是所有代码文件:
45 | 
46 |
47 |
48 | # 开源与总结
49 | 整个开发过程耗时2天,刚好这周学校的学生军训,笔者一天也就两节课,可以有大量的时间写这个APP。笔者除了现在学校的课程外,还在准备线上课程,时间比较忙,写这个APP花了两天,周末又要加班准备课程内容了。源代码通过git托管到了github上,有兴趣或者想二次开发的朋友可以去下载。
50 | 1. [github源代码](https://github.com/JafferLei/NoVIP)
51 | 2. [APP下载](https://pan.baidu.com/s/1341k5za08_A0OaqHqW_5RA)
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/AppApplication.java:
--------------------------------------------------------------------------------
1 | package com.novip;
2 |
3 | import android.app.Application;
4 | import android.util.Log;
5 |
6 | import com.novip.model.Novip;
7 | import com.novip.model.Platform;
8 | import com.novip.model.User;
9 | import com.novip.model.VParser;
10 | import com.novip.model.Version;
11 | import com.novip.utils.DeviceUtils;
12 | import com.novip.utils.LogUtils;
13 | import com.novip.utils.SharedPrefernceUtils;
14 | import com.umeng.commonsdk.UMConfigure;
15 |
16 | import java.lang.reflect.Field;
17 | import java.util.List;
18 |
19 | public class AppApplication extends Application {
20 | public static final boolean DEBUG = false;
21 | private User user;
22 | private List vParsers;
23 | private Version version;
24 | private static AppApplication instance;
25 | private Novip novip;
26 | private List platforms;
27 | private String[] filterUrls;
28 |
29 | @Override
30 | public void onCreate() {
31 | super.onCreate();
32 | instance = this;
33 | //SP初始化
34 | SharedPrefernceUtils.getInstance(this);
35 |
36 | //设置LOG开关,默认为false
37 | UMConfigure.setLogEnabled(true);
38 | try {
39 | Class> aClass = Class.forName("com.umeng.commonsdk.UMConfigure");
40 | Field[] fs = aClass.getDeclaredFields();
41 | for (Field f:fs){
42 | Log.e("xxxxxx","ff="+f.getName()+" "+f.getType().getName());
43 | }
44 | } catch (ClassNotFoundException e) {
45 | e.printStackTrace();
46 | }
47 | //初始化组件化基础库, 统计SDK/推送SDK/分享SDK都必须调用此初始化接口
48 | UMConfigure.init(this, "5bc58c00b465f50c1700035e", "常规推广", UMConfigure.DEVICE_TYPE_PHONE,
49 | null);
50 |
51 | }
52 |
53 | public static AppApplication getInstance(){
54 | return instance;
55 | }
56 |
57 | public User getUser() {
58 | return user;
59 | }
60 |
61 | public void setUser(User user) {
62 | if(user!=null){
63 | SharedPrefernceUtils.getInstance(getBaseContext()).putString(
64 | SharedPrefernceUtils.PHONE,user.getPhone()
65 | );
66 | SharedPrefernceUtils.getInstance(getBaseContext()).putString(
67 | SharedPrefernceUtils.PS,user.getPassword()
68 | );
69 | }
70 | this.user = user;
71 | }
72 |
73 | public List getvParsers() {
74 | return vParsers;
75 | }
76 |
77 | public void setvParsers(List vParsers) {
78 | this.vParsers = vParsers;
79 | }
80 |
81 | public Version getVersion() {
82 | return version;
83 | }
84 |
85 | public void setVersion(Version version) {
86 | this.version = version;
87 | }
88 |
89 | public Novip getNovip() {
90 | return novip;
91 | }
92 |
93 | public void setNovip(Novip novip) {
94 | this.novip = novip;
95 | Http.setHost(novip.getHost());
96 | Http.setPort(novip.getPort());
97 | }
98 |
99 | public List getPlatforms() {
100 | return platforms;
101 | }
102 |
103 | public void setPlatforms(List platforms) {
104 | this.platforms = platforms;
105 | }
106 |
107 | public String[] getFilterUrls() {
108 | return filterUrls;
109 | }
110 |
111 | public void setFilterUrls(String[] filterUrls) {
112 | this.filterUrls = filterUrls;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_registe.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
17 |
18 |
25 |
26 |
35 |
36 |
41 |
42 |
45 |
46 |
54 |
55 |
56 |
57 |
60 |
61 |
72 |
73 |
74 |
75 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_mine.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
20 |
24 |
27 |
32 |
42 |
43 |
48 |
53 |
58 |
62 |
67 |
71 |
75 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/web/WebPlayActivity.java:
--------------------------------------------------------------------------------
1 | package com.novip.web;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.webkit.WebChromeClient;
8 | import android.webkit.WebSettings;
9 | import android.webkit.WebView;
10 | import android.webkit.WebViewClient;
11 | import android.widget.ProgressBar;
12 |
13 | import com.novip.R;
14 | import com.novip.app.BaseActivity;
15 |
16 | public class WebPlayActivity extends BaseActivity {
17 | private WebView webView;
18 | private ProgressBar progressBar;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | setContentView(R.layout.activity_web_play);
24 | webView = findViewById(R.id.webview);
25 | progressBar = findViewById(R.id.progress);
26 | setWebView();
27 | webView.loadUrl(getIntent().getStringExtra("url"));
28 | }
29 |
30 | private void setWebView(){
31 |
32 | WebSettings webSettings = webView.getSettings();
33 | //支持缩放,默认为true。
34 | webSettings.setSupportZoom(false);
35 | //调整图片至适合webview的大小
36 | webSettings.setUseWideViewPort(true);
37 | // 缩放至屏幕的大小
38 | webSettings.setLoadWithOverviewMode(true);
39 | //设置默认编码
40 | webSettings.setDefaultTextEncodingName("utf-8");
41 | //设置自动加载图片
42 | webSettings.setLoadsImagesAutomatically(true);
43 | //允许访问文件
44 | webSettings.setAllowFileAccess(true);
45 | webSettings.setUseWideViewPort(true);
46 | //提高渲染的优先级
47 | webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
48 | //支持内容重新布局
49 | webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
50 | //缓存
51 | webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
52 | webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
53 |
54 | webSettings.setUseWideViewPort(true);
55 | webSettings.setDomStorageEnabled(true);
56 | webSettings.setJavaScriptEnabled(true);
57 | //设置浏览器标志
58 | //webSettings.setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36");
59 |
60 | //是否可以后退
61 | webView.canGoBack();
62 | webView.setWebViewClient(new NoADWebViewClent() {
63 | @Override
64 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
65 | //复写shouldOverrideUrlLoading()方法,使得打开网页时不调用系统浏览器, 而是在本WebView中显示
66 | view.loadUrl(url);
67 | return true;
68 | }
69 | @Override
70 | public void onPageFinished(final WebView view, String url) {
71 | // try {
72 | // //延时一段时间等待动态iframe加载完成
73 | // Thread.sleep(2000);
74 | // view.loadUrl("javascript:window.js_interface.showSource(''+"+ "document.getElementsByTagName('html')[0].innerHTML+'');");
75 | // } catch (InterruptedException e) {
76 | // e.printStackTrace();
77 | // }
78 | progressBar.setVisibility(View.GONE);
79 | super.onPageFinished(view,url);
80 | }
81 | });
82 | //加载进度,标题等
83 | webView.setWebChromeClient(new WebChromeClient() {
84 | @Override
85 | public void onProgressChanged(WebView view, int newProgress) {
86 | progressBar.setProgress(newProgress);
87 | }
88 | });
89 |
90 | }
91 |
92 |
93 |
94 | @Override
95 | protected void onDestroy() {
96 | if (webView != null) {
97 | webView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
98 | webView.clearHistory();
99 | ((ViewGroup) webView.getParent()).removeView(webView);
100 | webView.destroy();
101 | webView = null;
102 | }
103 | super.onDestroy();
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
17 |
18 |
25 |
26 |
35 |
36 |
41 |
42 |
45 |
46 |
54 |
55 |
56 |
57 |
60 |
61 |
72 |
73 |
74 |
75 |
84 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_change_password.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
17 |
18 |
25 |
26 |
35 |
36 |
41 |
42 |
45 |
46 |
54 |
55 |
56 |
57 |
60 |
61 |
71 |
72 |
73 |
76 |
77 |
87 |
88 |
89 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator.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 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/utils/DeviceUtils.java:
--------------------------------------------------------------------------------
1 | package com.novip.utils;
2 |
3 | import android.Manifest;
4 | import android.bluetooth.BluetoothAdapter;
5 | import android.content.Context;
6 | import android.content.pm.PackageInfo;
7 | import android.content.pm.PackageManager;
8 | import android.net.wifi.WifiManager;
9 | import android.os.Build;
10 | import android.provider.Settings;
11 | import android.support.v4.app.ActivityCompat;
12 | import android.telephony.TelephonyManager;
13 | import android.util.Log;
14 |
15 | import java.security.MessageDigest;
16 | import java.security.NoSuchAlgorithmException;
17 |
18 | import static android.content.Context.TELEPHONY_SERVICE;
19 |
20 | public class DeviceUtils {
21 |
22 | public static String getUniqueId(Context context) {
23 | String androidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
24 | String id = androidID + Build.SERIAL;
25 | try {
26 | return toMD5(id);
27 | } catch (NoSuchAlgorithmException e) {
28 | e.printStackTrace();
29 | return id;
30 | }
31 | }
32 |
33 | private String getImei(Context context) {
34 | TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
35 | if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
36 | // TODO: Consider calling
37 | // ActivityCompat#requestPermissions
38 | // here to request the missing permissions, and then overriding
39 | // public void onRequestPermissionsResult(int requestCode, String[] permissions,
40 | // int[] grantResults)
41 | // to handle the case where the user grants the permission. See the documentation
42 | // for ActivityCompat#requestPermissions for more details.
43 | return null;
44 | }
45 | String szImei = TelephonyMgr.getDeviceId();
46 | return szImei;
47 | }
48 | private String getAndroidId(Context context){
49 | String m_szAndroidID = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
50 | return m_szAndroidID;
51 | }
52 |
53 | /*
54 | * 返回的结果不正确,全部都返回了固定值:02:00:00:00:00:00
55 | * */
56 | public static String getWlanId(Context context){
57 | WifiManager wm = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
58 | String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
59 | return m_szWLANMAC;
60 | }
61 |
62 | private String getPseudo(){
63 | String m_szDevIDShort = "35" + "/"+//we make this look like a valid IMEI
64 | Build.BOARD.length()%10 +"/"+
65 | Build.BRAND.length()%10 +"/"+
66 | // Build.CPU_ABI.length()%10 +"/"+
67 | Build.DEVICE.length()%10 +"/"+
68 | Build.DISPLAY.length()%10 +"/"+
69 | Build.HOST.length()%10 +"/"+
70 | Build.ID.length()%10 +"/"+
71 | Build.MANUFACTURER.length()%10 +"/"+
72 | Build.MODEL.length()%10 +"/"+
73 | Build.PRODUCT.length()%10 +"/"+
74 | Build.TAGS.length()%10 +"/"+
75 | Build.TYPE.length()%10 +"/"+
76 | Build.USER.length()%10+"/"; //13 digits
77 | return m_szDevIDShort;
78 | }
79 |
80 | private static String toMD5(String text) throws NoSuchAlgorithmException {
81 | //获取摘要器 MessageDigest
82 | MessageDigest messageDigest = MessageDigest.getInstance("MD5");
83 | //通过摘要器对字符串的二进制字节数组进行hash计算
84 | byte[] digest = messageDigest.digest(text.getBytes());
85 |
86 | StringBuilder sb = new StringBuilder();
87 | for (int i = 0; i < digest.length; i++) {
88 | //循环每个字符 将计算结果转化为正整数;
89 | int digestInt = digest[i] & 0xff;
90 | //将10进制转化为较短的16进制
91 | String hexString = Integer.toHexString(digestInt);
92 | //转化结果如果是个位数会省略0,因此判断并补0
93 | if (hexString.length() < 2) {
94 | sb.append(0);
95 | }
96 | //将循环结果添加到缓冲区
97 | sb.append(hexString);
98 | }
99 | //返回整个结果
100 | return sb.toString();
101 | }
102 |
103 |
104 | /**
105 | * 返回当前程序版本号
106 | */
107 | public static int getAppVersionCode(Context context) {
108 | int versioncode = 0;
109 | try {
110 | PackageManager pm = context.getPackageManager();
111 | PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
112 | // versionName = pi.versionName;
113 | versioncode = pi.versionCode;
114 | } catch (Exception e) {
115 | Log.e("VersionInfo", "Exception", e);
116 | }
117 | return versioncode;
118 | }
119 |
120 | /**
121 | * 返回当前程序版本名
122 | */
123 | public static String getAppVersionName(Context context) {
124 | String versionName=null;
125 | try {
126 | PackageManager pm = context.getPackageManager();
127 | PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
128 | versionName = pi.versionName;
129 | } catch (Exception e) {
130 | Log.e("VersionInfo", "Exception", e);
131 | }
132 | return versionName;
133 | }
134 |
135 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/Http.java:
--------------------------------------------------------------------------------
1 | package com.novip;
2 |
3 | import java.io.IOException;
4 | import java.util.concurrent.TimeUnit;
5 |
6 | import okhttp3.Callback;
7 | import okhttp3.HttpUrl;
8 | import okhttp3.OkHttpClient;
9 | import okhttp3.Request;
10 | import okhttp3.Response;
11 |
12 | public class Http {
13 |
14 | private static OkHttpClient client;
15 |
16 | private static String host;
17 | private static int port;
18 | private Http(){ }
19 |
20 | private static synchronized OkHttpClient getClient(){
21 | if(client == null){
22 | client = new OkHttpClient.Builder()
23 | .readTimeout(30, TimeUnit.SECONDS)
24 | .build();
25 | }
26 | return client;
27 | }
28 |
29 | public static void login(String phone,String password,Callback cb){
30 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
31 | .addPathSegment("novip")
32 | .addPathSegment("user")
33 | .addPathSegment("login")
34 | .addEncodedQueryParameter("phone",phone)
35 | .addEncodedQueryParameter("password",password).build();
36 | Request request = new Request.Builder().url(url).build();
37 | getClient().newCall(request).enqueue(cb);
38 | }
39 |
40 | public static void registe(String phone,String password,String deviceId,Callback cb){
41 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
42 | .addPathSegment("novip")
43 | .addPathSegment("user")
44 | .addPathSegment("registe")
45 | .addEncodedQueryParameter("phone",phone)
46 | .addEncodedQueryParameter("password",password)
47 | .addEncodedQueryParameter("device_id",deviceId).build();
48 | Request request = new Request.Builder().url(url).build();
49 | getClient().newCall(request).enqueue(cb);
50 | }
51 |
52 | public static void getVParser(Callback cb){
53 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
54 | .addPathSegment("novip")
55 | .addPathSegment("video")
56 | .addPathSegment("get_v_parser")
57 | .build();
58 | Request request = new Request.Builder().url(url).build();
59 | getClient().newCall(request).enqueue(cb);
60 | }
61 |
62 | public static void checkUpdate(Callback cb){
63 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
64 | .addPathSegment("novip")
65 | .addPathSegment("update")
66 | .addPathSegment("check")
67 | .build();
68 | Request request = new Request.Builder().url(url).build();
69 | getClient().newCall(request).enqueue(cb);
70 | }
71 |
72 |
73 | public static void checkCode(String phone,String code,Callback cb){
74 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
75 | .addPathSegment("novip")
76 | .addPathSegment("vip")
77 | .addPathSegment("check_code")
78 | .addEncodedQueryParameter("phone", phone)
79 | .addEncodedQueryParameter("code", code)
80 | .build();
81 | Request request = new Request.Builder().url(url).build();
82 | getClient().newCall(request).enqueue(cb);
83 | }
84 |
85 | public static Response getNovip() throws IOException{
86 | Request request = new Request.Builder().url("http://novip.oss-cn-shenzhen.aliyuncs.com/novip.json").build();
87 | return getClient().newCall(request).execute();
88 | }
89 |
90 |
91 | public static void getPlatforms(Callback cb){
92 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
93 | .addPathSegment("novip")
94 | .addPathSegment("video")
95 | .addPathSegment("get_platform")
96 | .build();
97 | Request request = new Request.Builder().url(url).build();
98 | getClient().newCall(request).enqueue(cb);
99 | }
100 |
101 |
102 | public static void getMainTabAD(Callback cb){
103 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
104 | .addPathSegment("novip")
105 | .addPathSegment("ad")
106 | .addPathSegment("main_tab_ad")
107 | .build();
108 | Request request = new Request.Builder().url(url).build();
109 | getClient().newCall(request).enqueue(cb);
110 | }
111 |
112 | public static void getAdUrl(Callback cb){
113 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
114 | .addPathSegment("novip")
115 | .addPathSegment("ad")
116 | .addPathSegment("ad_filter")
117 | .build();
118 | Request request = new Request.Builder().url(url).build();
119 | getClient().newCall(request).enqueue(cb);
120 | }
121 | public static void changePassword(String phone,String password,String new_password,Callback cb){
122 | HttpUrl url = new HttpUrl.Builder().host(host).scheme("http").port(port)
123 | .addPathSegment("novip")
124 | .addPathSegment("user")
125 | .addPathSegment("change_password")
126 | .addEncodedQueryParameter("phone",phone)
127 | .addEncodedQueryParameter("password",password)
128 | .addEncodedQueryParameter("new_password",new_password)
129 | .build();
130 | Request request = new Request.Builder().url(url).build();
131 | getClient().newCall(request).enqueue(cb);
132 | }
133 |
134 | public static String getHost() {
135 | return host;
136 | }
137 |
138 | public static void setHost(String host) {
139 | Http.host = host;
140 | }
141 |
142 | public static int getPort() {
143 | return port;
144 | }
145 |
146 | public static void setPort(int port) {
147 | Http.port = port;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/view/CountDownView.java:
--------------------------------------------------------------------------------
1 | package com.novip.view;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.ValueAnimator;
6 | import android.content.Context;
7 | import android.content.res.TypedArray;
8 | import android.graphics.Canvas;
9 | import android.graphics.Paint;
10 | import android.graphics.RectF;
11 | import android.support.annotation.Nullable;
12 | import android.util.AttributeSet;
13 | import android.view.View;
14 | import android.view.animation.LinearInterpolator;
15 |
16 | import com.novip.R;
17 | import com.novip.utils.DensityUtils;
18 |
19 | public class CountDownView extends View {
20 | //圆轮颜色
21 | private int mRingColor;
22 | //圆轮宽度
23 | private float mRingWidth;
24 | //圆轮进度值文本大小
25 | private int mRingProgessTextSize;
26 | //宽度
27 | private int mWidth;
28 | //高度
29 | private int mHeight;
30 | private Paint mPaint;
31 | //圆环的矩形区域
32 | private RectF mRectF;
33 | //
34 | private int mProgessTextColor;
35 | private int mCountdownTime;
36 | private float mCurrentProgress;
37 | private OnCountDownFinishListener mListener;
38 |
39 | public CountDownView(Context context) {
40 | this(context, null);
41 | }
42 |
43 | public CountDownView(Context context, @Nullable AttributeSet attrs) {
44 | this(context, attrs, 0);
45 | }
46 |
47 | public CountDownView(Context context, AttributeSet attrs, int defStyleAttr) {
48 | super(context, attrs, defStyleAttr);
49 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CountDownView);
50 | mRingColor = a.getColor(R.styleable.CountDownView_ringColor, context.getResources().getColor(android.R.color.white));
51 | mRingWidth = a.getFloat(R.styleable.CountDownView_ringWidth, 6);
52 | mRingProgessTextSize = a.getDimensionPixelSize(R.styleable.CountDownView_progressTextSize, DensityUtils.sp2px(context, 10));
53 | mProgessTextColor = a.getColor(R.styleable.CountDownView_progressTextColor, context.getResources().getColor(android.R.color.white));
54 | mCountdownTime = a.getInteger(R.styleable.CountDownView_countdownTime, 3);
55 | a.recycle();
56 | mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
57 | mPaint.setAntiAlias(true);
58 | this.setWillNotDraw(false);
59 | }
60 |
61 |
62 | public void setCountdownTime(int mCountdownTime) {
63 | this.mCountdownTime = mCountdownTime;
64 | }
65 |
66 | @Override
67 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
68 | super.onLayout(changed, left, top, right, bottom);
69 | mWidth = 2 * getMeasuredWidth() / 3;
70 | mHeight = 2 * getMeasuredHeight() / 3;
71 | mRectF = new RectF(0 + mRingWidth / 3, 0 + mRingWidth / 3,
72 | mWidth - mRingWidth / 3, mHeight - mRingWidth / 3);
73 | }
74 |
75 | @Override
76 | protected void onDraw(Canvas canvas) {
77 | super.onDraw(canvas);
78 | /**
79 | *圆环
80 | */
81 | //颜色
82 | mPaint.setColor(mRingColor);
83 | //空心
84 | mPaint.setStyle(Paint.Style.STROKE);
85 | //宽度
86 | mPaint.setStrokeWidth(mRingWidth);
87 | canvas.drawArc(mRectF, -90, mCurrentProgress - 360, false, mPaint);
88 |
89 | //绘制圆形,此处绘制的是图中红色区域
90 | Paint circlePaint=new Paint();
91 | circlePaint.setAntiAlias(true);
92 | circlePaint.setColor(getResources().getColor(R.color.gray_7d7d7d));
93 | circlePaint.setAlpha(180);
94 | canvas.drawCircle(50,50,(mWidth/2-6),circlePaint);
95 |
96 | //绘制文本,可以根据需求进行更改,例如倒计时几秒
97 | Paint textPaint = new Paint();
98 | textPaint.setAntiAlias(true);
99 | textPaint.setTextAlign(Paint.Align.CENTER);
100 | // String text = mCountdownTime - (int) (mCurrentProgress / 360f * mCountdownTime) + "";
101 | String text = "跳过";
102 | textPaint.setTextSize(mRingProgessTextSize);
103 | textPaint.setColor(mProgessTextColor);
104 |
105 | //文字居中显示
106 | Paint.FontMetricsInt fontMetrics = textPaint.getFontMetricsInt();
107 | int baseline = (int) ((mRectF.bottom + mRectF.top - fontMetrics.bottom - fontMetrics.top) / 2);
108 | canvas.drawText(text, mRectF.centerX(), baseline, textPaint);
109 |
110 |
111 | }
112 |
113 | private ValueAnimator getValA(long countdownTime) {
114 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 100);
115 | valueAnimator.setDuration(countdownTime);
116 | valueAnimator.setInterpolator(new LinearInterpolator());
117 | valueAnimator.setRepeatCount(0);
118 | return valueAnimator;
119 | }
120 |
121 | /**
122 | * 开始倒计时
123 | */
124 | public void startCountDown() {
125 | setClickable(false);
126 | ValueAnimator valueAnimator = getValA(mCountdownTime * 1000);
127 | valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
128 | @Override
129 | public void onAnimationUpdate(ValueAnimator animation) {
130 | float i = Float.valueOf(String.valueOf(animation.getAnimatedValue()));
131 | mCurrentProgress = (int) (360 * (i / 100f));
132 | invalidate();
133 | }
134 | });
135 | valueAnimator.start();
136 | valueAnimator.addListener(new AnimatorListenerAdapter() {
137 | @Override
138 | public void onAnimationEnd(Animator animation) {
139 | super.onAnimationEnd(animation);
140 | //倒计时结束回调
141 | if (mListener != null) {
142 | mListener.countDownFinished();
143 | }
144 | setClickable(true);
145 | }
146 |
147 | });
148 | }
149 | //倒计时监听,可在countDownFinished()方法中进行倒计时结束后的逻辑
150 | public void setAddCountDownListener(OnCountDownFinishListener mListener) {
151 | this.mListener = mListener;
152 | }
153 |
154 | public interface OnCountDownFinishListener {
155 | void countDownFinished();
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
23 | #---------------------------------基本指令区----------------------------------
24 | -optimizationpasses 5
25 | -dontskipnonpubliclibraryclassmembers
26 | -printmapping proguardMapping.txt
27 | -optimizations !code/simplification/cast,!field/*,!class/merging/*
28 | -keepattributes *Annotation*,InnerClasses
29 | -keepattributes Signature
30 | -keepattributes SourceFile,LineNumberTable
31 | #---------------------------------默认保留区---------------------------------
32 | #继承activity,application,service,broadcastReceiver,contentprovider....不进行混淆
33 | -keep public class * extends android.app.Activity
34 | -keep public class * extends android.app.Application
35 | -keep public class * extends android.support.multidex.MultiDexApplication
36 | -keep public class * extends android.app.Service
37 | -keep public class * extends android.content.BroadcastReceiver
38 | -keep public class * extends android.content.ContentProvider
39 | -keep public class * extends android.app.backup.BackupAgentHelper
40 | -keep public class * extends android.preference.Preference
41 | -keep public class * extends android.view.View
42 | -keep public class com.android.vending.licensing.ILicensingService
43 | -keep class android.support.** {*;}
44 |
45 | -keep public class * extends android.view.View{
46 | *** get*();
47 | void set*(***);
48 | public (android.content.Context);
49 | public (android.content.Context, android.util.AttributeSet);
50 | public (android.content.Context, android.util.AttributeSet, int);
51 | }
52 | -keepclasseswithmembers class * {
53 | public (android.content.Context, android.util.AttributeSet);
54 | public (android.content.Context, android.util.AttributeSet, int);
55 | }
56 | #这个主要是在layout 中写的onclick方法android:onclick="onClick",不进行混淆
57 | -keepclassmembers class * extends android.app.Activity {
58 | public void *(android.view.View);
59 | }
60 |
61 | -keepclassmembers class * implements java.io.Serializable {
62 | static final long serialVersionUID;
63 | private static final java.io.ObjectStreamField[] serialPersistentFields;
64 | private void writeObject(java.io.ObjectOutputStream);
65 | private void readObject(java.io.ObjectInputStream);
66 | java.lang.Object writeReplace();
67 | java.lang.Object readResolve();
68 | }
69 | -keep class **.R$* {
70 | *;
71 | }
72 |
73 | -keepclassmembers class * {
74 | void *(*Event);
75 | }
76 |
77 | -keepclassmembers enum * {
78 | public static **[] values();
79 | public static ** valueOf(java.lang.String);
80 | }
81 | -keep class * implements android.os.Parcelable {
82 | public static final android.os.Parcelable$Creator *;
83 | }
84 | #// natvie 方法不混淆
85 | -keepclasseswithmembernames class * {
86 | native ;
87 | }
88 |
89 | #保持 Parcelable 不被混淆
90 | -keep class * implements android.os.Parcelable {
91 | public static final android.os.Parcelable$Creator *;
92 | }
93 | #---------------------------------webview------------------------------------
94 | -keepclassmembers class fqcn.of.javascript.interface.for.Webview {
95 | public *;
96 | }
97 | -keepclassmembers class * extends android.webkit.WebViewClient {
98 | public void *(android.webkit.WebView, java.lang.String, android.graphics.Bitmap);
99 | public boolean *(android.webkit.WebView, java.lang.String);
100 | }
101 | -keepclassmembers class * extends android.webkit.WebViewClient {
102 | public void *(android.webkit.WebView, jav.lang.String);
103 | }
104 |
105 | #---------------------------------实体类---------------------------------
106 | -keep class com.novip.model.** { *; }
107 |
108 | # support-v7
109 | -dontwarn android.support.v7.**
110 | -keep class android.support.v7.internal.** { *; }
111 | -keep interface android.support.v7.internal.** { *; }
112 | -keep class android.support.v7.** { *; }
113 |
114 | # support design
115 | #@link http://stackoverflow.com/a/31028536
116 | -dontwarn android.support.design.**
117 | -keep class android.support.design.** { *; }
118 | -keep interface android.support.design.** { *; }
119 | -keep public class android.support.design.R$* { *; }
120 |
121 | # glide 的混淆代码
122 | -keep public class * implements com.bumptech.glide.module.GlideModule
123 | -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
124 | **[] $VALUES;
125 | public *;
126 | }
127 | # banner 的混淆代码
128 | -keep class com.youth.banner.** {
129 | *;
130 | }
131 |
132 | #fastjson
133 | -keepnames class * implements java.io.Serializable
134 | -keep public class * implements java.io.Serializable {
135 | public *;
136 | }
137 | -keepclassmembers class * implements java.io.Serializable {
138 | static final long serialVersionUID;
139 | private static final java.io.ObjectStreamField[] serialPersistentFields;
140 | !static !transient ;
141 | private void writeObject(java.io.ObjectOutputStream);
142 | private void readObject(java.io.ObjectInputStream);
143 | java.lang.Object writeReplace();
144 | java.lang.Object readResolve();
145 | }
146 |
147 | # FastJson 混淆代码
148 | -dontwarn com.alibaba.fastjson.**
149 | -keep class com.alibaba.fastjson.** { *; }
150 | -keepattributes Signature
151 | -keepattributes *Annotation*
152 |
153 | #OKhttp3
154 | -dontwarn com.squareup.okhttp3.**
155 | -keep class com.squareup.okhttp3.** { *;}
156 | -dontwarn okio.**
157 |
158 | #友盟
159 | -keepclassmembers class * {
160 | public (org.json.JSONObject);
161 | }
162 | -keep public class com.novip.R$*{
163 | public static final int *;
164 | }
165 | -keepclassmembers enum * {
166 | public static **[] values(); public static ** valueOf(java.lang.String);
167 | }
168 |
169 | #jsoup
170 | -dontwarn org.jsoup.**
171 | -keep class org.jsoup.**{*;}
172 | -keeppackagenames org.jsoup.nodes
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/app/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.novip.app;
2 |
3 | import android.Manifest;
4 | import android.app.AlertDialog;
5 | import android.content.DialogInterface;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager;
8 | import android.content.res.Resources;
9 | import android.net.Uri;
10 | import android.os.Build;
11 | import android.os.Process;
12 | import android.support.v4.app.ActivityCompat;
13 | import android.support.v4.app.Fragment;
14 | import android.support.v4.app.FragmentManager;
15 | import android.support.v4.app.FragmentPagerAdapter;
16 | import android.support.v4.content.ContextCompat;
17 | import android.support.v4.view.ViewPager;
18 | import android.support.v7.app.AppCompatActivity;
19 | import android.os.Bundle;
20 | import android.view.KeyEvent;
21 | import android.widget.RadioButton;
22 | import android.widget.RadioGroup;
23 | import android.widget.Toast;
24 |
25 | import com.alibaba.fastjson.JSON;
26 | import com.novip.AppApplication;
27 | import com.novip.Http;
28 | import com.novip.R;
29 | import com.novip.R;
30 | import com.novip.model.User;
31 | import com.novip.model.VParser;
32 | import com.novip.model.Version;
33 | import com.novip.utils.DeviceUtils;
34 | import com.novip.utils.LogUtils;
35 | import com.novip.utils.SharedPrefernceUtils;
36 | import com.umeng.analytics.MobclickAgent;
37 |
38 | import org.jsoup.helper.StringUtil;
39 |
40 | import java.io.IOException;
41 | import java.util.ArrayList;
42 | import java.util.List;
43 |
44 | import okhttp3.Call;
45 | import okhttp3.Callback;
46 | import okhttp3.Response;
47 |
48 | public class MainActivity extends BaseActivity implements
49 | RadioGroup.OnCheckedChangeListener,
50 | OnFragmentInteractionListener, ViewPager.OnPageChangeListener {
51 |
52 | // Used to load the 'native-lib' library on application startup.
53 |
54 | private RadioGroup radioGroup;
55 | private ViewPager viewPager;
56 | private RadioButton radioButton0;
57 | private RadioButton radioButton1;
58 |
59 |
60 | @Override
61 | protected void onCreate(Bundle savedInstanceState) {
62 | super.onCreate(savedInstanceState);
63 |
64 | setContentView(R.layout.activity_main);
65 | radioGroup = findViewById(R.id.ll);
66 | viewPager = findViewById(R.id.viewpager);
67 | radioButton0 = findViewById(R.id.radio0);
68 | radioButton1 = findViewById(R.id.radio1);
69 | MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager());
70 | viewPager.setAdapter(adapter);
71 | viewPager.setCurrentItem(0);
72 | viewPager.addOnPageChangeListener(this);
73 |
74 |
75 | radioGroup.setOnCheckedChangeListener(this);
76 |
77 | }
78 |
79 | @Override
80 | public void onCheckedChanged(RadioGroup group, int checkedId) {
81 | switch (checkedId){
82 | case R.id.radio0:
83 | viewPager.setCurrentItem(0);
84 | radioButton0.setTextColor(getResources().getColor(android.R.color.white));
85 | radioButton1.setTextColor(getResources().getColor(android.R.color.black));
86 | break;
87 | case R.id.radio1:
88 | viewPager.setCurrentItem(1);
89 | radioButton1.setTextColor(getResources().getColor(android.R.color.white));
90 | radioButton0.setTextColor(getResources().getColor(android.R.color.black));
91 | break;
92 | }
93 | }
94 |
95 | @Override
96 | public void onFragmentInteraction(Uri uri) {
97 |
98 | }
99 |
100 | @Override
101 | public void onPageScrolled(int i, float v, int i1) {
102 |
103 | }
104 |
105 | @Override
106 | public void onPageSelected(int i) {
107 | //页面切换调研
108 | switch (i){
109 | case 0:
110 | radioButton0.setTextColor(getResources().getColor(android.R.color.white));
111 | radioButton1.setTextColor(getResources().getColor(android.R.color.black));
112 | radioButton0.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
113 | radioButton1.setBackgroundColor(getResources().getColor(android.R.color.white));
114 | break;
115 | case 1:
116 | radioButton1.setTextColor(getResources().getColor(android.R.color.white));
117 | radioButton0.setTextColor(getResources().getColor(android.R.color.black));
118 | radioButton1.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
119 | radioButton0.setBackgroundColor(getResources().getColor(android.R.color.white));
120 | break;
121 | }
122 | }
123 |
124 | @Override
125 | protected void onStart() {
126 | super.onStart();
127 | onPageSelected(0);
128 |
129 | if (Build.VERSION.SDK_INT >= 23) {
130 | int checkWriteStoragePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
131 | if(checkWriteStoragePermission != PackageManager.PERMISSION_GRANTED){
132 | //没有权限,需要申请
133 | ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE},1);
134 | }
135 | }else{
136 | //有权限
137 | }
138 |
139 |
140 |
141 | }
142 |
143 | @Override
144 | public void onPageScrollStateChanged(int i) {
145 |
146 | }
147 |
148 | @Override
149 | public boolean onKeyDown(int keyCode, KeyEvent event) {
150 | if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
151 | Intent intent = new Intent();// 创建Intent对象
152 | intent.setAction(Intent.ACTION_MAIN);// 设置Intent动作
153 | intent.addCategory(Intent.CATEGORY_HOME);// 设置Intent种类
154 | startActivity(intent);// 将Intent传递给Activity
155 | return true;
156 | }
157 | return super.onKeyDown(keyCode, event);
158 | }
159 |
160 | private class MyPagerAdapter extends FragmentPagerAdapter{
161 |
162 | private List fragmentList;
163 | public MyPagerAdapter(FragmentManager fm) {
164 | super(fm);
165 | fragmentList = new ArrayList<>();
166 | MainFragment f = new MainFragment();
167 | MineFragment m = new MineFragment();
168 | fragmentList.add(f);
169 | fragmentList.add(m);
170 | }
171 |
172 | @Override
173 | public Fragment getItem(int i) {
174 | return fragmentList.get(i);
175 | }
176 |
177 | @Override
178 | public int getCount() {
179 | return fragmentList.size();
180 | }
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/web/WebViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.novip.web;
2 |
3 | import android.content.DialogInterface;
4 | import android.content.Intent;
5 | import android.support.v7.app.AlertDialog;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.os.Bundle;
8 | import android.view.KeyEvent;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.webkit.WebChromeClient;
12 | import android.webkit.WebSettings;
13 | import android.webkit.WebView;
14 | import android.webkit.WebViewClient;
15 | import android.widget.ProgressBar;
16 | import android.widget.TextView;
17 |
18 | import com.alibaba.fastjson.JSON;
19 | import com.novip.AppApplication;
20 | import com.novip.Http;
21 | import com.novip.R;
22 | import com.novip.app.BaseActivity;
23 | import com.novip.model.VParser;
24 | import com.novip.utils.SharedPrefernceUtils;
25 | import com.novip.app.VipChannel;
26 |
27 | import java.io.IOException;
28 | import java.util.ArrayList;
29 | import java.util.List;
30 |
31 | import okhttp3.Call;
32 | import okhttp3.Callback;
33 | import okhttp3.Response;
34 |
35 | import static android.view.KeyEvent.KEYCODE_BACK;
36 |
37 | public class WebViewActivity extends BaseActivity implements View.OnClickListener {
38 | private WebView webView;
39 | TextView tv_title;
40 | TextView tv_channel;
41 | ProgressBar progressBar;
42 | private int channel = 0;//解析通道号
43 |
44 | @Override
45 | protected void onCreate(Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | setContentView(R.layout.activity_web_view);
48 | webView = findViewById(R.id.webview);
49 | tv_title = findViewById(R.id.title);
50 | tv_channel = findViewById(R.id.channel);
51 | progressBar = findViewById(R.id.progress);
52 | findViewById(R.id.image).setOnClickListener(this);
53 | findViewById(R.id.channel).setOnClickListener(this);
54 | tv_channel.setOnClickListener(this);
55 | setWebView();
56 | webView.loadUrl(getIntent().getStringExtra("url"));
57 | // webView.loadUrl("http://api.bbbbbb.me/yunjx/?url=https://www.iqiyi.com/v_19rr7p19oc.html");
58 | //webView.loadUrl("http://jx.618g.com/?url=https://v.qq.com/x/cover/wi8e2p5kirdaf3j.html");
59 |
60 | if(AppApplication.getInstance().getvParsers() == null){
61 | checkVideoParser();
62 | }else {
63 | setChannel(SharedPrefernceUtils.getInstance(this).getInt(SharedPrefernceUtils.KEY_CHANNEL));
64 | }
65 | }
66 |
67 | private void setWebView() {
68 | WebSettings webSettings = webView.getSettings();
69 | //支持缩放,默认为true。
70 | webSettings.setSupportZoom(false);
71 | //调整图片至适合webview的大小
72 | webSettings.setUseWideViewPort(true);
73 | // 缩放至屏幕的大小
74 | webSettings.setLoadWithOverviewMode(true);
75 | //设置默认编码
76 | webSettings.setDefaultTextEncodingName("utf-8");
77 | //设置自动加载图片
78 | webSettings.setLoadsImagesAutomatically(true);
79 | //允许访问文件
80 | webSettings.setAllowFileAccess(true);
81 | webSettings.setUseWideViewPort(true);
82 | //提高渲染的优先级
83 | webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
84 | //支持内容重新布局
85 | webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
86 | //缓存
87 | webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
88 | webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
89 |
90 | webSettings.setUseWideViewPort(true);
91 | webSettings.setDomStorageEnabled(true);
92 | webSettings.setJavaScriptEnabled(true);
93 | //是否可以后退
94 | webView.canGoBack();
95 | webView.setWebViewClient(new WebViewClient() {
96 | @Override
97 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
98 | if(url.startsWith("http") || url.startsWith("https")){
99 | //复写shouldOverrideUrlLoading()方法,使得打开网页时不调用系统浏览器, 而是在本WebView中显示
100 | view.loadUrl(url);
101 | return true;
102 | }else {
103 | //一些网页调用了第三方应用,比如支付宝支付,微信支付等,这些功能在webview中是会出现错误的
104 | //可以在这里跳转到浏览器浏览url或者什么都不做
105 | return true;
106 | }
107 |
108 |
109 | }
110 | });
111 | //加载进度,标题等
112 | webView.setWebChromeClient(new WebChromeClient() {
113 | @Override
114 | public void onProgressChanged(WebView view, int newProgress) {
115 | progressBar.setProgress(newProgress);
116 | }
117 |
118 | @Override
119 | public void onReceivedTitle(WebView view, String title) {
120 | tv_title.setText(title);
121 | }
122 | });
123 |
124 | }
125 |
126 | public void setChannel(int channel) {
127 | if(channel >=0 && channel < AppApplication.getInstance().getvParsers().size()){
128 | this.channel = channel;
129 | tv_channel.setText("当前线路:" + AppApplication.getInstance().getvParsers().get(channel).getNick_name());
130 | SharedPrefernceUtils.getInstance(this).putInt(SharedPrefernceUtils.KEY_CHANNEL, channel);
131 | }
132 |
133 | }
134 | private void checkVideoParser(){
135 | Http.getVParser(new Callback() {
136 | @Override
137 | public void onFailure(Call call, IOException e) {
138 |
139 | }
140 |
141 | @Override
142 | public void onResponse(Call call, Response response) throws IOException {
143 | if(response .code() == 200){
144 | List vParsers = JSON.parseArray(response.body().string(),VParser.class);
145 | AppApplication.getInstance().setvParsers(vParsers);
146 | }
147 | }
148 | });
149 | }
150 | @Override
151 | public void onClick(View v) {
152 | switch (v.getId()) {
153 | case R.id.channel:
154 | //线路选择
155 |
156 | if(AppApplication.getInstance().getvParsers() == null){
157 | checkVideoParser();
158 | return;
159 | }
160 | final String[] lines = new String[AppApplication.getInstance().getvParsers().size()];
161 | for(int i=0;i 4;
196 | }
197 |
198 | /**
199 | * Shows the progress UI and hides the login form.
200 | */
201 | @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
202 | private void showProgress(final boolean show) {
203 | // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
204 | // for very easy animations. If available, use these APIs to fade-in
205 | // the progress spinner.
206 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
207 | int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
208 |
209 | mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
210 | mLoginFormView.animate().setDuration(shortAnimTime).alpha(
211 | show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
212 | @Override
213 | public void onAnimationEnd(Animator animation) {
214 | mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
215 | }
216 | });
217 |
218 | mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
219 | mProgressView.animate().setDuration(shortAnimTime).alpha(
220 | show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
221 | @Override
222 | public void onAnimationEnd(Animator animation) {
223 | mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
224 | }
225 | });
226 | } else {
227 | // The ViewPropertyAnimator APIs are not available, so simply show
228 | // and hide the relevant UI components.
229 | mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
230 | mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
231 | }
232 | }
233 |
234 |
235 | @Override
236 | public void onClick(View v) {
237 | if(v.getId() == R.id.registe){
238 | startActivity(new Intent(this,RegisteActivity.class));
239 | finish();
240 | }
241 | }
242 |
243 | @Override
244 | public void onPrepared() {
245 | startActivity(new Intent(this,MainActivity.class));
246 | finish();
247 | }
248 | }
249 |
250 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/AppPrepare.java:
--------------------------------------------------------------------------------
1 | package com.novip;
2 |
3 | import android.app.Activity;
4 | import android.app.AlertDialog;
5 | import android.content.Context;
6 | import android.content.DialogInterface;
7 | import android.content.Intent;
8 | import android.net.Uri;
9 | import android.os.Process;
10 | import android.support.annotation.NonNull;
11 | import android.support.annotation.Nullable;
12 | import android.widget.Toast;
13 |
14 | import com.alibaba.fastjson.JSON;
15 | import com.novip.app.LoginActivity;
16 | import com.novip.app.MainActivity;
17 | import com.novip.app.StartActivity;
18 | import com.novip.model.AdUrl;
19 | import com.novip.model.Novip;
20 | import com.novip.model.Platform;
21 | import com.novip.model.User;
22 | import com.novip.model.VParser;
23 | import com.novip.model.Version;
24 | import com.novip.utils.DeviceUtils;
25 | import com.novip.utils.LogUtils;
26 | import com.novip.utils.SharedPrefernceUtils;
27 | import com.umeng.analytics.MobclickAgent;
28 |
29 | import org.jsoup.helper.StringUtil;
30 |
31 | import java.io.IOException;
32 | import java.util.List;
33 |
34 | import okhttp3.Call;
35 | import okhttp3.Callback;
36 | import okhttp3.Response;
37 |
38 | public class AppPrepare {
39 |
40 | private Activity context;
41 | private AppPrepareCallback cb;
42 |
43 | public interface AppPrepareCallback{
44 | void onPrepared();
45 | }
46 |
47 | private void isAppprepared(){
48 | if(AppApplication.getInstance().getVersion() != null &&
49 | AppApplication.getInstance().getvParsers() != null &&
50 | AppApplication.getInstance().getNovip() != null &&
51 | AppApplication.getInstance().getUser() != null &&
52 | AppApplication.getInstance().getPlatforms() != null &&
53 | AppApplication.getInstance().getFilterUrls() != null){
54 | cb.onPrepared();
55 | }
56 | }
57 |
58 | public void start(Activity context, @NonNull AppPrepareCallback cb){
59 | this.context = context;
60 | this.cb = cb;
61 | step1_checkServer();
62 | }
63 |
64 | private void step1_checkServer(){
65 |
66 | new Thread(new Runnable() {
67 | @Override
68 | public void run() {
69 | try {
70 | Novip novip;
71 | long ll = SharedPrefernceUtils.getInstance(context).getLong("novip_date");
72 | long period = System.currentTimeMillis() - ll;
73 | if(period > 24*60*60*1000){
74 | Response response = Http.getNovip();
75 | String json = response.body().string();
76 | LogUtils.D("下载",json);
77 | novip = JSON.parseObject(json, Novip.class);
78 | SharedPrefernceUtils.getInstance(context).putString("novip",json);
79 | SharedPrefernceUtils.getInstance(context).putLong("novip_date",System.currentTimeMillis());
80 |
81 | }else {
82 | LogUtils.D("下载","使用本地数据");
83 | String s = SharedPrefernceUtils.getInstance(context).getString("novip");
84 | novip = JSON.parseObject(s, Novip.class);
85 | }
86 | if(novip != null){
87 | AppApplication.getInstance().setNovip(novip);
88 | step2_checkUpdate();
89 | }else {
90 | LogUtils.D("无法获取主机IP");
91 | }
92 |
93 | } catch (IOException e) {
94 | e.printStackTrace();
95 | }
96 | }
97 | }).start();
98 | }
99 |
100 |
101 | private void step3_checkLogin(){
102 | if(AppApplication.getInstance().getUser() != null){
103 | step4_checkParser_Platform();
104 | return;
105 | }
106 | String phone = SharedPrefernceUtils.getInstance(context).getString(SharedPrefernceUtils.PHONE);
107 | String ps = SharedPrefernceUtils.getInstance(context).getString(SharedPrefernceUtils.PS);
108 | if(!StringUtil.isBlank(phone) &&! StringUtil.isBlank(ps)){
109 | //有登陆记录,再次登陆
110 | Http.login(phone, ps, new Callback() {
111 | @Override
112 | public void onFailure(Call call, IOException e) {
113 | }
114 |
115 | @Override
116 | public void onResponse(Call call, Response response) throws IOException {
117 | if(response.code() == 200){
118 | User user = JSON.parseObject(response.body().string(), User.class);
119 | LogUtils.D("登陆成功:"+user.getPhone());
120 | MobclickAgent.onProfileSignIn(user.getPhone());
121 | AppApplication.getInstance().setUser(user);
122 | step4_checkParser_Platform();
123 | }else {
124 | context.startActivity(new Intent(context,LoginActivity.class));
125 | }
126 | }
127 | });
128 | }else {
129 | //未登陆,跳转到登陆
130 | context.startActivity(new Intent(context,LoginActivity.class));
131 | }
132 | }
133 |
134 |
135 | private void update(final Version version){
136 | context.runOnUiThread(new Runnable() {
137 | @Override
138 | public void run() {
139 | new AlertDialog.Builder(context)
140 | .setTitle("软件更新")
141 | .setMessage("有新版软件,请更新后运行")
142 | .setPositiveButton("确定", new DialogInterface.OnClickListener() {
143 | @Override
144 | public void onClick(DialogInterface dialog, int which) {
145 | Uri uri = Uri.parse(version.getUrl());
146 | Intent intent = new Intent(Intent.ACTION_VIEW, uri);
147 | context.startActivity(intent);
148 | }
149 | })
150 | .setCancelable(false)
151 | .create().show();
152 | }
153 | });
154 | }
155 | private void step2_checkUpdate(){
156 | Http.checkUpdate(new Callback() {
157 | @Override
158 | public void onFailure(Call call, IOException e) {
159 |
160 | }
161 |
162 | @Override
163 | public void onResponse(Call call, final Response response) throws IOException {
164 | final int code = response.code();
165 | final String body = response.body().string();if(code == 200){
166 | Version version = JSON.parseObject(body,Version.class);
167 | AppApplication.getInstance().setVersion(version);
168 |
169 | if(version != null && version.getVersion_code() != DeviceUtils.getAppVersionCode(context)){
170 | update(version);
171 | }else {
172 | //不需要更新时,检测登陆和视频解析API
173 | step3_checkLogin();
174 | }
175 | }
176 | }
177 | });
178 | }
179 |
180 | public void step4_checkParser_Platform(){
181 | step4_checkVideoParser();
182 | step4_checkPlatforms();
183 | step4_getAdFilter();
184 | }
185 |
186 | private void step4_checkVideoParser(){
187 | Http.getVParser(new Callback() {
188 | @Override
189 | public void onFailure(Call call, IOException e) {
190 |
191 | }
192 |
193 | @Override
194 | public void onResponse(Call call, Response response) throws IOException {
195 | if(response .code() == 200){
196 | List vParsers = JSON.parseArray(response.body().string(),VParser.class);
197 | AppApplication.getInstance().setvParsers(vParsers);
198 | isAppprepared();
199 | }
200 | }
201 | });
202 | }
203 |
204 | private void step4_checkPlatforms(){
205 | Http.getPlatforms(new Callback() {
206 | @Override
207 | public void onFailure(Call call, IOException e) {
208 |
209 | }
210 |
211 | @Override
212 | public void onResponse(Call call, Response response) throws IOException {
213 | if(response.code() == 200){
214 | List platforms = JSON.parseArray(response.body().string(),Platform.class);
215 | if(platforms != null && !platforms.isEmpty()){
216 | AppApplication.getInstance().setPlatforms(platforms);
217 | isAppprepared();
218 | }
219 | }
220 | }
221 | });
222 | }
223 |
224 | private void step4_getAdFilter(){
225 | Http.getAdUrl(new Callback() {
226 | @Override
227 | public void onFailure(Call call, IOException e) {
228 |
229 | }
230 |
231 | @Override
232 | public void onResponse(Call call, Response response) throws IOException {
233 | if(response.code() == 200){
234 | List urls = JSON.parseArray(response.body().string(),AdUrl.class);
235 | if(urls != null && !urls.isEmpty()){
236 | String[] ads = new String[urls.size()];
237 | int i = 0;
238 | for(AdUrl url: urls){
239 | ads[i++] = url.getUrl();
240 | }
241 | AppApplication.getInstance().setFilterUrls(ads);
242 | isAppprepared();
243 | }
244 | }
245 | }
246 | });
247 | }
248 | }
249 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/app/MainFragment.java:
--------------------------------------------------------------------------------
1 | package com.novip.app;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.database.DataSetObserver;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.support.v4.app.Fragment;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.AdapterView;
14 | import android.widget.GridView;
15 | import android.widget.ListAdapter;
16 | import android.widget.Toast;
17 |
18 | import com.alibaba.fastjson.JSON;
19 | import com.novip.AppApplication;
20 | import com.novip.Http;
21 | import com.novip.R;
22 | import com.novip.VipCheck;
23 | import com.novip.model.Ad;
24 | import com.novip.model.Platform;
25 | import com.novip.view.IconTextView;
26 | import com.novip.web.WebViewActivity;
27 | import com.youth.banner.Banner;
28 | import com.youth.banner.BannerConfig;
29 | import com.youth.banner.Transformer;
30 |
31 | import java.io.IOException;
32 | import java.util.ArrayList;
33 | import java.util.List;
34 |
35 | import okhttp3.Call;
36 | import okhttp3.Callback;
37 | import okhttp3.Response;
38 |
39 |
40 | /**
41 | * A simple {@link Fragment} subclass.
42 | * Activities that contain this fragment must implement the
43 | * to handle interaction events.
44 | * Use the {@link MainFragment#newInstance} factory method to
45 | * create an instance of this fragment.
46 | */
47 | public class MainFragment extends Fragment implements AdapterView.OnItemClickListener {
48 | // TODO: Rename parameter arguments, choose names that match
49 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
50 | private static final String ARG_PARAM1 = "param1";
51 | private static final String ARG_PARAM2 = "param2";
52 |
53 | // TODO: Rename and change types of parameters
54 | private String mParam1;
55 | private String mParam2;
56 |
57 | private OnFragmentInteractionListener mListener;
58 | private IconTextViewAdapter iconTextViewAdapter;
59 | private Banner banner;
60 |
61 | public MainFragment() {
62 | // Required empty public constructor
63 | }
64 |
65 | /**
66 | * Use this factory method to create a new instance of
67 | * this fragment using the provided parameters.
68 | *
69 | * @param param1 Parameter 1.
70 | * @param param2 Parameter 2.
71 | * @return A new instance of fragment MainFragment.
72 | */
73 | // TODO: Rename and change types and number of parameters
74 | public static MainFragment newInstance(String param1, String param2) {
75 | MainFragment fragment = new MainFragment();
76 | Bundle args = new Bundle();
77 | args.putString(ARG_PARAM1, param1);
78 | args.putString(ARG_PARAM2, param2);
79 | fragment.setArguments(args);
80 | return fragment;
81 | }
82 |
83 | @Override
84 | public void onCreate(Bundle savedInstanceState) {
85 | super.onCreate(savedInstanceState);
86 | if (getArguments() != null) {
87 | mParam1 = getArguments().getString(ARG_PARAM1);
88 | mParam2 = getArguments().getString(ARG_PARAM2);
89 | }
90 | }
91 |
92 | @Override
93 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
94 | Bundle savedInstanceState) {
95 | // Inflate the layout for this fragment
96 | View view = inflater.inflate(R.layout.fragment_main, container, false);
97 | GridView gridView = view.findViewById(R.id.grid);
98 | if(iconTextViewAdapter == null){
99 | iconTextViewAdapter = new IconTextViewAdapter(getContext());
100 | }
101 | gridView.setAdapter(iconTextViewAdapter);
102 | gridView.setOnItemClickListener(this);
103 | banner = view.findViewById(R.id.banner);
104 | Http.getMainTabAD(new Callback() {
105 | @Override
106 | public void onFailure(Call call, IOException e) {
107 |
108 | }
109 |
110 | @Override
111 | public void onResponse(Call call, Response response) throws IOException {
112 | if(response.code() == 200){
113 | final List ads = JSON.parseArray(response.body().string(),Ad.class);
114 | getActivity().runOnUiThread(new Runnable() {
115 | @Override
116 | public void run() {
117 | show_ad(ads);
118 | }
119 | });
120 | }
121 | }
122 | });
123 | return view;
124 | }
125 |
126 | private void show_ad(List ads){
127 | List images = new ArrayList<>();
128 | List titles = new ArrayList<>();
129 | for(int i=0;i parent, View view, int position, long id) {
191 | /* if(AppApplication.getInstance().getUser() == null || AppApplication.getInstance().getUser().getVip_end().getTime() - System.currentTimeMillis() < 0){
192 | //非VIP
193 | Toast.makeText(getContext(),"请联系管理员购买VIP",Toast.LENGTH_SHORT).show();
194 | }else {
195 | //视频入口选择
196 | Log.d("MainFragment","onItemClick:" + id);
197 | Intent intent = new Intent(getContext(),WebViewActivity.class);
198 | intent.putExtra("url",AppApplication.getInstance().getPlatforms().get(position).getAction_url());
199 | startActivity(intent);
200 | }*/
201 |
202 | //视频入口选择
203 | Log.d("MainFragment","onItemClick:" + id);
204 | Intent intent = new Intent(getContext(),WebViewActivity.class);
205 | intent.putExtra("url",AppApplication.getInstance().getPlatforms().get(position).getAction_url());
206 | startActivity(intent);
207 | }
208 |
209 | private class IconTextViewAdapter implements ListAdapter {
210 | private Context context;
211 | public IconTextViewAdapter(Context context){
212 | this.context = context;
213 | }
214 |
215 | @Override
216 | public void registerDataSetObserver(DataSetObserver observer) {
217 |
218 | }
219 |
220 | @Override
221 | public void unregisterDataSetObserver(DataSetObserver observer) {
222 |
223 | }
224 |
225 | @Override
226 | public int getCount() {
227 | return AppApplication.getInstance().getPlatforms().size();
228 | }
229 |
230 | @Override
231 | public Platform getItem(int position) {
232 | return AppApplication.getInstance().getPlatforms().get(position);
233 | }
234 |
235 | @Override
236 | public long getItemId(int position) {
237 | return position;
238 | }
239 |
240 | @Override
241 | public boolean hasStableIds() {
242 | return false;
243 | }
244 |
245 | @Override
246 | public View getView(int position, View convertView, ViewGroup parent) {
247 | IconTextView ic ;
248 | if(convertView != null){
249 | ic = (IconTextView) convertView;
250 | }else{
251 | ic = new IconTextView(context);
252 | }
253 | ic.setImageText(getItem(position).getPicture_url(),getItem(position).getName());
254 | return ic;
255 | }
256 |
257 | @Override
258 | public int getItemViewType(int position) {
259 | return 0;
260 | }
261 |
262 | @Override
263 | public int getViewTypeCount() {
264 | return 1;
265 | }
266 |
267 | @Override
268 | public boolean isEmpty() {
269 | return false;
270 | }
271 |
272 | @Override
273 | public boolean areAllItemsEnabled() {
274 | return true;
275 | }
276 |
277 | @Override
278 | public boolean isEnabled(int position) {
279 | return true;
280 | }
281 | }
282 | }
283 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/app/src/main/java/com/novip/app/MineFragment.java:
--------------------------------------------------------------------------------
1 | package com.novip.app;
2 |
3 | import android.content.ClipboardManager;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.pm.PackageInfo;
7 | import android.content.pm.PackageManager;
8 | import android.net.Uri;
9 | import android.os.Bundle;
10 | import android.support.v4.app.Fragment;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.TextView;
15 | import android.widget.Toast;
16 |
17 | import com.alibaba.fastjson.JSON;
18 | import com.novip.AppApplication;
19 | import com.novip.Http;
20 | import com.novip.R;
21 | import com.novip.VipCheck;
22 | import com.novip.model.User;
23 | import com.novip.utils.ShareUtils;
24 | import com.novip.view.VipCodeDialog;
25 | import com.novip.utils.SharedPrefernceUtils;
26 | import com.novip.view.SettingItemView;
27 |
28 | import java.io.IOException;
29 | import java.util.List;
30 |
31 | import okhttp3.Call;
32 | import okhttp3.Callback;
33 | import okhttp3.Response;
34 |
35 |
36 | /**
37 | * A simple {@link Fragment} subclass.
38 | * Activities that contain this fragment must implement the
39 | * to handle interaction events.
40 | * Use the {@link MineFragment#newInstance} factory method to
41 | * create an instance of this fragment.
42 | */
43 | public class MineFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener, VipCodeDialog.VerifyListener {
44 | // TODO: Rename parameter arguments, choose names that match
45 | // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
46 | private static final String ARG_PARAM1 = "param1";
47 | private static final String ARG_PARAM2 = "param2";
48 |
49 | // TODO: Rename and change types of parameters
50 | private String mParam1;
51 | private String mParam2;
52 |
53 | private OnFragmentInteractionListener mListener;
54 | private SettingItemView setVipCode;
55 | private SettingItemView setBuyCode;
56 | private SettingItemView setAddQQGroup;
57 | private SettingItemView setContactAdminQQ;
58 | private SettingItemView setShare;
59 | private SettingItemView setLogin;
60 | private SettingItemView setExitLogin;
61 | private SettingItemView set_change_password;
62 | private TextView vip_left;
63 |
64 | public MineFragment() {
65 | // Required empty public constructor
66 | }
67 |
68 | /**
69 | * Use this factory method to create a new instance of
70 | * this fragment using the provided parameters.
71 | *
72 | * @param param1 Parameter 1.
73 | * @param param2 Parameter 2.
74 | * @return A new instance of fragment MineFragment.
75 | */
76 | // TODO: Rename and change types and number of parameters
77 | public static MineFragment newInstance(String param1, String param2) {
78 | MineFragment fragment = new MineFragment();
79 | Bundle args = new Bundle();
80 | args.putString(ARG_PARAM1, param1);
81 | args.putString(ARG_PARAM2, param2);
82 | fragment.setArguments(args);
83 | return fragment;
84 | }
85 |
86 | @Override
87 | public void onCreate(Bundle savedInstanceState) {
88 | super.onCreate(savedInstanceState);
89 | if (getArguments() != null) {
90 | mParam1 = getArguments().getString(ARG_PARAM1);
91 | mParam2 = getArguments().getString(ARG_PARAM2);
92 | }
93 |
94 |
95 | }
96 |
97 | @Override
98 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
99 | Bundle savedInstanceState) {
100 | // Inflate the layout for this fragment
101 | View view = inflater.inflate(R.layout.fragment_mine, container, false);
102 | vip_left = view.findViewById(R.id.vip_left);
103 | setVipCode = view.findViewById(R.id.set_vipcode);
104 | setBuyCode = view.findViewById(R.id.set_buy);
105 | setAddQQGroup = view.findViewById(R.id.set_qqgroup);
106 | setContactAdminQQ = view.findViewById(R.id.set_adminqq);
107 | setShare = view.findViewById(R.id.set_share);
108 | setLogin = view.findViewById(R.id.set_login);
109 | setExitLogin = view.findViewById(R.id.set_exit_account);
110 | set_change_password = view.findViewById(R.id.set_change_password);
111 | setLogin.setOnClickListener(this);
112 | setExitLogin.setOnClickListener(this);
113 | setVipCode.setOnClickListener(this);
114 | setBuyCode.setOnClickListener(this);
115 | setAddQQGroup.setOnClickListener(this);
116 | setContactAdminQQ.setOnClickListener(this);
117 | setShare.setOnClickListener(this);
118 | setLogin.setText("登陆","");
119 | setExitLogin.setText("退出登陆","");
120 | setVipCode.setText("输入授权码","输入授权码激活VIP使用权限");
121 | setBuyCode.setText("购买授权码","购买成功后可激活永久VIP");
122 | setAddQQGroup.setText("NoVIP内部群","各种免费的工具软件,长按复制群号:"+AppApplication.getInstance().getNovip().getQq_group());
123 | setContactAdminQQ.setText("联系管理员","联系管理员,长按复制管理员微信:"+AppApplication.getInstance().getNovip().getAdmin_qq());
124 | setShare.setText("软件分享","");
125 | set_change_password.setText("修改密码","");
126 |
127 | setAddQQGroup.setOnLongClickListener(this);
128 | setContactAdminQQ.setOnLongClickListener(this);
129 | set_change_password.setOnClickListener(this);
130 |
131 | return view;
132 | }
133 |
134 | // TODO: Rename method, update argument and hook method into UI event
135 | public void onButtonPressed(Uri uri) {
136 | if (mListener != null) {
137 | mListener.onFragmentInteraction(uri);
138 | }
139 | }
140 |
141 | public void refreshVip(){
142 | getActivity().runOnUiThread(new Runnable() {
143 | @Override
144 | public void run() {
145 | if(AppApplication.getInstance().getUser() == null){
146 | setLogin.setVisibility(View.VISIBLE);
147 | setExitLogin.setVisibility(View.GONE);
148 | }else {
149 | setLogin.setVisibility(View.GONE);
150 | setExitLogin.setVisibility(View.VISIBLE);
151 | }
152 | long v = AppApplication.getInstance().getUser() == null?0:AppApplication.getInstance().getUser().getVip_end().getTime();
153 | long duration = v - System.currentTimeMillis();
154 | if(duration <= 0){
155 | //VIP过期
156 | vip_left.setText("VIP剩余时间:"+0+"天");
157 | }else {
158 | long dt = 24*60*60*1000l;
159 | int days = duration/dt > 0?(int)(duration/dt+1):1;
160 | vip_left.setText("VIP剩余时间:"+days+"天");
161 | }
162 | }
163 | });
164 |
165 | }
166 | @Override
167 | public void onAttach(Context context) {
168 | super.onAttach(context);
169 | if (context instanceof OnFragmentInteractionListener) {
170 | mListener = (OnFragmentInteractionListener) context;
171 | } else {
172 | throw new RuntimeException(context.toString()
173 | + " must implement OnFragmentInteractionListener");
174 | }
175 | }
176 |
177 | @Override
178 | public void onDetach() {
179 | super.onDetach();
180 | mListener = null;
181 | }
182 |
183 |
184 | @Override
185 | public void onStart() {
186 | super.onStart();
187 | refreshVip();
188 | }
189 |
190 | @Override
191 | public void onClick(View v) {
192 | switch (v.getId()){
193 | case R.id.set_vipcode:
194 |
195 | new VipCodeDialog(getActivity(),this).show();
196 | break;
197 | case R.id.set_buy:
198 | Intent intent = new Intent();
199 | intent.setAction("android.intent.action.VIEW");
200 | Uri content_url = Uri.parse(AppApplication.getInstance().getNovip().getBuy_url());
201 | intent.setData(content_url);
202 | startActivity(intent);
203 | break;
204 | case R.id.set_qqgroup:
205 | Intent qqg = new Intent();
206 | qqg.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + "882519523"));
207 | // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
208 | try {
209 | startActivity(qqg);
210 | } catch (Exception e) {
211 | Toast.makeText(getContext(),"未安装QQ或版本不支持",Toast.LENGTH_SHORT).show();
212 | // 未安装手Q或安装的版本不支持
213 | }
214 | break;
215 | case R.id.set_adminqq:
216 | // if(isQQClientAvailable(getActivity())){
217 | // final String qqUrl = "mqqwpa://im/chat?chat_type=wpa&uin=2277896242&version=1";
218 | // startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(qqUrl)));
219 | // }else{
220 | // Toast.makeText(getActivity(),"请安装QQ客户端",Toast.LENGTH_SHORT).show();
221 | // }
222 | break;
223 | case R.id.set_share:
224 | ShareUtils.shareText(getContext(),"NoVIP视频APP","","爱奇艺、腾讯、优酷等VIP视频免费看,就在NoVIP视频APP,点这里下载:"
225 | +AppApplication.getInstance().getVersion().getUrl());
226 | /*ImageView imageView = new ImageView(getActivity());
227 | imageView.setImageResource(R.drawable.download_qrcode);
228 | imageView.setScaleType(ImageView.ScaleType.FIT_XY);
229 | ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(300,300);
230 | imageView.setLayoutParams(params);
231 | new AlertDialog.Builder(getActivity())
232 | .setView(imageView)
233 | .setTitle("扫一扫下载")
234 | .create()
235 | .show();*/
236 | break;
237 | case R.id.set_login:
238 | startActivity(new Intent(getActivity(),LoginActivity.class));
239 | break;
240 | case R.id.set_exit_account:
241 | SharedPrefernceUtils.getInstance(getContext()).putString(SharedPrefernceUtils.PHONE,"");
242 | SharedPrefernceUtils.getInstance(getContext()).putString(SharedPrefernceUtils.PS,"");
243 | AppApplication.getInstance().setUser(null);
244 | refreshVip();
245 | startActivity(new Intent(getActivity(),LoginActivity.class));
246 |
247 | break;
248 | case R.id.set_change_password:
249 | if(AppApplication.getInstance().getUser() != null){
250 | startActivity(new Intent(getActivity(),ChangePasswordActivity.class));
251 | }else {
252 | Toast.makeText(getActivity(),"请登陆后操作",Toast.LENGTH_SHORT).show();
253 | }
254 | break;
255 | }
256 | }
257 |
258 | public static boolean isQQClientAvailable(Context context) {
259 | final PackageManager packageManager = context.getPackageManager();
260 | List pinfo = packageManager.getInstalledPackages(0);
261 | if (pinfo != null) {
262 | for (int i = 0; i < pinfo.size(); i++) {
263 | String pn = pinfo.get(i).packageName;
264 | if (pn.equals("com.tencent.mobileqq")) {
265 | return true;
266 | }
267 | }
268 | }
269 | return false;
270 | }
271 |
272 | @Override
273 | public boolean onLongClick(View v) {
274 | ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
275 | switch (v.getId()){
276 | case R.id.set_qqgroup:
277 | // 从API11开始android推荐使用android.content.ClipboardManager
278 | // 为了兼容低版本我们这里使用旧版的android.text.ClipboardManager,虽然提示deprecated,但不影响使用。
279 | // 将文本内容放到系统剪贴板里。
280 | cm.setText(AppApplication.getInstance().getNovip().getQq_group());
281 | Toast.makeText(getActivity(), "复制成功", Toast.LENGTH_SHORT).show();
282 | break;
283 | case R.id.set_adminqq:
284 | cm.setText(AppApplication.getInstance().getNovip().getAdmin_qq());
285 | Toast.makeText(getActivity(), "复制成功", Toast.LENGTH_SHORT).show();
286 | break;
287 | }
288 | return true;
289 | }
290 |
291 | private void relogin(){
292 | Http.login(AppApplication.getInstance().getUser().getPhone(),
293 | AppApplication.getInstance().getUser().getPassword(), new Callback() {
294 | @Override
295 | public void onFailure(Call call, IOException e) {
296 |
297 | }
298 |
299 | @Override
300 | public void onResponse(Call call, Response response) throws IOException {
301 | if(response.code() == 200){
302 | User user = JSON.parseObject(response.body().string(),User.class);
303 | if(user != null){
304 | AppApplication.getInstance().setUser(user);
305 | refreshVip();
306 | }
307 | }
308 | }
309 | });
310 | }
311 | @Override
312 | public void verify(final boolean b) {
313 |
314 | getActivity().runOnUiThread(new Runnable() {
315 | @Override
316 | public void run() {
317 | if(b){
318 | Toast.makeText(getContext(),"VIP授权成功",Toast.LENGTH_SHORT).show();
319 | relogin();
320 | }else {
321 | Toast.makeText(getContext(),"授权码不正确",Toast.LENGTH_SHORT).show();
322 | }
323 | }
324 | });
325 | }
326 | }
327 |
--------------------------------------------------------------------------------