2010-04-25 04:18:48 -04:00
|
|
|
/*
|
|
|
|
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.activity;
|
|
|
|
|
2010-04-25 04:53:29 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2010-04-25 04:18:48 -04:00
|
|
|
import org.yaaic.R;
|
2010-04-25 04:53:29 -04:00
|
|
|
import org.yaaic.model.Extra;
|
2010-04-25 04:18:48 -04:00
|
|
|
|
|
|
|
import android.app.Activity;
|
2010-04-25 04:53:29 -04:00
|
|
|
import android.content.Intent;
|
2010-04-25 04:18:48 -04:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.ListView;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adding channels to a server
|
|
|
|
*
|
|
|
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
|
|
|
*/
|
|
|
|
public class AddChannelActivity extends Activity implements OnClickListener
|
|
|
|
{
|
|
|
|
private EditText channelInput;
|
|
|
|
private ArrayAdapter<String> adapter;
|
2010-04-25 04:53:29 -04:00
|
|
|
private ArrayList<String> channels;
|
2010-04-25 04:18:48 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* On create
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState)
|
|
|
|
{
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
setContentView(R.layout.channeladd);
|
|
|
|
|
|
|
|
channelInput = (EditText) findViewById(R.id.channel);
|
|
|
|
|
|
|
|
adapter = new ArrayAdapter<String>(this, R.layout.channelitem);
|
2010-04-25 04:53:29 -04:00
|
|
|
((ListView) findViewById(R.id.channels)).setAdapter(adapter);
|
2010-04-25 04:18:48 -04:00
|
|
|
|
|
|
|
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
|
|
|
((Button) findViewById(R.id.save)).setOnClickListener(this);
|
|
|
|
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
2010-04-25 04:53:29 -04:00
|
|
|
|
|
|
|
channels = getIntent().getExtras().getStringArrayList(Extra.CHANNELS);
|
|
|
|
|
|
|
|
for (String channel : channels) {
|
|
|
|
adapter.add(channel);
|
|
|
|
}
|
2010-04-25 04:18:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On Click
|
|
|
|
*/
|
|
|
|
public void onClick(View v)
|
|
|
|
{
|
|
|
|
switch (v.getId()) {
|
|
|
|
case R.id.add:
|
2010-04-25 04:53:29 -04:00
|
|
|
String channel = channelInput.getText().toString();
|
|
|
|
channels.add(channel);
|
|
|
|
adapter.add(channel);
|
2010-04-25 04:18:48 -04:00
|
|
|
break;
|
|
|
|
case R.id.cancel:
|
|
|
|
setResult(RESULT_CANCELED);
|
|
|
|
finish();
|
|
|
|
break;
|
|
|
|
case R.id.save:
|
|
|
|
// Get list and return as result
|
2010-04-25 04:53:29 -04:00
|
|
|
Intent intent = new Intent();
|
|
|
|
intent.putExtra(Extra.CHANNELS, channels);
|
|
|
|
setResult(RESULT_OK, intent);
|
2010-04-25 04:18:48 -04:00
|
|
|
finish();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|