mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-02 14:27:10 +01:00
Fix search user error.
This commit is contained in:
parent
91a979049d
commit
2db6fb8aca
@ -19,7 +19,7 @@ public class ParseUserData {
|
|||||||
new ParseUserListingDataAsyncTask(response, parseUserListingDataListener).execute();
|
new ParseUserListingDataAsyncTask(response, parseUserListingDataListener).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UserData parseUserDataBase(JSONObject userDataJson) throws JSONException {
|
private static UserData parseUserDataBase(JSONObject userDataJson, boolean parseFullKarma) throws JSONException {
|
||||||
if(userDataJson == null) {
|
if(userDataJson == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -37,9 +37,14 @@ public class ParseUserData {
|
|||||||
}
|
}
|
||||||
int linkKarma = userDataJson.getInt(JSONUtils.LINK_KARMA_KEY);
|
int linkKarma = userDataJson.getInt(JSONUtils.LINK_KARMA_KEY);
|
||||||
int commentKarma = userDataJson.getInt(JSONUtils.COMMENT_KARMA_KEY);
|
int commentKarma = userDataJson.getInt(JSONUtils.COMMENT_KARMA_KEY);
|
||||||
int awarderKarma = userDataJson.getInt(JSONUtils.AWARDER_KARMA_KEY);
|
int awarderKarma = 0;
|
||||||
int awardeeKarma = userDataJson.getInt(JSONUtils.AWARDEE_KARMA_KEY);
|
int awardeeKarma = 0;
|
||||||
int totalKarma = userDataJson.getInt(JSONUtils.TOTAL_KARMA_KEY);
|
int totalKarma = linkKarma + commentKarma;
|
||||||
|
if (parseFullKarma) {
|
||||||
|
awarderKarma = userDataJson.getInt(JSONUtils.AWARDER_KARMA_KEY);
|
||||||
|
awardeeKarma = userDataJson.getInt(JSONUtils.AWARDEE_KARMA_KEY);
|
||||||
|
totalKarma = userDataJson.getInt(JSONUtils.TOTAL_KARMA_KEY);
|
||||||
|
}
|
||||||
long cakeday = userDataJson.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
|
long cakeday = userDataJson.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
|
||||||
boolean isGold = userDataJson.getBoolean(JSONUtils.IS_GOLD_KEY);
|
boolean isGold = userDataJson.getBoolean(JSONUtils.IS_GOLD_KEY);
|
||||||
boolean isFriend = userDataJson.getBoolean(JSONUtils.IS_FRIEND_KEY);
|
boolean isFriend = userDataJson.getBoolean(JSONUtils.IS_FRIEND_KEY);
|
||||||
@ -83,7 +88,7 @@ public class ParseUserData {
|
|||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
try {
|
try {
|
||||||
userData = parseUserDataBase(jsonResponse);
|
userData = parseUserDataBase(jsonResponse, true);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
parseFailed = true;
|
parseFailed = true;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -130,7 +135,7 @@ public class ParseUserData {
|
|||||||
after = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.AFTER_KEY);
|
after = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.AFTER_KEY);
|
||||||
JSONArray children = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
JSONArray children = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
||||||
for (int i = 0; i < children.length(); i++) {
|
for (int i = 0; i < children.length(); i++) {
|
||||||
userDataArrayList.add(parseUserDataBase(children.getJSONObject(i)));
|
userDataArrayList.add(parseUserDataBase(children.getJSONObject(i), false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -54,11 +54,7 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
|
|||||||
new FetchUserData.FetchUserListingDataListener() {
|
new FetchUserData.FetchUserListingDataListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchUserListingDataSuccess(ArrayList<UserData> UserData, String after) {
|
public void onFetchUserListingDataSuccess(ArrayList<UserData> UserData, String after) {
|
||||||
if (UserData.size() == 0) {
|
hasUserLiveData.postValue(UserData.size() != 0);
|
||||||
hasUserLiveData.postValue(false);
|
|
||||||
} else {
|
|
||||||
hasUserLiveData.postValue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
callback.onResult(UserData, null, after);
|
callback.onResult(UserData, null, after);
|
||||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||||
|
Loading…
Reference in New Issue
Block a user