mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 12:57:12 +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();
|
||||
}
|
||||
|
||||
private static UserData parseUserDataBase(JSONObject userDataJson) throws JSONException {
|
||||
private static UserData parseUserDataBase(JSONObject userDataJson, boolean parseFullKarma) throws JSONException {
|
||||
if(userDataJson == null) {
|
||||
return null;
|
||||
}
|
||||
@ -37,9 +37,14 @@ public class ParseUserData {
|
||||
}
|
||||
int linkKarma = userDataJson.getInt(JSONUtils.LINK_KARMA_KEY);
|
||||
int commentKarma = userDataJson.getInt(JSONUtils.COMMENT_KARMA_KEY);
|
||||
int awarderKarma = userDataJson.getInt(JSONUtils.AWARDER_KARMA_KEY);
|
||||
int awardeeKarma = userDataJson.getInt(JSONUtils.AWARDEE_KARMA_KEY);
|
||||
int totalKarma = userDataJson.getInt(JSONUtils.TOTAL_KARMA_KEY);
|
||||
int awarderKarma = 0;
|
||||
int awardeeKarma = 0;
|
||||
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;
|
||||
boolean isGold = userDataJson.getBoolean(JSONUtils.IS_GOLD_KEY);
|
||||
boolean isFriend = userDataJson.getBoolean(JSONUtils.IS_FRIEND_KEY);
|
||||
@ -83,7 +88,7 @@ public class ParseUserData {
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
try {
|
||||
userData = parseUserDataBase(jsonResponse);
|
||||
userData = parseUserDataBase(jsonResponse, true);
|
||||
} catch (JSONException e) {
|
||||
parseFailed = true;
|
||||
e.printStackTrace();
|
||||
@ -130,7 +135,7 @@ public class ParseUserData {
|
||||
after = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.AFTER_KEY);
|
||||
JSONArray children = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
||||
for (int i = 0; i < children.length(); i++) {
|
||||
userDataArrayList.add(parseUserDataBase(children.getJSONObject(i)));
|
||||
userDataArrayList.add(parseUserDataBase(children.getJSONObject(i), false));
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
|
@ -54,11 +54,7 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
|
||||
new FetchUserData.FetchUserListingDataListener() {
|
||||
@Override
|
||||
public void onFetchUserListingDataSuccess(ArrayList<UserData> UserData, String after) {
|
||||
if (UserData.size() == 0) {
|
||||
hasUserLiveData.postValue(false);
|
||||
} else {
|
||||
hasUserLiveData.postValue(true);
|
||||
}
|
||||
hasUserLiveData.postValue(UserData.size() != 0);
|
||||
|
||||
callback.onResult(UserData, null, after);
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||
|
Loading…
Reference in New Issue
Block a user