@ -144,7 +144,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@@ -144,7 +144,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
protected ApplicationSettings applicationSettings ;
@InstanceState
boolean firstStart = true ;
boolean skipNextOnNavigationItemSelectedCall = false ;
int skipNextOnNavigationItemSelectedCalls = 2 ;
private IDaemonAdapter currentConnection = null ;
@InstanceState
protected NavigationFilter currentFilter = null ;
@ -208,7 +208,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@@ -208,7 +208,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Log messages from the server daemons using our singleton logger
DLog . setLogger ( Log_ . getInstance_ ( this ) ) ;
// Connect to the last used server or a server that was supplied in the starting intent
// Connect to the last used server or a server that was explicitly supplied in the starting intent
ServerSetting lastUsed = applicationSettings . getLastUsedServer ( ) ;
if ( lastUsed = = null ) {
// No server settings yet;
@ -230,15 +230,15 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@@ -230,15 +230,15 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
// Set this as selection in the action bar spinner; we can use the server setting key since we have stable ids
// Note: skipNextOnNavigationItemSelectedCalls is used to prevent this event from triggering filterSelected
getSupportActionBar ( ) . setSelectedNavigationItem ( lastUsed . getOrder ( ) + 1 ) ;
skipNextOnNavigationItemSelectedCall = true ;
filterSelected ( lastUsed , true ) ;
// Handle any start up intents
if ( startTorrent ! = null ) {
openDetails ( startTorrent ) ;
startTorrent = null ;
} else if ( firstStart & & getIntent ( ) ! = null ) {
currentConnection = lastUsed . createServerAdapter ( connectivityHelper . getConnectedNetworkName ( ) ) ;
handleStartIntent ( ) ;
}
@ -258,9 +258,13 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@@ -258,9 +258,13 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
if ( lastUsed = = null ) {
// Still no settings
updateFragmentVisibility ( false ) ;
// There is a server know (now): forcefully select it to establish a connection
filterSelected ( lastUsed , true ) ;
return ;
}
// There is a server know (now): forcefully select it to establish a connection
// If we had no connection before, establish it now
if ( currentConnection = = null )
filterSelected ( lastUsed , true ) ;
}
@ -335,8 +339,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@@ -335,8 +339,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
* /
@Override
public boolean onNavigationItemSelected ( int itemPosition , long itemId ) {
if ( skipNextOnNavigationItemSelectedCall ) {
skipNextOnNavigationItemSelectedCall = false ;
if ( skipNextOnNavigationItemSelectedCalls > 0 ) {
skipNextOnNavigationItemSelectedCalls - - ;
return false ;
}
Object item = navigationSpinnerAdapter . getItem ( itemPosition ) ;
@ -354,7 +358,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@@ -354,7 +358,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Override
public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) {
filtersList . setItemChecked ( position , true ) ;
filterSelected ( ( SimpleListItem ) filtersList . getAdapter ( ) . getItem ( position ) , false ) ;
Object item = filtersList . getAdapter ( ) . getItem ( position ) ;
if ( item instanceof SimpleListItem )
filterSelected ( ( SimpleListItem ) item , false ) ;
}
} ;
@ -426,6 +432,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@@ -426,6 +432,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
supportInvalidateOptionsMenu ( ) ;
}
@Override
protected void onNewIntent ( Intent intent ) {
setIntent ( intent ) ;
handleStartIntent ( ) ;
}
/ * *
* If required , add torrents , switch to a specific server , etc .
* /