use of androidx.appcompat.widget.PopupMenu in project J2ME-Loader by nikita36078.
the class ConfigActivity method showScreenPresets.
private void showScreenPresets(View v) {
PopupMenu popup = new PopupMenu(this, v);
Menu menu = popup.getMenu();
for (String preset : screenPresets) {
menu.add(preset);
}
popup.setOnMenuItemClickListener(item -> {
String string = item.getTitle().toString();
int separator = string.indexOf(" x ");
tfScreenWidth.setText(string.substring(0, separator));
tfScreenHeight.setText(string.substring(separator + 3));
return true;
});
popup.show();
}
use of androidx.appcompat.widget.PopupMenu in project Slide by ccrama.
the class MainActivity method openPopup.
public void openPopup() {
PopupMenu popup = new PopupMenu(MainActivity.this, findViewById(R.id.anchor), Gravity.RIGHT);
String id = ((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id;
final Spannable[] base = SortingUtil.getSortingSpannables(id);
for (Spannable s : base) {
// Do not add option for "Best" in any subreddit except for the frontpage.
if (!id.equals("frontpage") && s.toString().equals(getString(R.string.sorting_best))) {
continue;
}
MenuItem m = popup.getMenu().add(s);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
LogUtil.v("Chosen is " + item.getOrder());
int i = 0;
for (Spannable s : base) {
if (s.equals(item.getTitle())) {
break;
}
i++;
}
switch(i) {
case 0:
SortingUtil.setSorting(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.HOT);
reloadSubs();
break;
case 1:
SortingUtil.setSorting(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.NEW);
reloadSubs();
break;
case 2:
SortingUtil.setSorting(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.RISING);
reloadSubs();
break;
case 3:
SortingUtil.setSorting(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.TOP);
openPopupTime();
break;
case 4:
SortingUtil.setSorting(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.CONTROVERSIAL);
openPopupTime();
break;
case 5:
SortingUtil.setSorting(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, Sorting.BEST);
reloadSubs();
break;
}
return true;
}
});
popup.show();
}
use of androidx.appcompat.widget.PopupMenu in project Slide by ccrama.
the class MainActivity method openPopupTime.
public void openPopupTime() {
PopupMenu popup = new PopupMenu(MainActivity.this, findViewById(R.id.anchor), Gravity.RIGHT);
String id = ((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id;
final Spannable[] base = SortingUtil.getSortingTimesSpannables(id);
for (Spannable s : base) {
MenuItem m = popup.getMenu().add(s);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
LogUtil.v("Chosen is " + item.getOrder());
int i = 0;
for (Spannable s : base) {
if (s.equals(item.getTitle())) {
break;
}
i++;
}
switch(i) {
case 0:
SortingUtil.setTime(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.HOUR);
reloadSubs();
break;
case 1:
SortingUtil.setTime(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.DAY);
reloadSubs();
break;
case 2:
SortingUtil.setTime(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.WEEK);
reloadSubs();
break;
case 3:
SortingUtil.setTime(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.MONTH);
reloadSubs();
break;
case 4:
SortingUtil.setTime(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.YEAR);
reloadSubs();
break;
case 5:
SortingUtil.setTime(((SubmissionsView) (((MainPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.ALL);
reloadSubs();
break;
}
return true;
}
});
popup.show();
}
use of androidx.appcompat.widget.PopupMenu in project Slide by ccrama.
the class SubredditView method openPopupTime.
public void openPopupTime() {
PopupMenu popup = new PopupMenu(SubredditView.this, findViewById(R.id.anchor), Gravity.RIGHT);
final Spannable[] base = SortingUtil.getSortingTimesSpannables(subreddit);
for (Spannable s : base) {
MenuItem m = popup.getMenu().add(s);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
LogUtil.v("Chosen is " + item.getOrder());
int i = 0;
for (Spannable s : base) {
if (s.equals(item.getTitle())) {
break;
}
i++;
}
switch(i) {
case 0:
SortingUtil.setTime(subreddit, TimePeriod.HOUR);
reloadSubs();
break;
case 1:
SortingUtil.setTime(subreddit, TimePeriod.DAY);
reloadSubs();
break;
case 2:
SortingUtil.setTime(subreddit, TimePeriod.WEEK);
reloadSubs();
break;
case 3:
SortingUtil.setTime(subreddit, TimePeriod.MONTH);
reloadSubs();
break;
case 4:
SortingUtil.setTime(subreddit, TimePeriod.YEAR);
reloadSubs();
break;
case 5:
SortingUtil.setTime(subreddit, TimePeriod.ALL);
reloadSubs();
break;
}
return true;
}
});
popup.show();
}
use of androidx.appcompat.widget.PopupMenu in project Slide by ccrama.
the class SubredditView method openPopup.
public void openPopup() {
PopupMenu popup = new PopupMenu(SubredditView.this, findViewById(R.id.anchor), Gravity.RIGHT);
final Spannable[] base = SortingUtil.getSortingSpannables(subreddit);
for (Spannable s : base) {
// Do not add option for "Best" in any subreddit except for the frontpage.
if (!subreddit.equalsIgnoreCase("frontpage") && s.toString().equals(getString(R.string.sorting_best))) {
continue;
}
MenuItem m = popup.getMenu().add(s);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
LogUtil.v("Chosen is " + item.getOrder());
int i = 0;
for (Spannable s : base) {
if (s.equals(item.getTitle())) {
break;
}
i++;
}
switch(i) {
case 0:
SortingUtil.setSorting(subreddit, Sorting.HOT);
reloadSubs();
break;
case 1:
SortingUtil.setSorting(subreddit, Sorting.NEW);
reloadSubs();
break;
case 2:
SortingUtil.setSorting(subreddit, Sorting.RISING);
reloadSubs();
break;
case 3:
SortingUtil.setSorting(subreddit, Sorting.TOP);
openPopupTime();
break;
case 4:
SortingUtil.setSorting(subreddit, Sorting.CONTROVERSIAL);
openPopupTime();
break;
case 5:
SortingUtil.setSorting(subreddit, Sorting.BEST);
reloadSubs();
break;
}
return true;
}
});
popup.show();
}
Aggregations