everywindchase 5 месяцев назад
Родитель
Сommit
2961d25304

+ 0 - 55
app/src/main/java/jx/cn/escort/adapter/IndexBannerAdapter.kt

@@ -1,55 +0,0 @@
-package jx.cn.escort.adapter
-
-import android.annotation.SuppressLint
-import android.content.Context
-import android.util.Log
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import androidx.appcompat.widget.AppCompatTextView
-import androidx.recyclerview.widget.RecyclerView
-import jx.cn.escort.R
-
-class IndexBannerAdapter():RecyclerView.Adapter<IndexBannerAdapter.IndexBannerViewHolder>() {
-
-    private var context: Context? =null
-    constructor(context:Context?):this(){
-        this.context=context
-    }
-
-
-
-
-    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):IndexBannerViewHolder {
-
-            val view=LayoutInflater.from(this@IndexBannerAdapter.context).inflate(R.layout.layout_banner,parent,false)
-            return IndexBannerViewHolder(view)
-
-
-
-    }
-
-
-    override fun onBindViewHolder(holder: IndexBannerViewHolder, position: Int) {
-       val  textView= holder.item?.findViewById<AppCompatTextView>(R.id.banner_txt)
-        textView?.text="第${position}位"
-
-
-    }
-
-    override fun getItemCount(): Int {
-        return 5
-    }
-
-
-
-
-
-
-    class    IndexBannerViewHolder:RecyclerView.ViewHolder{
-        var item: View?=null
-        constructor(itemView: View):super(itemView){
-            this.item=itemView
-        }
-    }
-}

+ 37 - 3
app/src/main/java/jx/cn/escort/adapter/IndexRecycleAdapter.kt

@@ -1,13 +1,25 @@
 package jx.cn.escort.adapter
 
 import android.content.Context
+import android.graphics.Bitmap
+import android.graphics.Canvas
+import android.graphics.Color
+import android.graphics.drawable.Drawable
+import android.view.Gravity
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import androidx.appcompat.widget.AppCompatTextView
 import androidx.cardview.widget.CardView
+import androidx.core.graphics.drawable.toBitmap
 import androidx.recyclerview.widget.RecyclerView
+import com.google.android.material.divider.MaterialDivider
+import com.xuexiang.xui.XUI
+import com.xuexiang.xui.utils.DensityUtils
+import com.xuexiang.xui.utils.ResUtils
+import com.xuexiang.xui.widget.alpha.XUIAlphaTextView
 import jx.cn.escort.R
+import jx.cn.escort.ui.widget.TaskCardView
 
 
 class IndexRecycleAdapter(): RecyclerView.Adapter<IndexRecycleAdapter.IndexRecycleViewHolder>() {
@@ -37,9 +49,31 @@ class IndexRecycleAdapter(): RecyclerView.Adapter<IndexRecycleAdapter.IndexRecyc
     }
 
     override fun onBindViewHolder(holder: IndexRecycleViewHolder, position: Int) {
-                val  cardView= holder.item?.findViewById<CardView>(R.id.card_content)
-
-
+            val  cardView= holder.item?.findViewById<TaskCardView>(R.id.card_content)
+            val divideTop=  holder.item?.findViewById<MaterialDivider>(R.id.card_divide_top)
+            val     leftText = XUIAlphaTextView(context)
+            leftText.text="线路${position+1}"
+            leftText.setTextColor(Color.BLACK)
+            leftText.setSingleLine()
+            var  mLeftImageResource = ResUtils.getDrawable(context, R.drawable.ic_task_title);
+            val widthScale = 0.2f
+            val heightScale = 0.2f
+            var  bitmap=mLeftImageResource.toBitmap()
+            mLeftImageResource.setBounds(0, 0,(bitmap.width * widthScale).toInt(), (bitmap.height * heightScale).toInt());
+
+            // 如果你需要将缩放后的BitmapDrawable转换为Bitmap
+            val scaledBitmap: Bitmap = Bitmap.createBitmap(mLeftImageResource.bounds.right, mLeftImageResource.bounds.bottom, Bitmap.Config.ARGB_8888)
+            val canvas = Canvas(scaledBitmap)
+            mLeftImageResource.draw(canvas)
+
+
+            leftText.setCompoundDrawables(mLeftImageResource, null, null, null);
+            leftText.setGravity(Gravity.CENTER_VERTICAL);
+            leftText.setPadding(8, 0, 8, 0);
+            leftText.setTypeface(XUI.getDefaultTypeface());
+            cardView?.setLeftText(leftText)
+            cardView?.setDivideTop(divideTop)
+            cardView?.addView(leftText)
 
     }
 

+ 1 - 1
app/src/main/java/jx/cn/escort/ui/activity/LoginActivity.kt

@@ -59,7 +59,7 @@ class LoginActivity : AppCompatActivity(), KoinComponent {
                 rotateAnimation.fillAfter=true
                 mBinding.btnLoginAction.startAnimation(rotateAnimation)
 
-                delay(5000L)
+                delay(1000L)
                 defaultSharedPreferences.edit().putString("isAuth", "是").apply()
                 ActivityUtils.startActivity(this@LoginActivity,MainActivity::class.java)
                 finish()

+ 10 - 8
app/src/main/java/jx/cn/escort/ui/activity/MainActivity.kt

@@ -67,9 +67,8 @@ class MainActivity : AppCompatActivity(), KoinComponent {
 
         var bottomNav= findViewById<BottomNavigationView>(R.id.bottom_nav)
 
-        bottomNav.setSelectedItemId(R.id.index)
 
-       var ckColor=Color.parseColor("#3ADD5C")
+       var ckColor=Color.parseColor("#8ad1d2")
 
         var color=Color.parseColor("#5e5656")
 
@@ -87,7 +86,7 @@ class MainActivity : AppCompatActivity(), KoinComponent {
         // 设置文字颜色
         bottomNav.itemTextColor = colorStateList
         bottomNav.isItemActiveIndicatorEnabled=false
-        bottomNav.setItemBackgroundResource(R.drawable.nav_item_bg)
+        bottomNav.itemBackgroundResource = R.drawable.nav_item_bg
 
 
         bottomNav.setOnItemSelectedListener(object: NavigationBarView.OnItemSelectedListener {
@@ -96,7 +95,7 @@ class MainActivity : AppCompatActivity(), KoinComponent {
 
 
                 when(id){
-                   jx.cn.escort.R.id.index-> {
+                   R.id.index-> {
 
                        switchFragment(BaseNavFragment(R.layout.fragment_index, context = baseContext),item)
 
@@ -128,13 +127,11 @@ class MainActivity : AppCompatActivity(), KoinComponent {
                 return  true
             }
 
-
-
         })
 
 
 
-
+        bottomNav.setSelectedItemId(R.id.index)
 
 
 
@@ -146,7 +143,12 @@ class MainActivity : AppCompatActivity(), KoinComponent {
 
        var layout= findViewById<View>(R.id.top_bar)
        var topBarView=(layout as ViewGroup).getChildAt(0)  as  TitleBar
-       topBarView.setTitle(item.title)
+       if(item.itemId== R.id.tasks) {
+
+           topBarView.setTitle("${item.title}列表")
+       }else{
+           topBarView.setTitle(item.title)
+       }
 
 
         var fm=supportFragmentManager

+ 37 - 0
app/src/main/java/jx/cn/escort/ui/widget/TaskCardView.kt

@@ -0,0 +1,37 @@
+package jx.cn.escort.ui.widget
+
+import android.content.Context
+import android.util.AttributeSet
+import androidx.cardview.widget.CardView
+import androidx.core.view.marginTop
+import com.google.android.material.divider.MaterialDivider
+import com.xuexiang.xui.widget.alpha.XUIAlphaTextView
+
+class TaskCardView : CardView {
+    constructor(context: Context) : this(context, null)
+    constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
+    constructor(context: Context, attrs: AttributeSet?,defStyleAttr:Int) : super(context, attrs, 0)
+    private var mLeftText: XUIAlphaTextView? =null;
+    private var mDivideTop: MaterialDivider? =null;
+
+    fun setLeftText(view:XUIAlphaTextView?) {
+        mLeftText = view
+    }
+
+    fun setDivideTop(view:MaterialDivider?) {
+        mDivideTop = view
+    }
+
+    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
+    }
+
+    override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
+
+        val marginTop = mDivideTop?.marginTop
+        if (marginTop != null) {
+            mLeftText?.layout(l,marginTop/2,t,b)
+        }
+         super.onLayout(changed, l, t, r, b)
+    }
+}

BIN
app/src/main/res/drawable-hdpi/ic_task_title.png


+ 1 - 1
app/src/main/res/drawable/top_bar_bg.xml

@@ -2,7 +2,7 @@
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
         android:shape="rectangle"
 >
-<corners  android:radius="8dp"/>
+<corners  android:topLeftRadius="5dp"   android:topRightRadius="5dp" />
     <gradient
         android:angle="30"
         android:startColor="#95E4D4"

+ 49 - 8
app/src/main/res/layout/fragment_tasks.xml

@@ -1,26 +1,67 @@
 <?xml version="1.0" encoding="utf-8"?>
-<com.xuexiang.xui.widget.alpha.XUIAlphaLinearLayout
+<androidx.constraintlayout.widget.ConstraintLayout
         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:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:theme="@style/Theme.AppCompat"
 >
+    <com.google.android.material.divider.MaterialDivider
+            android:id="@+id/divide_top"
+            app:dividerThickness="5dp"
+            app:dividerColor="#E7FBF9"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintBottom_toTopOf="@id/divide_title"
+    />
 
+    <com.xuexiang.xui.widget.actionbar.TitleBar
+            android:id="@+id/divide_title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="5dp"
+            android:background="#F3FAF6"
+            app:tb_useThemeColor="false"
+            app:tb_barHeight="65dp"
+            app:tb_dividerColor="@color/white"
+            app:tb_sideTextColor="@color/black"
+            app:tb_leftText="当天任务"
+            app:tb_sideTextPadding="20dp"
+            app:tb_actionPadding="20dp"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintBottom_toTopOf="@id/divide_bottom"
+            app:tb_leftImageResource="@null"
+    />
 
-    <com.google.android.material.divider.MaterialDivider android:layout_width="match_parent"
-                                                         android:layout_height="118dp">
 
+    <com.google.android.material.divider.MaterialDivider
+            android:id="@+id/divide_bottom"
+            app:dividerThickness="5dp"
+            app:dividerColor="#E7FBF9"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintBottom_toTopOf="@id/tasks_recycle"
+    />
 
-    </com.google.android.material.divider.MaterialDivider>
 
     <androidx.recyclerview.widget.RecyclerView
             android:id="@+id/tasks_recycle"
-            android:layout_width="match_parent" android:layout_height="120dp"
+            android:layout_width="match_parent" android:layout_height="wrap_content"
             android:scrollbars="vertical"
-            android:background="#DA0D0D"
-            android:layout_marginTop="300dp"
+            android:background="#EFEFEF"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toBottomOf="@id/divide_bottom"
+            android:layout_marginHorizontal="5dp"
     />
 
 
 
 
-</com.xuexiang.xui.widget.alpha.XUIAlphaLinearLayout>
+    </androidx.constraintlayout.widget.ConstraintLayout>

+ 20 - 8
app/src/main/res/layout/fragment_tasks_card.xml

@@ -1,23 +1,35 @@
 <?xml version="1.0" encoding="utf-8"?>
-<androidx.cardview.widget.CardView
+<jx.cn.escort.ui.widget.TaskCardView
         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="150dp"
                 android:id="@+id/card_content"
-                app:cardCornerRadius="18dp"
-                app:contentPadding="8dp"
-                android:layout_margin="8dp"
+                app:cardCornerRadius="12dp"
+                app:contentPadding="2dp"
+                android:layout_margin="5dp"
+                app:cardBackgroundColor="#cde2e2"
+                android:theme="@style/App.Material"
         >
 
-                <TextView android:layout_width="match_parent" android:layout_height="match_parent"
-                          android:textAlignment="center"
 
-                          android:text="测试"/>
+
+        <com.google.android.material.divider.MaterialDivider
+                android:id="@+id/card_divide_top"
+                app:dividerThickness="1.pt"
+                app:dividerColor="#b5c6c6"
+                app:dividerInsetStart="2dp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="45dp"
+                app:layout_constraintStart_toStartOf="parent"
+                app:layout_constraintEnd_toEndOf="parent"
+
+        />
 
 
 
 
-        </androidx.cardview.widget.CardView>
+</jx.cn.escort.ui.widget.TaskCardView>