mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-03-28 04:15:29 +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);
|
mNameTextView.setText(mName);
|
||||||
mKarmaTextView.setText(mKarma);
|
mKarmaTextView.setText(mKarma);
|
||||||
|
|
||||||
if (!mProfileImageUrl.equals("")) {
|
if (mProfileImageUrl != null && !mProfileImageUrl.equals("")) {
|
||||||
glide.load(mProfileImageUrl)
|
glide.load(mProfileImageUrl)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(144, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(144, 0)))
|
||||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||||
@ -197,7 +197,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
.into(mProfileImageView);
|
.into(mProfileImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mBannerImageUrl.equals("")) {
|
if (mBannerImageUrl != null && !mBannerImageUrl.equals("")) {
|
||||||
glide.load(mBannerImageUrl).into(mBannerImageView);
|
glide.load(mBannerImageUrl).into(mBannerImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
@Override
|
@Override
|
||||||
public void onParseMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) {
|
public void onParseMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) {
|
||||||
mNameTextView.setText(name);
|
mNameTextView.setText(name);
|
||||||
if (!profileImageUrl.equals("")) {
|
if (profileImageUrl != null && !profileImageUrl.equals("")) {
|
||||||
glide.load(profileImageUrl)
|
glide.load(profileImageUrl)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
.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)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(128, 0)))
|
||||||
.into(mProfileImageView);
|
.into(mProfileImageView);
|
||||||
}
|
}
|
||||||
if (!bannerImageUrl.equals("")) {
|
if (bannerImageUrl != null && !bannerImageUrl.equals("")) {
|
||||||
glide.load(bannerImageUrl).into(mBannerImageView);
|
glide.load(bannerImageUrl).into(mBannerImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,40 +85,44 @@ class ParsePost {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (newPosts == null) {
|
||||||
if(newPosts == null) {
|
//Only one post
|
||||||
//Only one post
|
if (allData.length() == 0) {
|
||||||
if(allData.length() == 0) {
|
parseFailed = true;
|
||||||
parseFailed = true;
|
return null;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
try {
|
||||||
JSONObject data = allData.getJSONObject(0).getJSONObject(JSONUtils.DATA_KEY);
|
JSONObject data = allData.getJSONObject(0).getJSONObject(JSONUtils.DATA_KEY);
|
||||||
post = parseBasicData(data, locale, -1);
|
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 {
|
} else {
|
||||||
//Posts listing
|
size = nPosts;
|
||||||
int size;
|
}
|
||||||
if(nPosts < 0 || nPosts > allData.length()) {
|
|
||||||
size = allData.length();
|
|
||||||
} else {
|
|
||||||
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);
|
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
|
||||||
Post post = parseBasicData(data, locale, i);
|
Post post = parseBasicData(data, locale, i);
|
||||||
if(filter == PostFragment.EXTRA_NO_FILTER) {
|
if (filter == PostFragment.EXTRA_NO_FILTER) {
|
||||||
newPosts.add(post);
|
newPosts.add(post);
|
||||||
} else if(filter == post.getPostType()) {
|
} else if (filter == post.getPostType()) {
|
||||||
newPosts.add(post);
|
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);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user