Search in sources :

Example 26 with CheckBox

use of android.widget.CheckBox in project qksms by moezbhatti.

the class MainActivity method confirmDeleteThreadDialog.

/**
     * Build and show the proper delete thread dialog. The UI is slightly different
     * depending on whether there are locked messages in the thread(s) and whether we're
     * deleting single/multiple threads or all threads.
     *
     * @param listener          gets called when the delete button is pressed
     * @param threadIds         the thread IDs to be deleted (pass null for all threads)
     * @param hasLockedMessages whether the thread(s) contain locked messages
     * @param context           used to load the various UI elements
     */
public static void confirmDeleteThreadDialog(final DeleteThreadListener listener, Collection<Long> threadIds, boolean hasLockedMessages, Context context) {
    View contents = View.inflate(context, R.layout.dialog_delete_thread, null);
    android.widget.TextView msg = (android.widget.TextView) contents.findViewById(R.id.message);
    if (threadIds == null) {
        msg.setText(R.string.confirm_delete_all_conversations);
    } else {
        // Show the number of threads getting deleted in the confirmation dialog.
        int cnt = threadIds.size();
        msg.setText(context.getResources().getQuantityString(R.plurals.confirm_delete_conversation, cnt, cnt));
    }
    final CheckBox checkbox = (CheckBox) contents.findViewById(R.id.delete_locked);
    if (!hasLockedMessages) {
        checkbox.setVisibility(View.GONE);
    } else {
        listener.setDeleteLockedMessage(checkbox.isChecked());
        checkbox.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                listener.setDeleteLockedMessage(checkbox.isChecked());
            }
        });
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.confirm_dialog_title).setIconAttribute(android.R.attr.alertDialogIcon).setCancelable(true).setPositiveButton(R.string.delete, listener).setNegativeButton(R.string.cancel, null).setView(contents).show();
}
Also used : AlertDialog(android.app.AlertDialog) CheckBox(android.widget.CheckBox) ImageView(android.widget.ImageView) View(android.view.View)

Example 27 with CheckBox

use of android.widget.CheckBox in project KeepScore by nolanlawson.

the class SavedGameAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup parent) {
    // view wrapper optimization per Romain Guy
    final Context context = parent.getContext();
    ViewWrapper viewWrapper;
    if (view == null) {
        LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = vi.inflate(R.layout.saved_game_item, parent, false);
        viewWrapper = new ViewWrapper(view);
        view.setTag(viewWrapper);
    } else {
        viewWrapper = (ViewWrapper) view.getTag();
    }
    TextView titleTextView = viewWrapper.getTitleTextView();
    TextView numPlayersTextView = viewWrapper.getNumPlayersTextView();
    TextView subtitleTextView = viewWrapper.getSubtitleTextView();
    TextView savedTextView = viewWrapper.getSavedTextView();
    CheckBox checkBox = viewWrapper.getCheckBox();
    final GameSummary game = getItem(position);
    StringBuilder gameTitle = new StringBuilder();
    if (!TextUtils.isEmpty(game.getName())) {
        gameTitle.append(game.getName()).append(" ").append(context.getString(R.string.text_game_name_separator)).append(" ");
    }
    // Player 1, Player 2, Player3 etc.
    gameTitle.append(TextUtils.join(", ", CollectionUtil.transformWithIndices(game.getPlayerNames(), new FunctionWithIndex<String, CharSequence>() {

        @Override
        public CharSequence apply(String playerName, int index) {
            return PlayerScore.toDisplayName(playerName, index, context);
        }
    })));
    titleTextView.setText(gameTitle);
    numPlayersTextView.setText(Integer.toString(game.getPlayerNames().size()));
    numPlayersTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimensionPixelSize(// two
    game.getPlayerNames().size() >= 10 ? // digit
    R.dimen.saved_game_num_players_text_size_two_digits : R.dimen.saved_game_num_players_text_size_one_digit));
    int numRounds = game.getNumRounds();
    int roundsResId = numRounds == 1 ? R.string.text_format_rounds_singular : R.string.text_format_rounds;
    String rounds = String.format(context.getString(roundsResId), numRounds);
    subtitleTextView.setText(rounds);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(getContext().getString(R.string.date_format), Locale.getDefault());
    savedTextView.setText(simpleDateFormat.format(new Date(game.getDateSaved())));
    checkBox.setOnCheckedChangeListener(null);
    checkBox.setChecked(checked.contains(game));
    checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                checked.add(game);
            } else {
                checked.remove(game);
            }
            if (onCheckChangedRunnable != null) {
                onCheckChangedRunnable.run();
            }
        }
    });
    log.d("saved long is: %s", game.getDateSaved());
    return view;
}
Also used : Context(android.content.Context) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) GameSummary(com.nolanlawson.keepscore.db.GameSummary) Date(java.util.Date) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) SimpleDateFormat(java.text.SimpleDateFormat) CompoundButton(android.widget.CompoundButton)

Example 28 with CheckBox

use of android.widget.CheckBox in project bee by orhanobut.

the class SettingsAdapter method createCheckBox.

private View createCheckBox(ViewGroup parent, MethodInfo methodInfo) {
    final Method method = methodInfo.getMethod();
    final Object instance = methodInfo.getInstance();
    final Context context = parent.getContext();
    View view = inflater.inflate(R.layout.item_settings_checkbox, parent, false);
    ((TextView) view.findViewById(R.id.title)).setText(methodInfo.getTitle());
    CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            try {
                method.invoke(instance, isChecked);
            } catch (Exception e) {
                Log.e("Bee", e.getMessage());
            }
            PrefHelper.setBoolean(context, method.getName(), isChecked);
        }
    });
    checkBox.setChecked(PrefHelper.getBoolean(context, method.getName()));
    return view;
}
Also used : Context(android.content.Context) CheckBox(android.widget.CheckBox) TextView(android.widget.TextView) Method(java.lang.reflect.Method) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton)

Example 29 with CheckBox

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

the class BlacklistedArtistsPickerFragment method onCreateView.

@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mApp = (Common) getActivity().getApplicationContext();
    View rootView = inflater.inflate(R.layout.fragment_artists_music_library_editor, null);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        rootView.setBackground(UIElementsHelper.getBackgroundGradientDrawable(getActivity()));
    } else {
        rootView.setBackgroundDrawable(UIElementsHelper.getBackgroundGradientDrawable(getActivity()));
    }
    cursor = mApp.getDBAccessHelper().getAllUniqueArtistsNoBlacklist("");
    listView = (ListView) rootView.findViewById(R.id.musicLibraryEditorArtistsListView);
    listView.setFastScrollEnabled(true);
    listView.setAdapter(new BlacklistedArtistsMultiselectAdapter(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(0xCCFF4444);
                AsyncBlacklistArtistTask task = new AsyncBlacklistArtistTask((String) view.getTag(R.string.artist));
                task.execute(new String[] { "ADD" });
            } else {
                view.setBackgroundColor(0x00000000);
                AsyncBlacklistArtistTask task = new AsyncBlacklistArtistTask((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);
    instructions.setText(R.string.blacklist_manager_artists_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) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AsyncBlacklistArtistTask(com.jams.music.player.BlacklistManagerActivity.BlacklistedArtistsMultiselectAdapter.AsyncBlacklistArtistTask) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 30 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)

Aggregations

CheckBox (android.widget.CheckBox)183 View (android.view.View)92 TextView (android.widget.TextView)69 CompoundButton (android.widget.CompoundButton)46 Button (android.widget.Button)43 ImageView (android.widget.ImageView)29 Intent (android.content.Intent)28 EditText (android.widget.EditText)27 AdapterView (android.widget.AdapterView)25 ListView (android.widget.ListView)20 LayoutInflater (android.view.LayoutInflater)19 DialogInterface (android.content.DialogInterface)16 RadioButton (android.widget.RadioButton)16 SuppressLint (android.annotation.SuppressLint)14 RemoteException (android.os.RemoteException)13 AlertDialog (android.app.AlertDialog)12 Paint (android.graphics.Paint)12 GridLayout (android.widget.GridLayout)12 Bundle (android.os.Bundle)11 ViewGroup (android.view.ViewGroup)11