Skip to content

Commit

Permalink
1.2.6.2
Browse files Browse the repository at this point in the history
- JsonList 的 JsonMapPreprocessingEvents 增加设置 deleteWhenDataIsNull,当此选项为 true 时,预处理数据接口中返回 null 时将删除此数据;
  • Loading branch information
kongzue committed Feb 24, 2024
1 parent 7f57144 commit eec0a42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 1 addition & 1 deletion basejson/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 30
versionCode 19
versionName "1.2.6.1"
versionName "1.2.6.2"
}

buildTypes {
Expand Down
16 changes: 10 additions & 6 deletions basejson/src/main/java/com/kongzue/baseokhttp/util/JsonList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import org.json.JSONArray;

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import static com.kongzue.baseokhttp.util.JsonMap.preParsing;

import android.content.Context;
import android.util.Log;

import com.kongzue.baseokhttp.util.adapter.JsonListAdapter;
import com.kongzue.baseokhttp.util.interfaces.JsonMapPreprocessingEvents;
Expand Down Expand Up @@ -312,7 +314,7 @@ public Object get(int index) {
}

public JsonMap findJsonMap(String key, Object value) {
if (isNull(key)){
if (isNull(key)) {
return new JsonMap().preBuild(-1, this);
}
for (int i = 0; i < size(); i++) {
Expand All @@ -327,7 +329,7 @@ public JsonMap findJsonMap(String key, Object value) {
}

public int findJsonMapIndex(String key, Object value) {
if (isNull(key)){
if (isNull(key)) {
return -1;
}
for (int i = 0; i < size(); i++) {
Expand All @@ -342,7 +344,7 @@ public int findJsonMapIndex(String key, Object value) {
}

public JsonList findRemove(String key, Object value) {
if (isNull(key)){
if (isNull(key)) {
return this;
}
for (int i = 0; i < size(); i++) {
Expand Down Expand Up @@ -376,12 +378,14 @@ public JsonListAdapter createAdapter(Context context, int layoutResId) {
}

public JsonList preprocessedJsonMapData(JsonMapPreprocessingEvents events) {
for (Object data : new CopyOnWriteArrayList<>(this)) {
Iterator iterator = iterator();
while (iterator.hasNext()) {
Object data = iterator.next();
if (data instanceof JsonMap) {
JsonMap jsonMap = (JsonMap) data;
JsonMap result = events.processingData(jsonMap);
if (events.isDeleteWhenDataIsNull() && result==null){
remove(data);
if (events.isDeleteWhenDataIsNull() && result == null) {
iterator.remove();
}
}
}
Expand Down

0 comments on commit eec0a42

Please sign in to comment.