diff options
author | David Luhmer <david-dev@live.de> | 2022-03-10 20:07:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-10 20:07:24 +0300 |
commit | 7a8bae17e50ec5d42be73a936ee23ae7635a3575 (patch) | |
tree | 0897b9fb37c50a44e3a6a67856bb7e1e21a1e83c /News-Android-App/src/main/java | |
parent | 1266b70dd522b27baa27ab4b898c36bdcbf40d6a (diff) | |
parent | 16de87375e41241ac19045050c7278b4f7fca832 (diff) |
Merge pull request #1074 from proninyaroslav/fix-name-refresh
Fix details fragment title refreshing
Diffstat (limited to 'News-Android-App/src/main/java')
2 files changed, 48 insertions, 7 deletions
diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java index ec7abf0a..12d342ad 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderDetailFragment.java @@ -59,7 +59,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.google.android.material.floatingactionbutton.FloatingActionButton; import java.util.List; -import java.util.Objects; import javax.inject.Inject; @@ -111,7 +110,7 @@ public class NewsReaderDetailFragment extends Fragment { private int previousFirstVisibleItem = -1; private Long idFolder; - private String titel; + private String title; private int onResumeCount = 0; private RecyclerView.OnItemTouchListener itemTouchListener; @@ -179,8 +178,13 @@ public class NewsReaderDetailFragment extends Fragment { /** * @return the titel */ - public String getTitel() { - return titel; + public String getTitle() { + return title; + } + + protected void setTitle(String title) { + this.title = title; + requireNonNull(mActivity.getSupportActionBar()).setTitle(title); } protected void setData(Long idFeed, Long idFolder, String title, boolean updateListView) { @@ -188,8 +192,7 @@ public class NewsReaderDetailFragment extends Fragment { this.idFeed = idFeed; this.idFolder = idFolder; - this.titel = title; - requireNonNull(mActivity.getSupportActionBar()).setTitle(title); + setTitle(title); if (updateListView) { updateCurrentRssView(); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java index 26b45a37..f88b165b 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/NewsReaderListActivity.java @@ -101,6 +101,7 @@ import de.luhmer.owncloudnewsreader.adapter.RssItemViewHolder; import de.luhmer.owncloudnewsreader.authentication.AccountGeneral; import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm; import de.luhmer.owncloudnewsreader.database.model.Feed; +import de.luhmer.owncloudnewsreader.database.model.Folder; import de.luhmer.owncloudnewsreader.database.model.RssItem; import de.luhmer.owncloudnewsreader.databinding.ActivityNewsreaderBinding; import de.luhmer.owncloudnewsreader.events.podcast.FeedPanelSlideEvent; @@ -487,6 +488,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements newsReaderListFragment.reloadAdapter(); UpdateItemList(); updatePodcastView(); + updateDetailFragmentTitle(); if(mApi.getNewsAPI() != null) { getSlidingListFragment().startAsyncTaskGetUserInfo(); @@ -682,6 +684,42 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements return fragment; } + private void updateDetailFragmentTitle() { + NewsReaderDetailFragment fragment = getNewsReaderDetailFragment(); + Long id = fragment.getIdFeed() == null ? fragment.getIdFolder() : fragment.getIdFeed(); + if (id == null) { + return; + } + + DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(getApplicationContext()); + + String title = null; + boolean isFolder = fragment.getIdFolder() == null; + + if (isFolder) { + int idFolder = id.intValue(); + if (idFolder >= 0) { + Folder folder = dbConn.getFolderById(id); + if (folder == null) { + return; + } + title = folder.getLabel(); + } else if (idFolder == -10) { + title = getString(R.string.allUnreadFeeds); + } else if (idFolder == -11) { + title = getString(R.string.starredFeeds); + } + } else { + Feed feed = dbConn.getFeedById(id); + if (feed == null) { + return; + } + title = feed.getFeedTitle(); + } + + fragment.setTitle(title); + } + public void UpdateItemList() { try { @@ -1090,7 +1128,7 @@ public class NewsReaderListActivity extends PodcastFragmentActivity implements Intent intentNewsDetailAct = new Intent(this, NewsDetailActivity.class); intentNewsDetailAct.putExtra(NewsReaderListActivity.ITEM_ID, position); - intentNewsDetailAct.putExtra(NewsReaderListActivity.TITLE, getNewsReaderDetailFragment().getTitel()); + intentNewsDetailAct.putExtra(NewsReaderListActivity.TITLE, getNewsReaderDetailFragment().getTitle()); startActivityForResult(intentNewsDetailAct, Activity.RESULT_CANCELED); } } |