Commit 67ff3d03 authored by Grigory Fedorov's avatar Grigory Fedorov

Light code formatting.

parent cfffc807
...@@ -45,7 +45,6 @@ import com.xabber.android.data.NetworkException; ...@@ -45,7 +45,6 @@ import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener; import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.entity.BaseEntity; import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.avatar.AvatarManager; import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.data.extension.muc.MUCManager; import com.xabber.android.data.extension.muc.MUCManager;
...@@ -76,9 +75,8 @@ import java.util.Collection; ...@@ -76,9 +75,8 @@ import java.util.Collection;
* *
* @author alexander.ivanov * @author alexander.ivanov
*/ */
public class ContactList extends ManagedActivity implements public class ContactList extends ManagedActivity implements OnAccountChangedListener,
OnAccountChangedListener, View.OnClickListener, View.OnClickListener, OnChoosedListener, OnContactClickListener {
OnChoosedListener, OnContactClickListener {
/** /**
* Select contact to be invited to the room was requested. * Select contact to be invited to the room was requested.
...@@ -121,6 +119,7 @@ public class ContactList extends ManagedActivity implements ...@@ -121,6 +119,7 @@ public class ContactList extends ManagedActivity implements
ActivityManager.getInstance().startNewTask(this); ActivityManager.getInstance().startNewTask(this);
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (isFinishing()) { if (isFinishing()) {
return; return;
} }
...@@ -233,7 +232,6 @@ public class ContactList extends ManagedActivity implements ...@@ -233,7 +232,6 @@ public class ContactList extends ManagedActivity implements
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
updateStatusBar();
rebuildAccountToggle(); rebuildAccountToggle();
Application.getInstance().addUIListener(OnAccountChangedListener.class, this); Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
...@@ -281,9 +279,9 @@ public class ContactList extends ManagedActivity implements ...@@ -281,9 +279,9 @@ public class ContactList extends ManagedActivity implements
} }
} }
} }
if (Application.getInstance().doNotify()) { if (Application.getInstance().doNotify()) {
if (SettingsManager.bootCount() > 2 if (SettingsManager.bootCount() > 2 && !SettingsManager.connectionStartAtBoot()
&& !SettingsManager.connectionStartAtBoot()
&& !SettingsManager.startAtBootSuggested()) { && !SettingsManager.startAtBootSuggested()) {
StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT"); StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT");
} }
...@@ -458,8 +456,9 @@ public class ContactList extends ManagedActivity implements ...@@ -458,8 +456,9 @@ public class ContactList extends ManagedActivity implements
break; break;
default: default:
String account = accountToggleAdapter.getItemForView(view); String account = accountToggleAdapter.getItemForView(view);
if (account == null) // Check for tap on account in the title if (account == null) { // Check for tap on account in the title
break; break;
}
if (!SettingsManager.contactsShowAccounts()) { if (!SettingsManager.contactsShowAccounts()) {
if (AccountManager.getInstance().getAccounts().size() < 2) { if (AccountManager.getInstance().getAccounts().size() < 2) {
getContactListFragment().scrollUp(); getContactListFragment().scrollUp();
...@@ -538,7 +537,6 @@ public class ContactList extends ManagedActivity implements ...@@ -538,7 +537,6 @@ public class ContactList extends ManagedActivity implements
} }
private void rebuildAccountToggle() { private void rebuildAccountToggle() {
updateStatusBar();
accountToggleAdapter.rebuild(); accountToggleAdapter.rebuild();
if (SettingsManager.contactsShowPanel() && accountToggleAdapter.getCount() > 0) { if (SettingsManager.contactsShowPanel() && accountToggleAdapter.getCount() > 0) {
actionBarView.setVisibility(View.VISIBLE); actionBarView.setVisibility(View.VISIBLE);
...@@ -547,14 +545,6 @@ public class ContactList extends ManagedActivity implements ...@@ -547,14 +545,6 @@ public class ContactList extends ManagedActivity implements
} }
} }
private void updateStatusBar() {
String statusText = SettingsManager.statusText();
StatusMode statusMode = SettingsManager.statusMode();
if ("".equals(statusText)) {
statusText = getString(statusMode.getStringID());
}
}
public static Intent createPersistentIntent(Context context) { public static Intent createPersistentIntent(Context context) {
Intent intent = new Intent(context, ContactList.class); Intent intent = new Intent(context, ContactList.class);
intent.setAction("android.intent.action.MAIN"); intent.setAction("android.intent.action.MAIN");
...@@ -567,8 +557,7 @@ public class ContactList extends ManagedActivity implements ...@@ -567,8 +557,7 @@ public class ContactList extends ManagedActivity implements
return new Intent(context, ContactList.class); return new Intent(context, ContactList.class);
} }
public static Intent createRoomInviteIntent(Context context, public static Intent createRoomInviteIntent(Context context, String account, String room) {
String account, String room) {
Intent intent = new EntityIntentBuilder(context, ContactList.class) Intent intent = new EntityIntentBuilder(context, ContactList.class)
.setAccount(account).setUser(room).build(); .setAccount(account).setUser(room).build();
intent.setAction(ACTION_ROOM_INVITE); intent.setAction(ACTION_ROOM_INVITE);
......
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
*/ */
package com.xabber.android.ui.adapter; package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Locale;
import android.app.Activity; import android.app.Activity;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -27,6 +24,9 @@ import android.widget.Filterable; ...@@ -27,6 +24,9 @@ import android.widget.Filterable;
import com.xabber.android.data.entity.BaseEntity; import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
import java.util.ArrayList;
import java.util.Locale;
/** /**
* Base adapter for the list of contacts. * Base adapter for the list of contacts.
* *
...@@ -62,20 +62,13 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater> ...@@ -62,20 +62,13 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
public BaseContactAdapter(Activity activity, Inflater inflater) { public BaseContactAdapter(Activity activity, Inflater inflater) {
this.activity = activity; this.activity = activity;
this.locale = Locale.getDefault(); this.locale = Locale.getDefault();
this.baseEntities = new ArrayList<BaseEntity>(); this.baseEntities = new ArrayList<>();
this.inflater = inflater; this.inflater = inflater;
inflater.setAdapter(this); inflater.setAdapter(this);
contactFilter = null; contactFilter = null;
filterString = null; filterString = null;
} }
/**
* @return View inflater.
*/
public Inflater getInflater() {
return inflater;
}
@Override @Override
public void onChange() { public void onChange() {
notifyDataSetChanged(); notifyDataSetChanged();
...@@ -111,8 +104,9 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater> ...@@ -111,8 +104,9 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
@Override @Override
public Filter getFilter() { public Filter getFilter() {
if (contactFilter == null) if (contactFilter == null) {
contactFilter = new ContactFilter(); contactFilter = new ContactFilter();
}
return contactFilter; return contactFilter;
} }
...@@ -126,10 +120,11 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater> ...@@ -126,10 +120,11 @@ public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
@Override @Override
protected void publishResults(CharSequence constraint, protected void publishResults(CharSequence constraint,
FilterResults results) { FilterResults results) {
if (constraint == null || constraint.length() == 0) if (constraint == null || constraint.length() == 0) {
filterString = null; filterString = null;
else } else {
filterString = constraint.toString().toLowerCase(locale); filterString = constraint.toString().toLowerCase(locale);
}
onChange(); onChange();
} }
......
...@@ -59,14 +59,11 @@ public abstract class BaseContactInflater { ...@@ -59,14 +59,11 @@ public abstract class BaseContactInflater {
public BaseContactInflater(Activity activity) { public BaseContactInflater(Activity activity) {
this.activity = activity; this.activity = activity;
layoutInflater = (LayoutInflater) activity layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); avatarInflaterHelper = AbstractAvatarInflaterHelper.createAbstractContactInflaterHelper();
avatarInflaterHelper = AbstractAvatarInflaterHelper
.createAbstractContactInflaterHelper(); Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.shadow);
shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap);
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(),
R.drawable.shadow);
shadowDrawable = new BitmapDrawable(bitmap);
shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT); shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
} }
...@@ -115,19 +112,18 @@ public abstract class BaseContactInflater { ...@@ -115,19 +112,18 @@ public abstract class BaseContactInflater {
*/ */
public void getView(View view, AbstractContact abstractContact) { public void getView(View view, AbstractContact abstractContact) {
final ViewHolder viewHolder = (ViewHolder) view.getTag(); final ViewHolder viewHolder = (ViewHolder) view.getTag();
if (abstractContact.isConnected()) if (abstractContact.isConnected()) {
viewHolder.shadow.setVisibility(View.GONE); viewHolder.shadow.setVisibility(View.GONE);
else } else {
viewHolder.shadow.setVisibility(View.VISIBLE); viewHolder.shadow.setVisibility(View.VISIBLE);
}
viewHolder.color.setImageLevel(abstractContact.getColorLevel()); viewHolder.color.setImageLevel(abstractContact.getColorLevel());
if (SettingsManager.contactsShowAvatars()) { if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE); viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(abstractContact viewHolder.avatar.setImageDrawable(abstractContact.getAvatarForContactList());
.getAvatarForContactList()); avatarInflaterHelper.updateAvatar(viewHolder.avatar, abstractContact);
avatarInflaterHelper.updateAvatar(viewHolder.avatar,
abstractContact);
((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams()) ((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams())
.addRule(RelativeLayout.RIGHT_OF, R.id.avatar); .addRule(RelativeLayout.RIGHT_OF, R.id.avatar);
} else { } else {
...@@ -140,14 +136,12 @@ public abstract class BaseContactInflater { ...@@ -140,14 +136,12 @@ public abstract class BaseContactInflater {
final String statusText = getStatusText(abstractContact); final String statusText = getStatusText(abstractContact);
if ("".equals(statusText)) { if ("".equals(statusText)) {
viewHolder.name.getLayoutParams().height = activity.getResources() viewHolder.name.getLayoutParams().height = activity.getResources()
.getDimensionPixelSize( .getDimensionPixelSize(R.dimen.contact_name_height_hide_status);
R.dimen.contact_name_height_hide_status);
viewHolder.name.setGravity(Gravity.CENTER_VERTICAL); viewHolder.name.setGravity(Gravity.CENTER_VERTICAL);
viewHolder.status.setVisibility(View.GONE); viewHolder.status.setVisibility(View.GONE);
} else { } else {
viewHolder.name.getLayoutParams().height = activity.getResources() viewHolder.name.getLayoutParams().height = activity.getResources()
.getDimensionPixelSize( .getDimensionPixelSize(R.dimen.contact_name_height_show_status);
R.dimen.contact_name_height_show_status);
viewHolder.name.setGravity(Gravity.BOTTOM); viewHolder.name.setGravity(Gravity.BOTTOM);
viewHolder.status.setText(statusText); viewHolder.status.setText(statusText);
viewHolder.status.setVisibility(View.VISIBLE); viewHolder.status.setVisibility(View.VISIBLE);
......
...@@ -36,8 +36,7 @@ public abstract class SmoothContactAdapter<Inflater extends BaseContactInflater> ...@@ -36,8 +36,7 @@ public abstract class SmoothContactAdapter<Inflater extends BaseContactInflater>
*/ */
ListView listView; ListView listView;
public SmoothContactAdapter(Activity activity, ListView listView, public SmoothContactAdapter(Activity activity, ListView listView, Inflater inflater) {
Inflater inflater) {
super(activity, inflater); super(activity, inflater);
this.listView = listView; this.listView = listView;
} }
......
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