Commit f4f38bde authored by Grigory Fedorov's avatar Grigory Fedorov

OccupantList: refactored and modified (colored toolbar), called from conference avatar click.

parent 2c7d2e16
...@@ -565,7 +565,7 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem ...@@ -565,7 +565,7 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
private void showContactInfo() { private void showContactInfo() {
if (MUCManager.getInstance().hasRoom(account, user)) { if (MUCManager.getInstance().hasRoom(account, user)) {
startActivity(ContactViewer.createIntent(getActivity(), account, user)); startActivity(OccupantList.createIntent(getActivity(), account, user));
} else { } else {
startActivity(ContactEditor.createIntent(getActivity(), account, user)); startActivity(ContactEditor.createIntent(getActivity(), account, user));
} }
......
...@@ -17,7 +17,9 @@ package com.xabber.android.ui; ...@@ -17,7 +17,9 @@ package com.xabber.android.ui;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.View;
import com.xabber.android.R; import com.xabber.android.R;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
...@@ -28,6 +30,7 @@ import com.xabber.android.data.intent.AccountIntentBuilder; ...@@ -28,6 +30,7 @@ import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.data.intent.EntityIntentBuilder; import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.roster.OnContactChangedListener; import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.ui.adapter.OccupantListAdapter; import com.xabber.android.ui.adapter.OccupantListAdapter;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedListActivity; import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.xmpp.address.Jid; import com.xabber.xmpp.address.Jid;
...@@ -45,8 +48,7 @@ public class OccupantList extends ManagedListActivity implements ...@@ -45,8 +48,7 @@ public class OccupantList extends ManagedListActivity implements
private String room; private String room;
private OccupantListAdapter listAdapter; private OccupantListAdapter listAdapter;
public static Intent createIntent(Context context, String account, public static Intent createIntent(Context context, String account, String user) {
String user) {
return new EntityIntentBuilder(context, OccupantList.class) return new EntityIntentBuilder(context, OccupantList.class)
.setAccount(account).setUser(user).build(); .setAccount(account).setUser(user).build();
} }
...@@ -62,55 +64,63 @@ public class OccupantList extends ManagedListActivity implements ...@@ -62,55 +64,63 @@ public class OccupantList extends ManagedListActivity implements
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (isFinishing()) if (isFinishing()) {
return; return;
}
account = getAccount(getIntent()); account = getAccount(getIntent());
room = Jid.getBareAddress(getUser(getIntent())); room = Jid.getBareAddress(getUser(getIntent()));
if (account == null || room == null if (account == null || room == null || !MUCManager.getInstance().hasRoom(account, room)) {
|| !MUCManager.getInstance().hasRoom(account, room)) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND); Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish(); finish();
return; return;
} }
setContentView(R.layout.list); setContentView(R.layout.list);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default)); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NavUtils.navigateUpFromSameTask(OccupantList.this);
}
});
toolbar.setTitle(room);
BarPainter barPainter = new BarPainter(this, toolbar);
barPainter.updateWithAccountName(account);
listAdapter = new OccupantListAdapter(this, account, room); listAdapter = new OccupantListAdapter(this, account, room);
setListAdapter(listAdapter); setListAdapter(listAdapter);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
Application.getInstance().addUIListener(OnAccountChangedListener.class, Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
this); Application.getInstance().addUIListener(OnContactChangedListener.class, this);
Application.getInstance().addUIListener(OnContactChangedListener.class,
this);
listAdapter.onChange(); listAdapter.onChange();
} }
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
Application.getInstance().removeUIListener( Application.getInstance().removeUIListener(OnAccountChangedListener.class, this);
OnAccountChangedListener.class, this); Application.getInstance().removeUIListener(OnContactChangedListener.class, this);
Application.getInstance().removeUIListener(
OnContactChangedListener.class, this);
} }
@Override @Override
public void onContactsChanged(Collection<BaseEntity> entities) { public void onContactsChanged(Collection<BaseEntity> entities) {
if (entities.contains(new BaseEntity(account, room))) if (entities.contains(new BaseEntity(account, room))) {
listAdapter.onChange(); listAdapter.onChange();
}
} }
@Override @Override
public void onAccountsChanged(Collection<String> accounts) { public void onAccountsChanged(Collection<String> accounts) {
if (accounts.contains(account)) if (accounts.contains(account)) {
listAdapter.onChange(); listAdapter.onChange();
}
} }
} }
...@@ -16,6 +16,7 @@ import com.xabber.android.data.message.MessageManager; ...@@ -16,6 +16,7 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.ui.ContactEditor; import com.xabber.android.ui.ContactEditor;
import com.xabber.android.ui.ContactViewer; import com.xabber.android.ui.ContactViewer;
import com.xabber.android.ui.OccupantList;
import com.xabber.android.utils.StringUtils; import com.xabber.android.utils.StringUtils;
public class ContactItemInflater { public class ContactItemInflater {
...@@ -129,11 +130,11 @@ public class ContactItemInflater { ...@@ -129,11 +130,11 @@ public class ContactItemInflater {
private void onAvatarClick(AbstractContact contact) { private void onAvatarClick(AbstractContact contact) {
if (MUCManager.getInstance().hasRoom(contact.getAccount(), contact.getUser())) { if (MUCManager.getInstance().hasRoom(contact.getAccount(), contact.getUser())) {
context.startActivity(ContactViewer.createIntent(context, context.startActivity(
contact.getAccount(), contact.getUser())); OccupantList.createIntent(context, contact.getAccount(), contact.getUser()));
} else { } else {
context.startActivity(ContactEditor.createIntent(context, context.startActivity(
contact.getAccount(), contact.getUser())); ContactEditor.createIntent(context, contact.getAccount(), contact.getUser()));
} }
} }
} }
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