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

The following examples show how to use android.widget.ListView#getCheckedItemPosition() . 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 check out the related API usage on the sidebar.
Example 1
Source File: BrowseCategoriesActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
@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
Source File: BotScriptsActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
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 3
Source File: WebMediumUsersActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
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 4
Source File: WebMediumUsersActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
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
Source File: BrowseActivity.java    From BotLibre with 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 6
Source File: BrowseCategoriesActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
@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 7
Source File: WebMediumUsersActivity.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
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 8
Source File: BrowseActivity.java    From BotLibre with 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 9
Source File: TrainingActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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 10
Source File: AvatarEditorActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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 11
Source File: BrowseForumActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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 12
Source File: TrainingActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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 13
Source File: BotScriptsActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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 14
Source File: BrowseActivity.java    From BotLibre with 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 15
Source File: AvatarEditorActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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 16
Source File: BrowseForumActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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 17
Source File: ForumPostActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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 18
Source File: BrowseDomainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@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 19
Source File: BrowseChannelActivity.java    From BotLibre with Eclipse Public License 1.0 5 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 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 20
Source File: ForumPostActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
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();
}