Commit 708f2871 authored by Alexander Ivanov's avatar Alexander Ivanov

Replace base list activity with fragment activity.

parent 7c187aba
...@@ -28,7 +28,6 @@ import com.xabber.android.data.account.AccountManager; ...@@ -28,7 +28,6 @@ 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.ui.adapter.AccountListAdapter; import com.xabber.android.ui.adapter.AccountListAdapter;
import com.xabber.android.ui.adapter.BaseListEditorAdapter; import com.xabber.android.ui.adapter.BaseListEditorAdapter;
import com.xabber.android.ui.adapter.UpdatableAdapter;
import com.xabber.android.ui.helper.BaseListEditor; import com.xabber.android.ui.helper.BaseListEditor;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
...@@ -119,7 +118,7 @@ public class AccountList extends BaseListEditor<String> implements ...@@ -119,7 +118,7 @@ public class AccountList extends BaseListEditor<String> implements
@Override @Override
public void onAccountsChanged(Collection<String> accounts) { public void onAccountsChanged(Collection<String> accounts) {
((UpdatableAdapter) getListAdapter()).onChange(); adapter.onChange();
} }
@Override @Override
......
...@@ -40,7 +40,6 @@ import com.xabber.android.data.account.StatusMode; ...@@ -40,7 +40,6 @@ import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.intent.AccountIntentBuilder; import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.ui.adapter.StatusEditorAdapter; import com.xabber.android.ui.adapter.StatusEditorAdapter;
import com.xabber.android.ui.adapter.StatusModeAdapter; import com.xabber.android.ui.adapter.StatusModeAdapter;
import com.xabber.android.ui.adapter.UpdatableAdapter;
import com.xabber.android.ui.helper.ManagedListActivity; import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
...@@ -61,6 +60,7 @@ public class StatusEditor extends ManagedListActivity implements ...@@ -61,6 +60,7 @@ public class StatusEditor extends ManagedListActivity implements
private EditText statusTextView; private EditText statusTextView;
private SavedStatus actionWithItem; private SavedStatus actionWithItem;
private StatusEditorAdapter adapter;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -87,7 +87,8 @@ public class StatusEditor extends ManagedListActivity implements ...@@ -87,7 +87,8 @@ public class StatusEditor extends ManagedListActivity implements
listView.addHeaderView(header, null, false); listView.addHeaderView(header, null, false);
listView.setOnItemClickListener(this); listView.setOnItemClickListener(this);
registerForContextMenu(listView); registerForContextMenu(listView);
setListAdapter(new StatusEditorAdapter(this)); adapter = new StatusEditorAdapter(this);
setListAdapter(adapter);
statusTextView = (EditText) header.findViewById(R.id.status_text); statusTextView = (EditText) header.findViewById(R.id.status_text);
statusModeView = (Spinner) header.findViewById(R.id.status_mode); statusModeView = (Spinner) header.findViewById(R.id.status_mode);
...@@ -146,7 +147,7 @@ public class StatusEditor extends ManagedListActivity implements ...@@ -146,7 +147,7 @@ public class StatusEditor extends ManagedListActivity implements
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
((UpdatableAdapter) getListAdapter()).onChange(); adapter.onChange();
} }
@Override @Override
...@@ -164,7 +165,7 @@ public class StatusEditor extends ManagedListActivity implements ...@@ -164,7 +165,7 @@ public class StatusEditor extends ManagedListActivity implements
switch (item.getItemId()) { switch (item.getItemId()) {
case OPTION_MENU_CLEAR_STATUSES_ID: case OPTION_MENU_CLEAR_STATUSES_ID:
AccountManager.getInstance().clearSavedStatuses(); AccountManager.getInstance().clearSavedStatuses();
((UpdatableAdapter) getListAdapter()).onChange(); adapter.onChange();
return true; return true;
} }
return false; return false;
...@@ -202,7 +203,7 @@ public class StatusEditor extends ManagedListActivity implements ...@@ -202,7 +203,7 @@ public class StatusEditor extends ManagedListActivity implements
return true; return true;
case CONTEXT_MENU_REMOVE_STATUS_ID: case CONTEXT_MENU_REMOVE_STATUS_ID:
AccountManager.getInstance().removeSavedStatus(actionWithItem); AccountManager.getInstance().removeSavedStatus(actionWithItem);
((UpdatableAdapter) getListAdapter()).onChange(); adapter.onChange();
return true; return true;
} }
return false; return false;
......
...@@ -22,7 +22,6 @@ import java.util.Date; ...@@ -22,7 +22,6 @@ import java.util.Date;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.TreeMap; import java.util.TreeMap;
import android.app.ListActivity;
import android.os.Handler; import android.os.Handler;
import android.view.View; import android.view.View;
import android.view.animation.Animation; import android.view.animation.Animation;
...@@ -42,6 +41,7 @@ import com.xabber.android.data.roster.AbstractContact; ...@@ -42,6 +41,7 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.GroupManager; import com.xabber.android.data.roster.GroupManager;
import com.xabber.android.data.roster.RosterContact; import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
/** /**
...@@ -114,7 +114,7 @@ public class ContactListAdapter extends ...@@ -114,7 +114,7 @@ public class ContactListAdapter extends
*/ */
private Date nextRefresh; private Date nextRefresh;
public ContactListAdapter(ListActivity activity) { public ContactListAdapter(ManagedListActivity activity) {
super(activity, activity.getListView(), new ChatContactInflater( super(activity, activity.getListView(), new ChatContactInflater(
activity), GroupManager.getInstance()); activity), GroupManager.getInstance());
infoView = activity.findViewById(R.id.info); infoView = activity.findViewById(R.id.info);
......
...@@ -52,7 +52,7 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements ...@@ -52,7 +52,7 @@ public abstract class BaseListEditor<T> extends ManagedListActivity implements
private T actionWith; private T actionWith;
private BaseListEditorAdapter<T> adapter; protected BaseListEditorAdapter<T> adapter;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
......
...@@ -14,9 +14,11 @@ ...@@ -14,9 +14,11 @@
*/ */
package com.xabber.android.ui.helper; package com.xabber.android.ui.helper;
import android.app.ListActivity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.xabber.android.data.ActivityManager; import com.xabber.android.data.ActivityManager;
...@@ -28,7 +30,7 @@ import com.xabber.android.data.ActivityManager; ...@@ -28,7 +30,7 @@ import com.xabber.android.data.ActivityManager;
* @author alexander.ivanov * @author alexander.ivanov
* *
*/ */
public abstract class ManagedListActivity extends ListActivity { public abstract class ManagedListActivity extends FragmentActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -79,4 +81,12 @@ public abstract class ManagedListActivity extends ListActivity { ...@@ -79,4 +81,12 @@ public abstract class ManagedListActivity extends ListActivity {
super.startActivityForResult(intent, requestCode); super.startActivityForResult(intent, requestCode);
} }
public ListView getListView() {
return (ListView) findViewById(android.R.id.list);
}
public void setListAdapter(ListAdapter adapter) {
getListView().setAdapter(adapter);
}
} }
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