use of androidx.appcompat.widget.AppCompatCheckBox in project kcanotify by antest1.
the class KcaResoureLogFragment method setView.
public View setView(final View v) {
Log.e("KCA", "setView " + position);
v.setTag("fragment_view");
v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_box_%d", position), R.id.class)).setVisibility(View.VISIBLE);
v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_box_%d", 1 - position), R.id.class)).setVisibility(GONE);
for (int i = 0; i < 4; i++) {
final int k = i;
AppCompatCheckBox box = v.findViewById(KcaUtils.getId(KcaUtils.format("reslog_chart_filter_%d_%d", position, i), R.id.class));
box.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
is_draw_enabled[k] = b;
setChartDataVisibility(v, k);
}
});
box.setChecked(is_draw_enabled[k]);
}
((TextView) v.findViewById(R.id.reslog_item_label_0)).setText(getStringWithLocale(R.string.reslog_label_date));
if (position == 0) {
((TextView) v.findViewById(R.id.reslog_item_label_1)).setText(getStringWithLocale(R.string.item_fuel));
((TextView) v.findViewById(R.id.reslog_item_label_2)).setText(getStringWithLocale(R.string.item_ammo));
((TextView) v.findViewById(R.id.reslog_item_label_3)).setText(getStringWithLocale(R.string.item_stel));
((TextView) v.findViewById(R.id.reslog_item_label_4)).setText(getStringWithLocale(R.string.item_baux));
} else {
((TextView) v.findViewById(R.id.reslog_item_label_1)).setText(getStringWithLocale(R.string.item_bgtz));
((TextView) v.findViewById(R.id.reslog_item_label_2)).setText(getStringWithLocale(R.string.item_brnr));
((TextView) v.findViewById(R.id.reslog_item_label_3)).setText(getStringWithLocale(R.string.item_mmat));
((TextView) v.findViewById(R.id.reslog_item_label_4)).setText(getStringWithLocale(R.string.item_kmat));
}
ListView resource_data = v.findViewById(R.id.reslog_listview);
resource_data.setAdapter(adapter);
adapter.notifyDataSetChanged();
drawChart(v);
return v;
}
use of androidx.appcompat.widget.AppCompatCheckBox in project Slide by ccrama.
the class MainActivity method doSubOnlyStuff.
public void doSubOnlyStuff(final Subreddit subreddit) {
findViewById(R.id.loader).setVisibility(View.GONE);
if (subreddit.getSubredditType() != null) {
canSubmit = !subreddit.getSubredditType().equals("RESTRICTED");
} else {
canSubmit = true;
}
if (subreddit.getSidebar() != null && !subreddit.getSidebar().isEmpty()) {
findViewById(R.id.sidebar_text).setVisibility(View.VISIBLE);
final String text = subreddit.getDataNode().get("description_html").asText().trim();
setViews(text, subreddit.getDisplayName(), sidebarBody, sidebarOverflow);
// get all subs that have Notifications enabled
ArrayList<String> rawSubs = StringUtil.stringToArray(Reddit.appRestart.getString(CheckForMail.SUBS_TO_GET, ""));
HashMap<String, Integer> subThresholds = new HashMap<>();
for (String s : rawSubs) {
try {
String[] split = s.split(":");
subThresholds.put(split[0].toLowerCase(Locale.ENGLISH), Integer.valueOf(split[1]));
} catch (Exception ignored) {
// do nothing
}
}
// whether or not this subreddit was in the keySet
boolean isNotified = subThresholds.containsKey(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH));
((AppCompatCheckBox) findViewById(R.id.notify_posts_state)).setChecked(isNotified);
} else {
findViewById(R.id.sidebar_text).setVisibility(View.GONE);
}
{
View collection = findViewById(R.id.collection);
if (Authentication.isLoggedIn) {
collection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new AsyncTask<Void, Void, Void>() {
HashMap<String, MultiReddit> multis = new HashMap<String, MultiReddit>();
@Override
protected Void doInBackground(Void... params) {
if (UserSubscriptions.multireddits == null) {
UserSubscriptions.syncMultiReddits(MainActivity.this);
}
for (MultiReddit r : UserSubscriptions.multireddits) {
multis.put(r.getDisplayName(), r);
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
new MaterialDialog.Builder(MainActivity.this).title(getString(R.string.multi_add_to, subreddit.getDisplayName())).items(multis.keySet()).itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, final int which, CharSequence text) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
final String multiName = multis.keySet().toArray(new String[0])[which];
List<String> subs = new ArrayList<String>();
for (MultiSubreddit sub : multis.get(multiName).getSubreddits()) {
subs.add(sub.getDisplayName());
}
subs.add(subreddit.getDisplayName());
new MultiRedditManager(Authentication.reddit).createOrUpdate(new MultiRedditUpdateRequest.Builder(Authentication.name, multiName).subreddits(subs).build());
UserSubscriptions.syncMultiReddits(MainActivity.this);
runOnUiThread(new Runnable() {
@Override
public void run() {
drawerLayout.closeDrawers();
Snackbar s = Snackbar.make(mToolbar, getString(R.string.multi_subreddit_added, multiName), Snackbar.LENGTH_LONG);
LayoutUtils.showSnackbar(s);
}
});
} catch (final NetworkException | ApiException e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Snackbar.make(mToolbar, getString(R.string.multi_error), Snackbar.LENGTH_LONG).setAction(R.string.btn_ok, null).show();
}
});
}
});
e.printStackTrace();
}
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}).show();
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
} else {
collection.setVisibility(View.GONE);
}
}
{
final AppCompatCheckBox notifyStateCheckBox = (AppCompatCheckBox) findViewById(R.id.notify_posts_state);
assert notifyStateCheckBox != null;
notifyStateCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
final String sub = subreddit.getDisplayName();
if (!sub.equalsIgnoreCase("all") && !sub.equalsIgnoreCase("frontpage") && !sub.equalsIgnoreCase("friends") && !sub.equalsIgnoreCase("mod") && !sub.contains("+") && !sub.contains(".") && !sub.contains("/m/")) {
new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.sub_post_notifs_title, sub)).setMessage(R.string.sub_post_notifs_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> new MaterialDialog.Builder(MainActivity.this).title(R.string.sub_post_notifs_threshold).items(new String[] { "1", "5", "10", "20", "40", "50" }).alwaysCallSingleChoiceCallback().itemsCallbackSingleChoice(0, new MaterialDialog.ListCallbackSingleChoice() {
@Override
public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
ArrayList<String> subs = StringUtil.stringToArray(Reddit.appRestart.getString(CheckForMail.SUBS_TO_GET, ""));
subs.add(sub + ":" + text);
Reddit.appRestart.edit().putString(CheckForMail.SUBS_TO_GET, StringUtil.arrayToString(subs)).commit();
return true;
}
}).cancelable(false).show()).setNegativeButton(R.string.btn_cancel, null).setNegativeButton(R.string.btn_cancel, (dialog, which) -> notifyStateCheckBox.setChecked(false)).setOnCancelListener(dialog -> notifyStateCheckBox.setChecked(false)).show();
} else {
notifyStateCheckBox.setChecked(false);
Toast.makeText(MainActivity.this, R.string.sub_post_notifs_err, Toast.LENGTH_SHORT).show();
}
} else {
Intent cancelIntent = new Intent(MainActivity.this, CancelSubNotifs.class);
cancelIntent.putExtra(CancelSubNotifs.EXTRA_SUB, subreddit.getDisplayName());
startActivity(cancelIntent);
}
}
});
}
{
final TextView subscribe = (TextView) findViewById(R.id.subscribe);
currentlySubbed = (!Authentication.isLoggedIn && usedArray.contains(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH))) || subreddit.isUserSubscriber();
MiscUtil.doSubscribeButtonText(currentlySubbed, subscribe);
assert subscribe != null;
subscribe.setOnClickListener(new View.OnClickListener() {
private void doSubscribe() {
if (Authentication.isLoggedIn) {
new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.subscribe_to, subreddit.getDisplayName())).setPositiveButton(R.string.reorder_add_subscribe, (dialog, which) -> new AsyncTask<Void, Void, Boolean>() {
@Override
public void onPostExecute(Boolean success) {
if (!success) {
// If subreddit was removed from account or not
new AlertDialog.Builder(MainActivity.this).setTitle(R.string.force_change_subscription).setMessage(R.string.force_change_subscription_desc).setPositiveButton(R.string.btn_yes, (dialog1, which1) -> {
// Force add the subscription
changeSubscription(subreddit, true);
Snackbar s = Snackbar.make(mToolbar, getString(R.string.misc_subscribed), Snackbar.LENGTH_LONG);
LayoutUtils.showSnackbar(s);
}).setNegativeButton(R.string.btn_no, null).setCancelable(false).show();
} else {
changeSubscription(subreddit, true);
}
}
@Override
protected Boolean doInBackground(Void... params) {
try {
new AccountManager(Authentication.reddit).subscribe(subreddit);
} catch (NetworkException e) {
// Either network crashed or trying to unsubscribe to a subreddit that the account isn't subscribed to
return false;
}
return true;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)).setNeutralButton(R.string.btn_add_to_sublist, (dialog, which) -> {
// Force add the subscription
changeSubscription(subreddit, true);
Snackbar s = Snackbar.make(mToolbar, R.string.sub_added, Snackbar.LENGTH_LONG);
LayoutUtils.showSnackbar(s);
}).setNegativeButton(R.string.btn_cancel, null).show();
} else {
changeSubscription(subreddit, true);
}
}
private void doUnsubscribe() {
if (Authentication.didOnline) {
new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.unsubscribe_from, subreddit.getDisplayName())).setPositiveButton(R.string.reorder_remove_unsubscribe, (dialog, which) -> new AsyncTask<Void, Void, Boolean>() {
@Override
public void onPostExecute(Boolean success) {
if (!success) {
// If subreddit was removed from account or not
new AlertDialog.Builder(MainActivity.this).setTitle(R.string.force_change_subscription).setMessage(R.string.force_change_subscription_desc).setPositiveButton(R.string.btn_yes, (dialog12, which12) -> {
// Force add the subscription
changeSubscription(subreddit, false);
Snackbar s = Snackbar.make(mToolbar, getString(R.string.misc_unsubscribed), Snackbar.LENGTH_LONG);
LayoutUtils.showSnackbar(s);
}).setNegativeButton(R.string.btn_no, null).setCancelable(false).show();
} else {
changeSubscription(subreddit, false);
}
}
@Override
protected Boolean doInBackground(Void... params) {
try {
new AccountManager(Authentication.reddit).unsubscribe(subreddit);
} catch (NetworkException e) {
// Either network crashed or trying to unsubscribe to a subreddit that the account isn't subscribed to
return false;
}
return true;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)).setNeutralButton(R.string.just_unsub, (dialog, which) -> {
// Force add the subscription
changeSubscription(subreddit, false);
Snackbar s = Snackbar.make(mToolbar, R.string.misc_unsubscribed, Snackbar.LENGTH_LONG);
LayoutUtils.showSnackbar(s);
}).setNegativeButton(R.string.btn_cancel, null).show();
} else {
changeSubscription(subreddit, false);
}
}
@Override
public void onClick(View v) {
if (!currentlySubbed) {
doSubscribe();
} else {
doUnsubscribe();
}
MiscUtil.doSubscribeButtonText(currentlySubbed, subscribe);
}
});
}
if (!subreddit.getPublicDescription().isEmpty()) {
findViewById(R.id.sub_title).setVisibility(View.VISIBLE);
setViews(subreddit.getDataNode().get("public_description_html").asText(), subreddit.getDisplayName().toLowerCase(Locale.ENGLISH), ((SpoilerRobotoTextView) findViewById(R.id.sub_title)), (CommentOverflow) findViewById(R.id.sub_title_overflow));
} else {
findViewById(R.id.sub_title).setVisibility(View.GONE);
}
((ImageView) findViewById(R.id.subimage)).setImageResource(0);
if (subreddit.getDataNode().has("icon_img") && !subreddit.getDataNode().get("icon_img").asText().isEmpty()) {
findViewById(R.id.subimage).setVisibility(View.VISIBLE);
((Reddit) getApplication()).getImageLoader().displayImage(subreddit.getDataNode().get("icon_img").asText(), (ImageView) findViewById(R.id.subimage));
} else {
findViewById(R.id.subimage).setVisibility(View.GONE);
}
String bannerImage = subreddit.getBannerImage();
if (bannerImage != null && !bannerImage.isEmpty()) {
findViewById(R.id.sub_banner).setVisibility(View.VISIBLE);
((Reddit) getApplication()).getImageLoader().displayImage(bannerImage, (ImageView) findViewById(R.id.sub_banner));
} else {
findViewById(R.id.sub_banner).setVisibility(View.GONE);
}
((TextView) findViewById(R.id.subscribers)).setText(getString(R.string.subreddit_subscribers_string, subreddit.getLocalizedSubscriberCount()));
findViewById(R.id.subscribers).setVisibility(View.VISIBLE);
((TextView) findViewById(R.id.active_users)).setText(getString(R.string.subreddit_active_users_string_new, subreddit.getLocalizedAccountsActive()));
findViewById(R.id.active_users).setVisibility(View.VISIBLE);
}
use of androidx.appcompat.widget.AppCompatCheckBox in project Slide by ccrama.
the class SubredditView method doSubOnlyStuff.
private void doSubOnlyStuff(final Subreddit subreddit) {
if (!isFinishing()) {
findViewById(R.id.loader).setVisibility(View.GONE);
if (subreddit.getDataNode().has("subreddit_type") && !subreddit.getDataNode().get("subreddit_type").isNull()) {
canSubmit = !subreddit.getDataNode().get("subreddit_type").asText().equalsIgnoreCase("RESTRICTED");
}
if (subreddit.getSidebar() != null && !subreddit.getSidebar().isEmpty()) {
findViewById(R.id.sidebar_text).setVisibility(View.VISIBLE);
final String text = subreddit.getDataNode().get("description_html").asText().trim();
final SpoilerRobotoTextView body = (SpoilerRobotoTextView) findViewById(R.id.sidebar_text);
CommentOverflow overflow = (CommentOverflow) findViewById(R.id.commentOverflow);
setViews(text, subreddit.getDisplayName(), body, overflow);
// get all subs that have Notifications enabled
ArrayList<String> rawSubs = StringUtil.stringToArray(Reddit.appRestart.getString(CheckForMail.SUBS_TO_GET, ""));
HashMap<String, Integer> subThresholds = new HashMap<>();
for (String s : rawSubs) {
try {
String[] split = s.split(":");
subThresholds.put(split[0].toLowerCase(Locale.ENGLISH), Integer.valueOf(split[1]));
} catch (Exception ignored) {
// do nothing
}
}
// whether or not this subreddit was in the keySet
boolean isNotified = subThresholds.containsKey(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH));
((AppCompatCheckBox) findViewById(R.id.notify_posts_state)).setChecked(isNotified);
} else {
findViewById(R.id.sidebar_text).setVisibility(View.GONE);
}
View collection = findViewById(R.id.collection);
if (Authentication.isLoggedIn) {
collection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new AsyncTask<Void, Void, Void>() {
HashMap<String, MultiReddit> multis = new HashMap<String, MultiReddit>();
@Override
protected Void doInBackground(Void... params) {
if (UserSubscriptions.multireddits == null) {
UserSubscriptions.syncMultiReddits(SubredditView.this);
}
for (MultiReddit r : UserSubscriptions.multireddits) {
multis.put(r.getDisplayName(), r);
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
new MaterialDialog.Builder(SubredditView.this).title("Add /r/" + subreddit.getDisplayName() + " to").items(multis.keySet()).itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View itemView, final int which, CharSequence text) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
final String multiName = multis.keySet().toArray(new String[0])[which];
List<String> subs = new ArrayList<String>();
for (MultiSubreddit sub : multis.get(multiName).getSubreddits()) {
subs.add(sub.getDisplayName());
}
subs.add(subreddit.getDisplayName());
new MultiRedditManager(Authentication.reddit).createOrUpdate(new MultiRedditUpdateRequest.Builder(Authentication.name, multiName).subreddits(subs).build());
UserSubscriptions.syncMultiReddits(SubredditView.this);
runOnUiThread(new Runnable() {
@Override
public void run() {
drawerLayout.closeDrawers();
Snackbar s = Snackbar.make(mToolbar, getString(R.string.multi_subreddit_added, multiName), Snackbar.LENGTH_LONG);
LayoutUtils.showSnackbar(s);
}
});
} catch (final NetworkException | ApiException e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
Snackbar.make(mToolbar, getString(R.string.multi_error), Snackbar.LENGTH_LONG).setAction(R.string.btn_ok, null).show();
}
});
}
});
e.printStackTrace();
}
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}).show();
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
} else {
collection.setVisibility(View.GONE);
}
{
final TextView subscribe = (TextView) findViewById(R.id.subscribe);
currentlySubbed = Authentication.isLoggedIn ? subreddit.isUserSubscriber() : UserSubscriptions.getSubscriptions(this).contains(subreddit.getDisplayName().toLowerCase(Locale.ENGLISH));
MiscUtil.doSubscribeButtonText(currentlySubbed, subscribe);
assert subscribe != null;
subscribe.setOnClickListener(new View.OnClickListener() {
private void doSubscribe() {
if (Authentication.isLoggedIn) {
new AlertDialog.Builder(SubredditView.this).setTitle(getString(R.string.subscribe_to, subreddit.getDisplayName())).setPositiveButton(R.string.reorder_add_subscribe, (dialog, which) -> new AsyncTask<Void, Void, Boolean>() {
@Override
public void onPostExecute(Boolean success) {
if (!success) {
// If subreddit was removed from account or not
new AlertDialog.Builder(SubredditView.this).setTitle(R.string.force_change_subscription).setMessage(R.string.force_change_subscription_desc).setPositiveButton(R.string.btn_yes, (dialog1, which1) -> {
// Force add the subscription
changeSubscription(subreddit, true);
Snackbar s = Snackbar.make(mToolbar, getString(R.string.misc_subscribed), Snackbar.LENGTH_SHORT);
LayoutUtils.showSnackbar(s);
}).setNegativeButton(R.string.btn_no, null).setCancelable(false).show();
} else {
changeSubscription(subreddit, true);
}
}
@Override
protected Boolean doInBackground(Void... params) {
try {
new AccountManager(Authentication.reddit).subscribe(subreddit);
} catch (NetworkException e) {
// Either network crashed or trying to unsubscribe to a subreddit that the account isn't subscribed to
return false;
}
return true;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)).setNegativeButton(R.string.btn_cancel, null).setNeutralButton(R.string.btn_add_to_sublist, (dialog, which) -> {
// Force add the subscription
changeSubscription(subreddit, true);
Snackbar s = Snackbar.make(mToolbar, R.string.sub_added, Snackbar.LENGTH_SHORT);
LayoutUtils.showSnackbar(s);
}).show();
} else {
changeSubscription(subreddit, true);
}
}
@Override
public void onClick(View v) {
if (!currentlySubbed) {
doSubscribe();
} else {
doUnsubscribe();
}
MiscUtil.doSubscribeButtonText(currentlySubbed, subscribe);
}
private void doUnsubscribe() {
if (Authentication.didOnline) {
new AlertDialog.Builder(SubredditView.this).setTitle(getString(R.string.unsubscribe_from, subreddit.getDisplayName())).setPositiveButton(R.string.reorder_remove_unsubscribe, (dialog, which) -> new AsyncTask<Void, Void, Boolean>() {
@Override
public void onPostExecute(Boolean success) {
if (!success) {
// If subreddit was removed from account or not
new AlertDialog.Builder(SubredditView.this).setTitle(R.string.force_change_subscription).setMessage(R.string.force_change_subscription_desc).setPositiveButton(R.string.btn_yes, (dialog12, which12) -> {
// Force add the subscription
changeSubscription(subreddit, false);
Snackbar s = Snackbar.make(mToolbar, getString(R.string.misc_unsubscribed), Snackbar.LENGTH_SHORT);
LayoutUtils.showSnackbar(s);
}).setNegativeButton(R.string.btn_no, null).setCancelable(false).show();
} else {
changeSubscription(subreddit, false);
}
}
@Override
protected Boolean doInBackground(Void... params) {
try {
new AccountManager(Authentication.reddit).unsubscribe(subreddit);
} catch (NetworkException e) {
// Either network crashed or trying to unsubscribe to a subreddit that the account isn't subscribed to
return false;
}
return true;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)).setNeutralButton(R.string.just_unsub, (dialog, which) -> {
// Force add the subscription
changeSubscription(subreddit, false);
Snackbar s = Snackbar.make(mToolbar, R.string.misc_unsubscribed, Snackbar.LENGTH_SHORT);
LayoutUtils.showSnackbar(s);
}).setNegativeButton(R.string.btn_cancel, null).show();
} else {
changeSubscription(subreddit, false);
}
}
});
}
{
final AppCompatCheckBox notifyStateCheckBox = (AppCompatCheckBox) findViewById(R.id.notify_posts_state);
assert notifyStateCheckBox != null;
notifyStateCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
final String sub = subreddit.getDisplayName();
if (!sub.equalsIgnoreCase("all") && !sub.equalsIgnoreCase("frontpage") && !sub.equalsIgnoreCase("friends") && !sub.equalsIgnoreCase("mod") && !sub.contains("+") && !sub.contains(".") && !sub.contains("/m/")) {
new AlertDialog.Builder(SubredditView.this).setTitle(getString(R.string.sub_post_notifs_title, sub)).setMessage(R.string.sub_post_notifs_msg).setPositiveButton(R.string.btn_ok, (dialog, which) -> new MaterialDialog.Builder(SubredditView.this).title(R.string.sub_post_notifs_threshold).items(new String[] { "1", "5", "10", "20", "40", "50" }).alwaysCallSingleChoiceCallback().itemsCallbackSingleChoice(0, new MaterialDialog.ListCallbackSingleChoice() {
@Override
public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
ArrayList<String> subs = StringUtil.stringToArray(Reddit.appRestart.getString(CheckForMail.SUBS_TO_GET, ""));
subs.add(sub + ":" + text);
Reddit.appRestart.edit().putString(CheckForMail.SUBS_TO_GET, StringUtil.arrayToString(subs)).commit();
return true;
}
}).cancelable(false).show()).setNegativeButton(R.string.btn_cancel, null).setNegativeButton(R.string.btn_cancel, (dialog, which) -> notifyStateCheckBox.setChecked(false)).setOnCancelListener(dialog -> notifyStateCheckBox.setChecked(false)).show();
} else {
notifyStateCheckBox.setChecked(false);
Toast.makeText(SubredditView.this, R.string.sub_post_notifs_err, Toast.LENGTH_SHORT).show();
}
} else {
Intent cancelIntent = new Intent(SubredditView.this, CancelSubNotifs.class);
cancelIntent.putExtra(CancelSubNotifs.EXTRA_SUB, subreddit.getDisplayName());
startActivity(cancelIntent);
}
}
});
}
if (!subreddit.getPublicDescription().isEmpty()) {
findViewById(R.id.sub_title).setVisibility(View.VISIBLE);
setViews(subreddit.getDataNode().get("public_description_html").asText(), subreddit.getDisplayName().toLowerCase(Locale.ENGLISH), ((SpoilerRobotoTextView) findViewById(R.id.sub_title)), (CommentOverflow) findViewById(R.id.sub_title_overflow));
} else {
findViewById(R.id.sub_title).setVisibility(View.GONE);
}
if (subreddit.getDataNode().has("icon_img") && !subreddit.getDataNode().get("icon_img").asText().isEmpty()) {
((Reddit) getApplication()).getImageLoader().displayImage(subreddit.getDataNode().get("icon_img").asText(), (ImageView) findViewById(R.id.subimage));
} else {
findViewById(R.id.subimage).setVisibility(View.GONE);
}
String bannerImage = subreddit.getBannerImage();
if (bannerImage != null && !bannerImage.isEmpty()) {
findViewById(R.id.sub_banner).setVisibility(View.VISIBLE);
((Reddit) getApplication()).getImageLoader().displayImage(bannerImage, (ImageView) findViewById(R.id.sub_banner));
} else {
findViewById(R.id.sub_banner).setVisibility(View.GONE);
}
((TextView) findViewById(R.id.subscribers)).setText(getString(R.string.subreddit_subscribers_string, subreddit.getLocalizedSubscriberCount()));
findViewById(R.id.subscribers).setVisibility(View.VISIBLE);
((TextView) findViewById(R.id.active_users)).setText(getString(R.string.subreddit_active_users_string_new, subreddit.getLocalizedAccountsActive()));
findViewById(R.id.active_users).setVisibility(View.VISIBLE);
}
}
use of androidx.appcompat.widget.AppCompatCheckBox in project J2ME-Loader by nikita36078.
the class MicroActivity method showSaveVkAlert.
private void showSaveVkAlert(boolean keepScreenPreferred) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.CONFIRMATION_REQUIRED);
builder.setMessage(R.string.pref_vk_save_alert);
builder.setNegativeButton(android.R.string.no, null);
AlertDialog dialog = builder.create();
final VirtualKeyboard vk = ContextHolder.getVk();
if (vk.isPhone()) {
AppCompatCheckBox cb = new AppCompatCheckBox(this);
cb.setText(R.string.opt_save_screen_params);
cb.setChecked(keepScreenPreferred);
TypedValue out = new TypedValue();
getTheme().resolveAttribute(R.attr.dialogPreferredPadding, out, true);
int paddingH = getResources().getDimensionPixelOffset(out.resourceId);
int paddingT = getResources().getDimensionPixelOffset(R.dimen.abc_dialog_padding_top_material);
dialog.setView(cb, paddingH, paddingT, paddingH, 0);
dialog.setButton(dialog.BUTTON_POSITIVE, getText(android.R.string.yes), (d, w) -> {
if (cb.isChecked()) {
vk.saveScreenParams();
}
vk.onLayoutChanged(VirtualKeyboard.TYPE_CUSTOM);
});
} else {
dialog.setButton(dialog.BUTTON_POSITIVE, getText(android.R.string.yes), (d, w) -> ContextHolder.getVk().onLayoutChanged(VirtualKeyboard.TYPE_CUSTOM));
}
dialog.show();
}
use of androidx.appcompat.widget.AppCompatCheckBox in project J2ME-Loader by nikita36078.
the class ChoiceGroup method initButtonGroup.
private void initButtonGroup() {
buttongroup.setOrientation(LinearLayout.VERTICAL);
Context context = getOwnerForm().getParentActivity();
int size = selected.size();
if (buttongroup instanceof RadioGroup) {
for (int i = 0; i < size; i++) {
addButton(new AppCompatRadioButton(context), i, strings.get(i), images.get(i), selected.get(i));
}
} else {
for (int i = 0; i < size; i++) {
addButton(new AppCompatCheckBox(context), i, strings.get(i), images.get(i), selected.get(i));
}
}
}
Aggregations