Commit 7d81ef35 authored by sheteng's avatar sheteng

2.0 开发

parent d99fe237
......@@ -4,11 +4,9 @@ import android.view.*
import androidx.lifecycle.ViewModelProvider
import androidx.viewpager.widget.ViewPager
import com.ccwangluo.accelerator.databinding.FragmentBtnNavBinding
import com.ccwangluo.accelerator.ui.gameList.GameListFragment
import com.ccwangluo.accelerator.ui.home.*
import com.ccwangluo.accelerator.ui.home.AcceleratorFragment
import com.ccwangluo.accelerator.ui.home.AccelertorViewModel
import com.ccwangluo.accelerator.ui.home.MineFragment
import com.ccwangluo.accelerator.ui.home.NewsFragment
import com.ccwangluo.accelerator.utils.LoginUtils
import com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import com.google.android.material.bottomnavigation.BottomNavigationView
......@@ -37,10 +35,10 @@ class BottomNavigationFragment : XPageFragment(), ViewPager.OnPageChangeListener
return null
}
var titles = arrayOf("加速", "资讯", "我的")
var titles = arrayOf("加速", "消息", "我的")
var fragments = arrayOf(
AcceleratorFragment.newInstance(),
NewsFragment.newInstance(),
GameListFragment.newInstance(),
NoticeFragment.newInstance(),
MineFragment.newInstance()
)
......
......@@ -71,6 +71,9 @@ class DownloadDialog(
c.getInt(c.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR))
val mDownload_all =
c.getInt(c.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))
if (mDownload_all == 0) {
return 0f;
}
println("mDownload_so_far = $mDownload_so_far &&& mDownload_all = ${mDownload_all} &&& ${mDownload_so_far * 100 / mDownload_all} ")
return (mDownload_so_far.toFloat() / mDownload_all) * 100
}
......
package com.ccwangluo.accelerator.ui.gameList
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.ccwangluo.accelerator.R
import com.ccwangluo.accelerator.adapter.KotlinDataAdapter
import com.ccwangluo.accelerator.databinding.FragmentGameListBinding
import com.ccwangluo.accelerator.databinding.FragmentNewsBinding
import com.ccwangluo.accelerator.model.GameInfo
import com.ccwangluo.accelerator.model.Plugin
import com.ccwangluo.accelerator.ui.BottomNavigationFragment
import com.ccwangluo.accelerator.ui.home.NewsFragment
import com.ccwangluo.accelerator.ui.news.NewsObjectModel
import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.ccwangluo.accelerator.utils.ServerUtils
import com.ccwangluo.accelerator.utils.ShareUtils
import com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.utils.TitleBar
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class GameListFragment : XPageFragment() {
private lateinit var _binding: FragmentGameListBinding
private lateinit var gameListModel: GameListModel
private var page = 1;
var dataList = arrayListOf<GameInfo>()
override fun initTitleBar(): TitleBar? {
//不使用@Page标注的一定要注意覆盖这个方法
return null
}
override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
_binding = FragmentGameListBinding.inflate(inflater!!, container, false)
gameListModel = ViewModelProvider(this).get(GameListModel::class.java)
return _binding!!.root
}
override fun initViews() {
gameListModel.gameModel.observe(this) {
dataList.clear()
dataList.addAll(it)
_binding.gameList.adapter?.notifyDataSetChanged()
}
val layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
_binding.gameList.setLayoutManager(layoutManager)
_binding.gameList.adapter = KotlinDataAdapter.Builder<GameInfo>()
.setData(dataList)
.setLayoutId(R.layout.item_game)
.addBindView { itemView, itemData ->
val game_img = itemView.findViewById<ImageView>(R.id.game_img)
val game_server = itemView.findViewById<TextView>(R.id.game_server)
val game_name = itemView.findViewById<TextView>(R.id.game_name)
// val game_name = itemView.findViewById<TextView>(R.id.game_name)
Glide.with(this@GameListFragment)
.load(itemData.icon)
.into(game_img)
game_server.setText(itemData.boosterServer)
game_name.setText(itemData.gameName)
game_server.setOnClickListener {
activity?.let {
ServerUtils().choose(it)
}
}
}
.create()
gameListModel.freshData(this, page)
}
override fun initListeners() {
_binding.accShare.setOnClickListener {
DataRePortUtils.report("st_share_clk", mapOf("scene" to "3"))
activity?.let { it1 -> ShareUtils().share(it1) }
}
}
companion object {
fun newInstance(): GameListFragment {
val fragment = GameListFragment()
return fragment
}
}
}
\ No newline at end of file
package com.ccwangluo.accelerator.ui.gameList
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope
import com.ccwangluo.accelerator.model.Game
import com.ccwangluo.accelerator.model.GameInfo
import com.ccwangluo.accelerator.model.NewsModel
import com.ccwangluo.accelerator.utils.AcceleratorUtils
import com.ccwangluo.accelerator.utils.LoginUtils
import com.ccwangluo.accelerator.utils.SysUtils
import com.ccwangluo.accelerator.utils.http.HttpGo
import com.github.shadowsocks.bg.AuthManager
import com.xuexiang.xpage.base.XPageFragment
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class GameListModel : ViewModel() {
val gameModel = MutableLiveData<List<GameInfo>>()
fun freshData(xPageFragment: XPageFragment,page: Int) {
xPageFragment.lifecycleScope.launch(Dispatchers.IO) {
val res = HttpGo.getSync<Game>("/api/new/game/list?id=1&page=${page}&size=10")
res?.let {
it.data?.list?.let {
gameModel.postValue(it)
}
}
}
}
}
\ No newline at end of file
......@@ -125,11 +125,11 @@ class AcceleratorFragment : XPageFragment() {
}
acceleratorViewModel.userProfile.observe(this) {
if (it.hasUnreadNotice) {
binding.iconNoticeBadge.visibility = View.VISIBLE
} else {
binding.iconNoticeBadge.visibility = View.GONE
}
// if (it.hasUnreadNotice) {
// binding.iconNoticeBadge.visibility = View.VISIBLE
// } else {
// binding.iconNoticeBadge.visibility = View.GONE
// }
}
binding.progressViewCircleSmall.setProgressViewUpdateListener(object :
......@@ -158,14 +158,14 @@ class AcceleratorFragment : XPageFragment() {
}
override fun initListeners() {
binding.iconNotice.setOnClickListener {
DataRePortUtils.report("st_speed_sysmsg_clk")
openToWebview(HttpConfig.UI_MESSAGE_URL)
}
binding.accShare.setOnClickListener {
DataRePortUtils.report("st_share_clk", mapOf("scene" to "3"))
activity?.let { it1 -> ShareUtils().share(it1) }
}
// binding.iconNotice.setOnClickListener {
// DataRePortUtils.report("st_speed_sysmsg_clk")
// openToWebview(HttpConfig.UI_MESSAGE_URL)
// }
// binding.accShare.setOnClickListener {
// DataRePortUtils.report("st_share_clk", mapOf("scene" to "3"))
// activity?.let { it1 -> ShareUtils().share(it1) }
// }
binding.gamePage.setOnClickListener {
DataRePortUtils.report("st_game_sysmsg_clk")
......
package com.ccwangluo.accelerator.ui.home
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.fragment.app.Fragment
import com.ccwangluo.accelerator.databinding.FragmentMineBinding
import com.ccwangluo.accelerator.ui.web.AndroidInterface
import com.ccwangluo.accelerator.utils.LoginUtils
import com.ccwangluo.accelerator.utils.SysUtils
import com.github.shadowsocks.http.HttpConfig
import com.just.agentweb.core.AgentWeb
import com.just.agentweb.core.client.DefaultWebClient
import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.utils.TitleBar
class NoticeFragment : XPageFragment() {
private var _binding: FragmentMineBinding? = null
private val binding get() = _binding!!
private var agentWeb: AgentWeb? = null
override fun initTitleBar(): TitleBar? {
//不使用@Page标注的一定要注意覆盖这个方法
return null
}
override fun inflateView(inflater: LayoutInflater?, container: ViewGroup?): View {
_binding = FragmentMineBinding.inflate(inflater!!, container, false)
return binding.root
}
override fun initViews() {
var weburl = HttpConfig.UI_MAIN_URL +HttpConfig.UI_MESSAGE_URL + "?channel=${SysUtils.getChannel()}"
LoginUtils.token?.let {
weburl = weburl + "&token=${it}"
}
agentWeb =
createAgentWeb(this, binding.mineWebview, weburl)
agentWeb?.getJsInterfaceHolder()
?.addJavaObject("android", AndroidInterface(this, agentWeb!!))
}
override fun initListeners() {
}
companion object {
fun newInstance(): NoticeFragment {
val fragment = NoticeFragment()
return fragment
}
}
fun createAgentWeb(fragment: Fragment?, viewGroup: ViewGroup, url: String): AgentWeb {
return AgentWeb.with(fragment!!)
.setAgentWebParent(
viewGroup!!,
-1,
FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
)
.useDefaultIndicator(Color.parseColor("#3CA4FD"), 3)
.setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK)
.createAgentWeb()
.ready()
.go(url)
}
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
refreshLogin()
}
override fun onHiddenChanged(hidden: Boolean) {
super.onHiddenChanged(hidden)
if (!hidden) {
refreshLogin()
}
}
private fun refreshLogin() {
LoginUtils.token?.let {
agentWeb?.getJsAccessEntrace()
?.quickCallJs("userToken", it)
} ?: let {
agentWeb?.getJsAccessEntrace()
?.quickCallJs("clearToken")
}
}
override fun onPause() {
agentWeb?.getWebLifeCycle()?.onPause()
super.onPause()
}
override fun onResume() {
refreshLogin()
agentWeb?.getWebLifeCycle()?.onResume()
super.onResume()
}
override fun onDestroyView() {
agentWeb?.getWebLifeCycle()?.onDestroy()
super.onDestroyView()
}
}
\ No newline at end of file
......@@ -29,17 +29,13 @@ class SplashFragment : XPageFragment() {
}
override fun initViews() {
AcceleratorUtils.getGameList(this) {
if (it) {
lifecycleScope.launch(Dispatchers.IO) {
delay(1000)
withContext(Dispatchers.Main) {
openPage(BottomNavigationFragment::class.java, false)
}
}
TencentLocationManager.getInstance(context)
lifecycleScope.launch(Dispatchers.IO) {
delay(1000)
withContext(Dispatchers.Main) {
openPage(BottomNavigationFragment::class.java, false)
}
}
TencentLocationManager.getInstance(context)
}
override fun initListeners() {
......
package com.ccwangluo.accelerator.utils
import android.app.Activity
import android.view.View
import android.view.ViewGroup
import com.ccwangluo.accelerator.R
import com.ccwangluo.accelerator.utils.datareport.DataRePortUtils
import com.github.shadowsocks.http.HttpConfig
import com.umeng.socialize.ShareAction
import com.umeng.socialize.bean.SHARE_MEDIA
import com.umeng.socialize.media.UMWeb
import com.xuexiang.xui.widget.dialog.bottomsheet.BottomSheet
class ServerUtils {
var mdialog: BottomSheet? = null
fun choose(activity: Activity) {
mdialog = BottomSheet(activity)
val contentView: View = buildViews(activity)
mdialog?.setContentView(contentView,
ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
mdialog?.show()
}
fun buildViews(activity: Activity): View {
val inflate = View.inflate(activity, R.layout.bottom_server_choose, null)
inflate.findViewById<View>(R.id.share_close).setOnClickListener {
mdialog?.dismiss()
}
return inflate
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#E1F8FF" />
<corners android:radius="15dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginTop="11.5dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="选择区服"
android:textColor="#FF898F94"
android:textSize="14sp"
android:layout_centerInParent="true"
/>
<ImageView
android:id="@+id/share_close"
android:padding="2dp"
android:layout_alignParentRight="true"
android:layout_marginRight="11.5dp"
android:layout_width="14dp"
android:layout_height="14dp"
android:background="@mipmap/btn_close"
/>
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
......@@ -21,7 +21,7 @@
android:layout_gravity="bottom"
app:labelVisibilityMode="labeled"
app:itemTextColor="@color/color_state_menu_navi"
android:background="@color/nr_gray"
android:background="@color/white"
app:menu="@menu/bottom_nav_menu" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@color/colorPrimaryDark"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#31354B"
>
<TextView
android:layout_weight="1"
android:layout_marginTop="32.5dp"
android:layout_marginLeft="15.5dp"
android:layout_width="36dp"
android:layout_height="25dp"
android:text="加速"
android:textColor="#FFFFFFFF"
android:textSize="18sp"
/>
<View
android:id="@+id/acc_share"
android:layout_marginTop="37.5dp"
android:layout_marginRight="16.5dp"
android:layout_width="18dp"
android:layout_height="18dp"
android:background="@mipmap/share"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/game_list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
\ No newline at end of file
......@@ -31,39 +31,39 @@
android:textColor="#FFFFFFFF"
android:textSize="16sp" />
<ImageView
android:id="@+id/acc_share"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="22.15dp"
android:background="@mipmap/share" />
<RelativeLayout
android:id="@+id/icon_notice"
android:layout_width="19dp"
android:layout_height="21dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="58.5dp">
<ImageView
android:layout_width="19dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@mipmap/message" />
<com.xuexiang.xui.widget.button.roundbutton.RoundButton
android:id="@+id/icon_notice_badge"
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_alignParentEnd="true"
android:visibility="gone"
app:rb_backgroundColor="@color/red"
app:rb_radius="4dp" />
</RelativeLayout>
<!-- <ImageView-->
<!-- android:id="@+id/acc_share"-->
<!-- android:layout_width="20dp"-->
<!-- android:layout_height="20dp"-->
<!-- android:layout_alignParentEnd="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginEnd="22.15dp"-->
<!-- android:background="@mipmap/share" />-->
<!-- <RelativeLayout-->
<!-- android:id="@+id/icon_notice"-->
<!-- android:layout_width="19dp"-->
<!-- android:layout_height="21dp"-->
<!-- android:layout_alignParentEnd="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:layout_marginEnd="22.15dp">-->
<!-- <ImageView-->
<!-- android:layout_width="19dp"-->
<!-- android:layout_height="20dp"-->
<!-- android:layout_alignParentEnd="true"-->
<!-- android:layout_centerVertical="true"-->
<!-- android:background="@mipmap/message" />-->
<!-- <com.xuexiang.xui.widget.button.roundbutton.RoundButton-->
<!-- android:id="@+id/icon_notice_badge"-->
<!-- android:layout_width="8dp"-->
<!-- android:layout_height="8dp"-->
<!-- android:layout_alignParentEnd="true"-->
<!-- android:visibility="gone"-->
<!-- app:rb_backgroundColor="@color/red"-->
<!-- app:rb_radius="4dp" />-->
<!-- </RelativeLayout>-->
</RelativeLayout>
<RelativeLayout
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/game_img"
android:layout_width="52.5dp"
android:layout_height="52.5dp"
android:layout_marginLeft="22.5dp"
android:layout_marginTop="11dp"
android:background="@mipmap/game_download" />
<LinearLayout
android:layout_marginLeft="11.5dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<TextView
android:background="@drawable/acc_text_bg_blue"
android:padding="2dp"
android:maxLength="4"
android:id="@+id/game_server"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="全球"
android:textColor="#FF36B8F4"
android:textSize="11sp"
android:layout_marginRight="13dp"
/>
<TextView
android:id="@+id/game_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#FF333333"
android:textSize="14.5sp"
/>
</LinearLayout>
<TextView
android:id="@+id/game_update_notice"
android:layout_marginTop="4dp"
android:layout_width="84dp"
android:layout_height="14.5dp"
android:text="新版本,点击更新"
android:textColor="#FFFBB06B"
android:textSize="10.5sp"
/>
</LinearLayout>
<LinearLayout
android:layout_marginRight="21dp"
android:layout_width="65dp"
android:layout_height="30dp"
android:background="@mipmap/btn_bg"
android:gravity="center"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
>
<TextView
android:layout_width="25dp"
android:layout_height="18dp"
android:text="加速"
android:textColor="#FFFFFFFF"
android:textSize="12.5sp"
/>
</LinearLayout>
</LinearLayout>
<View
android:background="@color/divide_gray"
android:layout_marginTop="7.75dp"
android:layout_width="match_parent"
android:layout_marginLeft="22.5dp"
android:layout_marginRight="22.5dp"
android:layout_height="1dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginTop="7.75dp"
android:layout_marginBottom="7.75dp"
android:layout_height="wrap_content">
<TextView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="资讯社区"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#FF36B8F4"
android:textSize="11.5sp"
/>
<View
android:layout_gravity="center"
android:layout_width="1dp"
android:background="@color/divide_gray"
android:layout_height="14dp"
/>
<TextView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="资讯社区"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#FF36B8F4"
android:textSize="11.5sp"
/>
<View
android:layout_gravity="center"
android:layout_width="1dp"
android:background="@color/divide_gray"
android:layout_height="14dp"
/>
<TextView
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="资讯社区"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#FF36B8F4"
android:textSize="11.5sp"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="13dp"/>
</LinearLayout>
......@@ -2,17 +2,14 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/navigation_dashboard"
android:icon="@drawable/quick"
android:title="加速"/>
<item
android:id="@+id/navigation_home"
android:icon="@drawable/news"
android:title="资讯"/>
android:title="消息"/>
<item
android:id="@+id/navigation_notifications"
android:icon="@drawable/mine"
android:title="我的"/>
......
......@@ -5,6 +5,7 @@
<color name="colorPrimary">#2EE7F0</color>
<color name="colorPrimaryDark">#6A6D80</color>
<color name="divide_gray">#136A6D80</color>
<color name="text_litte_white">#ffd0fffd</color>
<color name="bg_litte_divi">#000000</color>
......
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