Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
android
/
dayu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1e9f718d
authored
Jul 14, 2020
by
mReturn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
020e3ff9
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
224 additions
and
78 deletions
app/src/main/java/com/dayu/bigfish/presenter/setting/SettingPresenter.java
app/src/main/java/com/dayu/bigfish/ui/MainActivity.java
app/src/main/java/com/dayu/bigfish/ui/SettingActivity.java
baseSDK/src/main/java/com/dayu/common/Constants.java
baseSDK/src/main/java/com/dayu/utils/AppUtils.java
baseSDK/src/main/java/com/dayu/utils/CommonUtils.java
baseSDK/src/main/java/com/dayu/widgets/JZMediaIjk.java
baseSDK/src/main/res/values/strings.xml
learnCenter/src/main/java/com/dayu/learncenter/api/bean/CourseDeatilBean.java
learnCenter/src/main/java/com/dayu/learncenter/ui/activity/CourseDetailActivity.java
learnCenter/src/main/res/layout/activity_course_detail.xml
orderCenter/src/main/java/com/dayu/order/ui/activity/PdfWebViewActivity.java
app/src/main/java/com/dayu/bigfish/presenter/setting/SettingPresenter.java
View file @
1e9f718d
...
...
@@ -16,6 +16,7 @@ import com.dayu.event.UserInfo;
import
com.dayu.usercenter.ui.activity.SmsLoginActivity
;
import
com.dayu.utils.AppManager
;
import
com.dayu.utils.AppUtils
;
import
com.dayu.utils.CommonUtils
;
import
com.dayu.utils.DataCleanManager
;
import
com.dayu.utils.SPUtils
;
import
com.dayu.utils.StationManager
;
...
...
@@ -24,6 +25,7 @@ import com.dayu.utils.UserManager;
import
com.hyphenate.chat.EMClient
;
import
com.umeng.analytics.MobclickAgent
;
import
java.io.File
;
import
java.util.concurrent.TimeUnit
;
import
io.reactivex.Observable
;
...
...
@@ -150,6 +152,9 @@ public class SettingPresenter extends SettingContract.Presenter {
});
DataCleanManager
.
deleteFolderFile
(
Environment
.
getExternalStorageDirectory
()
+
"/Android/data/com.dayu.bigfish/cache"
,
false
);
MobclickAgent
.
onEvent
(
MyApplication
.
getContext
(),
"sure_clear_cach"
);
File
sdDir
=
Environment
.
getExternalStorageDirectory
();
File
dir
=
new
File
(
sdDir
+
"/.dayu/"
);
CommonUtils
.
deleteFiles
(
dir
);
}
});
MobclickAgent
.
onEvent
(
MyApplication
.
getContext
(),
"clear_cach"
);
...
...
app/src/main/java/com/dayu/bigfish/ui/MainActivity.java
View file @
1e9f718d
...
...
@@ -4,15 +4,12 @@ import android.app.NotificationChannel;
import
android.app.NotificationManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.app.FragmentManager
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.content.FileProvider
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.View
;
...
...
@@ -25,7 +22,6 @@ import com.dayu.base.api.Api;
import
com.dayu.base.api.DownloadService
;
import
com.dayu.base.api.protocol.RedPacketBean
;
import
com.dayu.base.ui.activity.BaseActivity
;
import
com.dayu.bigfish.BuildConfig
;
import
com.dayu.bigfish.MyApplication
;
import
com.dayu.bigfish.R
;
import
com.dayu.bigfish.api.APIService
;
...
...
@@ -57,6 +53,7 @@ import com.dayu.provider.event.SwtichFragment;
import
com.dayu.provider.router.RouterPath
;
import
com.dayu.usercenter.ui.activity2.BusinessTypeActivity
;
import
com.dayu.usercenter.ui.fragment.HomeUserFragment
;
import
com.dayu.utils.AppUtils
;
import
com.dayu.utils.LogUtils
;
import
com.dayu.utils.SPUtils
;
import
com.dayu.utils.TimeUtils
;
...
...
@@ -301,37 +298,18 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
if
(
confirm
)
{
File
sdDir
=
Environment
.
getExternalStorageDirectory
();
File
file
;
file
=
new
File
(
sdDir
+
"/dayu/"
);
file
=
new
File
(
sdDir
+
"/
.
dayu/"
);
if
(!
file
.
exists
())
{
file
.
mkdirs
();
}
file
=
new
File
(
file
,
"dayu"
+
".apk"
);
if
(
Environment
.
getExternalStorageState
().
equals
(
Environment
.
MEDIA_MOUNTED
))
{
showToast
(
R
.
string
.
on_download
);
initNotification
();
DownloadService
.
startUpdateService
(
mActivity
,
info
.
getDownloadUrl
(),
file
.
getAbsolutePath
(),
new
onDownloadListener
()
{
@Override
public
void
onDownloadSuccess
(
File
file
)
{
//安装apk
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
intent
.
addCategory
(
"android.intent.category.DEFAULT"
);
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
M
)
{
intent
.
setFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
Uri
contentUri
=
FileProvider
.
getUriForFile
(
mActivity
,
BuildConfig
.
APPLICATION_ID
+
".fileProvider"
,
file
);
intent
.
setDataAndType
(
contentUri
,
"application/vnd.android.package-archive"
);
if
(
AppUtils
.
isApkDownloaded
(
file
.
getAbsolutePath
(),
this
,
info
.
getVersionCode
()))
{
// showInstallDialog(info, file);
AppUtils
.
installApk
(
mActivity
,
file
);
}
else
{
intent
.
setDataAndType
(
Uri
.
fromFile
(
file
),
"application/vnd.android.package-archive"
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startDownload
(
info
,
file
);
}
startActivity
(
intent
);
}
@Override
public
void
onDownloadFail
()
{
showToast
(
R
.
string
.
download_faile
);
}
});
}
MobclickAgent
.
onEvent
(
MyApplication
.
getContext
(),
"sure_update_app"
);
}
else
{
...
...
@@ -347,6 +325,40 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
dialog
.
show
();
}
//安装包已下载,提示安装
private
void
showInstallDialog
(
VersionInfo
info
,
File
file
)
{
CustomDialog
dialog
=
new
CustomDialog
(
mActivity
,
R
.
style
.
CustomDialog
,
getString
(
R
.
string
.
new_version_download
),
(
dialog1
,
confirm
)
->
{
if
(
confirm
)
{
AppUtils
.
installApk
(
mActivity
,
file
);
}
else
{
startDownload
(
info
,
file
);
}
});
dialog
.
setNegativeButton
(
getString
(
R
.
string
.
re_download
))
.
setPositiveButton
(
getString
(
R
.
string
.
install_now
));
dialog
.
show
();
}
//开始下载apk文件
private
void
startDownload
(
VersionInfo
info
,
File
file
)
{
showToast
(
R
.
string
.
on_download
);
initNotification
();
DownloadService
.
startUpdateService
(
mActivity
,
info
.
getDownloadUrl
(),
file
.
getAbsolutePath
(),
new
onDownloadListener
()
{
@Override
public
void
onDownloadSuccess
(
File
file
)
{
//安装apk
AppUtils
.
installApk
(
mActivity
,
file
);
}
@Override
public
void
onDownloadFail
()
{
showToast
(
R
.
string
.
download_faile
);
}
});
}
/**
* notifycation.
*/
...
...
@@ -357,7 +369,7 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
.
setSmallIcon
(
R
.
mipmap
.
wechatimg
)
.
setContentTitle
(
getString
(
R
.
string
.
start_download
))
.
setAutoCancel
(
true
)
.
setPriority
(
NotificationCompat
.
PRIORITY_
HIGH
)
.
setPriority
(
NotificationCompat
.
PRIORITY_
DEFAULT
)
.
setVibrate
(
new
long
[]{
0
})
.
setDefaults
(
NotificationCompat
.
FLAG_ONLY_ALERT_ONCE
)
.
setSound
(
null
)
...
...
app/src/main/java/com/dayu/bigfish/ui/SettingActivity.java
View file @
1e9f718d
...
...
@@ -3,17 +3,12 @@ package com.dayu.bigfish.ui;
import
android.app.NotificationChannel
;
import
android.app.NotificationManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.content.FileProvider
;
import
com.alibaba.android.arouter.facade.annotation.Route
;
import
com.dayu.base.api.DownloadService
;
import
com.dayu.base.ui.activity.BaseActivity
;
import
com.dayu.bigfish.BuildConfig
;
import
com.dayu.bigfish.MyApplication
;
import
com.dayu.bigfish.R
;
import
com.dayu.bigfish.api.protocol.VersionInfo
;
...
...
@@ -23,6 +18,7 @@ import com.dayu.bigfish.presenter.setting.SettingPresenter;
import
com.dayu.common.Constants
;
import
com.dayu.event.DownloadBean
;
import
com.dayu.provider.router.RouterPath
;
import
com.dayu.utils.AppUtils
;
import
com.dayu.utils.UIUtils
;
import
com.dayu.widgets.ChangeEnvDialog
;
import
com.dayu.widgets.CustomDialog
;
...
...
@@ -84,37 +80,18 @@ public class SettingActivity extends BaseActivity<SettingPresenter, ActivitySett
if
(
confirm
)
{
File
sdDir
=
Environment
.
getExternalStorageDirectory
();
File
file
;
file
=
new
File
(
sdDir
+
"/dayu/"
);
file
=
new
File
(
sdDir
+
"/
.
dayu/"
);
if
(!
file
.
exists
())
{
file
.
mkdirs
();
}
file
=
new
File
(
file
,
"dayu"
+
".apk"
);
if
(
Environment
.
getExternalStorageState
().
equals
(
Environment
.
MEDIA_MOUNTED
))
{
showToast
(
R
.
string
.
on_download
);
initNotification
();
DownloadService
.
startUpdateService
(
mActivity
,
info
.
getDownloadUrl
(),
file
.
getAbsolutePath
(),
new
onDownloadListener
()
{
@Override
public
void
onDownloadSuccess
(
File
file
)
{
//安装apk
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
intent
.
addCategory
(
"android.intent.category.DEFAULT"
);
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
M
)
{
intent
.
setFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
Uri
contentUri
=
FileProvider
.
getUriForFile
(
mActivity
,
BuildConfig
.
APPLICATION_ID
+
".fileProvider"
,
file
);
intent
.
setDataAndType
(
contentUri
,
"application/vnd.android.package-archive"
);
if
(
AppUtils
.
isApkDownloaded
(
file
.
getAbsolutePath
(),
this
,
info
.
getVersionCode
()))
{
// showInstallDialog(info, file);
AppUtils
.
installApk
(
mActivity
,
file
);
}
else
{
intent
.
setDataAndType
(
Uri
.
fromFile
(
file
),
"application/vnd.android.package-archive"
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
}
startActivity
(
intent
);
}
@Override
public
void
onDownloadFail
()
{
showToast
(
R
.
string
.
download_faile
);
startDownload
(
info
,
file
);
}
});
}
MobclickAgent
.
onEvent
(
MyApplication
.
getContext
(),
"sure_update_app"
);
}
else
{
...
...
@@ -130,13 +107,46 @@ public class SettingActivity extends BaseActivity<SettingPresenter, ActivitySett
dialog
.
show
();
}
//安装包已下载,提示安装
private
void
showInstallDialog
(
VersionInfo
info
,
File
file
)
{
CustomDialog
dialog
=
new
CustomDialog
(
mActivity
,
R
.
style
.
CustomDialog
,
getString
(
R
.
string
.
new_version_download
),
(
dialog1
,
confirm
)
->
{
if
(
confirm
)
{
AppUtils
.
installApk
(
mActivity
,
file
);
}
else
{
startDownload
(
info
,
file
);
}
});
dialog
.
setNegativeButton
(
getString
(
R
.
string
.
re_download
))
.
setPositiveButton
(
getString
(
R
.
string
.
install_now
));
dialog
.
show
();
}
//开始下载apk文件
private
void
startDownload
(
VersionInfo
info
,
File
file
)
{
showToast
(
R
.
string
.
on_download
);
initNotification
();
DownloadService
.
startUpdateService
(
mActivity
,
info
.
getDownloadUrl
(),
file
.
getAbsolutePath
(),
new
onDownloadListener
()
{
@Override
public
void
onDownloadSuccess
(
File
file
)
{
//安装apk
AppUtils
.
installApk
(
mActivity
,
file
);
}
@Override
public
void
onDownloadFail
()
{
showToast
(
R
.
string
.
download_faile
);
}
});
}
public
void
initNotification
()
{
notificationManager
=
(
NotificationManager
)
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
builder
=
new
NotificationCompat
.
Builder
(
this
)
.
setSmallIcon
(
R
.
mipmap
.
wechatimg
)
.
setContentTitle
(
getString
(
R
.
string
.
start_download
))
.
setAutoCancel
(
true
)
.
setPriority
(
NotificationCompat
.
PRIORITY_
MAX
)
.
setPriority
(
NotificationCompat
.
PRIORITY_
DEFAULT
)
.
setVibrate
(
new
long
[]{
0
})
.
setDefaults
(
NotificationCompat
.
FLAG_ONLY_ALERT_ONCE
)
.
setSound
(
null
)
...
...
baseSDK/src/main/java/com/dayu/common/Constants.java
View file @
1e9f718d
...
...
@@ -52,7 +52,6 @@ public class Constants {
// public static final String UP_PHOTO = "/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply";
// public static final String UP_VIDEO = "/file/uploadVideoOne?targetPath=dev/video";
// public static final boolean IS_DEBUG = true;
// public static final boolean CAN_CHANGE_ENV = true; //是否显示切换开发环境菜单
// public static String VIDEO_SHARE_URL = "http://uat.kf.ai:9099/#/shareVideo?type=_type&id="; //uat 学习视频分享链接 type(课程: course 直播: live)
...
...
@@ -69,8 +68,7 @@ public class Constants {
public
static
String
MULTI_WEB_SOP
=
"http://47.95.223.6:9004/#/manySop"
;
public
static
final
String
UP_PHOTO
=
"/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply"
;
public
static
final
String
UP_VIDEO
=
"/file/uploadVideoOne?targetPath=test/video"
;
public
static
final
boolean
IS_DEBUG
=
true
;
public
static
final
boolean
CAN_CHANGE_ENV
=
false
;
//是否显示切换开发环境菜单
public
static
final
boolean
IS_DEBUG
=
false
;
public
static
String
VIDEO_SHARE_URL
=
"http://uat.kf.ai:9099/#/shareVideo?type=_type&id="
;
//uat 学习视频分享链接 type(课程: course 直播: live)
...
...
@@ -89,7 +87,6 @@ public class Constants {
// public static final String UP_PHOTO = "/file/uploadMore?targetPath=online/sp/mobile/android/business/checkApply";
// public static final String UP_VIDEO = "/file/uploadVideoOne?targetPath=online/video";
// public static final boolean IS_DEBUG = false;
// public static final boolean CAN_CHANGE_ENV = false; //是否显示切换开发环境菜单
// public static String VIDEO_SHARE_URL = "http://app.dl.kf.ai/ext/#/shareVideo?type=_type&id="; //学习视频分享链接 type(课程: course 直播: live)
...
...
baseSDK/src/main/java/com/dayu/utils/AppUtils.java
View file @
1e9f718d
package
com
.
dayu
.
utils
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.graphics.drawable.Drawable
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.support.v4.content.FileProvider
;
import
android.telephony.TelephonyManager
;
import
com.cjt2325.cameralibrary.util.LogUtil
;
import
com.dayu.baselibrary.R
;
import
com.dayu.common.BaseApplication
;
import
com.dayu.common.Constants
;
import
com.hyphenate.chat.EMClient
;
import
java.io.File
;
/**
* Created by luofan on 2017/11/7.
*/
...
...
@@ -45,12 +57,82 @@ public class AppUtils {
}
/**
* 获取当前应用包名
*/
public
static
String
getPackageName
()
{
try
{
PackageInfo
packageInfo
=
BaseApplication
.
getContext
().
getPackageManager
().
getPackageInfo
(
BaseApplication
.
getContext
().
getPackageName
(),
0
);
String
packageName
=
packageInfo
.
packageName
;
return
packageName
;
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
return
""
;
}
}
/**
* 判断升级包是否已下载
*
* @param absPath
* @param context
* @param versionNum
*/
public
static
boolean
isApkDownloaded
(
String
absPath
,
Context
context
,
String
versionNum
)
{
PackageManager
pm
=
context
.
getPackageManager
();
PackageInfo
pkgInfo
=
pm
.
getPackageArchiveInfo
(
absPath
,
PackageManager
.
GET_ACTIVITIES
);
if
(
pkgInfo
!=
null
)
{
ApplicationInfo
appInfo
=
pkgInfo
.
applicationInfo
;
/* 必须加这两句,不然下面icon获取是default icon而不是应用包的icon */
appInfo
.
sourceDir
=
absPath
;
appInfo
.
publicSourceDir
=
absPath
;
String
appName
=
pm
.
getApplicationLabel
(
appInfo
).
toString
();
// 得到应用名
String
packageName
=
appInfo
.
packageName
;
// 得到包名
String
version
=
pkgInfo
.
versionName
;
// 得到版本信息
/* icon1和icon2其实是一样的 */
Drawable
icon1
=
pm
.
getApplicationIcon
(
appInfo
);
// 得到图标信息
Drawable
icon2
=
appInfo
.
loadIcon
(
pm
);
String
pkgInfoStr
=
String
.
format
(
"PackageName:%s, Vesion: %s, AppName: %s"
,
packageName
,
version
,
appName
);
LogUtil
.
e
(
"apkInfo: "
,
String
.
format
(
"PkgInfo: %s"
,
pkgInfoStr
));
LogUtil
.
e
(
"apkInfo2: "
,
getPackageName
()
+
" "
+
versionNum
);
if
(
getPackageName
().
equals
(
packageName
)
&&
versionNum
.
equals
(
version
))
return
true
;
}
else
{
LogUtil
.
e
(
"apkInfo: "
,
"apk error"
);
}
return
false
;
}
/**
* 安装apk
*
* @param mActivity
* @param file
*/
public
static
void
installApk
(
Activity
mActivity
,
File
file
)
{
LogUtil
.
e
(
"installApk: "
+
mActivity
+
" "
+
file
);
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
);
intent
.
addCategory
(
"android.intent.category.DEFAULT"
);
if
(
Build
.
VERSION
.
SDK_INT
>
Build
.
VERSION_CODES
.
M
)
{
intent
.
setFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
Uri
contentUri
=
FileProvider
.
getUriForFile
(
mActivity
,
"com.dayu.bigfish.fileProvider"
,
file
);
intent
.
setDataAndType
(
contentUri
,
"application/vnd.android.package-archive"
);
}
else
{
intent
.
setDataAndType
(
Uri
.
fromFile
(
file
),
"application/vnd.android.package-archive"
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
}
mActivity
.
startActivity
(
intent
);
}
public
static
boolean
isReleaseEnv
()
{
return
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
).
equals
(
"release"
);
}
public
static
boolean
isDevEnv
()
{
return
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
).
equals
(
"debug"
);
}
public
static
boolean
isUatEnv
()
{
return
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
).
equals
(
"uat"
);
}
...
...
@@ -59,7 +141,7 @@ public class AppUtils {
* 切换到dev环境
*/
public
static
void
changeToDevEnv
()
{
SPUtils
.
put
(
"env"
,
"debug"
);
SPUtils
.
put
(
"env"
,
"debug"
);
Constants
.
ENVIROMENT
=
"debug"
;
Constants
.
BASE_URL
=
"http://47.94.101.239:3112"
;
Constants
.
WEB_SOP
=
"http://47.94.101.239:9004/#/sop"
;
...
...
@@ -74,7 +156,7 @@ public class AppUtils {
* 切换到uat环境
*/
public
static
void
changeToUatEnv
()
{
SPUtils
.
put
(
"env"
,
"uat"
);
SPUtils
.
put
(
"env"
,
"uat"
);
Constants
.
ENVIROMENT
=
"uat"
;
Constants
.
BASE_URL
=
"http://47.95.223.6:3112"
;
Constants
.
WEB_SOP
=
"http://47.95.223.6:9004/#/sop"
;
...
...
@@ -89,7 +171,7 @@ public class AppUtils {
* 切换到release环境
*/
public
static
void
changeToReleaseEnv
()
{
SPUtils
.
put
(
"env"
,
"release"
);
SPUtils
.
put
(
"env"
,
"release"
);
Constants
.
ENVIROMENT
=
"release"
;
Constants
.
BASE_URL
=
"https://mobile.kf.ai"
;
Constants
.
WEB_SOP
=
"https://sop.kf.ai/#/sop"
;
...
...
@@ -103,7 +185,7 @@ public class AppUtils {
/**
* 退出登录
*/
public
static
void
exitApp
(){
public
static
void
exitApp
()
{
EMClient
.
getInstance
().
logout
(
true
);
UserManager
.
getInstance
().
clearUserInfo
();
AppManager
.
getInstance
().
finishAllActivity
();
...
...
@@ -114,8 +196,8 @@ public class AppUtils {
* 初始化开发环境
*/
public
static
void
initEnv
()
{
String
env
=
(
String
)
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
);
switch
(
env
){
String
env
=
(
String
)
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
);
switch
(
env
)
{
case
"debug"
:
changeToDevEnv
();
break
;
...
...
baseSDK/src/main/java/com/dayu/utils/CommonUtils.java
View file @
1e9f718d
...
...
@@ -296,11 +296,12 @@ public class CommonUtils {
// .setCallback(callBack).share();
}
/**
* 分享链接(包含标题内容)
*/
public
static
void
shareUrl
(
Activity
activity
,
String
url
,
String
imgUrl
,
String
title
,
String
description
,
SHARE_MEDIA
platform
,
UMShareListener
callBack
)
{
String
description
,
SHARE_MEDIA
platform
,
UMShareListener
callBack
)
{
UMWeb
web
=
new
UMWeb
(
url
);
web
.
setTitle
(
title
);
if
(
TextUtils
.
isEmpty
(
imgUrl
))
{
...
...
@@ -314,6 +315,7 @@ public class CommonUtils {
.
setCallback
(
callBack
).
share
();
}
/**
* 分享图片
*/
...
...
@@ -334,7 +336,7 @@ public class CommonUtils {
public
static
void
shareProgram
(
Activity
activity
,
String
imgUrl
,
String
title
,
String
description
,
int
uid
,
int
gid
,
SHARE_MEDIA
platform
,
UMShareListener
callBack
)
{
String
path
=
Constants
.
PROGRAM_PATH
.
replace
(
"uid"
,
uid
+
""
).
replace
(
"gid"
,
gid
+
""
);
shareProgramPath
(
activity
,
imgUrl
,
title
,
description
,
path
,
platform
,
callBack
);
shareProgramPath
(
activity
,
imgUrl
,
title
,
description
,
path
,
platform
,
callBack
);
}
...
...
@@ -391,12 +393,30 @@ public class CommonUtils {
/**
* 获取视频第一帧图片
*
* @param url
* @return
*/
public
static
String
getVideoImg
(
String
url
){
public
static
String
getVideoImg
(
String
url
)
{
if
(
TextUtils
.
isEmpty
(
url
))
return
""
;
return
url
.
replace
(
"http:"
,
"https:"
)+
"?x-oss-process=video/snapshot,t_0,f_jpg,ar_auto"
;
return
url
.
replace
(
"http:"
,
"https:"
)
+
"?x-oss-process=video/snapshot,t_0,f_jpg,ar_auto"
;
}
/**
* 删除文件夹下所有文件
* @param dir
*/
public
static
void
deleteFiles
(
File
dir
){
if
(
dir
==
null
||
!
dir
.
exists
()
||
!
dir
.
isDirectory
())
return
;
for
(
File
file
:
dir
.
listFiles
())
{
if
(
file
.
isFile
())
file
.
delete
();
// 删除所有文件
else
if
(
file
.
isDirectory
())
deleteFiles
(
file
);
// 递规的方式删除文件夹
}
dir
.
delete
();
// 删除目录本身
}
}
baseSDK/src/main/java/com/dayu/widgets/JZMediaIjk.java
View file @
1e9f718d
...
...
@@ -6,8 +6,6 @@ import android.os.Handler;
import
android.os.HandlerThread
;
import
android.view.Surface
;
import
java.io.IOException
;
import
cn.jzvd.JZMediaInterface
;
import
cn.jzvd.Jzvd
;
import
tv.danmaku.ijk.media.player.IMediaPlayer
;
...
...
@@ -51,12 +49,14 @@ public class JZMediaIjk extends JZMediaInterface implements IMediaPlayer.OnPrepa
ijkMediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec-auto-rotate"
,
1
);
ijkMediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"mediacodec-handle-resolution-change"
,
1
);
//使用opensles把文件从java层拷贝到native层
if
(
ijkMediaPlayer
!=
null
)
ijkMediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"opensles"
,
0
);
//视频格式
ijkMediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"overlay-format"
,
IjkMediaPlayer
.
SDL_FCC_RV32
);
//跳帧处理(-1~120)。CPU处理慢时,进行跳帧处理,保证音视频同步
ijkMediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"framedrop"
,
1
);
//0为一进入就播放,1为进入时不播放
if
(
ijkMediaPlayer
!=
null
)
ijkMediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_PLAYER
,
"start-on-prepared"
,
0
);
////域名检测
ijkMediaPlayer
.
setOption
(
IjkMediaPlayer
.
OPT_CATEGORY_FORMAT
,
"http-detect-range-support"
,
0
);
...
...
baseSDK/src/main/res/values/strings.xml
View file @
1e9f718d
...
...
@@ -515,6 +515,9 @@
<string
name=
"go_download"
>
去安装
</string>
<string
name=
"download_faile"
>
下载失败
</string>
<string
name=
"have_new_version"
>
有新版本
</string>
<string
name=
"new_version_download"
>
新版本安装包已下载,是否安装?
</string>
<string
name=
"install_now"
>
马上安装
</string>
<string
name=
"re_download"
>
重新下载
</string>
<string
name=
"next_again"
>
下次再说
</string>
<string
name=
"need_upglude"
>
立刻升级
</string>
<string
name=
"start_download"
>
开始下载
</string>
...
...
learnCenter/src/main/java/com/dayu/learncenter/api/bean/CourseDeatilBean.java
View file @
1e9f718d
...
...
@@ -40,6 +40,16 @@ public class CourseDeatilBean implements Serializable {
private
int
type
;
private
String
url
;
private
int
shares
;
private
int
shareWatchs
;
public
int
getShareWatchs
()
{
return
shareWatchs
;
}
public
void
setShareWatchs
(
int
shareWatchs
)
{
this
.
shareWatchs
=
shareWatchs
;
}
public
int
getShares
()
{
return
shares
;
...
...
learnCenter/src/main/java/com/dayu/learncenter/ui/activity/CourseDetailActivity.java
View file @
1e9f718d
...
...
@@ -130,7 +130,7 @@ public class CourseDetailActivity extends BaseActivity<SImplePresenter, Activity
mBind
.
jzVideo
.
setUp
(
data
.
getUrl
(),
""
,
JzvdStd
.
SCREEN_NORMAL
,
JZMediaIjk
.
class
);
CommonUtils
.
setVideoThumb
(
mActivity
,
mBind
.
jzVideo
,
data
.
getUrl
());
steVideoListener
();
mBind
.
tvLooks
.
setText
(
data
.
getLearners
()
+
""
);
mBind
.
tvLooks
.
setText
(
(
data
.
getLearners
()
+
+
data
.
getShareWatchs
())+
""
);
mBind
.
tvLike
.
setText
(
pointNum
+
""
);
mBind
.
tvShares
.
setText
(
data
.
getShares
()+
""
);
if
(
data
.
getCoursePointsVO
()
!=
null
&&
data
.
getCoursePointsVO
().
getPointStatus
()
==
1
)
{
...
...
learnCenter/src/main/res/layout/activity_course_detail.xml
View file @
1e9f718d
...
...
@@ -28,6 +28,14 @@
android:id=
"@+id/title_back"
style=
"@style/title_image_back"
/>
<ImageButton
android:id=
"@+id/ib_share"
android:layout_width=
"40dp"
android:layout_alignParentRight=
"true"
android:background=
"@color/transparent"
android:layout_height=
"match_parent"
android:src=
"@drawable/icon_share_gray"
/>
<ImageView
style=
"@style/card_line"
android:layout_alignParentBottom=
"true"
/>
...
...
@@ -144,7 +152,6 @@
android:gravity=
"center"
android:text=
"0"
/>
<ImageButton
android:id=
"@+id/ib_share"
android:layout_width=
"35dp"
android:background=
"@color/transparent"
android:layout_height=
"match_parent"
...
...
orderCenter/src/main/java/com/dayu/order/ui/activity/PdfWebViewActivity.java
View file @
1e9f718d
...
...
@@ -165,7 +165,7 @@ public class PdfWebViewActivity extends DataBindingActivity<ActivityWebviewBindi
// 允许漫游时下载
request
.
setAllowedOverRoaming
(
true
);
// 允许下载的网路类型
request
.
setAllowedNetworkTypes
(
DownloadManager
.
Request
.
NETWORK_WIFI
);
request
.
setAllowedNetworkTypes
(
DownloadManager
.
Request
.
NETWORK_WIFI
|
DownloadManager
.
Request
.
NETWORK_MOBILE
);
// 设置下载文件保存的路径和文件名
String
fileName
=
URLUtil
.
guessFileName
(
url
,
contentDisposition
,
mimeType
);
request
.
setDestinationInExternalPublicDir
(
Environment
.
DIRECTORY_DOWNLOADS
,
fileName
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment