1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-22 08:52:18 -05:00

Remove channels on disconnect

This commit is contained in:
Sebastian Kaspari 2010-03-05 19:43:02 +01:00
parent ef8ddfa227
commit 9367d44220
4 changed files with 18 additions and 12 deletions

View File

@ -92,7 +92,6 @@ public class DeckAdapter extends BaseAdapter
public void addItem(Channel channel)
{
channels.add(channel);
//views.add(view);
notifyDataSetChanged();
}
@ -120,11 +119,6 @@ public class DeckAdapter extends BaseAdapter
public void removeItem(Channel channel)
{
channels.remove(channel);
/*
View view = map.get(channel);
views.remove(view);
map.remove(channel);
*/
notifyDataSetChanged();
}

View File

@ -190,7 +190,7 @@ public class Server
}
/**
* Renive a (joined) channel
* Remove a (joined) channel
*
* @param name
*/
@ -199,6 +199,14 @@ public class Server
channels.remove(name);
}
/**
* Remove all channels
*/
public void clearChannels()
{
channels.clear();
}
/**
* Get icon for current server status
*

View File

@ -153,6 +153,7 @@ public class ServerActivity extends Activity implements ServiceConnection, Chann
switch (item.getItemId()) {
case R.id.disconnect:
binder.getService().getConnection(serverId).quitServer();
server.clearChannels();
setResult(RESULT_OK);
finish();
break;

View File

@ -63,7 +63,8 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
private ServerListAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.servers);
@ -82,9 +83,8 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
Intent intent = new Intent(this, IRCService.class);
startService(intent);
bindService(intent, this, 0);
receiver = new ServerReceiver(this);
registerReceiver(receiver, new IntentFilter(Broadcast.SERVER_UPDATE));
}
@ -158,6 +158,7 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
adapter.notifyDataSetChanged();
break;
case 1: // Disconnect
server.clearChannels();
binder.getService().getConnection(server.getId()).quitServer();
break;
case 2: // Delete
@ -186,7 +187,8 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
public boolean onMenuItemSelected(int featureId, MenuItem item)
{
switch (item.getItemId()) {
case R.id.add:
startActivityForResult(new Intent(this, AddServerActivity.class), 0);
@ -197,7 +199,8 @@ public class ServersActivity extends ListActivity implements ServiceConnection,
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK) {
// Refresh list from database
adapter.loadServers();