feat(layout): 适配平板设备
- 新增横屏布局文件,优化用户体验 - 重构部分代码以支持新布局 -移除不必要的工具类和适配器
This commit is contained in:
parent
c3ac73c8f4
commit
e77d3a390d
|
@ -9,8 +9,6 @@ Support Chinese and English code association, automatic completion.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### 源码运行问题解决:
|
#### 源码运行问题解决:
|
||||||
|
|
||||||
###### 1.打包时报错,缺少SDK路径
|
###### 1.打包时报错,缺少SDK路径
|
||||||
|
@ -24,3 +22,6 @@ SDK location not found.
|
||||||
```
|
```
|
||||||
sdk.dir=(安卓SDK路径)
|
sdk.dir=(安卓SDK路径)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### DeBug
|
||||||
|
偷偷的更新一下,适配一下平板吧
|
|
@ -287,7 +287,8 @@
|
||||||
android:icon="@drawable/table"
|
android:icon="@drawable/table"
|
||||||
android:taskAffinity="@string/code_table"
|
android:taskAffinity="@string/code_table"
|
||||||
android:documentLaunchMode="intoExisting"
|
android:documentLaunchMode="intoExisting"
|
||||||
android:exported="false">
|
android:exported="false"
|
||||||
|
tools:ignore="ManifestResource">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".LoginActivity"
|
android:name=".LoginActivity"
|
||||||
|
|
|
@ -1,33 +1,24 @@
|
||||||
package com.coldmint.rust.pro
|
package com.coldmint.rust.pro
|
||||||
|
|
||||||
import com.coldmint.rust.pro.base.BaseActivity
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import cat.ereza.customactivityoncrash.CustomActivityOnCrash
|
|
||||||
import com.coldmint.rust.pro.tool.AppSettings
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.core.view.isVisible
|
import cat.ereza.customactivityoncrash.CustomActivityOnCrash
|
||||||
import com.coldmint.rust.core.dataBean.ApiResponse
|
import com.coldmint.rust.core.dataBean.ApiResponse
|
||||||
import com.coldmint.rust.core.debug.LogCat
|
import com.coldmint.rust.core.debug.LogCat
|
||||||
import com.coldmint.rust.core.interfaces.ApiCallBack
|
import com.coldmint.rust.core.interfaces.ApiCallBack
|
||||||
import com.coldmint.rust.core.tool.FileOperator
|
import com.coldmint.rust.core.tool.FileOperator
|
||||||
import com.coldmint.rust.core.web.ErrorReport
|
import com.coldmint.rust.core.web.ErrorReport
|
||||||
import com.coldmint.rust.core.web.ServerConfiguration
|
import com.coldmint.rust.core.web.ServerConfiguration
|
||||||
|
import com.coldmint.rust.pro.base.BaseActivity
|
||||||
import com.coldmint.rust.pro.databean.ErrorInfo
|
import com.coldmint.rust.pro.databean.ErrorInfo
|
||||||
import com.coldmint.rust.pro.databinding.ActivityErrorBinding
|
import com.coldmint.rust.pro.databinding.ActivityErrorBinding
|
||||||
|
import com.coldmint.rust.pro.tool.AppSettings
|
||||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.google.gson.Gson
|
|
||||||
import java.io.File
|
|
||||||
import java.lang.StringBuilder
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class ErrorActivity() : BaseActivity<ActivityErrorBinding>() {
|
class ErrorActivity() : BaseActivity<ActivityErrorBinding>() {
|
||||||
private val errorInfo by lazy {
|
private val errorInfo by lazy {
|
||||||
|
@ -113,19 +104,19 @@ class ErrorActivity() : BaseActivity<ActivityErrorBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initAction() {
|
private fun initAction() {
|
||||||
viewBinding.shareLogButton.setOnClickListener(View.OnClickListener {
|
viewBinding.shareLogButton.setOnClickListener {
|
||||||
saveLog()
|
saveLog()
|
||||||
if (!errorInfo.getLogFile().exists()) {
|
if (!errorInfo.getLogFile().exists()) {
|
||||||
Snackbar.make(
|
Snackbar.make(
|
||||||
viewBinding.shareLogButton,
|
viewBinding.shareLogButton,
|
||||||
R.string.file_not_exist,
|
R.string.file_not_exist,
|
||||||
Snackbar.LENGTH_SHORT
|
Snackbar.LENGTH_SHORT
|
||||||
)
|
)
|
||||||
.show()
|
.show()
|
||||||
} else {
|
} else {
|
||||||
FileOperator.shareFile(this@ErrorActivity, errorInfo.getLogFile())
|
FileOperator.shareFile(this@ErrorActivity, errorInfo.getLogFile())
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ class RustApplication : Application() {
|
||||||
}
|
}
|
||||||
// android:screenOrientation="portrait"
|
// android:screenOrientation="portrait"
|
||||||
//全局强制横屏
|
//全局强制横屏
|
||||||
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
// activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
}
|
}
|
||||||
override fun onActivityStarted(activity: Activity) {}
|
override fun onActivityStarted(activity: Activity) {}
|
||||||
override fun onActivityResumed(activity: Activity) {}
|
override fun onActivityResumed(activity: Activity) {}
|
||||||
|
|
|
@ -9,18 +9,18 @@ import com.coldmint.rust.core.database.code.CodeInfo
|
||||||
import com.coldmint.rust.core.database.code.SectionInfo
|
import com.coldmint.rust.core.database.code.SectionInfo
|
||||||
import com.coldmint.rust.core.tool.LineParser
|
import com.coldmint.rust.core.tool.LineParser
|
||||||
import com.coldmint.rust.pro.R
|
import com.coldmint.rust.pro.R
|
||||||
|
import com.coldmint.rust.pro.base.BaseVh
|
||||||
import com.coldmint.rust.pro.databinding.ActivityCodeTableBinding
|
import com.coldmint.rust.pro.databinding.ActivityCodeTableBinding
|
||||||
import com.coldmint.rust.pro.databinding.ItemCodetableBinding
|
import com.coldmint.rust.pro.databinding.ItemCodetableBinding
|
||||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||||
import com.google.android.gms.common.internal.Objects
|
import com.google.android.gms.common.internal.Objects
|
||||||
import com.muqing.VH
|
|
||||||
|
|
||||||
class CodeTableAdapter(
|
class CodeTableAdapter(
|
||||||
val context: Context,
|
val context: Context,
|
||||||
private val group: List<SectionInfo>,
|
private val group: List<SectionInfo>,
|
||||||
private val itemList: List<List<CodeInfo>>,
|
private val itemList: List<List<CodeInfo>>,
|
||||||
private val binding: ActivityCodeTableBinding
|
private val binding: ActivityCodeTableBinding
|
||||||
) : RecyclerView.Adapter<VH<ItemCodetableBinding>>() {
|
) : RecyclerView.Adapter<BaseVh<ItemCodetableBinding>>() {
|
||||||
private var versionMap: HashMap<Int, String>? = null
|
private var versionMap: HashMap<Int, String>? = null
|
||||||
private var typeNameMap: HashMap<String, String>? = null
|
private var typeNameMap: HashMap<String, String>? = null
|
||||||
private var sectionMap: HashMap<String, String>? = null
|
private var sectionMap: HashMap<String, String>? = null
|
||||||
|
@ -182,8 +182,8 @@ class CodeTableAdapter(
|
||||||
return resultView.root
|
return resultView.root
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH<ItemCodetableBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseVh<ItemCodetableBinding> {
|
||||||
return VH(ItemCodetableBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
return BaseVh(ItemCodetableBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
|
@ -204,7 +204,7 @@ class CodeTableAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged", "StringFormatInvalid")
|
@SuppressLint("NotifyDataSetChanged", "StringFormatInvalid")
|
||||||
override fun onBindViewHolder(holder: VH<ItemCodetableBinding>, position: Int) {
|
override fun onBindViewHolder(holder: BaseVh<ItemCodetableBinding>, position: Int) {
|
||||||
holder.binging.title.text = group[position].translate
|
holder.binging.title.text = group[position].translate
|
||||||
val format = String.format(
|
val format = String.format(
|
||||||
context.getString(R.string.filenum),
|
context.getString(R.string.filenum),
|
||||||
|
|
|
@ -20,16 +20,16 @@ import com.coldmint.rust.core.database.code.CodeDataBase
|
||||||
import com.coldmint.rust.core.database.code.CodeInfo
|
import com.coldmint.rust.core.database.code.CodeInfo
|
||||||
import com.coldmint.rust.core.tool.LineParser
|
import com.coldmint.rust.core.tool.LineParser
|
||||||
import com.coldmint.rust.pro.R
|
import com.coldmint.rust.pro.R
|
||||||
|
import com.coldmint.rust.pro.base.BaseVh
|
||||||
import com.coldmint.rust.pro.databinding.CodeTableItemBinding
|
import com.coldmint.rust.pro.databinding.CodeTableItemBinding
|
||||||
import com.coldmint.rust.pro.dialog.MaterialBottomDialog
|
import com.coldmint.rust.pro.dialog.MaterialBottomDialog
|
||||||
import com.coldmint.rust.pro.tool.AppSettings
|
import com.coldmint.rust.pro.tool.AppSettings
|
||||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import com.muqing.VH
|
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
class CodeTableItemAdapter(val recyclerView: RecyclerView,
|
class CodeTableItemAdapter(val recyclerView: RecyclerView,
|
||||||
var list: List<CodeInfo>) : RecyclerView.Adapter<VH<CodeTableItemBinding>>() {
|
var list: List<CodeInfo>) : RecyclerView.Adapter<BaseVh<CodeTableItemBinding>>() {
|
||||||
|
|
||||||
private val lineParser = LineParser()
|
private val lineParser = LineParser()
|
||||||
|
|
||||||
|
@ -63,8 +63,8 @@ class CodeTableItemAdapter(val recyclerView: RecyclerView,
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH<CodeTableItemBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseVh<CodeTableItemBinding> {
|
||||||
return VH(CodeTableItemBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
return BaseVh(CodeTableItemBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
|
@ -112,7 +112,7 @@ class CodeTableItemAdapter(val recyclerView: RecyclerView,
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StringFormatInvalid")
|
@SuppressLint("StringFormatInvalid")
|
||||||
override fun onBindViewHolder(holder: VH<CodeTableItemBinding>, position: Int) {
|
override fun onBindViewHolder(holder: BaseVh<CodeTableItemBinding>, position: Int) {
|
||||||
val context = holder.itemView.context
|
val context = holder.itemView.context
|
||||||
val resultView: CodeTableItemBinding = holder.binging
|
val resultView: CodeTableItemBinding = holder.binging
|
||||||
val codeInfo = list[position]
|
val codeInfo = list[position]
|
||||||
|
|
|
@ -8,20 +8,19 @@ import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.coldmint.rust.core.turret.TurretData
|
import com.coldmint.rust.core.turret.TurretData
|
||||||
import com.coldmint.rust.pro.R
|
import com.coldmint.rust.pro.R
|
||||||
|
import com.coldmint.rust.pro.base.BaseVh
|
||||||
import com.coldmint.rust.pro.databinding.ItemTabBinding
|
import com.coldmint.rust.pro.databinding.ItemTabBinding
|
||||||
import com.muqing.VH
|
|
||||||
import com.muqing.gj
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Cold Mint
|
* @author Cold Mint
|
||||||
* @date 2022/1/10 8:49
|
* @date 2022/1/10 8:49
|
||||||
*/
|
*/
|
||||||
class DesignAdapter(private val onclick: Click) : RecyclerView.Adapter<VH<ItemTabBinding>>() {
|
class DesignAdapter(private val onclick: Click) : RecyclerView.Adapter<BaseVh<ItemTabBinding>>() {
|
||||||
|
|
||||||
var list: ArrayList<TurretData> = arrayListOf()
|
var list: ArrayList<TurretData> = arrayListOf()
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH<ItemTabBinding> {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseVh<ItemTabBinding> {
|
||||||
return VH(ItemTabBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
return BaseVh(ItemTabBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
|
@ -31,9 +30,9 @@ class DesignAdapter(private val onclick: Click) : RecyclerView.Adapter<VH<ItemTa
|
||||||
lateinit var string: TurretData
|
lateinit var string: TurretData
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
override fun onBindViewHolder(holder: VH<ItemTabBinding>, position: Int) {
|
override fun onBindViewHolder(holder: BaseVh<ItemTabBinding>, position: Int) {
|
||||||
holder.binging.button.text = list[position].name
|
holder.binging.button.text = list[position].name
|
||||||
gj.sc(list[position].imageFile)
|
// gj.sc(list[position].imageFile)
|
||||||
|
|
||||||
if (string == list[position]) {
|
if (string == list[position]) {
|
||||||
holder.binging.root.isEnabled = false
|
holder.binging.root.isEnabled = false
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.muqing;
|
package com.coldmint.rust.pro.base;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.viewbinding.ViewBinding;
|
import androidx.viewbinding.ViewBinding;
|
||||||
public class VH<Binging extends ViewBinding> extends RecyclerView.ViewHolder {
|
|
||||||
|
public class BaseVh<Binging extends ViewBinding> extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
public Binging binging;
|
public Binging binging;
|
||||||
public VH(@NonNull Binging itemView) {
|
public BaseVh(@NonNull Binging itemView) {
|
||||||
super(itemView.getRoot());
|
super(itemView.getRoot());
|
||||||
this.binging = itemView;
|
this.binging = itemView;
|
||||||
}
|
}
|
|
@ -2,14 +2,19 @@ package com.coldmint.rust.pro.fragments
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import com.coldmint.rust.pro.R
|
import com.coldmint.rust.pro.R
|
||||||
import com.coldmint.rust.pro.adapters.CommunityAdapter
|
import com.coldmint.rust.pro.adapters.CommunityAdapter
|
||||||
import com.coldmint.rust.pro.base.BaseFragment
|
import com.google.android.material.navigation.NavigationBarView
|
||||||
import com.coldmint.rust.pro.databinding.FragmentCommunityBinding
|
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
|
||||||
|
|
||||||
class CommunityFragment : BaseFragment<FragmentCommunityBinding>() {
|
class CommunityFragment : Fragment() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载tab
|
||||||
|
*/
|
||||||
private fun loadTab() {
|
private fun loadTab() {
|
||||||
if (!isAdded) {
|
if (!isAdded) {
|
||||||
return
|
return
|
||||||
|
@ -19,51 +24,98 @@ class CommunityFragment : BaseFragment<FragmentCommunityBinding>() {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
val inflate = inflater.inflate(R.layout.fragment_community, container, false)
|
||||||
|
|
||||||
|
onViewCreated(inflate)
|
||||||
|
return inflate
|
||||||
|
|
||||||
override fun getViewBindingObject(layoutInflater: LayoutInflater): FragmentCommunityBinding {
|
|
||||||
return FragmentCommunityBinding.inflate(layoutInflater)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
|
private fun onViewCreated(view: View) {
|
||||||
viewBinding.pager.adapter = CommunityAdapter(this)
|
val navigationBarView : NavigationBarView = view.findViewById(R.id.bottomnavigationView)
|
||||||
viewBinding.pager.isSaveEnabled = false
|
val pager : ViewPager2 = view.findViewById(R.id.pager)
|
||||||
viewBinding.pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
pager.adapter = CommunityAdapter(this)
|
||||||
|
pager.isSaveEnabled = false
|
||||||
|
pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
when (position) {
|
when (position) {
|
||||||
0 -> {
|
0 -> {
|
||||||
viewBinding.bottomnavigationView.selectedItemId = R.id.action_recommended
|
navigationBarView.selectedItemId = R.id.action_recommended
|
||||||
}
|
}
|
||||||
1 -> {
|
1 -> {
|
||||||
viewBinding.bottomnavigationView.selectedItemId = R.id.action_follow
|
navigationBarView.selectedItemId = R.id.action_follow
|
||||||
}
|
}
|
||||||
2 -> {
|
2 -> {
|
||||||
viewBinding.bottomnavigationView.selectedItemId = R.id.action_ranking
|
navigationBarView.selectedItemId = R.id.action_ranking
|
||||||
}
|
}
|
||||||
3 -> {
|
3 -> {
|
||||||
viewBinding.bottomnavigationView.selectedItemId = R.id.action_my
|
navigationBarView.selectedItemId = R.id.action_my
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
viewBinding.bottomnavigationView.setOnItemSelectedListener {
|
navigationBarView.setOnItemSelectedListener {
|
||||||
when (it.itemId) {
|
when (it.itemId) {
|
||||||
R.id.action_recommended -> {
|
R.id.action_recommended -> {
|
||||||
viewBinding.pager.currentItem = 0
|
pager.currentItem = 0
|
||||||
}
|
}
|
||||||
R.id.action_follow -> {
|
R.id.action_follow -> {
|
||||||
viewBinding.pager.currentItem = 1
|
pager.currentItem = 1
|
||||||
}
|
}
|
||||||
R.id.action_ranking -> {
|
R.id.action_ranking -> {
|
||||||
viewBinding.pager.currentItem = 2
|
pager.currentItem = 2
|
||||||
}
|
}
|
||||||
R.id.action_my -> {
|
R.id.action_my -> {
|
||||||
viewBinding.pager.currentItem = 3
|
pager.currentItem = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loadTab()
|
|
||||||
}
|
}
|
||||||
|
// override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) {
|
||||||
|
// viewBinding.pager.adapter = CommunityAdapter(this)
|
||||||
|
// viewBinding.pager.isSaveEnabled = false
|
||||||
|
// viewBinding.pager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||||
|
// override fun onPageSelected(position: Int) {
|
||||||
|
// when (position) {
|
||||||
|
// 0 -> {
|
||||||
|
// viewBinding.bottomnavigationView.selectedItemId = R.id.action_recommended
|
||||||
|
// }
|
||||||
|
// 1 -> {
|
||||||
|
// viewBinding.bottomnavigationView.selectedItemId = R.id.action_follow
|
||||||
|
// }
|
||||||
|
// 2 -> {
|
||||||
|
// viewBinding.bottomnavigationView.selectedItemId = R.id.action_ranking
|
||||||
|
// }
|
||||||
|
// 3 -> {
|
||||||
|
// viewBinding.bottomnavigationView.selectedItemId = R.id.action_my
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// viewBinding.bottomnavigationView.setOnItemSelectedListener {
|
||||||
|
// when (it.itemId) {
|
||||||
|
// R.id.action_recommended -> {
|
||||||
|
// viewBinding.pager.currentItem = 0
|
||||||
|
// }
|
||||||
|
// R.id.action_follow -> {
|
||||||
|
// viewBinding.pager.currentItem = 1
|
||||||
|
// }
|
||||||
|
// R.id.action_ranking -> {
|
||||||
|
// viewBinding.pager.currentItem = 2
|
||||||
|
// }
|
||||||
|
// R.id.action_my -> {
|
||||||
|
// viewBinding.pager.currentItem = 3
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// true
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// loadTab()
|
||||||
|
// }
|
||||||
}
|
}
|
|
@ -1,122 +0,0 @@
|
||||||
package com.muqing;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ClipData;
|
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.net.SocketException;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/** @noinspection unused*/
|
|
||||||
public class gj {
|
|
||||||
|
|
||||||
public final static String log_TAB = "输出";
|
|
||||||
|
|
||||||
public static void ts(Context a, Object b) {
|
|
||||||
Toast.makeText(a, b.toString(), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ts implements Runnable {
|
|
||||||
String string;
|
|
||||||
Context context;
|
|
||||||
|
|
||||||
public ts(Context context,String string) {
|
|
||||||
this.string = string;
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
ts(context,string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sc(Object a) {
|
|
||||||
if (a == null) {
|
|
||||||
a = "null";
|
|
||||||
}
|
|
||||||
Log.d(log_TAB, a.toString());
|
|
||||||
}
|
|
||||||
public static void fx(Context context, String str) {
|
|
||||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
|
||||||
shareIntent.setType("text/plain");
|
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, str);
|
|
||||||
context.startActivity(shareIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复制文字到剪切板
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static void fz(Context context, String text) {
|
|
||||||
ClipboardManager systemService =
|
|
||||||
(ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
|
||||||
// 创建能够存入剪贴板的ClipData对象
|
|
||||||
//‘Label’这是任意文字标签
|
|
||||||
ClipData mClipData = ClipData.newPlainText("Label", text);
|
|
||||||
//将ClipData数据复制到剪贴板:
|
|
||||||
systemService.setPrimaryClip(mClipData);
|
|
||||||
gj.ts(context, "复制成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isWiFiConnected() {
|
|
||||||
try {
|
|
||||||
for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
|
|
||||||
if (networkInterface.isUp() && !networkInterface.isLoopback()) {
|
|
||||||
if (networkInterface.getDisplayName().contains("wlan")) {
|
|
||||||
return true; // Wi-Fi网络
|
|
||||||
} else if (networkInterface.getDisplayName().contains("rmnet")) {
|
|
||||||
return false; // 流量网络
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SocketException e) {
|
|
||||||
sc(e);
|
|
||||||
}
|
|
||||||
return false; // 默认为流量网络
|
|
||||||
}
|
|
||||||
public static void tcjp(EditText editText) {
|
|
||||||
editText.requestFocus();//获取焦点
|
|
||||||
InputMethodManager imm = (InputMethodManager)
|
|
||||||
editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
// gj.sc(imm.isActive());
|
|
||||||
//没有显示键盘,弹出
|
|
||||||
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
}
|
|
||||||
public static void ycjp(EditText editText) {
|
|
||||||
InputMethodManager imm = (InputMethodManager)
|
|
||||||
editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
if (imm.isActive()) //有显示键盘,隐藏
|
|
||||||
imm.hideSoftInputFromWindow(editText.getWindowToken(),
|
|
||||||
InputMethodManager.HIDE_NOT_ALWAYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getztl(Context context) {
|
|
||||||
// 获得状态栏高度
|
|
||||||
@SuppressLint({"InternalInsetResource", "DiscouragedApi"}) int resourceId =
|
|
||||||
context.getResources().
|
|
||||||
getIdentifier("status_bar_height", "dimen", "android");
|
|
||||||
return context.getResources().getDimensionPixelSize(resourceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getbackgroundColor(AppCompatActivity appCompatActivity) {
|
|
||||||
TypedArray array = appCompatActivity.getTheme().obtainStyledAttributes(new int[] {
|
|
||||||
android.R.attr.colorBackground
|
|
||||||
// android.R.attr.textColorPrimary,
|
|
||||||
});
|
|
||||||
int backgroundColor = array.getColor(0, 0xFF00FF);
|
|
||||||
// int textColor = array.getColor(1, 0xFF00FF);
|
|
||||||
array.recycle();
|
|
||||||
return backgroundColor;
|
|
||||||
}
|
|
||||||
}
|
|
43
app/src/main/res/layout-land/activity_main.xml
Normal file
43
app/src/main/res/layout-land/activity_main.xml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drawerlayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="false">
|
||||||
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize" />
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/baseFragment"
|
||||||
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:defaultNavHost="true"
|
||||||
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.navigation.NavigationView
|
||||||
|
android:id="@+id/navaiagtion"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="start"
|
||||||
|
app:elevation="2dp"
|
||||||
|
app:menu="@menu/menu_drawer_left"
|
||||||
|
tools:ignore="VisualLintBounds" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.drawerlayout.widget.DrawerLayout>
|
25
app/src/main/res/layout-land/fragment_community.xml
Normal file
25
app/src/main/res/layout-land/fragment_community.xml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?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="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<com.google.android.material.navigationrail.NavigationRailView
|
||||||
|
android:id="@+id/bottomnavigationView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:menu="@menu/menu_main_bottom" />
|
||||||
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
android:id="@+id/pager"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<!-- <com.google.android.material.bottomnavigation.BottomNavigationView-->
|
||||||
|
<!-- android:id="@+id/bottomnavigationView"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- app:menu="@menu/menu_main_bottom" />-->
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user