1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-08-13 16:53:50 -04:00

ChannelListener and ChannelReceiver

This commit is contained in:
Sebastian Kaspari 2010-03-02 20:18:44 +01:00
parent 13efdb5938
commit 4414f5ab7c
3 changed files with 112 additions and 2 deletions

View File

@ -0,0 +1,28 @@
/*
Yaaic - Yet Another Android IRC Client
Copyright 2009 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;
public interface ChannelListener
{
public void onChannelMessage();
public void onNewChannel();
public void onRemoveChannel();
}

View File

@ -0,0 +1,48 @@
/*
Yaaic - Yet Another Android IRC Client
Copyright 2009 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.receiver;
import org.yaaic.listener.ChannelListener;
import org.yaaic.model.Broadcast;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class ChannelReceiver extends BroadcastReceiver
{
private ChannelListener listener;
public ChannelReceiver(ChannelListener listener)
{
this.listener = listener;
}
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (action.equals(Broadcast.CHANNEL_MESSAGE)) {
listener.onChannelMessage();
}
}
}

View File

@ -20,17 +20,25 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.view;
import java.util.Iterator;
import org.yaaic.R;
import org.yaaic.Yaaic;
import org.yaaic.irc.IRCBinder;
import org.yaaic.irc.IRCService;
import org.yaaic.listener.ChannelListener;
import org.yaaic.listener.FlingListener;
import org.yaaic.model.Broadcast;
import org.yaaic.model.Channel;
import org.yaaic.model.Server;
import org.yaaic.receiver.ChannelReceiver;
import org.yaaic.receiver.ServerReceiver;
import android.app.Activity;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
@ -52,9 +60,11 @@ import android.widget.ViewFlipper;
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public class ServerActivity extends Activity implements ServiceConnection
public class ServerActivity extends Activity implements ServiceConnection, ChannelListener
{
protected static final String TextView = null;
private Server server;
private ChannelReceiver receiver;
private IRCBinder binder;
private int serverId;
@ -67,7 +77,7 @@ public class ServerActivity extends Activity implements ServiceConnection
this.serverId = getIntent().getExtras().getInt("serverId");
Server server = (Server) Yaaic.getInstance().getServerById(serverId);
server = (Server) Yaaic.getInstance().getServerById(serverId);
setContentView(R.layout.server);
@ -95,6 +105,9 @@ public class ServerActivity extends Activity implements ServiceConnection
*/
flingDetector = new GestureDetector(new FlingListener((ViewFlipper) findViewById(R.id.channels)));
receiver = new ChannelReceiver(this);
registerReceiver(receiver, new IntentFilter(Broadcast.CHANNEL_MESSAGE));
}
@Override
@ -170,4 +183,25 @@ public class ServerActivity extends Activity implements ServiceConnection
return true;
}
/**
* On channel message
*/
public void onChannelMessage()
{
}
/**
* On new channel
*/
public void onNewChannel()
{
}
/**
* On channel remove
*/
public void onRemoveChannel()
{
}
}