mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-11 10:47:11 +01:00
Minor bugs fixed. Change logic of parsing post to avoid displaying error view if some of the posts are not parsed successfully.
This commit is contained in:
parent
1c8ba320bc
commit
eb1d243f2c
@ -185,7 +185,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
||||
mNameTextView.setText(mName);
|
||||
mKarmaTextView.setText(mKarma);
|
||||
|
||||
if (!mProfileImageUrl.equals("")) {
|
||||
if (mProfileImageUrl != null && !mProfileImageUrl.equals("")) {
|
||||
glide.load(mProfileImageUrl)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(144, 0)))
|
||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||
@ -197,7 +197,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
||||
.into(mProfileImageView);
|
||||
}
|
||||
|
||||
if (!mBannerImageUrl.equals("")) {
|
||||
if (mBannerImageUrl != null && !mBannerImageUrl.equals("")) {
|
||||
glide.load(mBannerImageUrl).into(mBannerImageView);
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
||||
@Override
|
||||
public void onParseMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) {
|
||||
mNameTextView.setText(name);
|
||||
if (!profileImageUrl.equals("")) {
|
||||
if (profileImageUrl != null && !profileImageUrl.equals("")) {
|
||||
glide.load(profileImageUrl)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||
@ -237,7 +237,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||
.into(mProfileImageView);
|
||||
}
|
||||
if (!bannerImageUrl.equals("")) {
|
||||
if (bannerImageUrl != null && !bannerImageUrl.equals("")) {
|
||||
glide.load(bannerImageUrl).into(mBannerImageView);
|
||||
}
|
||||
|
||||
|
@ -85,40 +85,44 @@ class ParsePost {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
if(newPosts == null) {
|
||||
//Only one post
|
||||
if(allData.length() == 0) {
|
||||
parseFailed = true;
|
||||
return null;
|
||||
}
|
||||
if (newPosts == null) {
|
||||
//Only one post
|
||||
if (allData.length() == 0) {
|
||||
parseFailed = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject data = allData.getJSONObject(0).getJSONObject(JSONUtils.DATA_KEY);
|
||||
post = parseBasicData(data, locale, -1);
|
||||
} catch (JSONException e) {
|
||||
Log.e("parsing post error", "message: " + e.getMessage());
|
||||
parseFailed = true;
|
||||
}
|
||||
} else {
|
||||
//Posts listing
|
||||
int size;
|
||||
if (nPosts < 0 || nPosts > allData.length()) {
|
||||
size = allData.length();
|
||||
} else {
|
||||
//Posts listing
|
||||
int size;
|
||||
if(nPosts < 0 || nPosts > allData.length()) {
|
||||
size = allData.length();
|
||||
} else {
|
||||
size = nPosts;
|
||||
}
|
||||
size = nPosts;
|
||||
}
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
try {
|
||||
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
||||
Post post = parseBasicData(data, locale, i);
|
||||
if(filter == PostFragment.EXTRA_NO_FILTER) {
|
||||
if (filter == PostFragment.EXTRA_NO_FILTER) {
|
||||
newPosts.add(post);
|
||||
} else if(filter == post.getPostType()) {
|
||||
} else if (filter == post.getPostType()) {
|
||||
newPosts.add(post);
|
||||
} else if(filter == Post.LINK_TYPE && post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||
} else if (filter == Post.LINK_TYPE && post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||
newPosts.add(post);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e("parsing post error", "message: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e("parsing post error", e.getMessage());
|
||||
parseFailed = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user