1
0
Fork 0
mirror of https://github.com/MatomoCamp/matomocamp-companion-android.git synced 2024-09-19 16:13:46 +02:00

Replaced manual divider inflation with LinearLayoutCompat's divider support in links list

This commit is contained in:
Christophe Beyls 2016-12-01 03:45:11 +01:00
parent 9496513e7e
commit 71b030c994
3 changed files with 19 additions and 20 deletions

View file

@ -67,6 +67,7 @@ public class EventDetailsFragment extends Fragment {
static class ViewHolder {
LayoutInflater inflater;
TextView personsTextView;
View linksHeader;
ViewGroup linksContainer;
}
@ -184,6 +185,7 @@ public class EventDetailsFragment extends Fragment {
textView.setMovementMethod(linkMovementMethod);
}
holder.linksHeader = view.findViewById(R.id.links_header);
holder.linksContainer = (ViewGroup) view.findViewById(R.id.links_container);
return view;
}
@ -428,12 +430,9 @@ public class EventDetailsFragment extends Fragment {
}
// 2. Links
// Keep the first view in links container (title) only
int linkViewCount = holder.linksContainer.getChildCount();
if (linkViewCount > 1) {
holder.linksContainer.removeViews(1, linkViewCount - 1);
}
holder.linksContainer.removeAllViews();
if ((data.links != null) && (data.links.size() > 0)) {
holder.linksHeader.setVisibility(View.VISIBLE);
holder.linksContainer.setVisibility(View.VISIBLE);
for (Link link : data.links) {
View view = holder.inflater.inflate(R.layout.item_link, holder.linksContainer, false);
@ -441,10 +440,9 @@ public class EventDetailsFragment extends Fragment {
tv.setText(link.getDescription());
view.setOnClickListener(new LinkClickListener(link));
holder.linksContainer.addView(view);
// Add a list divider
holder.inflater.inflate(R.layout.list_divider, holder.linksContainer, true);
}
} else {
holder.linksHeader.setVisibility(View.GONE);
holder.linksContainer.setVisibility(View.GONE);
}
}

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -93,7 +94,16 @@
android:textIsSelectable="true"
tools:text="Welcome to FOSDEM 2015!"/>
<LinearLayout
<TextView
android:id="@+id/links_header"
style="@style/Header"
android:layout_marginLeft="@dimen/content_margin"
android:layout_marginRight="@dimen/content_margin"
android:layout_marginTop="8dp"
android:text="@string/related_links_header"
android:visibility="gone"/>
<android.support.v7.widget.LinearLayoutCompat
android:id="@+id/links_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -101,13 +111,9 @@
android:paddingBottom="@dimen/content_margin"
android:paddingLeft="@dimen/content_margin"
android:paddingRight="@dimen/content_margin"
android:paddingTop="8dp"
android:visibility="gone">
<TextView
style="@style/Header"
android:text="@string/related_links_header"/>
</LinearLayout>
android:visibility="gone"
app:divider="?android:attr/listDivider"
app:showDividers="middle"/>
</LinearLayout>
</ScrollView>

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/listDivider" />