about summary refs log tree commit diff stats
path: root/org.fox.ttrss/src/main/java/org/fox
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2025-05-20 17:38:48 +0300
committerAndrew Dolgov <fox@fakecake.org>2025-05-20 17:38:48 +0300
commitb07fed4e03422639b3a797fafe6f3dbf85435d1c (patch)
treedda72f283aeeac6de2bd55fc75a53f7ace2b3f54 /org.fox.ttrss/src/main/java/org/fox
parentc0029fd68899be1c7c9ecff02e6fbb78d647f79e (diff)
downloadtt-rss-android-b07fed4e03422639b3a797fafe6f3dbf85435d1c.tar.gz
tt-rss-android-b07fed4e03422639b3a797fafe6f3dbf85435d1c.tar.xz
fix crash if attempting to open a gallery for null flavor image, remove several model updates before api operation completes
Diffstat (limited to 'org.fox.ttrss/src/main/java/org/fox')
-rwxr-xr-xorg.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java4
-rwxr-xr-xorg.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java69
2 files changed, 31 insertions, 42 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java
index 63c46edd..63de9bf8 100755
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java
@@ -90,11 +90,9 @@ public class DetailActivity extends OnlineActivity implements HeadlinesEventList
 						return true;
 					} else if (itemId == R.id.toggle_unread) {
 						Article articleClone = new Article(activeArticle);
-
 						articleClone.unread = !articleClone.unread;
-						saveArticleUnread(articleClone);
 
-						Application.getArticlesModel().update(articleClone);
+						saveArticleUnread(articleClone);
 					}
 				}
 
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
index d51ab02a..d9f57446 100755
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
@@ -192,11 +192,9 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
 
             if (a.unread) {
 				Article articleClone = new Article(a);
-
                 articleClone.unread = false;
-                tmp.add(articleClone);
 
-				Application.getArticlesModel().update(articleClone);
+				tmp.add(articleClone);
             }
         }
 
@@ -405,14 +403,6 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
 
 						m_activity.setArticlesUnread(m_readArticles, Article.UPDATE_SET_FALSE);
 
-						for (Article a : m_readArticles) {
-							Article articleClone = new Article(a);
-
-							articleClone.unread = false;
-
-							Application.getArticlesModel().update(articleClone);
-						}
-
 						m_readArticles.clear();
 
 						new Handler().postDelayed(() -> m_activity.refresh(false), 100);
@@ -1512,48 +1502,49 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
 		private void openGalleryForType(final Article article, final ArticleViewHolder holder, final View transitionView) {
 			//Log.d(TAG, "openGalleryForType: " + article + " " + holder + " " + transitionView);
 
-			if ("iframe".equalsIgnoreCase(article.flavorImage.tagName())) {
-				m_activity.openUri(Uri.parse(article.flavorStreamUri));
-			} else {
+			if (article.flavorImage != null) {
+				if ("iframe".equalsIgnoreCase(article.flavorImage.tagName())) {
+					m_activity.openUri(Uri.parse(article.flavorStreamUri));
+				} else {
 
-				Intent intent = new Intent(m_activity, GalleryActivity.class);
+					Intent intent = new Intent(m_activity, GalleryActivity.class);
 
-				intent.putExtra("firstSrc", article.flavorStreamUri != null ? article.flavorStreamUri : article.flavorImageUri);
-				intent.putExtra("title", article.title);
+					intent.putExtra("firstSrc", article.flavorStreamUri != null ? article.flavorStreamUri : article.flavorImageUri);
+					intent.putExtra("title", article.title);
 
-				// FIXME maybe: gallery view works with document as html, it's easier to add this hack rather than
-				// rework it to additionally operate on separate attachment array (?)
-				// also, maybe consider video attachments? kinda hard to do without a poster tho (for flavor view)
+					// FIXME maybe: gallery view works with document as html, it's easier to add this hack rather than
+					// rework it to additionally operate on separate attachment array (?)
+					// also, maybe consider video attachments? kinda hard to do without a poster tho (for flavor view)
 
-				String tempContent = article.content;
+					String tempContent = article.content;
 
-				if (article.attachments != null) {
-					Document doc = new Document("");
+					if (article.attachments != null) {
+						Document doc = new Document("");
 
-					for (Attachment a : article.attachments) {
-						if (a.content_type != null) {
-							if (a.content_type.contains("image/")) {
-								Element img = new Element("img").attr("src", a.content_url);
-								doc.appendChild(img);
+						for (Attachment a : article.attachments) {
+							if (a.content_type != null) {
+								if (a.content_type.contains("image/")) {
+									Element img = new Element("img").attr("src", a.content_url);
+									doc.appendChild(img);
+								}
 							}
 						}
-					}
 
-					tempContent = doc.outerHtml() + tempContent;
-				}
+						tempContent = doc.outerHtml() + tempContent;
+					}
 
-				intent.putExtra("content", tempContent);
+					intent.putExtra("content", tempContent);
 
-				/* ActivityOptionsCompat options =
-						ActivityOptionsCompat.makeSceneTransitionAnimation(m_activity,
-								transitionView != null ? transitionView : holder.flavorImageView,
-								"gallery:" + (article.flavorStreamUri != null ? article.flavorStreamUri : article.flavorImageUri));
+					/* ActivityOptionsCompat options =
+							ActivityOptionsCompat.makeSceneTransitionAnimation(m_activity,
+									transitionView != null ? transitionView : holder.flavorImageView,
+									"gallery:" + (article.flavorStreamUri != null ? article.flavorStreamUri : article.flavorImageUri));
 
-			 	ActivityCompat.startActivity(m_activity, intent, options.toBundle()); */
+					ActivityCompat.startActivity(m_activity, intent, options.toBundle()); */
 
-				startActivity(intent);
+					startActivity(intent);
+				}
 			}
-
 		}
 
 		private void adjustVideoKindView(final ArticleViewHolder holder, final Article article) {