├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── layout
│ │ │ ├── item_listview.xml
│ │ │ ├── activity_list_demo.xml
│ │ │ ├── activity_main.xml
│ │ │ └── activity_simple_demo.xml
│ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ └── drawable
│ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ └── com
│ │ │ └── sd
│ │ │ └── selectmanager
│ │ │ ├── DataModel.java
│ │ │ ├── MainActivity.java
│ │ │ ├── ListDemoActivity.java
│ │ │ ├── ListDemoAdapter.java
│ │ │ └── SimpleDemoActivity.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── lib
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── sd
│ │ └── lib
│ │ └── selectmanager
│ │ ├── FSelectViewManager.java
│ │ ├── SelectManager.java
│ │ └── FSelectManager.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── LICENSE
├── gradlew.bat
├── gradlew
└── README.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 |
--------------------------------------------------------------------------------
/lib/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':lib'
2 |
--------------------------------------------------------------------------------
/lib/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | selectmanager
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zj565061763/selectmanager/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | .DS_Store
8 | build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Apr 14 09:44:54 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_listview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sd/selectmanager/DataModel.java:
--------------------------------------------------------------------------------
1 | package com.sd.selectmanager;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class DataModel {
7 | public String name;
8 |
9 | public DataModel(String name) {
10 | this.name = name;
11 | }
12 |
13 | public static List get(int count) {
14 | final List list = new ArrayList<>();
15 | for (int i = 0; i < count; i++) {
16 | list.add(new DataModel(String.valueOf(i)));
17 | }
18 | return list;
19 | }
20 |
21 | @Override
22 | public String toString() {
23 | return name;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_list_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/lib/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 30
5 | defaultConfig {
6 | applicationId "com.sd.selectmanager"
7 | minSdkVersion 15
8 | targetSdkVersion 30
9 | versionCode 1
10 | versionName "1.0"
11 | }
12 |
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 |
20 | compileOptions {
21 | sourceCompatibility JavaVersion.VERSION_1_8
22 | targetCompatibility JavaVersion.VERSION_1_8
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation 'androidx.appcompat:appcompat:1.2.0'
28 | implementation project(':lib')
29 |
30 | implementation('com.github.zj565061763:adapter:1.2.2-beta01') {
31 | exclude module: 'selectmanager'
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sd/selectmanager/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.sd.selectmanager;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 |
6 | import androidx.appcompat.app.AppCompatActivity;
7 |
8 | import android.view.View;
9 |
10 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main);
15 | }
16 |
17 | @Override
18 | public void onClick(View v) {
19 | switch (v.getId()) {
20 | case R.id.btn_simple_demo:
21 | startActivity(new Intent(this, SimpleDemoActivity.class));
22 | break;
23 | case R.id.btn_list_demo:
24 | startActivity(new Intent(this, ListDemoActivity.class));
25 | break;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 fanwe
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/lib/src/main/java/com/sd/lib/selectmanager/FSelectViewManager.java:
--------------------------------------------------------------------------------
1 | package com.sd.lib.selectmanager;
2 |
3 | import android.view.View;
4 | import android.view.View.OnClickListener;
5 |
6 | public class FSelectViewManager extends FSelectManager implements OnClickListener
7 | {
8 | @Override
9 | protected void onInitItem(T item)
10 | {
11 | super.onInitItem(item);
12 | item.setOnClickListener(this);
13 | item.setSelected(false);
14 | }
15 |
16 | @Override
17 | protected void onSelectedChanged(boolean selected, T item)
18 | {
19 | super.onSelectedChanged(selected, item);
20 | item.setSelected(selected);
21 | }
22 |
23 | @Override
24 | public void onClick(View v)
25 | {
26 | if (getMode() == Mode.SINGLE_MUST_ONE_SELECTED)
27 | {
28 | final T selectedItem = getSelectedItem();
29 | if (selectedItem != null && selectedItem == v)
30 | onSingleSelectedItemClick(selectedItem);
31 | }
32 |
33 | performClick((T) v);
34 | }
35 |
36 | /**
37 | * 已经选中的Item被点击(单选模式)
38 | */
39 | protected void onSingleSelectedItemClick(T item)
40 | {
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'maven-publish'
4 | }
5 |
6 | def libGroupId = "com.sd.lib.android"
7 | def libArtifactId = "selectmanager"
8 | def libVersionCode = 20210530
9 | def libVersionName = "1.1.8"
10 |
11 | android {
12 | compileSdkVersion 30
13 | defaultConfig {
14 | minSdkVersion 15
15 | targetSdkVersion 30
16 | versionCode libVersionCode
17 | versionName libVersionName
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | compileOptions {
28 | sourceCompatibility JavaVersion.VERSION_1_8
29 | targetCompatibility JavaVersion.VERSION_1_8
30 | }
31 |
32 | lintOptions {
33 | checkReleaseBuilds false
34 | abortOnError false
35 | }
36 | }
37 |
38 | dependencies {
39 | }
40 |
41 | task generateSourcesJar(type: Jar) {
42 | from android.sourceSets.main.java.srcDirs
43 | classifier 'sources'
44 | }
45 |
46 | afterEvaluate {
47 | publishing {
48 | publications {
49 | release(MavenPublication) {
50 | from components.release
51 |
52 | groupId = libGroupId
53 | artifactId = libArtifactId
54 | version = libVersionName
55 |
56 | // 上传源码
57 | artifact generateSourcesJar
58 | }
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sd/selectmanager/ListDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.sd.selectmanager;
2 |
3 | import android.os.Bundle;
4 | import android.text.TextUtils;
5 | import android.widget.ListView;
6 | import android.widget.TextView;
7 |
8 | import androidx.appcompat.app.AppCompatActivity;
9 |
10 | import com.sd.lib.selectmanager.SelectManager;
11 |
12 | import java.util.List;
13 |
14 | public class ListDemoActivity extends AppCompatActivity {
15 | private ListView mListView;
16 | private final ListDemoAdapter mAdapter = new ListDemoAdapter();
17 | private TextView tv_selected_info;
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_list_demo);
23 | mListView = findViewById(R.id.lv_content);
24 | tv_selected_info = findViewById(R.id.tv_selected_info);
25 | mListView.setAdapter(mAdapter);
26 |
27 | mAdapter.getSelectManager().addCallback(new SelectManager.Callback() {
28 | @Override
29 | public void onSelectedChanged(boolean selected, DataModel item) {
30 | if (mAdapter.getSelectManager().getMode().isSingleType()) {
31 | // 得到当前选中的item数据
32 | final DataModel selectedItem = mAdapter.getSelectManager().getSelectedItem();
33 | if (selectedItem != null) {
34 | tv_selected_info.setText(selectedItem.toString());
35 | }
36 | } else {
37 | // 得到当前选中的item数据
38 | final List listSelected = mAdapter.getSelectManager().getSelectedItems();
39 | tv_selected_info.setText(TextUtils.join(",", listSelected));
40 | }
41 | }
42 | });
43 |
44 | // 设置数据
45 | mAdapter.getDataHolder().setData(DataModel.get(50));
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_simple_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
24 |
25 |
30 |
31 |
36 |
37 |
38 |
42 |
43 |
50 |
51 |
58 |
59 |
66 |
67 |
68 |
69 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sd/selectmanager/ListDemoAdapter.java:
--------------------------------------------------------------------------------
1 | package com.sd.selectmanager;
2 |
3 | import android.graphics.Color;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.Button;
7 |
8 | import com.sd.lib.adapter.FSimpleAdapter;
9 | import com.sd.lib.adapter.data.DataHolder;
10 | import com.sd.lib.selectmanager.FSelectManager;
11 | import com.sd.lib.selectmanager.SelectManager;
12 |
13 | import java.util.List;
14 |
15 | public class ListDemoAdapter extends FSimpleAdapter {
16 | private SelectManager mSelectManager;
17 |
18 | public ListDemoAdapter() {
19 | // adapter数据变化监听
20 | getDataHolder().addDataChangeCallback(new DataHolder.DataChangeCallback() {
21 | @Override
22 | public void onDataChanged(List list) {
23 | // 同步数据到SelectManager
24 | getSelectManager().setItems(list);
25 | }
26 |
27 | @Override
28 | public void onDataChanged(int index, DataModel data) {
29 | // 同步数据到SelectManager
30 | getSelectManager().updateItem(index, data);
31 | }
32 |
33 | @Override
34 | public void onDataAdded(int index, List list) {
35 | // 同步数据到SelectManager
36 | getSelectManager().addItems(index, list);
37 | }
38 |
39 | @Override
40 | public void onDataRemoved(int index, DataModel data) {
41 | // 同步数据到SelectManager
42 | getSelectManager().removeItem(data);
43 | }
44 | });
45 | }
46 |
47 | public SelectManager getSelectManager() {
48 | if (mSelectManager == null) {
49 | mSelectManager = new FSelectManager<>();
50 | // 设置多选模式
51 | mSelectManager.setMode(SelectManager.Mode.MULTI);
52 | // 设置item初始化回调
53 | mSelectManager.setOnItemInitCallback(new SelectManager.OnItemInitCallback() {
54 | @Override
55 | public void onInitItem(DataModel item) {
56 | /**
57 | * 假如添加的item有初始选中状态,则要在此同步选中状态到SelectManager中:mSelectManager.setSelected(item, selected);
58 | */
59 | }
60 | });
61 | // 选中变化回调
62 | mSelectManager.addCallback(new SelectManager.Callback() {
63 | @Override
64 | public void onSelectedChanged(boolean selected, DataModel item) {
65 | // 选中状态变化通知刷新adapter
66 | notifyDataSetChanged();
67 | }
68 | });
69 | }
70 | return mSelectManager;
71 | }
72 |
73 | @Override
74 | public void onBindData(int position, View convertView, ViewGroup parent, final DataModel model) {
75 | Button button = get(R.id.btn, convertView);
76 | button.setText(model.name);
77 |
78 | if (getSelectManager().isSelected(model)) {
79 | button.setTextColor(Color.RED);
80 | } else {
81 | button.setTextColor(Color.BLACK);
82 | }
83 |
84 | button.setOnClickListener(new View.OnClickListener() {
85 | @Override
86 | public void onClick(View v) {
87 | // 模拟点击该项,触发选中状态变更
88 | getSelectManager().performClick(model);
89 | }
90 | });
91 | }
92 |
93 | @Override
94 | public int getLayoutId(int position, View convertView, ViewGroup parent) {
95 | // 返回item的布局
96 | return R.layout.item_listview;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sd/selectmanager/SimpleDemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.sd.selectmanager;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.RadioGroup;
9 | import android.widget.TextView;
10 |
11 | import androidx.appcompat.app.AppCompatActivity;
12 |
13 | import com.sd.lib.selectmanager.FSelectManager;
14 | import com.sd.lib.selectmanager.SelectManager;
15 |
16 | import java.util.List;
17 |
18 | public class SimpleDemoActivity extends AppCompatActivity implements View.OnClickListener {
19 | public static final String TAG = SimpleDemoActivity.class.getSimpleName();
20 |
21 | private RadioGroup rg_mode;
22 | private Button btn_0, btn_1, btn_2;
23 | private TextView tv_selected_info;
24 |
25 | private final SelectManager