Search in sources :

Example 31 with CheckBox

use of android.widget.CheckBox in project JamsMusicPlayer by psaravan.

the class BlacklistedAlbumsPickerFragment method onCreateView.

@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_albums_music_library_editor, null);
    mApp = (Common) getActivity().getApplicationContext();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        rootView.setBackground(UIElementsHelper.getBackgroundGradientDrawable(getActivity()));
    } else {
        rootView.setBackgroundDrawable(UIElementsHelper.getBackgroundGradientDrawable(getActivity()));
    }
    cursor = mApp.getDBAccessHelper().getAllUniqueAlbumsNoBlacklist("");
    listView = (ListView) rootView.findViewById(R.id.musicLibraryEditorAlbumsListView);
    listView.setFastScrollEnabled(true);
    listView.setAdapter(new BlacklistedAlbumsMultiselectAdapter(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.albumCheckboxMusicLibraryEditor);
            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 album'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 album's songs from the 
				 * HashSet.
				 */
            if (checkbox.isChecked()) {
                view.setBackgroundColor(0xCCFF4444);
                AsyncBlacklistAlbumTask task = new AsyncBlacklistAlbumTask((String) view.getTag(R.string.album), (String) view.getTag(R.string.artist));
                task.execute(new String[] { "ADD" });
            } else {
                view.setBackgroundColor(0x00000000);
                AsyncBlacklistAlbumTask task = new AsyncBlacklistAlbumTask((String) view.getTag(R.string.album), (String) view.getTag(R.string.artist));
                task.execute(new String[] { "REMOVE" });
            }
        }
    });
    TextView instructions = (TextView) rootView.findViewById(R.id.albums_music_library_editor_instructions);
    instructions.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light"));
    instructions.setPaintFlags(instructions.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
    instructions.setText(R.string.blacklist_manager_albums_instructions);
    //KitKat translucent navigation/status bar.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //Calculate navigation bar height.
        int navigationBarHeight = 0;
        int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
        if (resourceId > 0) {
            navigationBarHeight = getResources().getDimensionPixelSize(resourceId);
        }
        listView.setClipToPadding(false);
        listView.setPadding(0, 0, 0, navigationBarHeight);
    }
    return rootView;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) CheckBox(android.widget.CheckBox) AsyncBlacklistAlbumTask(com.jams.music.player.BlacklistManagerActivity.BlacklistedAlbumsMultiselectAdapter.AsyncBlacklistAlbumTask) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 32 with CheckBox

use of android.widget.CheckBox in project JamsMusicPlayer by psaravan.

the class SongsPickerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mApp = (Common) getActivity().getApplicationContext();
    View rootView = inflater.inflate(R.layout.fragment_songs_music_library_editor, null);
    cursor = mApp.getDBAccessHelper().getAllSongs();
    listView = (ListView) rootView.findViewById(R.id.musicLibraryEditorSongsListView);
    listView.setFastScrollEnabled(true);
    listView.setAdapter(new PlaylistEditorSongsMultiselectAdapter(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.songCheckboxMusicLibraryEditor);
            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 song to the HashSet. If the checkbox is unchecked, that means the user 
				 * tapped on it when it was checked, so we should remove the song from the 
				 * HashSet.
				 */
            if (checkbox.isChecked()) {
                view.setBackgroundColor(0xCC0099CC);
                PlaylistEditorActivity.songDBIdsList.add((String) view.getTag(R.string.song_id));
            } else {
                view.setBackgroundColor(0x00000000);
                PlaylistEditorActivity.songDBIdsList.remove((String) view.getTag(R.string.song_id));
            }
        }
    });
    TextView instructions = (TextView) rootView.findViewById(R.id.songs_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;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Paint(android.graphics.Paint)

Example 33 with CheckBox

use of android.widget.CheckBox in project JamsMusicPlayer by psaravan.

the class AlbumsPickerFragment 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_albums_music_library_editor, null);
    cursor = mApp.getDBAccessHelper().getAllUniqueAlbums("");
    listView = (ListView) rootView.findViewById(R.id.musicLibraryEditorAlbumsListView);
    listView.setFastScrollEnabled(true);
    listView.setAdapter(new PlaylistEditorAlbumsMultiselectAdapter(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.albumCheckboxMusicLibraryEditor);
            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 album'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 album's songs from the 
				 * HashSet.
				 */
            if (checkbox.isChecked()) {
                view.setBackgroundColor(0xCC0099CC);
                AsyncGetAlbumSongIds task = new AsyncGetAlbumSongIds(mContext, (String) view.getTag(R.string.album), (String) view.getTag(R.string.artist));
                task.execute(new String[] { "ADD" });
            } else {
                view.setBackgroundColor(0x00000000);
                AsyncGetAlbumSongIds task = new AsyncGetAlbumSongIds(mContext, (String) view.getTag(R.string.album), (String) view.getTag(R.string.artist));
                task.execute(new String[] { "REMOVE" });
            }
        }
    });
    TextView instructions = (TextView) rootView.findViewById(R.id.albums_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;
}
Also used : AsyncGetAlbumSongIds(com.jams.music.player.PlaylistEditorActivity.PlaylistEditorAlbumsMultiselectAdapter.AsyncGetAlbumSongIds) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Paint(android.graphics.Paint)

Example 34 with CheckBox

use of android.widget.CheckBox 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;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) CheckBox(android.widget.CheckBox) AsyncGetArtistSongIds(com.jams.music.player.PlaylistEditorActivity.PlaylistEditorArtistsMultiselectAdapter.AsyncGetArtistSongIds) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Paint(android.graphics.Paint)

Example 35 with CheckBox

use of android.widget.CheckBox in project robolectric by robolectric.

the class ShadowLayoutInflaterTest method testCheckBoxCheckedIsSet.

@Test
public void testCheckBoxCheckedIsSet() throws Exception {
    int layoutResId = context.getResources().getIdentifier("main", "layout", TEST_PACKAGE);
    View mediaView = LayoutInflater.from(context).inflate(layoutResId, null);
    assertThat(((CheckBox) mediaView.findViewById(R.id.true_checkbox)).isChecked()).isTrue();
    assertThat(((CheckBox) mediaView.findViewById(R.id.false_checkbox)).isChecked()).isFalse();
    assertThat(((CheckBox) mediaView.findViewById(R.id.default_checkbox)).isChecked()).isFalse();
}
Also used : CheckBox(android.widget.CheckBox) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) CustomView(org.robolectric.android.CustomView) TextView(android.widget.TextView) CustomStateView(org.robolectric.android.CustomStateView) ListView(android.widget.ListView) Test(org.junit.Test)

Aggregations

CheckBox (android.widget.CheckBox)197 View (android.view.View)102 TextView (android.widget.TextView)78 CompoundButton (android.widget.CompoundButton)51 Button (android.widget.Button)48 ImageView (android.widget.ImageView)32 Intent (android.content.Intent)30 EditText (android.widget.EditText)30 LayoutInflater (android.view.LayoutInflater)25 AdapterView (android.widget.AdapterView)25 DialogInterface (android.content.DialogInterface)21 ListView (android.widget.ListView)20 SuppressLint (android.annotation.SuppressLint)19 RadioButton (android.widget.RadioButton)19 AlertDialog (android.app.AlertDialog)17 Paint (android.graphics.Paint)14 Bundle (android.os.Bundle)12 ViewGroup (android.view.ViewGroup)12 GridLayout (android.widget.GridLayout)12 LinearLayout (android.widget.LinearLayout)12