Commit 3b09394d by upwork.021

feat: 代码优化

parent 324e576c
...@@ -7,18 +7,17 @@ import android.animation.PropertyValuesHolder ...@@ -7,18 +7,17 @@ import android.animation.PropertyValuesHolder
import android.content.Context import android.content.Context
import android.graphics.Typeface import android.graphics.Typeface
import android.os.Build import android.os.Build
import androidx.core.content.ContextCompat
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import android.text.TextUtils import android.text.TextUtils
import android.view.Gravity
import android.view.View import android.view.View
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.ImageView import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
...@@ -59,12 +58,7 @@ import kotlinx.android.synthetic.main.consultant_item_filter_online.view.* ...@@ -59,12 +58,7 @@ import kotlinx.android.synthetic.main.consultant_item_filter_online.view.*
import kotlinx.android.synthetic.main.consultant_layout_search_content.* import kotlinx.android.synthetic.main.consultant_layout_search_content.*
import kotlinx.android.synthetic.main.consultant_layout_search_toolbar.* import kotlinx.android.synthetic.main.consultant_layout_search_toolbar.*
import org.json.JSONObject import org.json.JSONObject
import java.util.*
import java.util.concurrent.Executors import java.util.concurrent.Executors
import kotlin.collections.ArrayList
import kotlin.collections.LinkedHashSet
import kotlin.properties.Delegates
import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType
@Route(path = "/consultant/consultant") @Route(path = "/consultant/consultant")
class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPresenter>(), class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPresenter>(),
...@@ -241,18 +235,15 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -241,18 +235,15 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) { } else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
//没有滚动 //没有滚动
showConsultAssistantDialog() showConsultAssistantDialog()
if (sIsScrolling) { sIsScrolling = false
}
sIsScrolling = false;
} }
} }
override fun onScrollTop() { override fun onScrollTop() {
var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f) val alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f) val scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f) val scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
var animator = val animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY) ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200) .setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
...@@ -268,10 +259,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -268,10 +259,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (isBtnShow) { if (isBtnShow) {
return return
} }
var alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f) val alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f) val scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f) val scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f)
var animator = val animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY) ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200) .setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
...@@ -287,10 +278,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -287,10 +278,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (!isBtnShow) { if (!isBtnShow) {
return return
} }
var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f) val alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f) val scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f) val scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
var animator = val animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY) ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200) .setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() { animator.addListener(object : AnimatorListenerAdapter() {
......
...@@ -285,22 +285,26 @@ class ExpertSearchAdapter( ...@@ -285,22 +285,26 @@ class ExpertSearchAdapter(
holder.ll_tags, holder.ll_tags,
false false
) )
if (1 == item.isPackage) { when (item.isPackage) {
view.tvTitle.text = "单次" 1 -> {
view.tvTitle.setTextColor(context.resources.getColor(R.color.platform_color_1DA1F2)) view.tvTitle.text = "单次"
view.tvTitle.background = view.tvTitle.setTextColor(context.resources.getColor(R.color.platform_color_1DA1F2))
context.resources.getDrawable(R.drawable.consultant_expert_search_single) view.tvTitle.background =
view.tvContent.text = item.name context.resources.getDrawable(R.drawable.consultant_expert_search_single)
holder.ll_products.addView(view) view.tvContent.text = item.name
} else if (2 == item.isPackage) { holder.ll_products.addView(view)
view.tvTitle.text = "套餐" }
view.tvTitle.setTextColor(context.resources.getColor(R.color.consultant_color_FF9500)) 2 -> {
view.tvTitle.background = view.tvTitle.text = "套餐"
context.resources.getDrawable(R.drawable.consultant_expert_search_menu) view.tvTitle.setTextColor(context.resources.getColor(R.color.consultant_color_FF9500))
view.tvContent.text = item.name view.tvTitle.background =
holder.ll_products.addView(view) context.resources.getDrawable(R.drawable.consultant_expert_search_menu)
} else { view.tvContent.text = item.name
holder.ll_products.addView(view)
}
else -> {
}
} }
} }
} }
......
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