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,6 +101,7 @@ class NewsFragment : XPageFragment() {
val version =
AppUtils.getAppVersionCode(it.packageName)
itemData.url?.let {
if(!it.isNullOrBlank()){
var newversion = it.split("/").let { it1->
it1.get(it1.lastIndex - 1).toInt()
}
......@@ -111,6 +112,7 @@ class NewsFragment : XPageFragment() {
}
}
}
}
}
itemView.setOnClickListener {
......@@ -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)
}
......
package com.ccwangluo.accelerator.ui.news
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
......@@ -24,9 +25,11 @@ import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
import com.ccwangluo.accelerator.model.NewsModel
import com.ccwangluo.accelerator.ui.view.RatingBar
import com.ccwangluo.accelerator.ui.web.CommonWebViewFragment
import com.ccwangluo.accelerator.utils.LoginUtils
import com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import com.github.shadowsocks.http.HttpConfig
import com.hjq.toast.ToastUtils
import com.xuexiang.xpage.core.PageOption
class NewsObjectFragment : XPageFragment() {
......@@ -79,35 +82,64 @@ class NewsObjectFragment : XPageFragment() {
itemView.findViewById<TextView>(R.id.title).visibility = View.VISIBLE
itemView.findViewById<TextView>(R.id.title).setText(it)
}
?: let { itemView.findViewById<TextView>(R.id.title).visibility = View.GONE }
?: let {
itemView.findViewById<TextView>(R.id.title).visibility = View.GONE
}
if (itemData.type == 5) {
itemData.content?.let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.VISIBLE
itemView.findViewById<TextView>(R.id.abbrContent).visibility =
View.VISIBLE
itemView.findViewById<TextView>(R.id.abbrContent).setText(it)
} ?: let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.GONE
}
} else {
itemData.abbrContent?.let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.VISIBLE
itemView.findViewById<TextView>(R.id.abbrContent).visibility =
View.VISIBLE
itemView.findViewById<TextView>(R.id.abbrContent).setText(it)
} ?: let {
itemView.findViewById<TextView>(R.id.abbrContent).visibility = View.GONE
}
}
// 资讯类型:0攻略 1视频
val imgs = itemView.findViewById<ImageView>(R.id.imgs)
val imgs1 = itemView.findViewById<ImageView>(R.id.imgs1)
val imgs2 = itemView.findViewById<ImageView>(R.id.imgs2)
val vedio = itemView.findViewById<JCVideoPlayerStandard>(R.id.video_view)
vedio.backButton.visibility = View.GONE
vedio.tinyBackImageView.visibility = View.GONE
itemData.imgs?.let {
val split = itemData.imgs.split(",")
if (split.size > 0) {
imgs.visibility = View.VISIBLE
Glide.with(this@NewsObjectFragment).load(itemData.imgs.split(",").get(0))
Glide.with(this@NewsObjectFragment).load(split.get(0))
.into(imgs)
} else {
imgs.visibility = View.GONE
}
if (split.size > 1) {
imgs1.visibility = View.VISIBLE
Glide.with(this@NewsObjectFragment).load(split.get(1))
.into(imgs1)
} else {
imgs1.visibility = View.GONE
}
if (split.size > 2) {
imgs2.visibility = View.VISIBLE
Glide.with(this@NewsObjectFragment).load(split.get(2))
.into(imgs2)
} else {
imgs2.visibility = View.GONE
}
} ?: let {
imgs.visibility = View.GONE
imgs1.visibility = View.GONE
imgs2.visibility = View.GONE
}
itemData.videoUrl?.let {
vedio.visibility = View.VISIBLE
......@@ -118,7 +150,8 @@ class NewsObjectFragment : XPageFragment() {
Glide.with(this@NewsObjectFragment).load(it)
.into(vedio.thumbImageView)
}
} ?: let {
vedio.visibility = View.GONE
}
val star = itemView.findViewById<RatingBar>(R.id.star)
itemData.star?.let {
......@@ -136,11 +169,13 @@ class NewsObjectFragment : XPageFragment() {
}
itemData.isGreat?.let {
if (it) {
itemView.findViewById<TextView>(R.id.great_num).setTextColor(Color.parseColor("#3CA4FD"))
itemView.findViewById<TextView>(R.id.great_num)
.setTextColor(Color.parseColor("#3CA4FD"))
itemView.findViewById<ImageView>(R.id.great_img)
.setBackgroundResource(R.mipmap.icon_praise_bu)
} else {
itemView.findViewById<TextView>(R.id.great_num).setTextColor(Color.parseColor("#FFBBBBBB"))
itemView.findViewById<TextView>(R.id.great_num)
.setTextColor(Color.parseColor("#FFBBBBBB"))
itemView.findViewById<ImageView>(R.id.great_img)
.setBackgroundResource(R.mipmap.icon_praise_ga)
}
......@@ -150,7 +185,13 @@ class NewsObjectFragment : XPageFragment() {
if (!it) {
DataRePortUtils.report("st_like_clk")
}
newsViewModel?.greate(this@NewsObjectFragment, itemData.type, gameId, itemData.id, it) {
newsViewModel?.greate(
this@NewsObjectFragment,
itemData.type,
gameId,
itemData.id,
it
) {
if (!it) {
ToastUtils.show("点赞成功")
itemData.isGreat = true
......@@ -165,12 +206,7 @@ class NewsObjectFragment : XPageFragment() {
}
itemView.findViewById<View>(R.id.item_click_view).setOnClickListener {
val params = Bundle()
params.putString(
CommonWebViewFragment.WEBVIEW_URL_KEY, HttpConfig.UI_MAIN_URL +
"/gameDetail?gameId=${gameId}&id=${itemData.id}"
)
openPage(CommonWebViewFragment::class.java, params)
openWebviewForResult(itemData)
}
}
.create()
......@@ -201,6 +237,40 @@ class NewsObjectFragment : XPageFragment() {
recycle_view?.adapter?.notifyDataSetChanged()
viewModel.isRefresh.postValue(true)
})
newsViewModel?.clearList?.observe(this, {
if (it) {
dataList.clear()
}
})
}
var CLICK_GREAT_REQUEST_CODE = 200
var itemData: News? = null
private fun openWebviewForResult(itemData: News) {
this.itemData = itemData
PageOption.to(CommonWebViewFragment::class.java)
.putString(
CommonWebViewFragment.WEBVIEW_URL_KEY, HttpConfig.UI_MAIN_URL +
"/gameDetail?gameId=${gameId}&id=${itemData.id}"
)
.setRequestCode(CLICK_GREAT_REQUEST_CODE)
.open(this)
}
override fun onFragmentResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onFragmentResult(requestCode, resultCode, data)
if (requestCode == CLICK_GREAT_REQUEST_CODE) {
itemData?.let {
if (resultCode == 200) {
it.isGreat = true
it.greatNum++
} else {
it.isGreat = false
it.greatNum--
}
recycle_view?.adapter?.notifyDataSetChanged()
}
}
}
protected fun isSlideToBottom(recyclerView: RecyclerView?): Boolean {
......@@ -215,7 +285,6 @@ class NewsObjectFragment : XPageFragment() {
fun refresh() {
AcceleratorUtils.game?.let {
dataList.clear()
gameId = it.id
page = 1
newsViewModel?.freshData(position, it.id, page)
......
......@@ -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
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 {
/**
* 描述: 安装
*/
fun install(apkPath: String, context: Context): Boolean {
// 没有root权限,利用意图进行安装
val file = File(apkPath)
if (!file.exists()) {
return false
}
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")
val uri: Uri
val type = "application/vnd.android.package-archive"
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
uri = Uri.fromFile(file)
} else {
intent.setDataAndType(
Uri.fromFile(apkFile),
"application/vnd.android.package-archive"
)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
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)
} catch (e: Exception) {
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,17 +97,43 @@
android:maxLines="3"
android:textColor="#FF4A4A4A"
android:textSize="14sp" />
<ImageView
<LinearLayout
android:layout_marginTop="12.65dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:id="@+id/imgs"
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:layout_marginTop="12.65dp"
android:scaleType="fitXY"
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>
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
android:layout_marginLeft="20dp"
android:layout_marginRight="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