simplify method
This commit is contained in:
parent
21073b11d0
commit
bdd3c849e7
|
@ -187,7 +187,7 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
||||||
new GetLists().setCallback(new Callback<>() {
|
new GetLists().setCallback(new Callback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<ListTimeline> lists) {
|
public void onSuccess(List<ListTimeline> lists) {
|
||||||
addListsToSwitcher(lists);
|
addItemsToMap(lists, listItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -199,7 +199,7 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
||||||
new GetFollowedHashtags().setCallback(new Callback<>() {
|
new GetFollowedHashtags().setCallback(new Callback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(HeaderPaginationList<Hashtag> hashtags) {
|
public void onSuccess(HeaderPaginationList<Hashtag> hashtags) {
|
||||||
addHashtagsToSwitcher(hashtags);
|
addItemsToMap(hashtags, hashtagsItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -276,23 +276,9 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
||||||
}).exec(accountID);
|
}).exec(accountID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addListsToSwitcher(List<ListTimeline> lists) {
|
private <T> void addItemsToMap(List<T> addItems, Map<Integer, T> items) {
|
||||||
if (lists.size() == 0) return;
|
if (addItems.size() == 0) return;
|
||||||
for (int i = 0; i < lists.size(); i++) {
|
for (int i = 0; i < addItems.size(); i++) items.put(View.generateViewId(), addItems.get(i));
|
||||||
ListTimeline list = lists.get(i);
|
|
||||||
int id = View.generateViewId();
|
|
||||||
listItems.put(id, list);
|
|
||||||
}
|
|
||||||
updateSwitcherMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addHashtagsToSwitcher(List<Hashtag> hashtags) {
|
|
||||||
if (hashtags.size() == 0) return;
|
|
||||||
for (int i = 0; i < hashtags.size(); i++) {
|
|
||||||
Hashtag tag = hashtags.get(i);
|
|
||||||
int id = View.generateViewId();
|
|
||||||
hashtagsItems.put(id, tag);
|
|
||||||
}
|
|
||||||
updateSwitcherMenu();
|
updateSwitcherMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue