mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 04:37:25 +01:00
Correctly handle the case that the value of SELFTEXT_HTML or BODY_HTML_KEY is null. Delete the constraint that only when all the subscribed subreddits and users data have been inserted can the two RecyclerViews update their data in order to avoid the newly fetched data cannot be observed by observers and make the RecyclerView getting the new data impossible.
This commit is contained in:
parent
80058ff6ab
commit
97079663ff
@ -54,7 +54,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private String mBannerImageUrl;
|
private String mBannerImageUrl;
|
||||||
private String mKarma;
|
private String mKarma;
|
||||||
private boolean mFetchUserInfoSuccess;
|
private boolean mFetchUserInfoSuccess;
|
||||||
private boolean mIsInserting;
|
|
||||||
private boolean mInsertSuccess;
|
private boolean mInsertSuccess;
|
||||||
|
|
||||||
private SubscribedSubredditViewModel mSubscribedSubredditViewModel;
|
private SubscribedSubredditViewModel mSubscribedSubredditViewModel;
|
||||||
@ -153,15 +152,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, new Observer<List<SubscribedSubredditData>>() {
|
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, new Observer<List<SubscribedSubredditData>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable final List<SubscribedSubredditData> subscribedSubredditData) {
|
public void onChanged(@Nullable final List<SubscribedSubredditData> subscribedSubredditData) {
|
||||||
if(!mIsInserting) {
|
if (subscribedSubredditData == null || subscribedSubredditData.size() == 0) {
|
||||||
if(subscribedSubredditData == null || subscribedSubredditData.size() == 0) {
|
subscriptionsLabelTextView.setVisibility(View.GONE);
|
||||||
subscriptionsLabelTextView.setVisibility(View.GONE);
|
} else {
|
||||||
} else {
|
subscriptionsLabelTextView.setVisibility(View.VISIBLE);
|
||||||
subscriptionsLabelTextView.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
subredditadapter.setSubscribedSubreddits(subscribedSubredditData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subredditadapter.setSubscribedSubreddits(subscribedSubredditData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -171,15 +168,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
mSubscribedUserViewModel.getAllSubscribedUsers().observe(this, new Observer<List<SubscribedUserData>>() {
|
mSubscribedUserViewModel.getAllSubscribedUsers().observe(this, new Observer<List<SubscribedUserData>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable final List<SubscribedUserData> subscribedUserData) {
|
public void onChanged(@Nullable final List<SubscribedUserData> subscribedUserData) {
|
||||||
if(!mIsInserting) {
|
if (subscribedUserData == null || subscribedUserData.size() == 0) {
|
||||||
Log.i("view", "observed");
|
followingLabelTextView.setVisibility(View.GONE);
|
||||||
if(subscribedUserData == null || subscribedUserData.size() == 0) {
|
} else {
|
||||||
followingLabelTextView.setVisibility(View.GONE);
|
followingLabelTextView.setVisibility(View.VISIBLE);
|
||||||
} else {
|
|
||||||
followingLabelTextView.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
userAdapter.setSubscribedUsers(subscribedUserData);
|
|
||||||
}
|
}
|
||||||
|
userAdapter.setSubscribedUsers(subscribedUserData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -240,7 +234,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public void onFetchSubscribedSubredditsSuccess(ArrayList<SubscribedSubredditData> subscribedSubredditData,
|
public void onFetchSubscribedSubredditsSuccess(ArrayList<SubscribedSubredditData> subscribedSubredditData,
|
||||||
ArrayList<SubscribedUserData> subscribedUserData,
|
ArrayList<SubscribedUserData> subscribedUserData,
|
||||||
ArrayList<SubredditData> subredditData) {
|
ArrayList<SubredditData> subredditData) {
|
||||||
mIsInserting = true;
|
|
||||||
new InsertSubscribedThingsAsyncTask(
|
new InsertSubscribedThingsAsyncTask(
|
||||||
SubscribedSubredditRoomDatabase.getDatabase(MainActivity.this),
|
SubscribedSubredditRoomDatabase.getDatabase(MainActivity.this),
|
||||||
SubscribedUserRoomDatabase.getDatabase(MainActivity.this),
|
SubscribedUserRoomDatabase.getDatabase(MainActivity.this),
|
||||||
@ -251,7 +244,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
new InsertSubscribedThingsAsyncTask.InsertSubscribedThingListener() {
|
new InsertSubscribedThingsAsyncTask.InsertSubscribedThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void insertSuccess() {
|
public void insertSuccess() {
|
||||||
mIsInserting = false;
|
|
||||||
mInsertSuccess = true;
|
mInsertSuccess = true;
|
||||||
}
|
}
|
||||||
}).execute();
|
}).execute();
|
||||||
|
@ -72,7 +72,10 @@ class ParseComment {
|
|||||||
String fullName = data.getString(JSONUtils.LINK_ID);
|
String fullName = data.getString(JSONUtils.LINK_ID);
|
||||||
String author = data.getString(JSONUtils.AUTHOR_KEY);
|
String author = data.getString(JSONUtils.AUTHOR_KEY);
|
||||||
boolean isSubmitter = data.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
|
boolean isSubmitter = data.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
|
||||||
String commentContent = data.getString(JSONUtils.BODY_HTML_KEY);
|
String commentContent = "";
|
||||||
|
if(!data.isNull(JSONUtils.BODY_HTML_KEY)) {
|
||||||
|
commentContent = data.getString(JSONUtils.BODY_HTML_KEY);
|
||||||
|
}
|
||||||
String permalink = data.getString(JSONUtils.PERMALINK_KEY);
|
String permalink = data.getString(JSONUtils.PERMALINK_KEY);
|
||||||
int score = data.getInt(JSONUtils.SCORE_KEY);
|
int score = data.getInt(JSONUtils.SCORE_KEY);
|
||||||
long submitTime = data.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
|
long submitTime = data.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
|
||||||
|
@ -135,7 +135,6 @@ class ParsePost {
|
|||||||
} else {
|
} else {
|
||||||
postData.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
|
postData.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
|
||||||
}
|
}
|
||||||
postData.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
|
|
||||||
bestPostData.add(postData);
|
bestPostData.add(postData);
|
||||||
} else {
|
} else {
|
||||||
//No preview link post
|
//No preview link post
|
||||||
|
Loading…
Reference in New Issue
Block a user