Skip to content

Commit

Permalink
+ IDslItem / banner item
Browse files Browse the repository at this point in the history
  • Loading branch information
angcyo committed Apr 28, 2023
1 parent 0ab6493 commit 92c5a7c
Show file tree
Hide file tree
Showing 16 changed files with 184 additions and 326 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ buildscript {
repositories {
google()
mavenCentral()

}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
Expand Down
7 changes: 7 additions & 0 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'

android {
compileSdk Integer.parseInt(C_SDK)
Expand Down Expand Up @@ -36,4 +37,10 @@ dependencies {

implementation project(":dslitem")
implementation project(":dslitem2")

def glide_version = "4.15.1"
//https://muyangmin.github.io/glide-docs-cn/
//https://github.com/bumptech/glide
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
}
3 changes: 3 additions & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
18 changes: 18 additions & 0 deletions demo/src/main/java/com/angcyo/dslitem/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.angcyo.dslitem.demo
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import com.angcyo.dsladapter.dpi
import com.angcyo.dsladapter.initDslAdapter
import com.angcyo.dslitem.demo.dslitem.SingleImageItem
import com.angcyo.item.DslBaseEditItem
import com.angcyo.item.DslBaseInfoItem
import com.angcyo.item.DslBaseLabelItem
Expand All @@ -15,6 +17,8 @@ import com.angcyo.item.DslSwitchInfoItem
import com.angcyo.item.DslTextInfoItem
import com.angcyo.item.DslTextItem
import com.angcyo.item.style.itemEditText
import com.angcyo.item.style.renderNestedAdapter
import com.angcyo.item2.DslBannerItem

class MainActivity : AppCompatActivity() {

Expand All @@ -24,6 +28,20 @@ class MainActivity : AppCompatActivity() {

findViewById<RecyclerView>(R.id.recycler_view)?.initDslAdapter {
render {
DslBannerItem()() {
itemHeight = 200 * dpi
renderNestedAdapter {
SingleImageItem()() {
itemImageUri =
"https://scpic.chinaz.net/files/default/imgs/2023-04-26/22c25fc6b5b32280.jpg"
}
SingleImageItem()() {
itemImageUri =
"https://scpic.chinaz.net/files/default/imgs/2023-04-26/927afbe5af4fec22.jpg"
}
}
}

DslBaseEditItem()() {
itemEditText = this::class.java.simpleName
editItemConfig._lastEditSelectionStart = itemEditText?.length ?: -1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.angcyo.dslitem.demo.dslitem

import com.angcyo.dsladapter.DslAdapterItem
import com.angcyo.dsladapter.DslViewHolder
import com.angcyo.dslitem.demo.R
import com.bumptech.glide.Glide

/**
* Email:[email protected]
* @author angcyo
* @date 2023/04/28
*/
class SingleImageItem : DslAdapterItem() {

var itemImageUri: String? = null

init {
itemLayoutId = R.layout.item_single_image
}

override fun onItemBind(
itemHolder: DslViewHolder,
itemPosition: Int,
adapterItem: DslAdapterItem,
payloads: List<Any>
) {
super.onItemBind(itemHolder, itemPosition, adapterItem, payloads)

itemHolder.img(R.id.lib_image_view)?.let {
Glide.with(itemHolder.itemView).load(itemImageUri).centerCrop().into(it)
}
}

}
12 changes: 12 additions & 0 deletions demo/src/main/res/layout/item_single_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/lib_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />

</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit 92c5a7c

Please sign in to comment.