• <rp id="vcwyv"></rp>

      <b id="vcwyv"></b>
      <tt id="vcwyv"></tt>

    1. Yasha - Kotlin時代的RecyclerView應該這么寫

      [復制鏈接]
      來自: Season.zlc 分類: Android精品源碼 上傳時間: 2020-1-15 10:13:49
      Tag:

      項目介紹:

      [i=s] 本帖最后由 Season.zlc 于 2020-1-15 10:22 編輯 [/i]

      Yasha (夜叉)

      Github地址

      物品介紹:

      夜叉是一個基于散華打造的快速渲染RecyclerView的DSL工具.

      功能介紹:

      • 無需Adapter

      • 無需ViewHolder

      • 支持初始化數據加載

      • 支持數據分頁加載

      • 支持MultiViewType

      • 支持Header和Footer

      • 支持DiffUtil

      • 支持Loading State

      • 支持CleanUp, 釋放資源避免內存泄漏

      Prepare

      1. 添加jitpack到build.gradle

      
      allprojects {
          repositories {
              ...
              maven { url 'https://jitpack.io' }
          }
      }
      1. 添加依賴

      
      dependencies {
          // 替換 xyz 為具體的版本號, 例如 1.0.0
          implementation 'com.github.ssseasonnn:Yasha:xyz'
      }

      First Blood

      • 渲染Linear列表:

        
          recycler_view.linear(dataSource) {
              renderItem<NormalItem> {
                  res(R.layout.view_holder_normal)
                  onBind {
                      tv_normal_content.text = data.toString()
                  }
              }
              renderItem<HeaderItem> {
                  res(R.layout.view_holder_header)
                  onBind {
                      tv_header_content.text = data.toString()
                  }
              }
              renderItem<FooterItem> {
                  res(R.layout.view_holder_footer)
                  onBind {
                      tv_footer_content.text = data.toString()
                  }
              }
          }

      Double Kill

      • 渲染Grid列表:

        
          recycler_view.grid(dataSource) {
              //設置SpanCount
              spanCount(3)
          
              renderItem<HeaderItem> {
                  res(R.layout.view_holder_header)
                  onBind {
                      tv_header_content.text = data.toString()
                  }
                  
                  //設置Item的SpanSize
                  gridSpanSize(3)
              }
            
              renderItem<NormalItem> {
                  res(R.layout.view_holder_normal)
                  onBind {
                      tv_normal_content.text = data.toString()
                  }
              }
        
              renderItem<FooterItem> {
                  res(R.layout.view_holder_footer)
                  onBind {
                      tv_footer_content.text = data.toString()
                  }
              }
          }

      Triple Kill

      • 渲染Grid列表:

        
          recycler_view.stagger(dataSource) {
              //設置SpanCount
              spanCount(3)
            
              renderItem<HeaderItem> {
                  res(R.layout.view_holder_header)
                  onBind {
                      tv_header_content.text = data.toString()
                  }
                  
                  //設置Item是否為full span
                  staggerFullSpan(true)
              }
              renderItem<NormalItem> {
                  res(R.layout.view_holder_normal)
                  onBind {
                      tv_normal_content.text = data.toString()
                  }
              }
              renderItem<FooterItem> {
                  res(R.layout.view_holder_footer)
                  onBind {
          }

      License

      Copyright 2019 Season.Zlc
      
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
      
         http://www.apache.org/licenses/LICENSE-2.0
      
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.

      相關源碼推薦:

      我來說兩句
      所有評論(3)
      幻影旅團 2020-4-17 02:39:16
      正需要啊,感謝樓主無私分享!
      回復
      強烈支持樓主ing……
      回復
      篤信,篤行 7 小時前
      強烈支持樓主ing……
      回復
      777 0 0
      代碼貢獻英雄榜
      用戶名 下載數
      聯系我們
      首頁/微信公眾賬號投稿
      帖子代碼編輯/版權問題
      QQ:435399051,1294855032
      如何獲得代碼達人稱號?
      如何成為簽約作者?
      領先的中文移動開發者社區
      18620764416
      7*24全天服務
      意見反饋:1294855032@qq.com

      掃一掃關注我們

      Powered by Discuz! X3.2© 2001-2019 Comsenz Inc.( 粵ICP備15117877號 )

      夫妻性姿势真人示范 - 视频 - 在线观看 - 影视资讯 - 唯爱网