Commit f7329d29 authored by Grigory Fedorov's avatar Grigory Fedorov

Account list colors fixed.

parent 814d9321
...@@ -14,12 +14,8 @@ ...@@ -14,12 +14,8 @@
*/ */
package com.xabber.android.ui.adapter; package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import android.app.Activity; import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
...@@ -32,15 +28,23 @@ import com.xabber.android.data.extension.avatar.AvatarManager; ...@@ -32,15 +28,23 @@ import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.ui.preferences.AccountList; import com.xabber.android.ui.preferences.AccountList;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/** /**
* Adapter for the list of accounts for {@link AccountList}. * Adapter for the list of accounts for {@link AccountList}.
* *
* @author alexander.ivanov * @author alexander.ivanov
*/ */
public class AccountListAdapter extends BaseListEditorAdapter<String> { public class AccountListAdapter extends BaseListEditorAdapter<String> {
private final int[] accountColors;
public AccountListAdapter(Activity activity) { public AccountListAdapter(Activity activity) {
super(activity); super(activity);
accountColors = activity.getResources().getIntArray(R.array.account_action_bar);
} }
@Override @Override
...@@ -48,34 +52,31 @@ public class AccountListAdapter extends BaseListEditorAdapter<String> { ...@@ -48,34 +52,31 @@ public class AccountListAdapter extends BaseListEditorAdapter<String> {
View view; View view;
AccountManager accountManager = AccountManager.getInstance(); AccountManager accountManager = AccountManager.getInstance();
if (convertView == null) { if (convertView == null) {
view = getActivity().getLayoutInflater().inflate( view = getActivity().getLayoutInflater().inflate(R.layout.account_list_item, parent, false);
R.layout.account_list_item, parent, false);
} else { } else {
view = convertView; view = convertView;
} }
String account = getItem(position); String account = getItem(position);
((ImageView) view.findViewById(R.id.color)) ((ImageView) view.findViewById(R.id.color)).setImageDrawable(
.setImageLevel(accountManager.getColorLevel(account)); new ColorDrawable(accountColors[accountManager.getColorLevel(account)]));
((ImageView) view.findViewById(R.id.avatar)) ((ImageView) view.findViewById(R.id.avatar))
.setImageDrawable(AvatarManager.getInstance().getAccountAvatar( .setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
account)); ((TextView) view.findViewById(R.id.name)).setText(accountManager.getVerboseName(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager
.getVerboseName(account));
AccountItem accountItem = accountManager.getAccount(account); AccountItem accountItem = accountManager.getAccount(account);
ConnectionState state; ConnectionState state;
if (accountItem == null) if (accountItem == null) {
state = ConnectionState.offline; state = ConnectionState.offline;
else } else {
state = accountItem.getState(); state = accountItem.getState();
((TextView) view.findViewById(R.id.status)).setText(getActivity() }
.getString(state.getStringId())); ((TextView) view.findViewById(R.id.status)).setText(getActivity().getString(state.getStringId()));
return view; return view;
} }
@Override @Override
protected Collection<String> getTags() { protected Collection<String> getTags() {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<>();
list.addAll(AccountManager.getInstance().getAllAccounts()); list.addAll(AccountManager.getInstance().getAllAccounts());
Collections.sort(list); Collections.sort(list);
return list; return list;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
android:layout_height="@dimen/avatar_size" android:layout_height="@dimen/avatar_size"
android:layout_marginRight="3dp" android:layout_marginRight="3dp"
android:layout_marginEnd="3dp" android:layout_marginEnd="3dp"
/> />
<ImageView <ImageView
android:id="@+id/avatar" android:id="@+id/avatar"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment