Commit bfb1cbf9 authored by Grigory Fedorov's avatar Grigory Fedorov

ContactListDrawerFragment layout changed, header and divider added.

parent cc7a39e8
......@@ -23,6 +23,9 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
ContactListDrawerListener listener;
private NavigationDrawerAccountAdapter adapter;
private ListView listView;
private View divider;
private View headerTitle;
@Override
public void onAttach(Activity activity) {
......@@ -36,12 +39,19 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
View view = inflater.inflate(R.layout.contact_list_drawer, container, false);
ListView listView = (ListView) view.findViewById(R.id.drawer_account_list);
listView = (ListView) view.findViewById(R.id.drawer_account_list);
View footerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.contact_list_drawer_footer, null, false);
.inflate(R.layout.contact_list_drawer_footer, listView, false);
listView.addFooterView(footerView);
View headerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.contact_list_drawer_header, listView, false);
headerTitle = headerView.findViewById(R.id.drawer_header_title);
listView.addHeaderView(headerView);
adapter = new NavigationDrawerAccountAdapter(getActivity());
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
......@@ -50,6 +60,8 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
footerView.findViewById(R.id.drawer_action_about).setOnClickListener(this);
footerView.findViewById(R.id.drawer_action_exit).setOnClickListener(this);
divider = footerView.findViewById(R.id.drawer_divider);
return view;
}
......@@ -58,6 +70,14 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
super.onResume();
Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
adapter.onChange();
if (adapter.getCount() == 0) {
headerTitle.setVisibility(View.GONE);
divider.setVisibility(View.GONE);
} else {
headerTitle.setVisibility(View.VISIBLE);
divider.setVisibility(View.VISIBLE);
}
}
@Override
......@@ -84,7 +104,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
listener.onAccountSelected(adapter.getItem(position));
listener.onAccountSelected((String) listView.getItemAtPosition(position));
}
interface ContactListDrawerListener {
......
......@@ -33,7 +33,7 @@ public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String
View view;
AccountManager accountManager = AccountManager.getInstance();
if (convertView == null) {
view = getActivity().getLayoutInflater().inflate(R.layout.navigation_drawer_account_item, parent, false);
view = getActivity().getLayoutInflater().inflate(R.layout.contact_list_drawer_account_item, parent, false);
} else {
view = convertView;
}
......
......@@ -11,17 +11,34 @@
android:layout_height="170dp"
android:background="@color/grey_300">
<ImageView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="16dp"
android:src="@drawable/ic_connect" />
android:layout_marginTop="16dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:src="@drawable/ic_connect" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/production_title"
android:textSize="32sp" />
</LinearLayout>
</RelativeLayout>
<ListView
android:id="@+id/drawer_account_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:divider="@null"
android:dividerHeight="0dp"
/>
</LinearLayout>
\ No newline at end of file
......@@ -6,6 +6,26 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/drawer_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="8dp" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/grey_300" />
<View
android:layout_width="match_parent"
android:layout_height="8dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/drawer_action_settings"
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_header_title"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/xmpp_accounts"
android:textSize="16sp" />
</LinearLayout>
......@@ -114,4 +114,6 @@
<string name="contact_search_hint">Поиск контактов</string>
<string name="sender_is_you">Вы</string>
<string name="xmpp_accounts">XMPP accounts</string>
</resources>
\ No newline at end of file
......@@ -114,4 +114,6 @@
<string name="contact_search_hint">Search contacts</string>
<string name="sender_is_you">You</string>
<string name="xmpp_accounts">XMPP accounts</string>
</resources>
\ No newline at end of file
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