mirror of
https://github.com/moparisthebest/Yaaic
synced 2025-02-16 23:10:11 -05:00
AddChannelActivity: Get channel list from AddServerActivity and return edited list
This commit is contained in:
parent
b54e92c1e2
commit
68079baff8
@ -20,9 +20,13 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.yaaic.activity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.yaaic.R;
|
||||
import org.yaaic.model.Extra;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@ -30,7 +34,6 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Adding channels to a server
|
||||
@ -39,9 +42,9 @@ import android.widget.Toast;
|
||||
*/
|
||||
public class AddChannelActivity extends Activity implements OnClickListener
|
||||
{
|
||||
private ListView channelList;
|
||||
private EditText channelInput;
|
||||
private ArrayAdapter<String> adapter;
|
||||
private ArrayList<String> channels;
|
||||
|
||||
/**
|
||||
* On create
|
||||
@ -53,15 +56,20 @@ public class AddChannelActivity extends Activity implements OnClickListener
|
||||
|
||||
setContentView(R.layout.channeladd);
|
||||
|
||||
channelList = (ListView) findViewById(R.id.channels);
|
||||
channelInput = (EditText) findViewById(R.id.channel);
|
||||
|
||||
adapter = new ArrayAdapter<String>(this, R.layout.channelitem);
|
||||
channelList.setAdapter(adapter);
|
||||
((ListView) findViewById(R.id.channels)).setAdapter(adapter);
|
||||
|
||||
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
||||
((Button) findViewById(R.id.save)).setOnClickListener(this);
|
||||
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
||||
|
||||
channels = getIntent().getExtras().getStringArrayList(Extra.CHANNELS);
|
||||
|
||||
for (String channel : channels) {
|
||||
adapter.add(channel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +79,9 @@ public class AddChannelActivity extends Activity implements OnClickListener
|
||||
{
|
||||
switch (v.getId()) {
|
||||
case R.id.add:
|
||||
adapter.add(channelInput.getText().toString());
|
||||
String channel = channelInput.getText().toString();
|
||||
channels.add(channel);
|
||||
adapter.add(channel);
|
||||
break;
|
||||
case R.id.cancel:
|
||||
setResult(RESULT_CANCELED);
|
||||
@ -79,8 +89,9 @@ public class AddChannelActivity extends Activity implements OnClickListener
|
||||
break;
|
||||
case R.id.save:
|
||||
// Get list and return as result
|
||||
|
||||
setResult(RESULT_OK);
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Extra.CHANNELS, channels);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
package org.yaaic.activity;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import android.app.Activity;
|
||||
@ -53,6 +54,7 @@ import org.yaaic.model.Status;
|
||||
public class AddServerActivity extends Activity implements OnClickListener
|
||||
{
|
||||
private Server server;
|
||||
private ArrayList<String> channels;
|
||||
|
||||
/**
|
||||
* On create
|
||||
@ -63,6 +65,7 @@ public class AddServerActivity extends Activity implements OnClickListener
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.serveradd);
|
||||
channels = new ArrayList<String>();
|
||||
|
||||
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
||||
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
||||
@ -116,6 +119,17 @@ public class AddServerActivity extends Activity implements OnClickListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On activity result
|
||||
*/
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||
{
|
||||
if (resultCode == RESULT_OK) {
|
||||
channels = data.getExtras().getStringArrayList(Extra.CHANNELS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On click add server or cancel activity
|
||||
@ -124,7 +138,9 @@ public class AddServerActivity extends Activity implements OnClickListener
|
||||
{
|
||||
switch (v.getId()) {
|
||||
case R.id.channels:
|
||||
startActivityForResult(new Intent(this, AddChannelActivity.class), 0);
|
||||
Intent intent = new Intent(this, AddChannelActivity.class);
|
||||
intent.putExtra(Extra.CHANNELS, channels);
|
||||
startActivityForResult(intent, 0);
|
||||
break;
|
||||
case R.id.add:
|
||||
try {
|
||||
|
@ -30,4 +30,6 @@ public class Extra
|
||||
public static final String SERVER = "server";
|
||||
public static final String CONVERSATION = "conversation";
|
||||
public static final String USERS = "users";
|
||||
|
||||
public static final String CHANNELS = "channels";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user