mirror of
https://github.com/moparisthebest/Yaaic
synced 2025-01-14 07:08:01 -05:00
Get channel view from channel list and not from a (broken) cache
This commit is contained in:
parent
6b8b1d25b9
commit
691f3b3982
@ -20,7 +20,6 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package org.yaaic.adapter;
|
package org.yaaic.adapter;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.yaaic.model.Channel;
|
import org.yaaic.model.Channel;
|
||||||
@ -41,7 +40,6 @@ public class DeckAdapter extends BaseAdapter
|
|||||||
{
|
{
|
||||||
public static final String TAG = "Yaaic/DeckAdapter";
|
public static final String TAG = "Yaaic/DeckAdapter";
|
||||||
|
|
||||||
private HashMap<String, MessageListView> map = new HashMap<String, MessageListView>();
|
|
||||||
private LinkedList<Channel> channels = new LinkedList<Channel>();
|
private LinkedList<Channel> channels = new LinkedList<Channel>();
|
||||||
private MessageListView currentView;
|
private MessageListView currentView;
|
||||||
private String currentChannel;
|
private String currentChannel;
|
||||||
@ -92,13 +90,15 @@ public class DeckAdapter extends BaseAdapter
|
|||||||
* @param channel
|
* @param channel
|
||||||
* @return The item
|
* @return The item
|
||||||
*/
|
*/
|
||||||
public MessageListView getItemByName(String channel)
|
public int getPositionByName(String name)
|
||||||
{
|
{
|
||||||
if (map.containsKey(channel)) {
|
for (int i = 0; i < channels.size(); i++) {
|
||||||
return map.get(channel);
|
if (channels.get(i).getName().equals(name)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,15 +160,7 @@ public class DeckAdapter extends BaseAdapter
|
|||||||
public View getView(int position, View convertView, ViewGroup parent)
|
public View getView(int position, View convertView, ViewGroup parent)
|
||||||
{
|
{
|
||||||
Channel channel = getItem(position);
|
Channel channel = getItem(position);
|
||||||
convertView = map.get(channel.getName());
|
return renderChannel(channel, parent);
|
||||||
|
|
||||||
if (convertView == null) {
|
|
||||||
MessageListView view = renderChannel(channel, parent);
|
|
||||||
map.put(channel.getName(), view);
|
|
||||||
return view;
|
|
||||||
} else {
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,8 +182,8 @@ public class DeckAdapter extends BaseAdapter
|
|||||||
));
|
));
|
||||||
list.setBackgroundColor(0xff222222);
|
list.setBackgroundColor(0xff222222);
|
||||||
list.setPadding(5, 5, 5, 5);
|
list.setPadding(5, 5, 5, 5);
|
||||||
list.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
|
||||||
list.setScrollContainer(false);
|
list.setScrollContainer(false);
|
||||||
|
list.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
||||||
list.setSelection(list.getAdapter().getCount() - 1); // scroll to bottom
|
list.setSelection(list.getAdapter().getCount() - 1); // scroll to bottom
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -221,11 +221,17 @@ public class ServerActivity extends Activity implements ServiceConnection, Chann
|
|||||||
|
|
||||||
while(channel.hasBufferedMessages()) {
|
while(channel.hasBufferedMessages()) {
|
||||||
Message message = channel.pollBufferedMessage();
|
Message message = channel.pollBufferedMessage();
|
||||||
MessageListView view = (MessageListView) deckAdapter.getItemByName(target);
|
|
||||||
|
|
||||||
|
int position = deckAdapter.getPositionByName(target);
|
||||||
|
|
||||||
|
if (position != -1) {
|
||||||
|
MessageListView view = (MessageListView) deck.getChildAt(position);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
MessageListAdapter adapter = view.getAdapter();
|
MessageListAdapter adapter = view.getAdapter();
|
||||||
adapter.addMessage(message);
|
adapter.addMessage(message);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "MessageListView Adapter is null");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deckAdapter.isSwitched()) {
|
if (deckAdapter.isSwitched()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user