Skip to content

Instantly share code, notes, and snippets.

@monkeydone
Created July 16, 2020 12:22
Show Gist options
  • Save monkeydone/59e2264f561032d4bc1c2a04bd714798 to your computer and use it in GitHub Desktop.
Save monkeydone/59e2264f561032d4bc1c2a04bd714798 to your computer and use it in GitHub Desktop.
#注解使用
@IntDef({ALIGN_BOTTOM, ALIGN_BASELINE, ALIGN_TOP, ALIGN_CENTER})
@Retention(RetentionPolicy.SOURCE)
public @interface Alignment {
}
public AlignImageSpan(Drawable d, @Alignment int verticalAlignment) {
super(d, verticalAlignment);
}
val span: ImageSpan = AlignImageSpan(drawable, AlignImageSpan.ALIGN_CENTER)
@monkeydone
Copy link
Author

monkeydone commented Aug 25, 2020

DataBinding 启用配置

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.1"
    
    dataBinding {
        enabled = true
    }

其中

dataBinding {
    enabled = true
}

apply plugin: "kotlin-kapt"

最重要

@monkeydone
Copy link
Author

通用item

package com.x.media.entity

import com.chad.library.adapter.base.entity.MultiItemEntity

/**
 * 文 件 名: MultipleItem
 * 创 建 人: Allen
 * 创建日期: 2017/6/13 14:20
 * 修改时间:
 * 修改备注:
 */
class CommonMultiItem<T> : MultiItemEntity {
    private var itemType: Int = 0
    var spanSize: Int = 0

    constructor(itemType: Int, spanSize: Int, content: T) {
        this.itemType = itemType
        this.spanSize = spanSize
        this.content = content
    }

    constructor(itemType: Int, spanSize: Int) {
        this.itemType = itemType
        this.spanSize = spanSize
    }

    var content: T? = null

    override fun getItemType(): Int {
        return itemType
    }

    companion object {
        const val ITEM_HEADER = 1
        const val ITEM_ONE = 2
    }
}



@monkeydone
Copy link
Author

monkeydone commented Aug 25, 2020

implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.47'

maven { url "https://jitpack.io" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment