}
GoodsTypeRvAdapter.kt商品左侧主界面的RecycleView,其中使用FragmentActivity?来作为androidx下面的Context
package com.example.takeout.ui.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.RecyclerView
import com.example.takeout.R
import com.example.takeout.model.beans.GoodsTypeInfo
import com.example.takeout.ui.fragment.GoodsFragment
import org.jetbrains.anko.find
class GoodsTypeRvAdapter(val context: FragmentActivity?, val goodsFragment: GoodsFragment) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
var goodsTypeList: List = listOf()
fun setDatas(list: List) {
this.goodsTypeList = list
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val itemView = LayoutInflater.from(context).inflate(R.layout.item_type, parent, false)
return GoodsTypeItemHolder(itemView)
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val goodsTypeItemHolder = holder as GoodsTypeItemHolder
goodsTypeItemHolder.bindData(goodsTypeList.get(position), position)
}
override fun getItemCount(): Int {
return goodsTypeList.size
}
inner class GoodsTypeItemHolder(val item: View) : RecyclerView.ViewHolder(item) {
val tvType: TextView
init {
tvType = item.find(R.id.type)
}
fun bindData(goodsTypeInfo: GoodsTypeInfo, position: Int) {
tvType.text = goodsTypeInfo.name
}
}
}
TakeoutService.kt服务端的请求格式
package com.example.takeout.model.net
import retrofit2.Call
import retrofit2.http.GET
import rx.Observable
interface TakeoutService {
//ex. @GET(“users/{user}/repos”)
//ex. fun listRepos(@Path(“user”) user: String): Call<List>
//http://127.0.0.1:8090/takeout?index=0
@GET(“takeout?index=0”)
fun getHomeInfo(): Call
//http://127.0.0.1:8090/takelogin?index=0
@GET(“takelogin?index=0”)
fun loginByPhone(): Call
//http://127.0.0.1:8090/takeorder?index=0
@GET(“takeorder?index=0”)
fun getOrderList(): Call
//使用Rxjava组合的接口
//http://127.0.0.1:8090/takeorder?index=0
@GET(“takeorder?index=0”)
fun getOrderListByRxjava(): Observable
@GET(“takebusiness?index=0”)
fun getBusinessInfo(): Call
}
item_type.xml布局文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:clickable=“true”
android:layout_height=“wrap_content”
android:minHeight=“80dp”
android:background="#b9dedcdc"
android:orientation=“vertical”>
<TextView android:gravity=“center”
android:id="@+id/tvRedDotCount"
android:layout_marginTop=“5dp”
android:textColor="#fff"
android:text=“1”
android:visibility=“invisible”
android:layout_marginRight=“5dp”
android:textSize=“12sp”
android:background="@drawable/circle_red"
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“right”
/>
<TextView
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_centerInParent=“true”
最后
现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
上述【高清技术脑图】以及【配套的架构技术PDF】点击:Android架构视频+BAT面试专题PDF+学习笔记,或者私信回复【技能提升】即可获取!
为什么某些人会一直比你优秀,是因为他本身就很优秀还一直在持续努力变得更优秀,而你是不是还在满足于现状内心在窃喜!
Android架构师之路很漫长,一起共勉吧!