use of com.jams.music.player.PlaylistEditorActivity.PlaylistEditorArtistsMultiselectAdapter.AsyncGetArtistSongIds in project JamsMusicPlayer by psaravan.
the class ArtistsPickerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContext = getActivity().getApplicationContext();
mApp = (Common) getActivity().getApplicationContext();
View rootView = inflater.inflate(R.layout.fragment_artists_music_library_editor, null);
cursor = mApp.getDBAccessHelper().getAllUniqueArtists("");
listView = (ListView) rootView.findViewById(R.id.musicLibraryEditorArtistsListView);
listView.setFastScrollEnabled(true);
listView.setAdapter(new PlaylistEditorArtistsMultiselectAdapter(getActivity(), cursor));
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int which, long dbID) {
CheckBox checkbox = (CheckBox) view.findViewById(R.id.artistCheckboxMusicLibraryEditor);
checkbox.performClick();
/* Since we've performed a software-click (checkbox.performClick()), all we have
* to do now is determine the *new* state of the checkbox. If the checkbox is checked,
* that means that the user tapped on it when it was unchecked, and we should add
* the artist's songs to the HashSet. If the checkbox is unchecked, that means the user
* tapped on it when it was checked, so we should remove the artist's songs from the
* HashSet.
*/
if (checkbox.isChecked()) {
view.setBackgroundColor(0xCC0099CC);
AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(mContext, (String) view.getTag(R.string.artist));
task.execute(new String[] { "ADD" });
} else {
view.setBackgroundColor(0x00000000);
AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(mContext, (String) view.getTag(R.string.artist));
task.execute(new String[] { "REMOVE" });
}
}
});
instructions = (TextView) rootView.findViewById(R.id.artists_music_library_editor_instructions);
instructions.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
instructions.setPaintFlags(instructions.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
return rootView;
}
Aggregations