下面列出了android.widget.ListView#getCheckedItemPosition ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void selectInstance(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select a category", this);
return;
}
this.instance = instances.get(index);
BrowseConfig config = new BrowseConfig();
config.typeFilter = "Public";
config.category = this.instance.name;
config.type = getType();
config.contentRating = MainActivity.contentRating;
HttpAction action = new HttpGetInstancesAction(this, config, MainActivity.browsing);
action.execute();
}
public void removeUser(View view) {
UserAdminConfig config = new UserAdminConfig();
config.instance = MainActivity.instance.id;
config.type = getType();
config.operation = "RemoveUser";
ListView list = (ListView) findViewById(R.id.usersList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.error("Select user to remove", null, this);
return;
}
config.operationUser = (String)this.users.get(index);
HttpUserAdminAction action = new HttpUserAdminAction(this, config);
action.execute();
}
public void selectInstance(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select a bot", this);
return;
}
this.instance = instances.get(index);
if (MainActivity.browsing) {
MainActivity.instance = this.instance;
finish();
return;
}
InstanceConfig config = new InstanceConfig();
config.id = this.instance.id;
config.name = this.instance.name;
HttpAction action = new HttpFetchAction(this, config);
action.execute();
}
public void removeAdmin(View view) {
UserAdminConfig config = new UserAdminConfig();
config.instance = MainActivity.instance.id;
config.type = getType();
config.operation = "RemoveAdmin";
ListView list = (ListView) findViewById(R.id.adminList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.error("Select admin to remove", null, this);
return;
}
config.operationUser = (String)this.admins.get(index);
HttpUserAdminAction action = new HttpUserAdminAction(this, config);
action.execute();
}
@Override
public void selectInstance(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select a category", this);
return;
}
this.instance = instances.get(index);
BrowseConfig config = new BrowseConfig();
config.typeFilter = "Public";
config.category = this.instance.name;
config.type = getType();
config.contentRating = MainActivity.contentRating;
HttpAction action = new HttpGetInstancesAction(this, config, MainActivity.browsing);
action.execute();
}
public void removeAdmin(View view) {
UserAdminConfig config = new UserAdminConfig();
config.instance = MainActivity.instance.id;
config.type = getType();
config.operation = "RemoveAdmin";
ListView list = (ListView) findViewById(R.id.adminList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.error("Select admin to remove", null, this);
return;
}
config.operationUser = (String)this.admins.get(index);
HttpUserAdminAction action = new HttpUserAdminAction(this, config);
action.execute();
}
public void deleteBotScript() {
ListView list = (ListView)findViewById(R.id.botScriptList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select a script to delete", this);
return;
}
ScriptConfig script = this.scripts.get(index);
ScriptSourceConfig botScript = new ScriptSourceConfig();
InstanceConfig bot = this.instance;
botScript.id = script.id;
botScript.instance = bot.id;
scripts.remove(index);
HttpDeleteBotScriptAction action = new HttpDeleteBotScriptAction(this, botScript);
action.execute();
}
public ResponseConfig getSelectedResponse() {
Spinner spin = (Spinner) findViewById(R.id.responseTypeSpin);
String type = (String)spin.getSelectedItem();
ListView list = (ListView) findViewById(R.id.responseList);
int index = list.getCheckedItemPosition();
if (index < 0) {
return null;
}
if (type.equals("conversations")) {
Object selected = this.conversationInput.get(index);
if (selected instanceof ConversationConfig) {
return null;
} else {
ResponseConfig response = new ResponseConfig();
response.response = ((InputConfig)selected).value;
if (index > 1) {
Object previous = this.conversationInput.get(index - 1);
if (previous instanceof InputConfig) {
response.question = ((InputConfig)previous).value;
}
}
return response;
}
} else {
return this.responses.get(index);
}
}
public void viewReply() {
ListView list = (ListView) findViewById(R.id.repliesList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select reply", this);
return;
}
ForumPostConfig reply = this.instance.replies.get(index);
ForumPostConfig config = new ForumPostConfig();
config.id = reply.id;
HttpAction action = new HttpFetchForumPostAction(this, config);
action.execute();
}
public void selectInstance(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select a channel", this);
return;
}
this.instance = instances.get(index);
ChannelConfig config = new ChannelConfig();
config.id = this.instance.id;
config.name = this.instance.name;
HttpAction action = new HttpFetchAction(this, config);
action.execute();
}
@Override
public void selectInstance(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
this.instance = instances.get(index);
DomainConfig config = new DomainConfig();
config.id = this.instance.id;
HttpAction action = new HttpFetchAction(this, config);
action.execute();
}
public void viewReply() {
ListView list = (ListView) findViewById(R.id.repliesList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select reply", this);
return;
}
ForumPostConfig reply = this.instance.replies.get(index);
ForumPostConfig config = new ForumPostConfig();
config.id = reply.id;
HttpAction action = new HttpFetchForumPostAction(this, config);
action.execute();
}
public void selectInstance(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
this.instance = this.instances.get(index);
ForumConfig config = new ForumConfig();
config.id = this.instance.id;
HttpAction action = new HttpFetchAction(this, config);
action.execute();
}
public void tagMedia() {
ListView list = (ListView) findViewById(R.id.mediaList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select the media to tag", this);
return;
}
MainActivity.avatarMedia = this.media.get(index);
Intent intent = new Intent(this, AvatarMediaActivity.class);
startActivity(intent);
}
public void chat(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select a bot", this);
return;
}
this.instance = instances.get(index);
InstanceConfig config = new InstanceConfig();
config.id = this.instance.id;
config.name = this.instance.name;
HttpAction action = new HttpFetchAction(this, config, true);
action.execute();
}
public void upScript() {
ListView list = (ListView)findViewById(R.id.botScriptList);
int index = list.getCheckedItemPosition();
if (index < 0) {
System.out.println("The other index: " + index);
MainActivity.showMessage("Select a script to move up in precedence", this);
return;
}
if (index != 0) {
ScriptConfig script = this.scripts.get(index);
ScriptSourceConfig botScript = new ScriptSourceConfig();
InstanceConfig bot = this.instance;
botScript.id = script.id;
botScript.instance = bot.id;
System.out.println("Bot id: " + bot.id + "Bot instance: " + bot.instance
+ "ScriptConfig id: " + script.id + "ScriptConfig instance: " + script.instance);
//This code should change the index of the thing?
Collections.swap(scripts, index, index-1);
HttpUpBotScriptAction action = new HttpUpBotScriptAction(this, botScript);
action.execute();
}
}
public ResponseConfig getSelectedResponse() {
Spinner spin = (Spinner) findViewById(R.id.responseTypeSpin);
String type = (String)spin.getSelectedItem();
ListView list = (ListView) findViewById(R.id.responseList);
int index = list.getCheckedItemPosition();
if (index < 0) {
return null;
}
if (type.equals("conversations")) {
Object selected = this.conversationInput.get(index);
if (selected instanceof ConversationConfig) {
return null;
} else {
ResponseConfig response = new ResponseConfig();
response.response = ((InputConfig)selected).value;
if (index > 1) {
Object previous = this.conversationInput.get(index - 1);
if (previous instanceof InputConfig) {
response.question = ((InputConfig)previous).value;
}
}
return response;
}
} else {
return this.responses.get(index);
}
}
public void selectInstance(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
this.instance = this.instances.get(index);
ForumConfig config = new ForumConfig();
config.id = this.instance.id;
HttpAction action = new HttpFetchAction(this, config);
action.execute();
}
public void deleteMedia() {
ListView list = (ListView) findViewById(R.id.mediaList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select the media to delete", this);
return;
}
AvatarMedia config = this.media.get(index);
AvatarMedia config2 = new AvatarMedia();
config2.mediaId = config.mediaId;
config2.instance = this.instance.id;
HttpAction action = new HttpDeleteAvatarMediaAction(AvatarEditorActivity.this, config2);
action.execute();
}
public void chat(View view) {
ListView list = (ListView) findViewById(R.id.instancesList);
int index = list.getCheckedItemPosition();
if (index < 0) {
MainActivity.showMessage("Select a bot", this);
return;
}
this.instance = instances.get(index);
InstanceConfig config = new InstanceConfig();
config.id = this.instance.id;
config.name = this.instance.name;
HttpAction action = new HttpFetchAction(this, config, true);
action.execute();
}