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