Browse Source

Fixed duplicate view IDs used that caused a crash when resuming (explicitly via the up button in the action bar). Fixes #154.

pull/173/head
Eric Kok 10 years ago
parent
commit
0b6ea2c9ba
  1. 2
      core/res/layout-w600dp/activity_search.xml
  2. 2
      core/res/layout-w600dp/activity_torrents.xml
  3. 4
      core/res/layout-w900dp/activity_rssfeeds.xml
  4. 4
      core/res/layout-w900dp/activity_torrents.xml
  5. 2
      core/res/layout/activity_details.xml
  6. 2
      core/res/layout/activity_rssfeeds.xml
  7. 2
      core/res/layout/activity_rssitems.xml
  8. 2
      core/res/layout/activity_search.xml
  9. 2
      core/res/layout/activity_torrents.xml
  10. 2
      core/src/org/transdroid/core/gui/DetailsActivity.java
  11. 28
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  12. 6
      core/src/org/transdroid/core/gui/rss/RssfeedsActivity.java
  13. 2
      core/src/org/transdroid/core/gui/rss/RssitemsActivity.java
  14. 13
      core/src/org/transdroid/core/gui/search/SearchActivity.java

2
core/res/layout-w600dp/activity_search.xml

@ -32,7 +32,7 @@
android:listSelector="?attr/selectable_background_transdroid" /> android:listSelector="?attr/selectable_background_transdroid" />
<fragment <fragment
android:id="@+id/searchresults_list" android:id="@+id/searchresults_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"

2
core/res/layout-w600dp/activity_torrents.xml

@ -17,7 +17,7 @@
android:listSelector="?attr/selectable_background_transdroid" /> android:listSelector="?attr/selectable_background_transdroid" />
<fragment <fragment
android:id="@+id/torrent_list" android:id="@+id/torrents_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="3" android:layout_weight="3"

4
core/res/layout-w900dp/activity_rssfeeds.xml

@ -24,7 +24,7 @@
tools:context=".RssfeedsActivity" > tools:context=".RssfeedsActivity" >
<fragment <fragment
android:id="@+id/rssfeeds_list" android:id="@+id/rssfeeds_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"
@ -32,7 +32,7 @@
tools:layout="@layout/fragment_rssfeeds" /> tools:layout="@layout/fragment_rssfeeds" />
<fragment <fragment
android:id="@+id/rssitems_list" android:id="@+id/rssitems_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="3" android:layout_weight="3"

4
core/res/layout-w900dp/activity_torrents.xml

@ -17,7 +17,7 @@
android:listSelector="?attr/selectable_background_transdroid" /> android:listSelector="?attr/selectable_background_transdroid" />
<fragment <fragment
android:id="@+id/torrent_list" android:id="@+id/torrents_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"
@ -25,7 +25,7 @@
tools:layout="@layout/fragment_torrents" /> tools:layout="@layout/fragment_torrents" />
<fragment <fragment
android:id="@+id/torrent_details" android:id="@+id/torrentdetails_fragment"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="2" android:layout_weight="2"

2
core/res/layout/activity_details.xml

@ -7,7 +7,7 @@
tools:context=".DetailsActivity" > tools:context=".DetailsActivity" >
<fragment <fragment
android:id="@+id/torrent_details" android:id="@+id/torrentdetails_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.DetailsFragment_" class="org.transdroid.core.gui.DetailsFragment_"

2
core/res/layout/activity_rssfeeds.xml

@ -22,7 +22,7 @@
tools:context=".RssfeedsActivity" > tools:context=".RssfeedsActivity" >
<fragment <fragment
android:id="@+id/rssfeeds_list" android:id="@+id/rssfeeds_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.rss.RssfeedsFragment_" class="org.transdroid.core.gui.rss.RssfeedsFragment_"

2
core/res/layout/activity_rssitems.xml

@ -22,7 +22,7 @@
tools:context=".RssItemsActivity" > tools:context=".RssItemsActivity" >
<fragment <fragment
android:id="@+id/rssitems_list" android:id="@+id/rssitems_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.rss.RssitemsFragment_" class="org.transdroid.core.gui.rss.RssitemsFragment_"

2
core/res/layout/activity_search.xml

@ -22,7 +22,7 @@
tools:context=".SearchActivity" > tools:context=".SearchActivity" >
<fragment <fragment
android:id="@+id/searchresults_list" android:id="@+id/searchresults_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.search.SearchResultsFragment_" class="org.transdroid.core.gui.search.SearchResultsFragment_"

2
core/res/layout/activity_torrents.xml

@ -7,7 +7,7 @@
tools:context=".TorrentsActivity" > tools:context=".TorrentsActivity" >
<fragment <fragment
android:id="@+id/torrent_list" android:id="@+id/torrents_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
class="org.transdroid.core.gui.TorrentsFragment_" class="org.transdroid.core.gui.TorrentsFragment_"

2
core/src/org/transdroid/core/gui/DetailsActivity.java

@ -104,7 +104,7 @@ public class DetailsActivity extends Activity implements TorrentTasksExecutor, R
private PullToRefreshAttacher pullToRefreshAttacher = null; private PullToRefreshAttacher pullToRefreshAttacher = null;
// Details view components // Details view components
@FragmentById(resName = "torrent_details") @FragmentById(resName = "torrentdetails_fragment")
protected DetailsFragment fragmentDetails; protected DetailsFragment fragmentDetails;
@Override @Override

28
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -173,9 +173,9 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
protected ArrayList<Label> lastNavigationLabels; protected ArrayList<Label> lastNavigationLabels;
// Contained torrent and details fragments // Contained torrent and details fragments
@FragmentById(resName = "torrent_list") @FragmentById(resName = "torrents_fragment")
protected TorrentsFragment fragmentTorrents; protected TorrentsFragment fragmentTorrents;
@FragmentById(resName = "torrent_details") @FragmentById(resName = "torrentdetails_fragment")
protected DetailsFragment fragmentDetails; protected DetailsFragment fragmentDetails;
// Auto refresh task // Auto refresh task
@ -368,14 +368,12 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
super.onDestroy(); super.onDestroy();
} }
@TargetApi(Build.VERSION_CODES.FROYO)
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
if (navigationHelper.enableSearchUi()) { if (navigationHelper.enableSearchUi()) {
// For Android 2.1+, add an expandable SearchView to the action bar // Add an expandable SearchView to the action bar
MenuItem item = menu.findItem(R.id.action_search); MenuItem item = menu.findItem(R.id.action_search);
if (android.os.Build.VERSION.SDK_INT >= 8) {
SearchView searchView = new SearchView(this); SearchView searchView = new SearchView(this);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true); searchView.setQueryRefinementEnabled(true);
@ -387,7 +385,6 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
stopAutoRefresh(); stopAutoRefresh();
} }
}); });
// NOTE ABS's OnCloseListener is not working, hence using an OnActionExpandListener
item.setOnActionExpandListener(new OnActionExpandListener() { item.setOnActionExpandListener(new OnActionExpandListener() {
@Override @Override
public boolean onMenuItemActionExpand(MenuItem item) { public boolean onMenuItemActionExpand(MenuItem item) {
@ -404,7 +401,6 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
item.setActionView(searchView); item.setActionView(searchView);
searchMenu = item; searchMenu = item;
} }
}
return true; return true;
} }
@ -510,7 +506,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Clear the currently shown list of torrents and perhaps the details // Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(true, true); fragmentTorrents.clear(true, true);
if (fragmentDetails != null && fragmentDetails.getActivity() != null) { if (fragmentDetails != null && fragmentDetails.isAdded() && fragmentDetails.getActivity() != null) {
fragmentDetails.updateIsLoading(false, null); fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear(); fragmentDetails.clear();
fragmentDetails.setCurrentServerSettings(server); fragmentDetails.setCurrentServerSettings(server);
@ -530,7 +526,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Remember that the user last selected this // Remember that the user last selected this
applicationSettings.setLastUsedNavigationFilter(currentFilter); applicationSettings.setLastUsedNavigationFilter(currentFilter);
// Clear the details view // Clear the details view
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateIsLoading(false, null); fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear(); fragmentDetails.clear();
} }
@ -545,7 +541,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
private void updateFragmentVisibility(boolean hasServerSettings) { private void updateFragmentVisibility(boolean hasServerSettings) {
if (filtersList != null) if (filtersList != null)
filtersList.setVisibility(hasServerSettings ? View.VISIBLE : View.GONE); filtersList.setVisibility(hasServerSettings ? View.VISIBLE : View.GONE);
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (hasServerSettings) if (hasServerSettings)
getFragmentManager().beginTransaction().show(fragmentDetails).commit(); getFragmentManager().beginTransaction().show(fragmentDetails).commit();
else else
@ -818,7 +814,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
* @param torrent The torrent to show detailed statistics for * @param torrent The torrent to show detailed statistics for
*/ */
public void openDetails(Torrent torrent) { public void openDetails(Torrent torrent) {
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.updateTorrent(torrent); fragmentDetails.updateTorrent(torrent);
} else { } else {
DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels) DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels)
@ -1186,7 +1182,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
fragmentTorrents.updateIsLoading(false); fragmentTorrents.updateIsLoading(false);
if (isCritical) { if (isCritical) {
fragmentTorrents.updateError(error); fragmentTorrents.updateError(error);
if (fragmentDetails != null) if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateIsLoading(false, error); fragmentDetails.updateIsLoading(false, error);
} }
} }
@ -1202,7 +1198,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
fragmentTorrents.updateTorrents(new ArrayList<Torrent>(torrents), lastNavigationLabels); fragmentTorrents.updateTorrents(new ArrayList<Torrent>(torrents), lastNavigationLabels);
// Update the details fragment if the currently shown torrent is in the newly retrieved list // Update the details fragment if the currently shown torrent is in the newly retrieved list
if (fragmentDetails != null) { if (fragmentDetails != null && fragmentDetails.isAdded()) {
fragmentDetails.perhapsUpdateTorrent(torrents); fragmentDetails.perhapsUpdateTorrent(torrents);
} }
@ -1214,7 +1210,7 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
// Labels are shown in the action bar spinner // Labels are shown in the action bar spinner
navigationSpinnerAdapter.updateLabels(lastNavigationLabels); navigationSpinnerAdapter.updateLabels(lastNavigationLabels);
} }
if (fragmentDetails != null) if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateLabels(lastNavigationLabels); fragmentDetails.updateLabels(lastNavigationLabels);
// Perhaps we were still waiting to preselect the last used filter (on a fresh application start) // Perhaps we were still waiting to preselect the last used filter (on a fresh application start)
@ -1244,14 +1240,14 @@ public class TorrentsActivity extends Activity implements OnNavigationListener,
@UiThread @UiThread
protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) { protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) {
// Update the details fragment with the new fine details for the shown torrent // Update the details fragment with the new fine details for the shown torrent
if (fragmentDetails != null) if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateTorrentDetails(torrent, torrentDetails); fragmentDetails.updateTorrentDetails(torrent, torrentDetails);
} }
@UiThread @UiThread
protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) { protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) {
// Update the details fragment with the newly retrieved list of files // Update the details fragment with the newly retrieved list of files
if (fragmentDetails != null) if (fragmentDetails != null && fragmentDetails.isAdded())
fragmentDetails.updateTorrentFiles(torrent, new ArrayList<TorrentFile>(torrentFiles)); fragmentDetails.updateTorrentFiles(torrent, new ArrayList<TorrentFile>(torrentFiles));
} }

6
core/src/org/transdroid/core/gui/rss/RssfeedsActivity.java

@ -53,9 +53,9 @@ public class RssfeedsActivity extends Activity {
protected List<RssfeedLoader> loaders; protected List<RssfeedLoader> loaders;
// Contained feeds and items fragments // Contained feeds and items fragments
@FragmentById(resName = "rssfeeds_list") @FragmentById(resName = "rssfeeds_fragment")
protected RssfeedsFragment fragmentFeeds; protected RssfeedsFragment fragmentFeeds;
@FragmentById(resName = "rssitems_list") @FragmentById(resName = "rssitems_fragment")
protected RssitemsFragment fragmentItems; protected RssitemsFragment fragmentItems;
@Override @Override
@ -145,7 +145,7 @@ public class RssfeedsActivity extends Activity {
public void openRssfeed(RssfeedLoader loader, boolean markAsViewedNow) { public void openRssfeed(RssfeedLoader loader, boolean markAsViewedNow) {
// The RSS feed content was loaded and can now be shown in the dedicated fragment or a new activity // The RSS feed content was loaded and can now be shown in the dedicated fragment or a new activity
if (fragmentItems != null) { if (fragmentItems != null && fragmentItems.isAdded()) {
// If desired, update the lastViewedDate and lastViewedItemUrl of this feed in the user setting; this won't // If desired, update the lastViewedDate and lastViewedItemUrl of this feed in the user setting; this won't
// be loaded until the RSS feeds screen in opened again. // be loaded until the RSS feeds screen in opened again.

2
core/src/org/transdroid/core/gui/rss/RssitemsActivity.java

@ -41,7 +41,7 @@ public class RssitemsActivity extends Activity {
@Extra @Extra
protected String rssfeedName; protected String rssfeedName;
@FragmentById(resName = "rssitems_list") @FragmentById(resName = "rssitems_fragment")
protected RssitemsFragment fragmentItems; protected RssitemsFragment fragmentItems;
@Override @Override

13
core/src/org/transdroid/core/gui/search/SearchActivity.java

@ -29,8 +29,10 @@ import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.search.SearchHelper; import org.transdroid.core.app.search.SearchHelper;
import org.transdroid.core.app.search.SearchSite; import org.transdroid.core.app.search.SearchSite;
import org.transdroid.core.app.settings.*; import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.gui.*; import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import android.annotation.TargetApi; import android.annotation.TargetApi;
@ -62,7 +64,7 @@ import android.widget.TextView;
@OptionsMenu(resName = "activity_search") @OptionsMenu(resName = "activity_search")
public class SearchActivity extends Activity implements OnNavigationListener { public class SearchActivity extends Activity implements OnNavigationListener {
@FragmentById(resName = "searchresults_list") @FragmentById(resName = "searchresults_fragment")
protected SearchResultsFragment fragmentResults; protected SearchResultsFragment fragmentResults;
@ViewById @ViewById
protected ListView searchsitesList; protected ListView searchsitesList;
@ -141,21 +143,18 @@ public class SearchActivity extends Activity implements OnNavigationListener {
} }
@TargetApi(Build.VERSION_CODES.FROYO)
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
if (navigationHelper.enableSearchUi()) { if (navigationHelper.enableSearchUi()) {
// For Android 2.1+, add an expandable SearchView to the action bar // Add an expandable SearchView to the action bar
MenuItem item = menu.findItem(R.id.action_search); MenuItem item = menu.findItem(R.id.action_search);
if (android.os.Build.VERSION.SDK_INT >= 8) {
final SearchView searchView = new SearchView(this); final SearchView searchView = new SearchView(this);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true); searchView.setQueryRefinementEnabled(true);
item.setActionView(searchView); item.setActionView(searchView);
searchMenu = item; searchMenu = item;
} }
}
return true; return true;
} }

Loading…
Cancel
Save