Java Code Examples for android.widget.ListView#getCheckedItemPosition()

The following examples show how to use android.widget.ListView#getCheckedItemPosition() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@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();
}
 
Example 2
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();
}
 
Example 3
Source Project: BotLibre   File: BrowseActivity.java    License: Eclipse Public License 1.0 6 votes vote down vote up
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();
}
 
Example 4
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();
}
 
Example 5
@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();
}
 
Example 6
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();
}
 
Example 7
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();
	
	
}
 
Example 8
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);
	}
}
 
Example 9
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();
}
 
Example 10
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();
}
 
Example 11
@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();
}
 
Example 12
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();
}
 
Example 13
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();
}
 
Example 14
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);
}
 
Example 15
Source Project: BotLibre   File: BrowseActivity.java    License: Eclipse Public License 1.0 5 votes vote down vote up
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();
}
 
Example 16
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();

	}

}
 
Example 17
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);
	}
}
 
Example 18
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();
}
 
Example 19
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();
}
 
Example 20
Source Project: BotLibre   File: BrowseActivity.java    License: Eclipse Public License 1.0 5 votes vote down vote up
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();
}