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

Show name of selected channel at the top

This commit is contained in:
Sebastian Kaspari 2010-03-09 02:11:34 +01:00
parent 691f3b3982
commit 8dda8861e1
2 changed files with 29 additions and 1 deletions

View File

@ -51,6 +51,13 @@ public class MessageListAdapter extends BaseAdapter
{
this.context = context;
// Render channel name as first message in channel
// XXX: There will be no messages shown if channel is empty, why?
Message header = new Message(channel.getName());
header.setColor(Message.COLOR_RED);
messages.add(header.renderTextView(context));
for (Message message : channel.getHistory()) {
messages.add(message.renderTextView(context));
}

View File

@ -44,6 +44,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ViewSwitcher;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.TableLayout.LayoutParams;
import org.yaaic.R;
@ -64,7 +65,7 @@ import org.yaaic.receiver.ChannelReceiver;
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public class ServerActivity extends Activity implements ServiceConnection, ChannelListener, OnItemClickListener, OnKeyListener
public class ServerActivity extends Activity implements ServiceConnection, ChannelListener, OnItemClickListener, OnKeyListener, OnItemSelectedListener
{
public static final String TAG = "Yaaic/ServerActivity";
@ -96,6 +97,7 @@ public class ServerActivity extends Activity implements ServiceConnection, Chann
((EditText) findViewById(R.id.input)).setOnKeyListener(this);
deck = (Gallery) findViewById(R.id.deck);
deck.setOnItemSelectedListener(this);
deckAdapter = new DeckAdapter();
deck.setAdapter(deckAdapter);
deck.setOnItemClickListener(this);
@ -333,4 +335,23 @@ public class ServerActivity extends Activity implements ServiceConnection, Chann
}
return false;
}
/**
* On channel selected/focused
*/
public void onItemSelected(AdapterView<?> deck, View view, int position, long id)
{
Channel channel = (Channel) deck.getItemAtPosition(position);
if (channel != null) {
((TextView) findViewById(R.id.title)).setText(server.getTitle() + " - " + channel.getName());
}
}
/**
* On no channel selected/focused
*/
public void onNothingSelected(AdapterView<?> arg0)
{
((TextView) findViewById(R.id.title)).setText(server.getTitle());
}
}