Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vedio
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_vedio
Commits
d7507051
Commit
d7507051
authored
Sep 05, 2023
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
35de9505
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
22 additions
and
425 deletions
+22
-425
VersionUpdatePresenter.java
...ints/helivideo/mvp/presenters/VersionUpdatePresenter.java
+10
-13
GsonConverterFactory.java
...in/java/com/mints/helivideo/net/GsonConverterFactory.java
+0
-2
DownloadProgressDialog.kt
.../com/mints/helivideo/ui/widgets/DownloadProgressDialog.kt
+10
-3
AESUtils.java
...app/src/main/java/com/mints/helivideo/utils/AESUtils.java
+0
-3
BaseSubscriber.java
...n/java/com/mints/library/net/neterror/BaseSubscriber.java
+1
-1
FormatException.java
.../java/com/mints/library/net/neterror/FormatException.java
+1
-1
AppUtils.java
...o/app/src/main/java/com/mints/library/utils/AppUtils.java
+0
-59
TLog.java
video/app/src/main/java/com/mints/library/utils/TLog.java
+0
-147
Utils.java
video/app/src/main/java/com/mints/library/utils/Utils.java
+0
-196
No files found.
video/app/src/main/java/com/mints/helivideo/mvp/presenters/VersionUpdatePresenter.java
View file @
d7507051
...
...
@@ -8,7 +8,9 @@ import android.content.Intent;
import
android.content.ServiceConnection
;
import
android.net.Uri
;
import
android.os.IBinder
;
import
androidx.appcompat.app.AlertDialog
;
import
android.text.TextUtils
;
import
android.text.method.ScrollingMovementMethod
;
import
android.view.KeyEvent
;
...
...
@@ -29,7 +31,6 @@ import com.mints.helivideo.ui.service.UpdateService;
import
com.mints.helivideo.utils.ToastUtil
;
import
com.mints.library.net.neterror.BaseSubscriber
;
import
com.mints.library.net.neterror.Throwable
;
import
com.mints.library.utils.AppUtils
;
import
com.mints.library.utils.CommonUtils
;
import
com.mints.library.utils.ConstantUtil
;
...
...
@@ -292,18 +293,14 @@ public class VersionUpdatePresenter {
intent
.
setData
(
Uri
.
parse
(
appFileUrl
));
activity
.
startActivity
(
intent
);
}
else
{
if
(
AppUtils
.
isServiceRunning
(
loanApplication
,
loanApplication
.
getPackageName
()
+
".service.UpdateService"
))
{
ToastUtil
.
show
(
MintsApplication
.
getContext
(),
loanApplication
.
getString
(
R
.
string
.
update_text5
));
}
else
{
Context
applicationContext
=
loanApplication
.
getApplicationContext
();
Intent
updateIntent
=
new
Intent
(
applicationContext
,
UpdateService
.
class
);
updateIntent
.
putExtra
(
"path"
,
appFileUrl
);
updateIntent
.
putExtra
(
"app_name"
,
Constant
.
MINTS_PKG_NAME
);
updateIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
applicationContext
.
bindService
(
updateIntent
,
conn
,
Context
.
BIND_AUTO_CREATE
);
ToastUtil
.
show
(
MintsApplication
.
getContext
(),
loanApplication
.
getString
(
R
.
string
.
update_text6
));
}
Context
applicationContext
=
loanApplication
.
getApplicationContext
();
Intent
updateIntent
=
new
Intent
(
applicationContext
,
UpdateService
.
class
);
updateIntent
.
putExtra
(
"path"
,
appFileUrl
);
updateIntent
.
putExtra
(
"app_name"
,
Constant
.
MINTS_PKG_NAME
);
updateIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
applicationContext
.
bindService
(
updateIntent
,
conn
,
Context
.
BIND_AUTO_CREATE
);
ToastUtil
.
show
(
MintsApplication
.
getContext
(),
loanApplication
.
getString
(
R
.
string
.
update_text6
));
}
}
...
...
video/app/src/main/java/com/mints/helivideo/net/GsonConverterFactory.java
View file @
d7507051
package
com
.
mints
.
helivideo
.
net
;
import
com.google.gson.Gson
;
import
com.mints.library.utils.TLog
;
import
com.mints.helivideo.common.Constant
;
import
com.mints.helivideo.manager.UserManager
;
import
com.mints.helivideo.mvp.model.BaseResponse
;
...
...
@@ -102,7 +101,6 @@ public class GsonConverterFactory extends Converter.Factory {
// }
// }
}
catch
(
Exception
e
)
{
TLog
.
d
(
Constant
.
TAG_NAME
,
"获取最上层activity出错"
);
}
}
...
...
video/app/src/main/java/com/mints/helivideo/ui/widgets/DownloadProgressDialog.kt
View file @
d7507051
...
...
@@ -10,11 +10,10 @@ import android.widget.ImageView
import
android.widget.TextView
import
com.downloader.PRDownloader
import
com.downloader.Progress
import
com.mints.helivideo.MintsApplication
import
com.mints.helivideo.R
import
com.mints.helivideo.utils.CacheUtil
import
com.mints.library.utils.Utils
import
com.mints.library.utils.nodoubleclick.AntiShake
import
java.util.*
/**
* 下载进度弹窗
...
...
@@ -57,6 +56,14 @@ class DownloadProgressDialog(context: Context) :
}
fun
setProgress
(
progress
:
Progress
)
{
tvDownloadProgress
?.
text
=
"正在下载 "
+
Utils
.
getProgressDisplayLine
(
progress
.
currentBytes
,
progress
.
totalBytes
)
tvDownloadProgress
?.
text
=
"正在下载 "
+
getProgressDisplayLine
(
progress
.
currentBytes
,
progress
.
totalBytes
)
}
fun
getProgressDisplayLine
(
currentBytes
:
Long
,
totalBytes
:
Long
):
String
?
{
return
getBytesToMBString
(
currentBytes
)
+
"/"
+
getBytesToMBString
(
totalBytes
)
}
private
fun
getBytesToMBString
(
bytes
:
Long
):
String
{
return
String
.
format
(
Locale
.
ENGLISH
,
"%.2fMB"
,
bytes
/
(
1024.00
*
1024.00
))
}
}
\ No newline at end of file
video/app/src/main/java/com/mints/helivideo/utils/AESUtils.java
View file @
d7507051
package
com
.
mints
.
helivideo
.
utils
;
import
com.mints.library.utils.TLog
;
import
com.mints.helivideo.common.Constant
;
import
com.mints.helivideo.BuildConfig
;
...
...
@@ -38,7 +37,6 @@ public class AESUtils {
byte
[]
encrypted
=
cipher
.
doFinal
(
message
.
getBytes
(
"UTF-8"
));
return
new
BASE64Encoder
().
encode
(
encrypted
);
}
catch
(
Exception
e
)
{
TLog
.
e
(
Constant
.
TAG_NAME
,
"aes加密失败"
);
}
return
""
;
}
...
...
@@ -54,7 +52,6 @@ public class AESUtils {
byte
[]
detrypted
=
cipher
.
doFinal
(
res
);
return
new
String
(
detrypted
,
"UTF-8"
);
}
catch
(
Exception
e
)
{
TLog
.
e
(
Constant
.
TAG_NAME
,
"aes解密失败"
);
}
return
""
;
}
...
...
video/app/src/main/java/com/mints/library/net/neterror/BaseSubscriber.java
View file @
d7507051
...
...
@@ -24,7 +24,7 @@ public abstract class BaseSubscriber<T> extends Subscriber<T> {
onError
(
CashException
.
handleException
(
e
));
}
else
{
Throwable
throwable
=
new
Throwable
(
e
,
CashException
.
ERROR
.
UNKNOWN
);
throwable
.
setMessage
(
"
Exceção do sistema, por favor saia do aplicativo e abra-o novamente
"
);
throwable
.
setMessage
(
"
网络异常
"
);
onError
(
throwable
);
}
}
...
...
video/app/src/main/java/com/mints/library/net/neterror/FormatException.java
View file @
d7507051
...
...
@@ -9,7 +9,7 @@ package com.mints.library.net.neterror;
public
class
FormatException
extends
RuntimeException
{
public
int
code
=
-
200
;
public
String
message
=
"
Formato de dados anormal devolvido pelo servidor
"
;
public
String
message
=
""
;
public
FormatException
()
{
}
...
...
video/app/src/main/java/com/mints/library/utils/AppUtils.java
deleted
100755 → 0
View file @
35de9505
package
com
.
mints
.
library
.
utils
;
import
android.app.ActivityManager
;
import
android.content.Context
;
import
java.util.List
;
/**
* 描述:某个应用或服务是否在运行
* 作者:孟崔广
* 时间:2018/1/10 17:51
* 邮箱:mengcuiguang@cashbang.cn
*/
public
class
AppUtils
{
/**
* 方法描述:判断某一应用是否正在运行
*
* @param context 上下文
* @param packageName 应用的包名
* @return true 表示正在运行,false表示没有运行
*/
public
static
boolean
isAppRunning
(
Context
context
,
String
packageName
)
{
boolean
isAppRunning
=
false
;
ActivityManager
am
=
(
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
List
<
ActivityManager
.
RunningTaskInfo
>
list
=
am
.
getRunningTasks
(
100
);
if
(
list
.
size
()
<=
0
)
{
return
false
;
}
for
(
ActivityManager
.
RunningTaskInfo
info
:
list
)
{
if
(
info
.
baseActivity
.
getPackageName
().
equals
(
packageName
))
{
return
true
;
}
}
return
false
;
}
/**
* 方法描述:判断某一Service是否正在运行
*
* @param context 上下文
* @param serviceName Service的全路径: 包名 + service的类名
* @return true 表示正在运行,false 表示没有运行
*/
public
static
boolean
isServiceRunning
(
Context
context
,
String
serviceName
)
{
ActivityManager
am
=
(
ActivityManager
)
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
);
List
<
ActivityManager
.
RunningServiceInfo
>
runningServiceInfos
=
am
.
getRunningServices
(
200
);
if
(
runningServiceInfos
.
size
()
<=
0
)
{
return
false
;
}
for
(
ActivityManager
.
RunningServiceInfo
serviceInfo
:
runningServiceInfos
)
{
if
(
serviceInfo
.
service
.
getClassName
().
equals
(
serviceName
))
{
return
true
;
}
}
return
false
;
}
}
video/app/src/main/java/com/mints/library/utils/TLog.java
deleted
100755 → 0
View file @
35de9505
/*
* Copyright (c) 2015 [1076559197@qq.com | tchen0707@gmail.com]
*
* Licensed under the Apache License, Version 2.0 (the "License”);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
mints
.
library
.
utils
;
import
android.util.Log
;
import
com.mints.helivideo.BuildConfig
;
/**
* 描述:TLog
* 作者:孟崔广
* 时间:2018/1/10 17:51
* 邮箱:mengcuiguang@cashbang.cn
*/
public
class
TLog
{
/**
* This flag to indicate the log is enabled or disabled.
*/
private
static
boolean
isLogEnable
=
BuildConfig
.
DEBUG
;
// private static boolean isLogEnable = false;
/**
* Disable the log output.
*/
public
static
void
disableLog
()
{
isLogEnable
=
false
;
}
/**
* Enable the log output.
*/
public
static
void
enableLog
()
{
isLogEnable
=
true
;
}
/**
* Debug
*
* @param tag
* @param msg
*/
public
static
void
d
(
String
tag
,
String
msg
)
{
if
(
isLogEnable
)
{
StackTraceElement
stackTraceElement
=
Thread
.
currentThread
().
getStackTrace
()[
3
];
Log
.
d
(
tag
,
rebuildMsg
(
stackTraceElement
,
msg
));
}
}
/**
* Information
*
* @param tag
* @param msg
*/
public
static
void
i
(
String
tag
,
String
msg
)
{
if
(
isLogEnable
)
{
StackTraceElement
stackTraceElement
=
Thread
.
currentThread
().
getStackTrace
()[
3
];
Log
.
i
(
tag
,
rebuildMsg
(
stackTraceElement
,
msg
));
}
}
/**
* Verbose
*
* @param tag
* @param msg
*/
public
static
void
v
(
String
tag
,
String
msg
)
{
if
(
isLogEnable
)
{
StackTraceElement
stackTraceElement
=
Thread
.
currentThread
().
getStackTrace
()[
3
];
Log
.
v
(
tag
,
rebuildMsg
(
stackTraceElement
,
msg
));
}
}
/**
* Warning
*
* @param tag
* @param msg
*/
public
static
void
w
(
String
tag
,
String
msg
)
{
if
(
isLogEnable
)
{
StackTraceElement
stackTraceElement
=
Thread
.
currentThread
().
getStackTrace
()[
3
];
Log
.
w
(
tag
,
rebuildMsg
(
stackTraceElement
,
msg
));
}
}
/**
* Error
*
* @param tag
* @param msg
*/
public
static
void
e
(
String
tag
,
String
msg
)
{
if
(
isLogEnable
)
{
StackTraceElement
stackTraceElement
=
Thread
.
currentThread
().
getStackTrace
()[
3
];
Log
.
e
(
tag
,
rebuildMsg
(
stackTraceElement
,
msg
));
}
}
/**
* Error
*
* @param tag
* @param msg
* @param e
*/
public
static
void
e
(
String
tag
,
String
msg
,
Exception
e
)
{
if
(
isLogEnable
)
{
StackTraceElement
stackTraceElement
=
Thread
.
currentThread
().
getStackTrace
()[
3
];
Log
.
e
(
tag
,
rebuildMsg
(
stackTraceElement
,
msg
),
e
);
}
}
/**
* Rebuild Log Msg
*
* @param msg
* @return
*/
private
static
String
rebuildMsg
(
StackTraceElement
stackTraceElement
,
String
msg
)
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
stackTraceElement
.
getFileName
());
sb
.
append
(
" ("
);
sb
.
append
(
stackTraceElement
.
getLineNumber
());
sb
.
append
(
") "
);
sb
.
append
(
stackTraceElement
.
getMethodName
());
sb
.
append
(
": "
);
sb
.
append
(
msg
);
return
sb
.
toString
();
}
}
video/app/src/main/java/com/mints/library/utils/Utils.java
deleted
100755 → 0
View file @
35de9505
/*
* Copyright (C) 2017 MINDORKS NEXTGEN PRIVATE LIMITED
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
mints
.
library
.
utils
;
import
android.accessibilityservice.AccessibilityServiceInfo
;
import
android.app.Activity
;
import
android.content.ClipData
;
import
android.content.ClipboardManager
;
import
android.content.Context
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.view.accessibility.AccessibilityManager
;
import
androidx.core.content.ContextCompat
;
import
com.mints.helivideo.MintsApplication
;
import
com.mints.helivideo.manager.UserManager
;
import
java.io.File
;
import
java.text.DecimalFormat
;
import
java.util.List
;
import
java.util.Locale
;
public
final
class
Utils
{
private
Utils
()
{
// no instance
}
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public
static
int
dip2px
(
Context
context
,
float
dpValue
)
{
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
dpValue
*
scale
+
0.5f
);
}
public
static
String
formatSize
(
long
size
)
{
if
(
size
<=
0
)
return
""
;
final
String
[]
units
=
new
String
[]{
"B"
,
"KB"
,
"MB"
,
"GB"
,
"TB"
};
int
digitGroups
=
(
int
)
(
Math
.
log10
(
size
)
/
Math
.
log10
(
1024
));
return
new
DecimalFormat
(
"#,##0.#"
).
format
(
size
/
Math
.
pow
(
1024
,
digitGroups
))
+
" "
+
units
[
digitGroups
];
}
public
static
File
[]
getFileList
(
String
str
)
{
File
file
=
new
File
(
str
);
if
(!
file
.
isDirectory
())
{
return
new
File
[
0
];
}
return
file
.
listFiles
();
}
/**
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
*/
public
static
int
px2dip
(
Context
context
,
float
pxValue
)
{
final
float
scale
=
context
.
getResources
().
getDisplayMetrics
().
density
;
return
(
int
)
(
pxValue
/
scale
+
0.5f
);
}
public
static
String
getRootDirPath
(
Context
context
)
{
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
Environment
.
getExternalStorageState
()))
{
File
file
=
ContextCompat
.
getExternalFilesDirs
(
context
.
getApplicationContext
(),
null
)[
0
];
return
file
.
getAbsolutePath
();
}
else
{
return
context
.
getApplicationContext
().
getFilesDir
().
getAbsolutePath
();
}
}
public
static
String
getProgressDisplayLine
(
long
currentBytes
,
long
totalBytes
)
{
return
getBytesToMBString
(
currentBytes
)
+
"/"
+
getBytesToMBString
(
totalBytes
);
}
private
static
String
getBytesToMBString
(
long
bytes
)
{
return
String
.
format
(
Locale
.
ENGLISH
,
"%.2fMB"
,
bytes
/
(
1024.00
*
1024.00
));
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
((
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
));
}
/**
* 隐藏按键状态栏
*
* @param activity
*/
public
static
void
hideBottomUIMenu
(
Activity
activity
)
{
//隐藏虚拟按键,并且全屏
if
(
Build
.
VERSION
.
SDK_INT
>
11
&&
Build
.
VERSION
.
SDK_INT
<
19
)
{
// lower api
View
v
=
activity
.
getWindow
().
getDecorView
();
v
.
setSystemUiVisibility
(
View
.
GONE
);
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
19
)
{
Window
_window
=
activity
.
getWindow
();
WindowManager
.
LayoutParams
params
=
_window
.
getAttributes
();
params
.
systemUiVisibility
=
View
.
SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
View
.
SYSTEM_UI_FLAG_IMMERSIVE
;
_window
.
setAttributes
(
params
);
}
}
/**
* 隐藏顶部状态栏
*
* @param activity
*/
public
static
void
hideTopUIStatus
(
Activity
activity
)
{
//去掉电池状态栏
activity
.
getWindow
().
setFlags
(
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
,
WindowManager
.
LayoutParams
.
FLAG_FULLSCREEN
);
}
/**
* 设置全屏
*
* @param activity
*/
public
static
void
setPhoneFullscreen
(
Activity
activity
)
{
//去掉电池状态栏
activity
.
getWindow
().
setLayout
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
MATCH_PARENT
);
}
/**
* 判断Activity是否Destroy
*
* @return
*/
public
static
boolean
isDestroy
(
Activity
activity
)
{
if
(
activity
==
null
||
activity
.
isFinishing
()
||
activity
.
isDestroyed
())
{
return
true
;
}
else
{
return
false
;
}
}
/**
* @return true 加载广告
*/
public
static
boolean
canLoadAd
()
{
if
(
UserManager
.
getInstance
().
getVipFlag
())
{
return
false
;
}
return
true
;
}
public
static
String
floatFormat
(
double
value
)
{
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
".00"
);
return
decimalFormat
.
format
(
value
);
}
public
static
void
copyText
(
String
text
)
{
Context
context
=
MintsApplication
.
getContext
();
ClipboardManager
clipboardManager
=
(
ClipboardManager
)
context
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
);
clipboardManager
.
setPrimaryClip
(
ClipData
.
newPlainText
(
"box_copy"
,
text
));
}
public
static
String
replaceWithEscapeCharForSql
(
String
src
)
{
if
(
src
==
null
)
{
return
null
;
}
/*String[][] escapeCharReplaceInSql = {{"/", "//"}, {"'", "''"}, {"[", "/["}, {"]", "/]"}, {"%", "/%"}, {"&","/&"}, {"_", "/_"}, {"(", "/("}, {")", "/)"}};
for(String[] escapeChars : escapeCharReplaceInSql){
src = src.replace(escapeChars[0], escapeChars[1]);
}*/
src
=
src
.
replace
(
"'"
,
"''"
);
return
src
;
}
}
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