fix account list loading and clean up a lot of code (#823)

* fix account list loading and clean up a lot of code

* remove ACCESS_COARSE_LOCATION for API levels 23+

* small improvements
This commit is contained in:
Konrad Pozniak 2018-08-31 21:52:09 +02:00 committed by GitHub
commit 28c1c90a98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 135 additions and 378 deletions

View file

@ -31,8 +31,6 @@ import com.keylesspalace.tusky.util.CustomEmojiHelper;
import com.squareup.picasso.Picasso;
public class BlocksAdapter extends AccountAdapter {
private static final int VIEW_TYPE_BLOCKED_USER = 0;
private static final int VIEW_TYPE_FOOTER = 1;
public BlocksAdapter(AccountActionListener accountActionListener) {
super(accountActionListener);
@ -43,7 +41,7 @@ public class BlocksAdapter extends AccountAdapter {
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (viewType) {
default:
case VIEW_TYPE_BLOCKED_USER: {
case VIEW_TYPE_ACCOUNT: {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_blocked_user, parent, false);
return new BlockedUserViewHolder(view);
@ -51,29 +49,17 @@ public class BlocksAdapter extends AccountAdapter {
case VIEW_TYPE_FOOTER: {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_footer, parent, false);
return new FooterViewHolder(view);
return new LoadingFooterViewHolder(view);
}
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
if (position < accountList.size()) {
if (getItemViewType(position) == VIEW_TYPE_ACCOUNT) {
BlockedUserViewHolder holder = (BlockedUserViewHolder) viewHolder;
holder.setupWithAccount(accountList.get(position));
holder.setupActionListener(accountActionListener);
} else {
FooterViewHolder holder = (FooterViewHolder) viewHolder;
holder.setState(footerState);
}
}
@Override
public int getItemViewType(int position) {
if (position == accountList.size()) {
return VIEW_TYPE_FOOTER;
} else {
return VIEW_TYPE_BLOCKED_USER;
}
}