Просмотр исходного кода

首页完善/不同账号下任务列表刷新完善

everywindchase 4 месяцев назад
Родитель
Сommit
b2a43be553

+ 65 - 0
app/src/main/java/jx/cn/escort/adapter/IndexAbilityRecycleAdapter.kt

@@ -0,0 +1,65 @@
+package jx.cn.escort.adapter
+
+
+import android.content.Context
+import android.util.TypedValue
+import android.view.*
+import androidx.recyclerview.widget.RecyclerView
+import com.xuexiang.xui.utils.ResUtils.getResources
+import com.xuexiang.xui.widget.textview.supertextview.SuperTextView
+import jx.cn.escort.R
+import jx.cn.escort.beans.AbilityData
+import jx.cn.escort.beans.StatData
+
+
+open class IndexAbilityRecycleAdapter(): RecyclerView.Adapter<IndexAbilityRecycleAdapter.IndexAbilityRecycleViewHolder>() {
+
+
+    private var context: Context?=null
+    private var mData = mutableListOf<AbilityData>()
+    constructor(context: Context?):this(){
+        this.context=context
+    }
+    constructor(context: Context?,  source:Collection<AbilityData>):this(context){
+        if (source.isNotEmpty()) {
+            source.forEach{
+                mData.add(it)
+            }
+
+        }
+
+    }
+
+
+
+
+
+
+
+    class    IndexAbilityRecycleViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
+        var item: View?= itemView
+    }
+
+    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IndexAbilityRecycleViewHolder {
+        val view= LayoutInflater.from(context).inflate(R.layout.fragment_stat,parent,false)
+        return IndexAbilityRecycleViewHolder(view)
+
+    }
+
+    override fun onBindViewHolder(holder: IndexAbilityRecycleViewHolder, position: Int) {
+        var statListItem=holder.item?.findViewById<SuperTextView>(R.id.stat_list_item)
+        statListItem?.setCenterBottomString("哈哈")
+
+        val width = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100f,
+            context?.let { getResources(it).getDisplayMetrics() }).toInt()
+        val params: ViewGroup.LayoutParams? = statListItem?.layoutParams
+        params?.width = width
+        statListItem?.setLayoutParams(params)
+
+    }
+
+    override fun getItemCount(): Int {
+        return mData.size
+    }
+
+}

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

@@ -63,13 +63,12 @@ open class IndexRecycleAdapter(): RecyclerView.Adapter<IndexRecycleAdapter.Index
             var     leftText = XUIAlphaTextView(contextThemeWrapper)
 
 
-            var leftP=ViewGroup.MarginLayoutParams(DensityUtils.px2dp(context,300f),DensityUtils.px2dp(context,120f))  as  MarginLayoutParams
-            leftP.topMargin=30
+            var leftP=ViewGroup.LayoutParams(DensityUtils.px2dp(context,300f),DensityUtils.px2dp(context,120f))  as ViewGroup.LayoutParams
             leftText.layoutParams=leftP
 
 
-        val layoutPosition = holder.layoutPosition
-        leftText.text=mData.get(layoutPosition).name
+            val layoutPosition = holder.layoutPosition
+            leftText.text=mData.get(layoutPosition).name
             leftText.setTextColor(Color.BLACK)
             leftText.setSingleLine()
             var  mLeftImageResource = ResUtils.getDrawable(context, R.drawable.ic_task_title);

+ 66 - 0
app/src/main/java/jx/cn/escort/adapter/IndexStatRecycleAdapter.kt

@@ -0,0 +1,66 @@
+package jx.cn.escort.adapter
+
+
+import android.content.Context
+import android.util.TypedValue
+import android.view.*
+import androidx.recyclerview.widget.RecyclerView
+import com.xuexiang.xui.utils.ResUtils.getResources
+import com.xuexiang.xui.widget.textview.supertextview.SuperTextView
+import jx.cn.escort.R
+import jx.cn.escort.beans.StatData
+
+
+open class IndexStatRecycleAdapter(): RecyclerView.Adapter<IndexStatRecycleAdapter.IndexStatRecycleViewHolder>() {
+
+
+    private var context: Context?=null
+    private var mData = mutableListOf<StatData>()
+    constructor(context: Context?):this(){
+        this.context=context
+    }
+    constructor(context: Context?,  source:Collection<StatData>):this(context){
+        if (source.isNotEmpty()) {
+            source.forEach{
+                mData.add(it)
+            }
+
+        }
+
+    }
+
+
+
+
+
+
+
+    class    IndexStatRecycleViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
+        var item: View?= itemView
+    }
+
+    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IndexStatRecycleViewHolder {
+        val view= LayoutInflater.from(context).inflate(R.layout.fragment_stat,parent,false)
+        return IndexStatRecycleViewHolder(view)
+
+    }
+
+    override fun onBindViewHolder(holder: IndexStatRecycleViewHolder, position: Int) {
+
+        var statListItem=holder.item?.findViewById<SuperTextView>(R.id.stat_list_item)
+        var layoutPosition = holder.layoutPosition
+        statListItem?.setCenterBottomString(mData.get(layoutPosition).title)
+        statListItem?.setCenterString(mData.get(layoutPosition).state)
+
+        val width = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100f,
+            context?.let { getResources(it).getDisplayMetrics() }).toInt()
+        val params: ViewGroup.LayoutParams? = statListItem?.layoutParams
+        params?.width = width
+        statListItem?.setLayoutParams(params)
+    }
+
+    override fun getItemCount(): Int {
+        return mData.size
+    }
+
+}

+ 9 - 0
app/src/main/java/jx/cn/escort/beans/AbilityData.kt

@@ -0,0 +1,9 @@
+package jx.cn.escort.beans
+
+import android.app.Activity
+
+data    class AbilityData(
+     var title:String,
+     var link: Class<Activity>?
+)
+

+ 7 - 0
app/src/main/java/jx/cn/escort/beans/StatData.kt

@@ -0,0 +1,7 @@
+package jx.cn.escort.beans
+
+data    class StatData(
+     var title:String,
+    var  state :String
+)
+

+ 72 - 5
app/src/main/java/jx/cn/escort/ui/fragment/BaseNavFragment.kt

@@ -6,21 +6,28 @@ package jx.cn.escort.ui.fragment
 import android.content.Context
 import android.content.SharedPreferences
 import android.graphics.Color
+import android.graphics.Typeface
 import android.os.Bundle
-import android.util.Log
+import android.view.Gravity
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import androidx.appcompat.widget.AppCompatTextView
 import androidx.fragment.app.Fragment
+import androidx.recyclerview.widget.GridLayoutManager
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import com.necer.calendar.Miui9Calendar
-import com.necer.listener.OnCalendarChangedListener
 import com.xuexiang.xui.widget.actionbar.TitleBar
+import com.xuexiang.xui.widget.banner.recycler.BannerLayout
+import com.xuexiang.xui.widget.dialog.materialdialog.DialogAction
 import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog
 import jx.cn.escort.R
+import jx.cn.escort.adapter.IndexAbilityRecycleAdapter
 import jx.cn.escort.adapter.IndexRecycleAdapter
+import jx.cn.escort.adapter.IndexStatRecycleAdapter
+import jx.cn.escort.beans.AbilityData
+import jx.cn.escort.beans.StatData
 import jx.cn.escort.beans.TaskData
 import jx.cn.escort.ui.activity.LoginActivity
 import org.koin.core.component.KoinComponent
@@ -86,9 +93,12 @@ class BaseNavFragment(name:Int,context: Context?):Fragment(),KoinComponent {
                             val inflate = li.inflate(jx.cn.escort.R.layout.layout_task_calendar, null)
                             var miui9Calendar=inflate.findViewById<Miui9Calendar>(jx.cn.escort.R.id.miui9Calendar)
                             var textView=inflate.findViewById<AppCompatTextView>(jx.cn.escort.R.id.calendarTitle)
-                            miui9Calendar.setOnCalendarChangedListener(OnCalendarChangedListener { baseCalendar, year, month, localDate, dateChangeBehavior ->
-                                textView.setText(year.toString() + "年" + month + "月" + "   当前页面选中 " + localDate)
-                            })
+                            miui9Calendar.setOnCalendarChangedListener { baseCalendar, year, month, localDate, dateChangeBehavior ->
+                                textView.text = localDate.toString()
+                                textView.setTypeface(null, Typeface.BOLD)
+                                textView.setGravity(Gravity.CENTER)
+
+                            }
 
                             context?.let {
                             MaterialDialog.Builder(it)
@@ -96,6 +106,12 @@ class BaseNavFragment(name:Int,context: Context?):Fragment(),KoinComponent {
                                     .title("选择日期")
                                     .positiveText("确定")
                                     .negativeText("取消")
+                                .onPositive(object:MaterialDialog.SingleButtonCallback{
+                                    override fun onClick(dialog: MaterialDialog, which: DialogAction) {
+                                        divideTitle.setTitle(textView.text)
+                                    }
+
+                                })
                                 .show()
 
                             }
@@ -106,6 +122,57 @@ class BaseNavFragment(name:Int,context: Context?):Fragment(),KoinComponent {
 
                 }
                 return view
+            }else   if(name==R.layout.fragment_index){
+                val view:View=inflater.inflate(name!!,container,false)
+                val recycle=view.findViewById<BannerLayout>(R.id.index_stat_recycle)
+                val abilityRecycle=view.findViewById<RecyclerView>(R.id.index_ability_recycle)
+
+
+                var statDatas=mutableListOf<StatData>()
+                for(index in 0..<4 step 1){
+                    when(index){
+                        0->{
+                            var data=StatData("当日线路","10")
+                            statDatas.add(data)
+                        }
+                        1->{
+                            var data= StatData("网点任务","120")
+                            statDatas.add(data)
+                        }
+                        2->{
+                            var data= StatData("周转箱(出)","30")
+                            statDatas.add(data)
+                        }
+                        3->{
+                           var data=StatData("周转箱(入)","150")
+                            statDatas.add(data)
+                        }
+
+                    }
+                }
+                var indexStatRecycleAdapter=IndexStatRecycleAdapter(context,statDatas)
+                recycle.setAdapter(indexStatRecycleAdapter)
+
+
+
+
+
+                var abilityDatas=mutableListOf<AbilityData>()
+                for(index in 0..<18 step 1){
+                    var     activity=AbilityData("测试${index}",null)
+                    abilityDatas.add(activity)
+                }
+
+                var layoutManager=GridLayoutManager(context,9,GridLayoutManager.HORIZONTAL,false)
+                layoutManager.spanSizeLookup=object:GridLayoutManager.SpanSizeLookup(){
+                    override fun getSpanSize(p0: Int): Int {
+                        return 9
+                    }
+
+                }
+                abilityRecycle.layoutManager=layoutManager
+                abilityRecycle.adapter = IndexAbilityRecycleAdapter(context,abilityDatas)
+                return view
             }else{
                 return inflater.inflate(name!!,container,false)
             }

+ 22 - 40
app/src/main/res/layout/fragment_index.xml

@@ -44,45 +44,16 @@
 
                 >
 
-                        <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
-                                app:sCenterTextColor="#46DCB1"
-                                app:sCenterTextIsBold="true"
-                                app:sCenterTextSize="20sp"
-                                app:sCenterTextString="10"
-                                app:sCenterBottomTextString="当日线路"
-                                app:sDividerLineColor="#F12323"
-                                android:layout_width="80dp" android:layout_height="70dp"
-                                app:sDividerLineType="bottom"
-                        />
-                        <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
-                                app:sCenterTextColor="#46DCB1"
-                                app:sCenterTextIsBold="true"
-                                app:sCenterTextSize="20sp"
-                                app:sCenterTextString="120"
-                                android:layout_marginStart="110dp"
-                                app:sDividerLineColor="#F12323"
-                                app:sCenterBottomTextString="网点任务"
-                                android:layout_width="80dp" android:layout_height="70dp"
-                        />
-                        <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
-                                app:sCenterTextColor="#46DCB1"
-                                app:sCenterTextIsBold="true"
-                                app:sCenterTextSize="20sp"
-                                app:sCenterTextString="30"
-                                android:layout_marginStart="220dp"
-                                app:sDividerLineColor="#F12323"
-                                app:sCenterBottomTextString="周转箱(出)"
-                                android:layout_width="80dp" android:layout_height="70dp"
-                        />
-                        <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
-                                app:sCenterTextColor="#46DCB1"
-                                app:sCenterTextIsBold="true"
-                                app:sCenterTextSize="20sp"
-                                app:sCenterTextString="50"
-                                android:layout_marginStart="320dp"
-                                app:sDividerLineColor="#F12323"
-                                app:sCenterBottomTextString="周转箱(入)"
-                                android:layout_width="80dp" android:layout_height="70dp"
+
+                        <com.xuexiang.xui.widget.banner.recycler.BannerLayout
+                                android:id="@+id/index_stat_recycle"
+                                android:layout_width="match_parent"
+                                android:layout_height="wrap_content"
+                                app:bl_autoPlaying="false"
+                                app:bl_centerScale="1.0"
+                                app:bl_itemSpace="20dp"
+                                app:bl_indicatorGravity="center"
+                                app:bl_showIndicator="false"
                         />
 
 
@@ -97,7 +68,18 @@
                                 app:layout_constraintEnd_toEndOf="parent"
                                 app:layout_constraintTop_toBottomOf="@id/ability_layout"
                                 app:layout_constraintBottom_toBottomOf="parent"
-                        />
+                                app:contentPadding="10dp"
+                        >
+
+                                <androidx.recyclerview.widget.RecyclerView
+                                        android:id="@+id/index_ability_recycle"
+                                        android:layout_width="match_parent" android:layout_height="match_parent"
+                                        android:scrollbars="horizontal"
+                                        android:background="@color/xui_config_color_red"
+                                />
+
+
+                        </androidx.cardview.widget.CardView >
 
         </androidx.constraintlayout.widget.ConstraintLayout>
 

+ 20 - 0
app/src/main/res/layout/fragment_mine.xml

@@ -7,6 +7,26 @@
 >
 
 
+<!--    <androidx.cardview.widget.CardView-->
+<!--            android:id="@+id/mime_profile"-->
+<!--            android:layout_width="match_parent" android:layout_height="100dp">-->
 
+<!--    </androidx.cardview.widget.CardView>-->
 
+<!--    <androidx.cardview.widget.CardView-->
+
+
+<!--            android:layout_width="match_parent" android:layout_height="100dp">-->
+
+<!--    </androidx.cardview.widget.CardView>-->
+
+
+    <com.google.android.material.tabs.TabLayout
+            android:layout_width="match_parent"
+            android:layout_height="12dp"
+            android:layout_weight="1"
+            android:background="#369DE3"
+            android:visibility="visible"
+            app:vtl_indicator_color="@color/xui_config_color_white"
+            app:vtl_tab_mode="fixed" />
 </FrameLayout>

+ 30 - 0
app/src/main/res/layout/fragment_stat.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.appcompat.widget.LinearLayoutCompat
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:app="http://schemas.android.com/apk/res-auto"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                app:cardBackgroundColor="#cde2e2"
+        >
+
+
+
+
+        <com.xuexiang.xui.widget.textview.supertextview.SuperTextView
+                                        android:id="@+id/stat_list_item"
+                                        app:sCenterTextColor="#46DCB1"
+                                        app:sCenterTextIsBold="true"
+                                        app:sCenterTextSize="20sp"
+                                        app:sCenterTextString="0"
+                                        android:layout_marginStart="2dp"
+                                        app:sDividerLineColor="#F12323"
+                                        app:sDividerLineHeight="2dp"
+                                        app:sCenterBottomTextString="统计"
+                                        android:layout_width="match_parent"
+                                        android:layout_height="80dp"/>
+
+
+
+ </androidx.appcompat.widget.LinearLayoutCompat>
+
+

+ 0 - 21
app/src/main/res/layout/layout_banner.xml

@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<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="50dp"
-        android:background="@color/xui_config_color_red"
-       >
-
-
-       <androidx.appcompat.widget.AppCompatTextView
-               android:id="@+id/banner_txt"
-               android:layout_width="match_parent"
-               android:layout_height="match_parent"
-               android:gravity="center"
-               android:textSize="30sp"
-       />
-
-
-</androidx.constraintlayout.widget.ConstraintLayout>