Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: David Luhmer <david-dev@live.de>
  • Loading branch information
David-Development committed Dec 10, 2023
1 parent cba48b0 commit 1608fbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,13 @@ private void updateListView() {
@Override
public void onClick(RssItemViewHolder vh, int position) {
Feed feed = vh.getRssItem().getFeed();
Long openIn = feed.getOpenIn();

// check @NewsReadListDialogFragment
// open feed in means:
// 1: openInDetailedView
// 2: openInBrowserCct
// 3: openInBrowserExternal
Long openIn = feed.getOpenIn();

Uri currentUrl = Uri.parse(vh.getRssItem().getLink());

Expand All @@ -1199,14 +1205,9 @@ public void onClick(RssItemViewHolder vh, int position) {
//Choose Browser based on user settings
//modified copy from NewsDetailFragment.java:loadUrl(String url)
int selectedBrowser = Integer.parseInt(mPrefs.getString(SettingsActivity.SP_DISPLAY_BROWSER, "0"));
switch(selectedBrowser) {
case 0:
case 2:
openRssItemInCustomTab(currentUrl);
break;
case 1:
openRssItemInExternalBrowser(currentUrl);
break;
switch (selectedBrowser) {
case 0, 2 -> openRssItemInCustomTab(currentUrl);
case 1 -> openRssItemInExternalBrowser(currentUrl);
}

((NewsListRecyclerAdapter) getNewsReaderDetailFragment().getRecyclerView().getAdapter()).changeReadStateOfItem(vh, true);
Expand All @@ -1215,17 +1216,11 @@ public void onClick(RssItemViewHolder vh, int position) {
}
} else {
switch (openIn.intValue()) {
case 1:
openRssItemInDetailedView(position);
break;
case 2:
openRssItemInCustomTab(currentUrl);
break;
case 3:
openRssItemInExternalBrowser(currentUrl);
break;
default:
throw new RuntimeException("Unreachable: openIn has illegal value " + openIn);
case 1 -> openRssItemInDetailedView(position);
case 2 -> openRssItemInCustomTab(currentUrl);
case 3 -> openRssItemInExternalBrowser(currentUrl);
default ->
throw new RuntimeException("Unreachable: openIn has illegal value " + openIn);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions News-Android-App/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@

<string-array name="pref_display_browser" translatable="false">
<item>@string/pref_display_browser_cct</item>
<item>@string/pref_display_browser_built_in</item>
<item>@string/pref_display_browser_external</item>
<item>@string/pref_display_browser_built_in</item>
</string-array>
<string-array name="pref_display_browser_values" translatable="false">
<item>0</item>
<item>2</item>
<item>1</item>
<item>2</item>
</string-array>

<string name="pref_display_feed_list_layout_headline_thumbnails">Thumbnails (only Headlines)</string>
Expand Down

0 comments on commit 1608fbf

Please sign in to comment.