Skip to content

Commit

Permalink
增加状态layout,优化dataadapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuanarcheannovice committed Oct 18, 2018
1 parent 00de16f commit 336bf15
Show file tree
Hide file tree
Showing 19 changed files with 1,623 additions and 1,176 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

36 changes: 0 additions & 36 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

10 changes: 7 additions & 3 deletions .idea/misc.xml

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

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

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

2,373 changes: 1,299 additions & 1,074 deletions .idea/workspace.xml

Large diffs are not rendered by default.

31 changes: 15 additions & 16 deletions Xadapter/Xadapter.iml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
<option name="PROJECT_TYPE" value="1" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<output url="file://$MODULE_DIR$/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes" />
<output-test url="file://$MODULE_DIR$/build/intermediates/javac/debugUnitTest/compileDebugUnitTestJavaWithJavac/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources/debug/generateDebugRFile/out" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources/debugAndroidTest/processDebugAndroidTestResources/r" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
Expand Down Expand Up @@ -71,26 +71,25 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/attr" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/aapt_friendly_merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged-aidl" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint_jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged_manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/packaged_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/public_res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
Expand Down
8 changes: 4 additions & 4 deletions Xadapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile "com.android.support:recyclerview-v7:${supportVersion}"
testImplementation 'junit:junit:4.12'
implementation "com.android.support:recyclerview-v7:${supportVersion}"
}

// 指定编码
Expand Down
20 changes: 12 additions & 8 deletions Xadapter/src/main/java/com/xz/xadapter/XRvPureDataAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public List<T> getDatas() {
return mDatas;
}

/**
* 一般使用 不带刷新
*/
public void setData(@NonNull T data) {
List<T> lists = new ArrayList<>();
lists.add(data);
setDatas(lists, true);
}

/**
* 一般使用 不带刷新
Expand All @@ -42,9 +50,6 @@ public void setDatas(@NonNull List<T> datas) {
* @param isRefresh 是否刷新
*/
public void setDatas(@NonNull List<T> datas, boolean isRefresh) {
if (datas == null) {
return;
}
if (mDatas == null) {
mDatas = new ArrayList<>();
} else {
Expand All @@ -62,7 +67,7 @@ public void setDatas(@NonNull List<T> datas, boolean isRefresh) {
* @param data 数据
* @param isRefresh 是否刷新
*/
public void addData(T data, boolean isRefresh) {
public void addData(@NonNull T data, boolean isRefresh) {
if (this.mDatas == null) {
this.mDatas = new ArrayList<>();
this.mDatas.add(data);
Expand All @@ -83,7 +88,7 @@ public void addData(T data, boolean isRefresh) {
* @param data 数据
* @param isRefresh 是否刷新
*/
public void addDatas(List<T> data, boolean isRefresh) {
public void addDatas(@NonNull List<T> data, boolean isRefresh) {
if (this.mDatas == null) {
this.mDatas = new ArrayList<>();
this.mDatas.addAll(data);
Expand All @@ -99,14 +104,13 @@ public void addDatas(List<T> data, boolean isRefresh) {
}



/**
* 移除data
*
* @param data 对象
* @return 是否移除成功
*/
public boolean removeData(T data) {
public boolean removeData(@NonNull T data) {
return this.mDatas != null && this.mDatas.remove(data);
}

Expand All @@ -131,7 +135,7 @@ public boolean removeData(int index) {
if (mDatas != null && index >= 0) {
if (index < mDatas.size()) {
mDatas.remove(index);
notifyItemRangeRemoved(index,1);
notifyItemRangeRemoved(index, 1);
return true;
} else {
return false;
Expand Down
Loading

0 comments on commit 336bf15

Please sign in to comment.