mirror of
https://github.com/moparisthebest/Yaaic
synced 2025-01-09 12:48:00 -05:00
Created ConversationClickListener
This commit is contained in:
parent
8f0ae05493
commit
ec131a93a2
72
src/org/yaaic/listener/ConversationClickListener.java
Normal file
72
src/org/yaaic/listener/ConversationClickListener.java
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
Yaaic - Yet Another Android IRC Client
|
||||
|
||||
Copyright 2009-2010 Sebastian Kaspari
|
||||
|
||||
This file is part of Yaaic.
|
||||
|
||||
Yaaic is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Yaaic is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.yaaic.listener;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ViewSwitcher;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.TableLayout.LayoutParams;
|
||||
|
||||
import org.yaaic.adapter.DeckAdapter;
|
||||
import org.yaaic.model.Conversation;
|
||||
import org.yaaic.view.MessageListView;
|
||||
|
||||
/**
|
||||
* Listener for clicks on conversations
|
||||
*
|
||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||
*/
|
||||
public class ConversationClickListener implements OnItemClickListener
|
||||
{
|
||||
private DeckAdapter adapter;
|
||||
private ViewSwitcher switcher;
|
||||
|
||||
/**
|
||||
* Create a new ConversationClickListener
|
||||
*
|
||||
* @param adapter
|
||||
* @param switcher
|
||||
*/
|
||||
public ConversationClickListener(DeckAdapter adapter, ViewSwitcher switcher)
|
||||
{
|
||||
this.adapter = adapter;
|
||||
this.switcher = switcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* On conversation item clicked
|
||||
*/
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id)
|
||||
{
|
||||
Conversation conversation = adapter.getItem(position);
|
||||
|
||||
MessageListView canvas = adapter.renderConversation(conversation, switcher);
|
||||
canvas.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
||||
canvas.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||
canvas.setDelegateTouchEvents(false); // Do not delegate
|
||||
|
||||
adapter.setSwitched(conversation.getName(), canvas);
|
||||
switcher.addView(canvas);
|
||||
switcher.showNext();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user