└── RecycleviewCheckBoxDemo
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_checked.png
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_uncheck.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable
│ │ │ │ ├── bg_white_cornor_10.xml
│ │ │ │ ├── divider_main_bg_height_1.xml
│ │ │ │ ├── button_shape.xml
│ │ │ │ ├── button_noclickable_shape.xml
│ │ │ │ └── bg_selete_all.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── item_my_live.xml
│ │ │ │ ├── pop_user.xml
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── xiaohao
│ │ │ └── recycleviewcheckboxdemo
│ │ │ ├── MyLiveList.java
│ │ │ ├── MineRadioAdapter.java
│ │ │ ├── DividerItemDecoration.java
│ │ │ └── MainActivity.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── xiaohao
│ │ │ └── recycleviewcheckboxdemo
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── xiaohao
│ │ └── recycleviewcheckboxdemo
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── build.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
/RecycleviewCheckBoxDemo/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RecycleviewCheckBoxDemo
3 |
4 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohaosir/RecyclerDemo/HEAD/RecycleviewCheckBoxDemo/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohaosir/RecyclerDemo/HEAD/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohaosir/RecyclerDemo/HEAD/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohaosir/RecyclerDemo/HEAD/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xxhdpi/ic_checked.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohaosir/RecyclerDemo/HEAD/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xxhdpi/ic_checked.png
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohaosir/RecyclerDemo/HEAD/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xxhdpi/ic_uncheck.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohaosir/RecyclerDemo/HEAD/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xxhdpi/ic_uncheck.png
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guohaosir/RecyclerDemo/HEAD/RecycleviewCheckBoxDemo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/drawable/bg_white_cornor_10.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/drawable/divider_main_bg_height_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
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-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #b7b8bd
7 |
8 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/drawable/button_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/drawable/button_noclickable_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/drawable/bg_selete_all.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/test/java/com/example/xiaohao/recycleviewcheckboxdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.xiaohao.recycleviewcheckboxdemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\studio2.2\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/java/com/example/xiaohao/recycleviewcheckboxdemo/MyLiveList.java:
--------------------------------------------------------------------------------
1 | package com.example.xiaohao.recycleviewcheckboxdemo;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by guohao on 2017/9/6.
7 | * Description
8 | */
9 |
10 | public class MyLiveList {
11 |
12 | private String title;
13 | private String source;
14 | public boolean isSelect;
15 |
16 | public boolean isSelect() {
17 | return isSelect;
18 | }
19 |
20 | public void setSelect(boolean isSelect) {
21 | this.isSelect = isSelect;
22 | }
23 |
24 | public String getTitle() {
25 | return title;
26 | }
27 |
28 | public void setTitle(String title) {
29 | this.title = title;
30 | }
31 |
32 | public String getSource() {
33 | return source;
34 | }
35 |
36 | public void setSource(String source) {
37 | this.source = source;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/androidTest/java/com/example/xiaohao/recycleviewcheckboxdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.xiaohao.recycleviewcheckboxdemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.xiaohao.recycleviewcheckboxdemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 |
4 | android {
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.3"
7 | defaultConfig {
8 | applicationId "com.example.xiaohao.recycleviewcheckboxdemo"
9 | minSdkVersion 15
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(include: ['*.jar'], dir: 'libs')
25 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
26 | exclude group: 'com.android.support', module: 'support-annotations'
27 | })
28 | compile 'com.android.support:appcompat-v7:25.3.1'
29 | testCompile 'junit:junit:4.12'
30 | compile 'com.android.support:recyclerview-v7:25.3.1'
31 | compile 'com.jakewharton:butterknife:6.1.0'
32 | }
33 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/layout/item_my_live.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
17 |
23 |
24 |
31 |
32 |
43 |
44 |
51 |
52 |
58 |
59 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/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 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/layout/pop_user.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
25 |
26 |
35 |
36 |
41 |
42 |
46 |
47 |
57 |
58 |
63 |
64 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 1.8 (2)
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/java/com/example/xiaohao/recycleviewcheckboxdemo/MineRadioAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.xiaohao.recycleviewcheckboxdemo;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.RelativeLayout;
10 | import android.widget.TextView;
11 |
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import butterknife.ButterKnife;
17 | import butterknife.InjectView;
18 |
19 | /**
20 | * Created by guohao on 2017/9/6.
21 | */
22 |
23 | public class MineRadioAdapter extends RecyclerView.Adapter {
24 |
25 | private static final int MYLIVE_MODE_CHECK = 0;
26 | int mEditMode = MYLIVE_MODE_CHECK;
27 |
28 | private int secret = 0;
29 | private String title = "";
30 | private Context context;
31 | private List mMyLiveList;
32 | private OnItemClickListener mOnItemClickListener;
33 |
34 | public MineRadioAdapter(Context context) {
35 | this.context = context;
36 | }
37 |
38 |
39 | public void notifyAdapter(List myLiveList, boolean isAdd) {
40 | if (!isAdd) {
41 | this.mMyLiveList = myLiveList;
42 | } else {
43 | this.mMyLiveList.addAll(myLiveList);
44 | }
45 | notifyDataSetChanged();
46 | }
47 |
48 | public List getMyLiveList() {
49 | if (mMyLiveList == null) {
50 | mMyLiveList = new ArrayList<>();
51 | }
52 | return mMyLiveList;
53 | }
54 |
55 | @Override
56 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
57 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_my_live, parent, false);
58 | ViewHolder holder = new ViewHolder(view);
59 | return holder;
60 | }
61 |
62 | @Override
63 | public int getItemCount() {
64 | return mMyLiveList.size();
65 | }
66 |
67 | @Override
68 | public void onBindViewHolder(final ViewHolder holder, final int position) {
69 | final MyLiveList myLive = mMyLiveList.get(holder.getAdapterPosition());
70 | holder.mTvTitle.setText(myLive.getTitle());
71 | holder.mTvSource.setText(myLive.getSource());
72 | if (mEditMode == MYLIVE_MODE_CHECK) {
73 | holder.mCheckBox.setVisibility(View.GONE);
74 | } else {
75 | holder.mCheckBox.setVisibility(View.VISIBLE);
76 |
77 | if (myLive.isSelect()) {
78 | holder.mCheckBox.setImageResource(R.mipmap.ic_checked);
79 | } else {
80 | holder.mCheckBox.setImageResource(R.mipmap.ic_uncheck);
81 | }
82 | }
83 | holder.itemView.setOnClickListener(new View.OnClickListener() {
84 | @Override
85 | public void onClick(View v) {
86 | mOnItemClickListener.onItemClickListener(holder.getAdapterPosition(), mMyLiveList);
87 | }
88 | });
89 | }
90 |
91 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
92 | this.mOnItemClickListener = onItemClickListener;
93 | }
94 | public interface OnItemClickListener {
95 | void onItemClickListener(int pos,List myLiveList);
96 | }
97 | public void setEditMode(int editMode) {
98 | mEditMode = editMode;
99 | notifyDataSetChanged();
100 | }
101 |
102 | public static class ViewHolder extends RecyclerView.ViewHolder {
103 | @InjectView(R.id.radio_img)
104 | ImageView mRadioImg;
105 | @InjectView(R.id.tv_title)
106 | TextView mTvTitle;
107 | @InjectView(R.id.tv_source)
108 | TextView mTvSource;
109 | @InjectView(R.id.root_view)
110 | RelativeLayout mRootView;
111 | @InjectView(R.id.check_box)
112 | ImageView mCheckBox;
113 |
114 |
115 |
116 | public ViewHolder(View itemView) {
117 | super(itemView);
118 | ButterKnife.inject(this,itemView);
119 |
120 | }
121 | }
122 |
123 |
124 | }
125 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/java/com/example/xiaohao/recycleviewcheckboxdemo/DividerItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.example.xiaohao.recycleviewcheckboxdemo;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Rect;
7 | import android.graphics.drawable.Drawable;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.View;
11 |
12 | /**
13 | * Created by guohao on 2017/9/6.
14 | * RecyclerView的通用间隔条(vivider)
15 | */
16 | public class DividerItemDecoration extends RecyclerView.ItemDecoration {
17 | private static final int[] ATTRS = new int[]{android.R.attr.listDivider};
18 |
19 | public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL;
20 | public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL;
21 | private Drawable mDivider;
22 | private int mOrientation;
23 | private boolean hasBottomeDrive = true;
24 |
25 | public DividerItemDecoration(Context context, int orientation) {
26 | final TypedArray a = context.obtainStyledAttributes(ATTRS);
27 | mDivider = a.getDrawable(0);
28 | a.recycle();
29 | setOrientation(orientation);
30 | }
31 |
32 | public DividerItemDecoration(Context context, int orientation, boolean hasBottomDrive) {
33 | final TypedArray a = context.obtainStyledAttributes(ATTRS);
34 | mDivider = a.getDrawable(0);
35 | a.recycle();
36 | setOrientation(orientation);
37 | this.hasBottomeDrive = hasBottomDrive;
38 | }
39 |
40 |
41 | public void setOrientation(int orientation) {
42 | if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) {
43 | throw new IllegalArgumentException("invalid orientation");
44 | }
45 | mOrientation = orientation;
46 | }
47 |
48 | @Override
49 | public void onDraw(Canvas c, RecyclerView parent) {
50 | if (mOrientation == VERTICAL_LIST) {
51 | drawVertical(c, parent);
52 | } else {
53 | drawHorizontal(c, parent);
54 | }
55 |
56 | }
57 |
58 | public void setDividerDrawable(Drawable drawable) {
59 | this.mDivider = drawable;
60 | }
61 |
62 | public void drawVertical(Canvas c, RecyclerView parent) {
63 | final int left = parent.getPaddingLeft();
64 | final int right = parent.getWidth() - parent.getPaddingRight();
65 |
66 | final int childCount = hasBottomeDrive ? parent.getChildCount() : parent.getChildCount() - 1;
67 | for (int i = 0; i < childCount; i++) {
68 | final View child = parent.getChildAt(i);
69 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
70 | final int top = child.getBottom() + params.bottomMargin;
71 | final int bottom = top + mDivider.getIntrinsicHeight();
72 | mDivider.setBounds(left, top, right, bottom);
73 | mDivider.draw(c);
74 | }
75 | }
76 |
77 | public void drawHorizontal(Canvas c, RecyclerView parent) {
78 | final int top = parent.getPaddingTop();
79 | final int bottom = parent.getHeight() - parent.getPaddingBottom();
80 |
81 | final int childCount = hasBottomeDrive ? parent.getChildCount() : parent.getChildCount() - 1;
82 | for (int i = 0; i < childCount; i++) {
83 | final View child = parent.getChildAt(i);
84 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
85 | final int left = child.getRight() + params.rightMargin;
86 | final int right = left + mDivider.getIntrinsicHeight();
87 | mDivider.setBounds(left, top, right, bottom);
88 | mDivider.draw(c);
89 | }
90 | }
91 |
92 | @Override
93 | public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
94 | if (mOrientation == VERTICAL_LIST) {
95 | outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
96 | } else {
97 | outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
16 |
27 |
28 |
32 |
38 |
39 |
47 |
48 |
52 |
53 |
58 |
59 |
68 |
69 |
79 |
80 |
92 |
93 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/RecycleviewCheckBoxDemo/app/src/main/java/com/example/xiaohao/recycleviewcheckboxdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.xiaohao.recycleviewcheckboxdemo;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Color;
5 | import android.os.Bundle;
6 | import android.support.v4.content.ContextCompat;
7 | import android.support.v7.app.AlertDialog;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.LinearLayout;
13 | import android.widget.TextView;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | import butterknife.ButterKnife;
19 | import butterknife.InjectView;
20 |
21 | /**
22 | * Created by guohao on 2017/9/6.
23 | */
24 | public class MainActivity extends Activity implements View.OnClickListener, MineRadioAdapter.OnItemClickListener {
25 |
26 | private static final int MYLIVE_MODE_CHECK = 0;
27 | private static final int MYLIVE_MODE_EDIT = 1;
28 |
29 | @InjectView(R.id.recyclerview)
30 | RecyclerView mRecyclerview;
31 | @InjectView(R.id.tv_select_num)
32 | TextView mTvSelectNum;
33 | @InjectView(R.id.btn_delete)
34 | Button mBtnDelete;
35 | @InjectView(R.id.select_all)
36 | TextView mSelectAll;
37 | @InjectView(R.id.ll_mycollection_bottom_dialog)
38 | LinearLayout mLlMycollectionBottomDialog;
39 | @InjectView(R.id.btn_editor)
40 | TextView mBtnEditor;
41 | private MineRadioAdapter mRadioAdapter = null;
42 | private LinearLayoutManager mLinearLayoutManager;
43 | private List mList = new ArrayList<>();
44 | private int mEditMode = MYLIVE_MODE_CHECK;
45 | private boolean isSelectAll = false;
46 | private boolean editorStatus = false;
47 | private int index = 0;
48 |
49 | @Override
50 | protected void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 | setContentView(R.layout.activity_main);
53 | ButterKnife.inject(this);
54 |
55 | initView();
56 | initData();
57 | initListener();
58 | }
59 |
60 | private void initView() {
61 | }
62 |
63 | private void initData() {
64 | mRadioAdapter = new MineRadioAdapter(this);
65 | mLinearLayoutManager = new LinearLayoutManager(this);
66 | mRecyclerview.setLayoutManager(mLinearLayoutManager);
67 | DividerItemDecoration itemDecorationHeader = new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST);
68 | itemDecorationHeader.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.divider_main_bg_height_1));
69 | mRecyclerview.addItemDecoration(itemDecorationHeader);
70 | mRecyclerview.setAdapter(mRadioAdapter);
71 | for (int i = 0; i < 30; i++) {
72 | MyLiveList myLiveList = new MyLiveList();
73 | myLiveList.setTitle("这是第" + i + "个条目");
74 | myLiveList.setSource("来源" + i);
75 | mList.add(myLiveList);
76 | mRadioAdapter.notifyAdapter(mList, false);
77 | }
78 | }
79 |
80 |
81 | /**
82 | * 根据选择的数量是否为0来判断按钮的是否可点击.
83 | *
84 | * @param size
85 | */
86 | private void setBtnBackground(int size) {
87 | if (size != 0) {
88 | mBtnDelete.setBackgroundResource(R.drawable.button_shape);
89 | mBtnDelete.setEnabled(true);
90 | mBtnDelete.setTextColor(Color.WHITE);
91 | } else {
92 | mBtnDelete.setBackgroundResource(R.drawable.button_noclickable_shape);
93 | mBtnDelete.setEnabled(false);
94 | mBtnDelete.setTextColor(ContextCompat.getColor(this, R.color.color_b7b8bd));
95 | }
96 | }
97 |
98 | private void initListener() {
99 | mRadioAdapter.setOnItemClickListener(this);
100 | mBtnDelete.setOnClickListener(this);
101 | mSelectAll.setOnClickListener(this);
102 | mBtnEditor.setOnClickListener(this);
103 | }
104 |
105 | @Override
106 | public void onClick(View v) {
107 | switch (v.getId()){
108 | case R.id.btn_delete:
109 | deleteVideo();
110 | break;
111 | case R.id.select_all:
112 | selectAllMain();
113 | break;
114 | case R.id.btn_editor:
115 | updataEditMode();
116 | break;
117 | default:
118 | break;
119 | }
120 | }
121 |
122 | /**
123 | * 全选和反选
124 | */
125 | private void selectAllMain() {
126 | if (mRadioAdapter == null) return;
127 | if (!isSelectAll) {
128 | for (int i = 0, j = mRadioAdapter.getMyLiveList().size(); i < j; i++) {
129 | mRadioAdapter.getMyLiveList().get(i).setSelect(true);
130 | }
131 | index = mRadioAdapter.getMyLiveList().size();
132 | mBtnDelete.setEnabled(true);
133 | mSelectAll.setText("取消全选");
134 | isSelectAll = true;
135 | } else {
136 | for (int i = 0, j = mRadioAdapter.getMyLiveList().size(); i < j; i++) {
137 | mRadioAdapter.getMyLiveList().get(i).setSelect(false);
138 | }
139 | index = 0;
140 | mBtnDelete.setEnabled(false);
141 | mSelectAll.setText("全选");
142 | isSelectAll = false;
143 | }
144 | mRadioAdapter.notifyDataSetChanged();
145 | setBtnBackground(index);
146 | mTvSelectNum.setText(String.valueOf(index));
147 | }
148 |
149 | /**
150 | * 删除逻辑
151 | */
152 | private void deleteVideo() {
153 | if (index == 0){
154 | mBtnDelete.setEnabled(false);
155 | return;
156 | }
157 | final AlertDialog builder = new AlertDialog.Builder(this)
158 | .create();
159 | builder.show();
160 | if (builder.getWindow() == null) return;
161 | builder.getWindow().setContentView(R.layout.pop_user);//设置弹出框加载的布局
162 | TextView msg = (TextView) builder.findViewById(R.id.tv_msg);
163 | Button cancle = (Button) builder.findViewById(R.id.btn_cancle);
164 | Button sure = (Button) builder.findViewById(R.id.btn_sure);
165 | if (msg == null || cancle == null || sure == null) return;
166 |
167 | if (index == 1) {
168 | msg.setText("删除后不可恢复,是否删除该条目?");
169 | } else {
170 | msg.setText("删除后不可恢复,是否删除这" + index + "个条目?");
171 | }
172 | cancle.setOnClickListener(new View.OnClickListener() {
173 | @Override
174 | public void onClick(View v) {
175 | builder.dismiss();
176 | }
177 | });
178 | sure.setOnClickListener(new View.OnClickListener() {
179 | @Override
180 | public void onClick(View v) {
181 | for (int i = mRadioAdapter.getMyLiveList().size(), j =0 ; i > j; i--) {
182 | MyLiveList myLive = mRadioAdapter.getMyLiveList().get(i-1);
183 | if (myLive.isSelect()) {
184 |
185 | mRadioAdapter.getMyLiveList().remove(myLive);
186 | index--;
187 | }
188 | }
189 | index = 0;
190 | mTvSelectNum.setText(String.valueOf(0));
191 | setBtnBackground(index);
192 | if (mRadioAdapter.getMyLiveList().size() == 0){
193 | mLlMycollectionBottomDialog.setVisibility(View.GONE);
194 | }
195 | mRadioAdapter.notifyDataSetChanged();
196 | builder.dismiss();
197 | }
198 | });
199 | }
200 | private void updataEditMode() {
201 | mEditMode = mEditMode == MYLIVE_MODE_CHECK ? MYLIVE_MODE_EDIT : MYLIVE_MODE_CHECK;
202 | if (mEditMode == MYLIVE_MODE_EDIT) {
203 | mBtnEditor.setText("取消");
204 | mLlMycollectionBottomDialog.setVisibility(View.VISIBLE);
205 | editorStatus = true;
206 | } else {
207 | mBtnEditor.setText("编辑");
208 | mLlMycollectionBottomDialog.setVisibility(View.GONE);
209 | editorStatus = false;
210 | clearAll();
211 | }
212 | mRadioAdapter.setEditMode(mEditMode);
213 | }
214 |
215 |
216 | private void clearAll() {
217 | mTvSelectNum.setText(String.valueOf(0));
218 | isSelectAll = false;
219 | mSelectAll.setText("全选");
220 | setBtnBackground(0);
221 | }
222 |
223 | @Override
224 | public void onItemClickListener(int pos, List myLiveList) {
225 | if (editorStatus) {
226 | MyLiveList myLive = myLiveList.get(pos);
227 | boolean isSelect = myLive.isSelect();
228 | if (!isSelect) {
229 | index++;
230 | myLive.setSelect(true);
231 | if (index == myLiveList.size()) {
232 | isSelectAll = true;
233 | mSelectAll.setText("取消全选");
234 | }
235 |
236 | } else {
237 | myLive.setSelect(false);
238 | index--;
239 | isSelectAll = false;
240 | mSelectAll.setText("全选");
241 | }
242 | setBtnBackground(index);
243 | mTvSelectNum.setText(String.valueOf(index));
244 | mRadioAdapter.notifyDataSetChanged();
245 | }
246 | }
247 | }
248 |
--------------------------------------------------------------------------------