Commit ead1ad79 authored by sheteng's avatar sheteng

版本1.0.1

feed流排版,缩略图错乱
parent b53fd3fa
......@@ -10,6 +10,8 @@ import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
import com.xuexiang.xutil.app.AppUtils;
public class AppDownloadReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
......
......@@ -101,13 +101,15 @@ class NewsFragment : XPageFragment() {
val version =
AppUtils.getAppVersionCode(it.packageName)
itemData.url?.let {
var newversion = it.split("/").let { it1->
it1.get(it1.lastIndex - 1).toInt()
}
if (newversion > version && version!= -1) {
itemView.findViewById<TextView>(R.id.plugin_name).setText("游戏更新")
itemView.findViewById<TextView>(R.id.plugin_name)
.setTextColor(Color.parseColor("#329CF3"))
if(!it.isNullOrBlank()){
var newversion = it.split("/").let { it1->
it1.get(it1.lastIndex - 1).toInt()
}
if (newversion > version && version!= -1) {
itemView.findViewById<TextView>(R.id.plugin_name).setText("游戏更新")
itemView.findViewById<TextView>(R.id.plugin_name)
.setTextColor(Color.parseColor("#329CF3"))
}
}
}
}
......@@ -138,7 +140,6 @@ class NewsFragment : XPageFragment() {
if (itemData.type == 3) {
itemData.url?.let {
DataRePortUtils.report("st_game_down_clk", mapOf("scene" to "3"))
activity?.let { it1 ->
DownloadUtils.downloadFile(it1, it)
}
......
......@@ -14,6 +14,7 @@ import kotlinx.coroutines.withContext
class NewsObjectModel : ViewModel() {
val newsModel = MutableLiveData<NewsModel>()
val clearList = MutableLiveData<Boolean>()
fun freshData(position: String, gameId: Int, page: Int) {
val type = when (position) {
......@@ -29,6 +30,7 @@ class NewsObjectModel : ViewModel() {
res?.let {
if (it.code == 200) {
it.data?.let {
clearList.postValue(page == 1)
newsModel.postValue(it)
}
}
......@@ -39,7 +41,14 @@ class NewsObjectModel : ViewModel() {
/**
* 点赞
*/
fun greate(xPageFragment: XPageFragment,type: Int?, gameId: Int, parentId: Int, isGreate: Boolean, callback: () -> Unit) {
fun greate(
xPageFragment: XPageFragment,
type: Int?,
gameId: Int,
parentId: Int,
isGreate: Boolean,
callback: () -> Unit
) {
val map = mutableMapOf<String, Any>()
map.put("gameId", gameId)
map.put("parentId", parentId)
......@@ -48,7 +57,7 @@ class NewsObjectModel : ViewModel() {
map.put("type", it)
}
if (LoginUtils.token == null) {
xPageFragment.context?.let { LoginUtils.login(it,{}) }
xPageFragment.context?.let { LoginUtils.login(it, {}) }
return
}
viewModelScope.launch(Dispatchers.IO) {
......
......@@ -78,7 +78,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
* 跳转协议
*/
@JavascriptInterface
fun openWebviewByWholeUrl(url: String,showTitle: Boolean) {
fun openWebviewByWholeUrl(url: String, showTitle: Boolean) {
val params = Bundle()
if (url.startsWith("http:") || url.startsWith("https:")) {
params.putString(CommonWebViewFragment.WEBVIEW_URL_KEY, url)
......@@ -97,7 +97,7 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
*/
@JavascriptInterface
fun openWebviewByWholeUrl(url: String) {
openWebviewByWholeUrl(url,false)
openWebviewByWholeUrl(url, false)
}
//打开系统设置
......@@ -371,5 +371,16 @@ class AndroidInterface(val xPageFragment: XPageFragment, val agentWeb: AgentWeb)
}
}
@JavascriptInterface
fun isGrate(isopen: Boolean) {
handler.post {
if (isopen) {
xPageFragment.setFragmentResult(200, Intent())
} else {
xPageFragment.setFragmentResult(400, Intent())
}
}
}
}
\ No newline at end of file
......@@ -95,8 +95,12 @@ object AcceleratorUtils : TencentLocationListener {
fun initContext(context: XPageActivity, connect: ActivityResultLauncher<Void?>) {
this.context = context
this.connect = connect
NetworkAdapter.initNetworks(context)
ProfileManager.ensureNotEmpty()
try {
NetworkAdapter.initNetworks(context)
ProfileManager.ensureNotEmpty()
} catch (e: Exception) {
}
context.lifecycleScope.launch(Dispatchers.IO) {
while (true) {
if (state == BaseService.State.Connected) {
......@@ -157,7 +161,7 @@ object AcceleratorUtils : TencentLocationListener {
}
}
fun openLocation(context: Context){
fun openLocation(context: Context) {
PermissionUtils.permission(
Manifest.permission.ACCESS_FINE_LOCATION
).rationale({
......
......@@ -7,16 +7,23 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.webkit.MimeTypeMap
import androidx.core.content.FileProvider
import androidx.fragment.app.FragmentActivity
import com.ccwangluo.accelerator.ui.dialog.DownloadDialog
import com.hjq.toast.ToastUtils
import com.xuexiang.xutil.app.AppUtils
import com.xuexiang.xutil.file.FileUtils
import com.xuexiang.xutil.system.PermissionUtils
import java.io.File
object DownloadUtils {
fun downloadFile(activity: FragmentActivity, url: String) {
if(url.isNullOrBlank()){
return
}
if (!PermissionUtils.isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
ToastUtils.show("下载需要打开存储权限")
PermissionUtils.permission(Manifest.permission.WRITE_EXTERNAL_STORAGE.toString())
......@@ -26,22 +33,24 @@ object DownloadUtils {
return
}
var filename = url.split("/").last()
val file = File(
Environment.getExternalStorageDirectory().absolutePath + "/${Environment.DIRECTORY_DOWNLOADS}",
var file = File(
activity.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
filename
)
if (file.exists()) {
installApp(activity, file)
install(file.absolutePath, activity)
return
}
val downloadManager = activity.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
val request =
DownloadManager.Request(Uri.parse(url)) //添加下载文件的网络路径
request.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS,
filename
) //添加保存文件路径与名称
request.setDestinationInExternalFilesDir(activity,Environment.DIRECTORY_DOWNLOADS,filename)
val mimeTypeMap = MimeTypeMap.getSingleton()
val mimeString =
mimeTypeMap.getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(url))
request.setMimeType(mimeString)
request.setTitle("下载中") //添加在通知栏里显示的标题
// request.setDescription("下载中") //添加在通知栏里显示的描述
......@@ -57,29 +66,34 @@ object DownloadUtils {
DownloadDialog(activity, downloadManager, id).show()
}
fun installApp(context: Context, apkFile: File) {
try {
val intent = Intent(Intent.ACTION_VIEW)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
intent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
val contentUri: Uri = FileProvider.getUriForFile(
context,
"com.ccwangluo.accelerator.fileprovider",
apkFile
) //authorities就是provider里声明的authorities
intent.setDataAndType(contentUri, "application/vnd.android.package-archive")
} else {
intent.setDataAndType(
Uri.fromFile(apkFile),
"application/vnd.android.package-archive"
)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
context.startActivity(intent)
} catch (e: Exception) {
/**
* 描述: 安装
*/
fun install(apkPath: String, context: Context): Boolean {
// 没有root权限,利用意图进行安装
val file = File(apkPath)
if (!file.exists()) {
return false
}
val intent = Intent(Intent.ACTION_VIEW)
val uri: Uri
val type = "application/vnd.android.package-archive"
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
uri = Uri.fromFile(file)
} else {
val authority = "com.ccwangluo.accelerator.fileprovider"
uri = FileProvider.getUriForFile(context, authority, file)
intent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
}
context.grantUriPermission(
context.packageName,
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION
)
intent.setDataAndType(uri, type)
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(intent)
return true
}
}
\ No newline at end of file
......@@ -131,7 +131,7 @@ object SysUtils {
"OPPO" -> 6
"baiduzhushou" -> 7
"wufan" -> 8
else -> 0
else -> 1
}
}
}
......
......@@ -97,16 +97,42 @@
android:maxLines="3"
android:textColor="#FF4A4A4A"
android:textSize="14sp" />
<LinearLayout
android:layout_marginTop="12.65dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imgs"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="182.5dp"
android:scaleType="centerCrop"
android:visibility="gone" />
<ImageView
android:layout_marginLeft="5dp"
android:id="@+id/imgs1"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="182.5dp"
android:scaleType="centerCrop"
android:visibility="gone" />
<ImageView
android:layout_marginLeft="5dp"
android:id="@+id/imgs2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="182.5dp"
android:scaleType="centerCrop"
android:visibility="gone" />
</LinearLayout>
<ImageView
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="@+id/imgs"
android:layout_width="match_parent"
android:layout_height="182.5dp"
android:layout_marginTop="12.65dp"
android:scaleType="fitXY"
android:visibility="gone" />
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
android:layout_marginLeft="20dp"
......
......@@ -5,10 +5,16 @@
<root-path name="opensdk_root" path=""/>
<external-files-path name="opensdk_external" path="Images/tmp"/>
<external-path name="external_storage_root" path="."/>
<external-path
name="external"
path="./Download"/>
<files-path
name="files"
path="."/>
<files-path name="files-path" path="/."/>
<cache-path name="cache-path" path="/."/>
<external-path name="external-path" path="/."/>
<external-files-path name="external-files-path" path="/."/>
<external-cache-path name="external-cache-path" path="/."/>
<external-path path="." name="download" />
<external-cache-path
name="storage/emulated/0"
path="." />
</paths>
\ No newline at end of file
......@@ -56,8 +56,8 @@ fun Project.setupCore() {
setupCommon()
android.apply {
defaultConfig {
versionCode = 1
versionName = "1.0.0"
versionCode = 2
versionName = "1.0.1"
}
compileOptions.isCoreLibraryDesugaringEnabled = true
lintOptions {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment