修复BUG,优化UI
This commit is contained in:
parent
290156a322
commit
f78d05f340
|
@ -7,7 +7,6 @@ import android.content.pm.PackageManager
|
|||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
|
@ -18,7 +17,6 @@ import androidx.core.view.isVisible
|
|||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.navigateUp
|
||||
import androidx.navigation.ui.setupActionBarWithNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.bumptech.glide.Glide
|
||||
|
@ -53,7 +51,6 @@ import java.io.File
|
|||
import java.util.concurrent.Executors
|
||||
import java.util.zip.ZipEntry
|
||||
|
||||
|
||||
class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
|
||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||
|
@ -117,8 +114,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
)
|
||||
viewBinding.drawerlayout.addDrawerListener(actionToggle)
|
||||
actionToggle.syncState()
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,7 +240,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
val newDynamicColor = AppSettings.getValue(
|
||||
AppSettings.Setting.DynamicColor,
|
||||
DynamicColors.isDynamicColorAvailable()
|
||||
);
|
||||
)
|
||||
if (oldDynamicColor != newDynamicColor) {
|
||||
recreate()
|
||||
return
|
||||
|
@ -333,6 +328,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
intent.putExtra("type", "template")
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
@ -611,21 +607,31 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
}).start()
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_DOWN) {
|
||||
|
||||
override fun onBackPressed() {
|
||||
val navController = findNavController(R.id.baseFragment)
|
||||
//判断是否在第一个导航 社区或者仓库
|
||||
if (navController.currentDestination?.id == navController.graph.startDestinationId) {
|
||||
MaterialAlertDialogBuilder(this).setTitle(R.string.dialog_close).setMessage(
|
||||
String.format(
|
||||
getString(R.string.exit_tip),
|
||||
getString(R.string.app_name)
|
||||
)
|
||||
).setPositiveButton(R.string.dialog_ok) { i, i2 ->
|
||||
finish()
|
||||
}.setNegativeButton(R.string.dialog_cancel) { i, i2 ->
|
||||
).setPositiveButton(R.string.dialog_ok) { _, _ ->
|
||||
super.onBackPressed()
|
||||
}.setNegativeButton(R.string.dialog_cancel) { _, _ ->
|
||||
}.show()
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
/*
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_DOWN) {
|
||||
return true
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
}*/
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
val inflater = menuInflater
|
||||
|
@ -633,11 +639,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
return true
|
||||
}
|
||||
|
||||
/*不知道干什么的代码
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
val navController = findNavController(R.id.baseFragment)
|
||||
return navController.navigateUp(appBarConfiguration)
|
||||
|| super.onSupportNavigateUp()
|
||||
}
|
||||
*/
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.search) {
|
||||
|
@ -737,7 +745,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||
oldDynamicColor = AppSettings.getValue(
|
||||
AppSettings.Setting.DynamicColor,
|
||||
DynamicColors.isDynamicColorAvailable()
|
||||
);
|
||||
)
|
||||
useToolbarSetSupportActionBar()
|
||||
initNav()
|
||||
observeStartViewModel()
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
package com.coldmint.rust.pro
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityOptions
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.Shader
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.drawToBitmap
|
||||
import androidx.core.view.isVisible
|
||||
import com.bumptech.glide.Glide
|
||||
import com.coldmint.dialog.CoreDialog
|
||||
|
@ -31,13 +22,12 @@ import com.coldmint.rust.pro.dialog.CommentDialog
|
|||
import com.coldmint.rust.pro.tool.AnimUtil
|
||||
import com.coldmint.rust.pro.tool.AppSettings
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.gyf.immersionbar.ktx.immersionBar
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
class UserHomePageActivity : BaseActivity<ActivityUserHomePageBinding>() {
|
||||
|
@ -180,14 +170,14 @@ class UserHomePageActivity : BaseActivity<ActivityUserHomePageBinding>() {
|
|||
}
|
||||
userName = spaceInfoData.data.userName
|
||||
|
||||
viewBinding.appBar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
|
||||
viewBinding.appBar.addOnOffsetChangedListener { appBarLayout, verticalOffset ->
|
||||
viewBinding.toolbar.title =
|
||||
if ((Math.abs(verticalOffset) >= appBarLayout.totalScrollRange)) {
|
||||
if ((abs(verticalOffset) >= appBarLayout.totalScrollRange)) {
|
||||
spaceInfoData.data.userName
|
||||
} else {
|
||||
""
|
||||
}
|
||||
})
|
||||
}
|
||||
viewBinding.nameView.text = spaceInfoData.data.userName
|
||||
viewBinding.describeView.text =
|
||||
spaceInfoData.data.introduce ?: getString(R.string.defaultIntroduced)
|
||||
|
@ -208,8 +198,7 @@ class UserHomePageActivity : BaseActivity<ActivityUserHomePageBinding>() {
|
|||
.into(viewBinding.genderView)
|
||||
}
|
||||
|
||||
val permission = spaceInfoData.data.permission
|
||||
when (permission) {
|
||||
when (spaceInfoData.data.permission) {
|
||||
1 -> {
|
||||
viewBinding.cardView.isVisible = true
|
||||
viewBinding.cardView.setCardBackgroundColor(Color.parseColor("#f47920"))
|
||||
|
@ -311,9 +300,8 @@ class UserHomePageActivity : BaseActivity<ActivityUserHomePageBinding>() {
|
|||
viewBinding.tabLayout.addOnTabSelectedListener(object :
|
||||
TabLayout.OnTabSelectedListener {
|
||||
override fun onTabSelected(tab: TabLayout.Tab?) {
|
||||
val finalTab = tab
|
||||
if (finalTab != null) {
|
||||
val tiltle = finalTab.text
|
||||
if (tab != null) {
|
||||
val tiltle = tab.text
|
||||
val dynamic = getString(R.string.dynamic)
|
||||
if (dynamic == tiltle && userId == account) {
|
||||
viewBinding.fab.show()
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?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:fitsSystemWindows="false"
|
||||
android:fitsSystemWindows="true"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
|
@ -27,7 +28,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:visibility="gone">
|
||||
|
||||
<com.google.android.material.tabs.TabItem
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -50,8 +50,6 @@
|
|||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/mainButton"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -63,7 +61,6 @@
|
|||
android:fitsSystemWindows="true"
|
||||
android:src="@drawable/add" />
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<com.google.android.material.navigation.NavigationView
|
||||
|
|
|
@ -109,10 +109,9 @@
|
|||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:paddingHorizontal="6dp"
|
||||
android:background="?android:colorBackground"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingTop="6dp"
|
||||
android:visibility="gone"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:windowBackground">
|
||||
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -278,7 +276,7 @@
|
|||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/add"
|
||||
android:visibility="gone" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user