|
|
@ -144,7 +144,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
protected ApplicationSettings applicationSettings; |
|
|
|
protected ApplicationSettings applicationSettings; |
|
|
|
@InstanceState |
|
|
|
@InstanceState |
|
|
|
boolean firstStart = true; |
|
|
|
boolean firstStart = true; |
|
|
|
boolean skipNextOnNavigationItemSelectedCall = false; |
|
|
|
int skipNextOnNavigationItemSelectedCalls = 2; |
|
|
|
private IDaemonAdapter currentConnection = null; |
|
|
|
private IDaemonAdapter currentConnection = null; |
|
|
|
@InstanceState |
|
|
|
@InstanceState |
|
|
|
protected NavigationFilter currentFilter = null; |
|
|
|
protected NavigationFilter currentFilter = null; |
|
|
@ -208,7 +208,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
// Log messages from the server daemons using our singleton logger
|
|
|
|
// Log messages from the server daemons using our singleton logger
|
|
|
|
DLog.setLogger(Log_.getInstance_(this)); |
|
|
|
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(); |
|
|
|
ServerSetting lastUsed = applicationSettings.getLastUsedServer(); |
|
|
|
if (lastUsed == null) { |
|
|
|
if (lastUsed == null) { |
|
|
|
// No server settings yet;
|
|
|
|
// No server settings yet;
|
|
|
@ -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
|
|
|
|
// 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); |
|
|
|
getSupportActionBar().setSelectedNavigationItem(lastUsed.getOrder() + 1); |
|
|
|
skipNextOnNavigationItemSelectedCall = true; |
|
|
|
filterSelected(lastUsed, true); |
|
|
|
|
|
|
|
|
|
|
|
// Handle any start up intents
|
|
|
|
// Handle any start up intents
|
|
|
|
if (startTorrent != null) { |
|
|
|
if (startTorrent != null) { |
|
|
|
openDetails(startTorrent); |
|
|
|
openDetails(startTorrent); |
|
|
|
startTorrent = null; |
|
|
|
startTorrent = null; |
|
|
|
} else if (firstStart && getIntent() != null) { |
|
|
|
} else if (firstStart && getIntent() != null) { |
|
|
|
currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName()); |
|
|
|
|
|
|
|
handleStartIntent(); |
|
|
|
handleStartIntent(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -258,10 +258,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
if (lastUsed == null) { |
|
|
|
if (lastUsed == null) { |
|
|
|
// Still no settings
|
|
|
|
// Still no settings
|
|
|
|
updateFragmentVisibility(false); |
|
|
|
updateFragmentVisibility(false); |
|
|
|
|
|
|
|
// There is a server know (now): forcefully select it to establish a connection
|
|
|
|
|
|
|
|
filterSelected(lastUsed, true); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// There is a server know (now): forcefully select it to establish a connection
|
|
|
|
|
|
|
|
filterSelected(lastUsed, true); |
|
|
|
// If we had no connection before, establish it now
|
|
|
|
|
|
|
|
if (currentConnection == null) |
|
|
|
|
|
|
|
filterSelected(lastUsed, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -335,8 +339,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onNavigationItemSelected(int itemPosition, long itemId) { |
|
|
|
public boolean onNavigationItemSelected(int itemPosition, long itemId) { |
|
|
|
if (skipNextOnNavigationItemSelectedCall) { |
|
|
|
if (skipNextOnNavigationItemSelectedCalls > 0) { |
|
|
|
skipNextOnNavigationItemSelectedCall = false; |
|
|
|
skipNextOnNavigationItemSelectedCalls--; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
Object item = navigationSpinnerAdapter.getItem(itemPosition); |
|
|
|
Object item = navigationSpinnerAdapter.getItem(itemPosition); |
|
|
@ -354,7 +358,9 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
|
|
|
filtersList.setItemChecked(position, true); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -425,6 +431,12 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi |
|
|
|
} |
|
|
|
} |
|
|
|
supportInvalidateOptionsMenu(); |
|
|
|
supportInvalidateOptionsMenu(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void onNewIntent(Intent intent) { |
|
|
|
|
|
|
|
setIntent(intent); |
|
|
|
|
|
|
|
handleStartIntent(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* If required, add torrents, switch to a specific server, etc. |
|
|
|
* If required, add torrents, switch to a specific server, etc. |
|
|
|