Refresh

This website github.com/tuuzedarchive/ListAdapter/commit/3bae23d1fd438e280fa0c5d09d400c4eeaaf516a is currently offline. Cloudflare's Always Online™ shows a snapshot of this web page from the Internet Archive's Wayback Machine. To check for the live version, click Refresh.

Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
2.1.0-alpha01
Browse files Browse the repository at this point in the history
  • Loading branch information
tuuzed committed May 15, 2019
1 parent 603070e commit 3bae23d
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 217 deletions.
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.30'
ext.kotlin_version = '1.3.31'
ext.compileSdk = 28
ext.minSdk = 16
ext.targetSdk = 28
Expand All @@ -10,9 +10,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.novoda:bintray-release:0.9'
classpath 'com.novoda:bintray-release:0.9.1'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
Expand All @@ -23,13 +23,14 @@ allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://dl.bintray.com/tuuzed/maven' }
google()
jcenter()
}
}

group = 'com.tuuzed.recyclerview'
version = '2.0.3'
version = '2.1.0-alpha01'

task clean(type: Delete) {
delete rootProject.buildDir
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Mar 06 10:55:12 CST 2019
#Wed May 15 12:24:23 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\:https://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\:https://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 changes: 3 additions & 4 deletions prefs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'com.afollestad.material-dialogs:core:2.6.0'
implementation 'com.afollestad.material-dialogs:input:2.6.0'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
implementation 'com.google.android.material:material:1.1.0-alpha06'
api project(':adapter')
api 'com.tuuzed.androidx.exdialog:exdialog:0.1.1-alpha01'

// 单元测试
testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.tuuzed.recyclerview.adapter.prefs
import android.text.InputType
import android.view.View
import androidx.annotation.LayoutRes
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import com.tuuzed.androidx.exdialog.ExDialog
import com.tuuzed.androidx.exdialog.ext.input
import com.tuuzed.recyclerview.adapter.AbstractItemViewBinder
import com.tuuzed.recyclerview.adapter.CommonItemViewHolder

Expand All @@ -31,24 +31,30 @@ open class PrefEditTextItemViewBinder<in T : PrefEditTextItem>(
}

open fun handleItemLayoutClick(view: View, holder: CommonItemViewHolder, item: T, position: Int) {
MaterialDialog(view.context).show {
title(text = item.title)
input(
hint = item.hint,
maxLength = item.maxLength,
prefill = item.summary,
inputType = item.inputType,
allowEmpty = item.allowEmpty,
callback = { _, text ->
val oldSummary = item.summary
item.summary = text.toString()
if (item.callback(item, position)) {
holder.text(R.id.pref_summary, item.summary)
} else {
item.summary = oldSummary
}

ExDialog(view.context).show {
input {
title(text = item.title)
hint(item.hint)
maxLength(item.maxLength)
prefill(text = item.summary)
inputType(item.inputType)
onTextChanged { _, text ->
if (!item.allowEmpty) {
positiveButtonEnable(text.isNotEmpty())
}
}
callback { _, text ->
val oldSummary = item.summary
item.summary = text.toString()
if (item.callback(item, position)) {
holder.text(R.id.pref_summary, item.summary)
} else {
item.summary = oldSummary
}
)
}
positiveButton()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.tuuzed.recyclerview.adapter.prefs

import android.view.View
import androidx.annotation.LayoutRes
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsMultiChoice
import com.tuuzed.androidx.exdialog.ExDialog
import com.tuuzed.androidx.exdialog.ext.multiChoiceItems
import com.tuuzed.recyclerview.adapter.AbstractItemViewBinder
import com.tuuzed.recyclerview.adapter.CommonItemViewHolder
import java.util.*
Expand Down Expand Up @@ -38,30 +38,31 @@ open class PrefMultiListItemViewBinder<in T : PrefMultiListItem>(
initialSelection.add(index)
}
}
MaterialDialog(view.context).show {
title(text = item.title)
noAutoDismiss()
listItemsMultiChoice(
items = items.map { item.itemToString(it) },
allowEmptySelection = item.allowEmptySelection,
initialSelection = initialSelection.toIntArray(),
selection = { _, indices, _ ->
val oldCheckedItems = item.checkedItems
val oldSummary = item.summary
item.checkedItems = items.filterIndexed { index, _ -> indices.contains(index) }
item.summary = item.checkedItems.joinToString(item.itemSeparator) { item.itemToString(it) }
if (item.callback(item, position)) {
holder.text(R.id.pref_summary, item.summary)
} else {
item.checkedItems = oldCheckedItems
item.summary = oldSummary
}
ExDialog(view.context).show {
multiChoiceItems<Any> {
title(text = item.title)
items(items, initialSelection)
onSelectedItemChanged { _, _, selectedItems ->
if (!item.allowEmptySelection) {
positiveButtonEnable(selectedItems.isNotEmpty())
}
)
positiveButton { dismiss() }
negativeButton { dismiss() }
}
callback { _, _, selectedItems ->
val oldCheckedItems = item.checkedItems
val oldSummary = item.summary
item.checkedItems = selectedItems
item.summary = item.checkedItems.joinToString(item.itemSeparator) { item.itemToString(it) }
if (item.callback(item, position)) {
holder.text(R.id.pref_summary, item.summary)
} else {
item.checkedItems = oldCheckedItems
item.summary = oldSummary
}
}
negativeButton()
positiveButton()
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open class PrefRadioItemViewBinder<in T : PrefRadioItem>(
val oldChecked = item.checked
item.checked = !item.checked
if (item.callback(item, position)) {
holder.find<CompoundButton>(R.id.pref_switch_widget).isChecked = item.checked
holder.find<CompoundButton>(R.id.pref_radio_widget).isChecked = item.checked
} else {
item.checked = oldChecked
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.tuuzed.recyclerview.adapter.prefs

import android.view.View
import androidx.annotation.LayoutRes
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.listItemsSingleChoice
import com.tuuzed.androidx.exdialog.ExDialog
import com.tuuzed.androidx.exdialog.ext.singleChoiceItems
import com.tuuzed.recyclerview.adapter.AbstractItemViewBinder
import com.tuuzed.recyclerview.adapter.CommonItemViewHolder

Expand All @@ -29,24 +29,24 @@ open class PrefSingleListItemViewBinder<in T : PrefSingleListItem>(

open fun handleItemLayoutClick(view: View, holder: CommonItemViewHolder, item: T, position: Int) {
item.itemsLoader { items ->
MaterialDialog(view.context).show {
title(text = item.title)
listItemsSingleChoice(
items = items.map { item.itemToString(it) },
initialSelection = items.indexOf(item.checkedItem),
selection = { _, index, text ->
val oldCheckedItem = item.checkedItem
val oldSummary = item.summary
item.checkedItem = items[index]
item.summary = text
if (item.callback(item, position)) {
holder.text(R.id.pref_summary, item.summary)
} else {
item.checkedItem = oldCheckedItem
item.summary = oldSummary
}
ExDialog(view.context).show {
singleChoiceItems<Any>(toReadable = { item.itemToString(it) }) {
title(text = item.title)
items(items, items.indexOf(item.checkedItem))
onSelectedItemChanged { dialog, _, selectedItem ->
val oldCheckedItem = item.checkedItem
val oldSummary = item.summary
item.checkedItem = selectedItem
item.summary = item.itemToString(item.checkedItem ?: "")
if (item.callback(item, position)) {
holder.text(R.id.pref_summary, item.summary)
} else {
item.checkedItem = oldCheckedItem
item.summary = oldSummary
}
)
dialog.dismiss()
}
}
}
}
}
Expand Down
66 changes: 0 additions & 66 deletions prefs/src/main/res/layout/md_dialog_base.xml

This file was deleted.

16 changes: 0 additions & 16 deletions prefs/src/main/res/layout/md_dialog_stub_input.xml

This file was deleted.

15 changes: 0 additions & 15 deletions prefs/src/main/res/layout/md_listitem_multichoice.xml

This file was deleted.

Loading

0 comments on commit 3bae23d

Please sign in to comment.