mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
keep story-mode content visible while loading text-mode content. (#1104)
This commit is contained in:
parent
83763aa3f4
commit
5dfc177287
3 changed files with 31 additions and 9 deletions
|
@ -37,6 +37,20 @@
|
|||
style="?divider"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reading_textloading"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
style="?readingBackground"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/orig_text_loading"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="italic"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<com.newsblur.view.NewsblurWebview
|
||||
android:id="@+id/reading_webview"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<string name="add_feed_message">Add \"%s\" to your feeds?</string>
|
||||
|
||||
<string name="loading">Loading…</string>
|
||||
<string name="orig_text_loading">Fetching text…</string>
|
||||
<string name="orig_text_loading">Fetching story text…</string>
|
||||
|
||||
<string name="follow_error">There was a problem following the user. Check your internet connection and try again.</string>
|
||||
<string name="unfollow_error">There was a problem unfollowing the user. Check your internet connection and try again.</string>
|
||||
|
|
|
@ -81,6 +81,8 @@ public class ReadingItemFragment extends NbFragment {
|
|||
private View view;
|
||||
private UserDetails user;
|
||||
private DefaultFeedView selectedFeedView;
|
||||
private boolean textViewUnavailable;
|
||||
@Bind(R.id.reading_textloading) TextView textViewLoadingMsg;
|
||||
@Bind(R.id.save_story_button) Button saveButton;
|
||||
@Bind(R.id.share_story_button) Button shareButton;
|
||||
|
||||
|
@ -482,7 +484,15 @@ public class ReadingItemFragment extends NbFragment {
|
|||
synchronized (selectedFeedView) {
|
||||
selectedFeedView = PrefsUtils.getDefaultViewModeForFeed(getActivity(), story.feedId);
|
||||
}
|
||||
reloadStoryContent();
|
||||
// these can come from async tasks
|
||||
Activity a = getActivity();
|
||||
if (a != null) {
|
||||
a.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
reloadStoryContent();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public DefaultFeedView getSelectedViewMode() {
|
||||
|
@ -490,7 +500,8 @@ public class ReadingItemFragment extends NbFragment {
|
|||
}
|
||||
|
||||
private void reloadStoryContent() {
|
||||
if (selectedFeedView == DefaultFeedView.STORY) {
|
||||
if ((selectedFeedView == DefaultFeedView.STORY) || textViewUnavailable) {
|
||||
textViewLoadingMsg.setVisibility(View.GONE);
|
||||
enableProgress(false);
|
||||
if (storyContent == null) {
|
||||
loadStoryContent();
|
||||
|
@ -503,6 +514,7 @@ public class ReadingItemFragment extends NbFragment {
|
|||
enableProgress(true);
|
||||
loadOriginalText();
|
||||
} else {
|
||||
textViewLoadingMsg.setVisibility(View.GONE);
|
||||
setupWebview(originalText);
|
||||
onContentLoadFinished();
|
||||
enableProgress(false);
|
||||
|
@ -564,18 +576,14 @@ public class ReadingItemFragment extends NbFragment {
|
|||
// the server reported that text mode is not available. kick back to story mode
|
||||
com.newsblur.util.Log.d(this, "orig text not avail for story: " + story.storyHash);
|
||||
UIUtils.safeToast(getActivity(), R.string.text_mode_unavailable, Toast.LENGTH_SHORT);
|
||||
if (getActivity() != null) {
|
||||
setViewMode(DefaultFeedView.STORY);
|
||||
Reading activity = (Reading) getActivity();
|
||||
activity.viewModeChanged();
|
||||
}
|
||||
textViewUnavailable = true;
|
||||
} else {
|
||||
ReadingItemFragment.this.originalText = result;
|
||||
}
|
||||
reloadStoryContent();
|
||||
} else {
|
||||
com.newsblur.util.Log.d(this, "orig text not yet cached for story: " + story.storyHash);
|
||||
if (getActivity() != null) setupWebview(getActivity().getResources().getString(R.string.orig_text_loading));
|
||||
textViewLoadingMsg.setVisibility(View.VISIBLE);
|
||||
OriginalTextService.addPriorityHash(story.storyHash);
|
||||
triggerSync();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue