use of android.support.v7.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) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id;
final Spannable[] base = Reddit.getSortingSpannablesTime(getBaseContext(), 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:
Reddit.setTime(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.HOUR);
reloadSubs();
break;
case 1:
Reddit.setTime(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.DAY);
reloadSubs();
break;
case 2:
Reddit.setTime(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.WEEK);
reloadSubs();
break;
case 3:
Reddit.setTime(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.MONTH);
reloadSubs();
break;
case 4:
Reddit.setTime(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.YEAR);
reloadSubs();
break;
case 5:
Reddit.setTime(((SubmissionsView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).id, TimePeriod.ALL);
reloadSubs();
break;
}
return true;
}
});
popup.show();
}
use of android.support.v7.widget.PopupMenu in project Slide by ccrama.
the class MultiredditOverview method openPopupTime.
public void openPopupTime() {
PopupMenu popup = new PopupMenu(MultiredditOverview.this, findViewById(R.id.anchor), Gravity.RIGHT);
String id = ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH);
final Spannable[] base = Reddit.getSortingSpannablesTime(getBaseContext(), "multi" + id);
for (Spannable s : base) {
MenuItem m = popup.getMenu().add(s);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
int i = 0;
for (Spannable s : base) {
if (s.equals(item.getTitle())) {
break;
}
i++;
}
LogUtil.v("Chosen is " + i);
if (pager.getAdapter() != null) {
switch(i) {
case 0:
Reddit.setTime("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), TimePeriod.HOUR);
reloadSubs();
break;
case 1:
Reddit.setTime("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), TimePeriod.DAY);
reloadSubs();
break;
case 2:
Reddit.setTime("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), TimePeriod.WEEK);
reloadSubs();
break;
case 3:
Reddit.setTime("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), TimePeriod.MONTH);
reloadSubs();
break;
case 4:
Reddit.setTime("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), TimePeriod.YEAR);
reloadSubs();
break;
case 5:
Reddit.setTime("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), TimePeriod.ALL);
reloadSubs();
break;
}
}
return true;
}
});
popup.show();
}
use of android.support.v7.widget.PopupMenu in project Slide by ccrama.
the class MultiredditOverview method openPopup.
public void openPopup() {
PopupMenu popup = new PopupMenu(MultiredditOverview.this, findViewById(R.id.anchor), Gravity.RIGHT);
String id = ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH);
final Spannable[] base = Reddit.getSortingSpannables(getBaseContext(), "multi" + id);
for (Spannable s : base) {
MenuItem m = popup.getMenu().add(s);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
int i = 0;
for (Spannable s : base) {
if (s.equals(item.getTitle())) {
break;
}
i++;
}
LogUtil.v("Chosen is " + i);
if (pager.getAdapter() != null) {
switch(i) {
case 0:
Reddit.setSorting("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), Sorting.HOT);
reloadSubs();
break;
case 1:
Reddit.setSorting("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), Sorting.NEW);
reloadSubs();
break;
case 2:
Reddit.setSorting("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), Sorting.RISING);
reloadSubs();
break;
case 3:
Reddit.setSorting("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), Sorting.TOP);
openPopupTime();
break;
case 4:
Reddit.setSorting("multi" + ((MultiredditView) (((OverviewPagerAdapter) pager.getAdapter()).getCurrentFragment())).posts.multiReddit.getDisplayName().toLowerCase(Locale.ENGLISH), Sorting.CONTROVERSIAL);
openPopupTime();
break;
}
}
return true;
}
});
popup.show();
}
use of android.support.v7.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 = Reddit.getSortingSpannables(getBaseContext(), 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:
Reddit.setSorting(subreddit, Sorting.HOT);
reloadSubs();
break;
case 1:
Reddit.setSorting(subreddit, Sorting.NEW);
reloadSubs();
break;
case 2:
Reddit.setSorting(subreddit, Sorting.RISING);
reloadSubs();
break;
case 3:
Reddit.setSorting(subreddit, Sorting.TOP);
openPopupTime();
break;
case 4:
Reddit.setSorting(subreddit, Sorting.CONTROVERSIAL);
openPopupTime();
break;
}
return true;
}
});
popup.show();
}
use of android.support.v7.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 = Reddit.getSortingSpannablesTime(getBaseContext(), 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:
Reddit.setTime(subreddit, TimePeriod.HOUR);
reloadSubs();
break;
case 1:
Reddit.setTime(subreddit, TimePeriod.DAY);
reloadSubs();
break;
case 2:
Reddit.setTime(subreddit, TimePeriod.WEEK);
reloadSubs();
break;
case 3:
Reddit.setTime(subreddit, TimePeriod.MONTH);
reloadSubs();
break;
case 4:
Reddit.setTime(subreddit, TimePeriod.YEAR);
reloadSubs();
break;
case 5:
Reddit.setTime(subreddit, TimePeriod.ALL);
reloadSubs();
break;
}
return true;
}
});
popup.show();
}
Aggregations