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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations