diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-01-25 23:26:47 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-01-25 23:26:47 +0100 |
commit | 96aa72c0ab5869d3ade69974616b3f1d4c49ae72 (patch) | |
tree | 125d4a5a2839f561febe204ea9433da5ea5404e7 | |
parent | bf14dced03452e25b8031b336900ba33760850dc (diff) | |
download | AntennaPod-96aa72c0ab5869d3ade69974616b3f1d4c49ae72.zip |
Added OnClickListener for header view
-rwxr-xr-x | res/drawable-hdpi/navigation_collapse.png | bin | 0 -> 1425 bytes | |||
-rwxr-xr-x | res/drawable-hdpi/navigation_collapse_dark.png | bin | 0 -> 1384 bytes | |||
-rwxr-xr-x | res/drawable-mdpi/navigation_collapse.png | bin | 0 -> 1238 bytes | |||
-rwxr-xr-x | res/drawable-mdpi/navigation_collapse_dark.png | bin | 0 -> 1208 bytes | |||
-rwxr-xr-x | res/drawable-xhdpi/navigation_collapse.png | bin | 0 -> 1658 bytes | |||
-rwxr-xr-x | res/drawable-xhdpi/navigation_collapse_dark.png | bin | 0 -> 1635 bytes | |||
-rw-r--r-- | res/layout/feeditemlist_header.xml | 13 | ||||
-rw-r--r-- | res/values/attrs.xml | 1 | ||||
-rw-r--r-- | res/values/styles.xml | 2 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/adapter/OnItemlistHeaderClicked.java | 55 |
10 files changed, 70 insertions, 1 deletions
diff --git a/res/drawable-hdpi/navigation_collapse.png b/res/drawable-hdpi/navigation_collapse.png Binary files differnew file mode 100755 index 000000000..bd405bada --- /dev/null +++ b/res/drawable-hdpi/navigation_collapse.png diff --git a/res/drawable-hdpi/navigation_collapse_dark.png b/res/drawable-hdpi/navigation_collapse_dark.png Binary files differnew file mode 100755 index 000000000..ca78f2ec0 --- /dev/null +++ b/res/drawable-hdpi/navigation_collapse_dark.png diff --git a/res/drawable-mdpi/navigation_collapse.png b/res/drawable-mdpi/navigation_collapse.png Binary files differnew file mode 100755 index 000000000..6673c7aea --- /dev/null +++ b/res/drawable-mdpi/navigation_collapse.png diff --git a/res/drawable-mdpi/navigation_collapse_dark.png b/res/drawable-mdpi/navigation_collapse_dark.png Binary files differnew file mode 100755 index 000000000..01d6511ee --- /dev/null +++ b/res/drawable-mdpi/navigation_collapse_dark.png diff --git a/res/drawable-xhdpi/navigation_collapse.png b/res/drawable-xhdpi/navigation_collapse.png Binary files differnew file mode 100755 index 000000000..be6a7688c --- /dev/null +++ b/res/drawable-xhdpi/navigation_collapse.png diff --git a/res/drawable-xhdpi/navigation_collapse_dark.png b/res/drawable-xhdpi/navigation_collapse_dark.png Binary files differnew file mode 100755 index 000000000..2ed325108 --- /dev/null +++ b/res/drawable-xhdpi/navigation_collapse_dark.png diff --git a/res/layout/feeditemlist_header.xml b/res/layout/feeditemlist_header.xml index a88cd992a..b0fbbcb9c 100644 --- a/res/layout/feeditemlist_header.xml +++ b/res/layout/feeditemlist_header.xml @@ -4,15 +4,26 @@ android:layout_height="match_parent" android:background="?attr/borderless_button" > + <ImageView + android:id="@+id/imgvHeaderArrow" + android:layout_width="@dimen/thumbnail_length" + android:layout_height="match_parent" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:padding="12dp" + android:scaleType="fitEnd" + android:src="?attr/navigation_expand" /> + <TextView android:id="@+id/txtvHeaderTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginBottom="24dp" - android:layout_marginLeft="16dp" + android:layout_marginLeft="8dp" android:layout_marginRight="16dp" android:layout_marginTop="24dp" + android:layout_toRightOf="@id/imgvHeaderArrow" android:textColor="@color/bright_blue" android:textSize="@dimen/text_size_large" android:textStyle="bold" /> diff --git a/res/values/attrs.xml b/res/values/attrs.xml index c565a6897..ec8329aca 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -18,6 +18,7 @@ <attr name="navigation_accept" format="reference" /> <attr name="navigation_cancel" format="reference" /> <attr name="navigation_expand" format="reference" /> + <attr name="navigation_collapse" format="reference" /> <attr name="navigation_refresh" format="reference" /> <attr name="navigation_up" format="reference" /> <attr name="social_share" format="reference" /> diff --git a/res/values/styles.xml b/res/values/styles.xml index 4ada53ef8..37fda099f 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -20,6 +20,7 @@ <item name="attr/navigation_accept">@drawable/navigation_accept</item> <item name="attr/navigation_cancel">@drawable/navigation_cancel</item> <item name="attr/navigation_expand">@drawable/navigation_expand</item> + <item name="attr/navigation_collapse">@drawable/navigation_collapse</item> <item name="attr/navigation_refresh">@drawable/navigation_refresh</item> <item name="attr/navigation_up">@drawable/navigation_up</item> <item name="attr/social_share">@drawable/social_share</item> @@ -55,6 +56,7 @@ <item name="attr/navigation_accept">@drawable/navigation_accept_dark</item> <item name="attr/navigation_cancel">@drawable/navigation_cancel_dark</item> <item name="attr/navigation_expand">@drawable/navigation_expand_dark</item> + <item name="attr/navigation_collapse">@drawable/navigation_collapse_dark</item> <item name="attr/navigation_refresh">@drawable/navigation_refresh_dark</item> <item name="attr/navigation_up">@drawable/navigation_up_dark</item> <item name="attr/social_share">@drawable/social_share_dark</item> diff --git a/src/de/danoeh/antennapod/adapter/OnItemlistHeaderClicked.java b/src/de/danoeh/antennapod/adapter/OnItemlistHeaderClicked.java new file mode 100644 index 000000000..14bb06051 --- /dev/null +++ b/src/de/danoeh/antennapod/adapter/OnItemlistHeaderClicked.java @@ -0,0 +1,55 @@ +package de.danoeh.antennapod.adapter; + +import de.danoeh.antennapod.R; +import android.content.res.TypedArray; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.ImageView; + +/** + * OnClickListener for the itemlist headers of feeditem lists. This class takes + * care of changing the appearance of the arrow on the left side of the header + * view. An instance of this class should be set as the OnClickListener of the + * header view. + */ +public class OnItemlistHeaderClicked implements OnClickListener { + private ImageView arrow; + private View header; + + private boolean isExpanded; + + /** + * Constructor + * + * @param header + * Reference to the header View of the itemlist. + * @param isExpanded + * true if the itemlist is currently expanded. + * */ + public OnItemlistHeaderClicked(View header, boolean isExpanded) { + if (header == null) + throw new IllegalArgumentException("Header view must not be null"); + this.header = header; + arrow = (ImageView) header.findViewById(R.id.imgvHeaderArrow); + this.isExpanded = isExpanded; + refreshArrowState(); + } + + private void refreshArrowState() { + TypedArray typeDrawables = header.getContext().obtainStyledAttributes( + new int[] { R.attr.navigation_collapse, + R.attr.navigation_expand }); + if (isExpanded) { + arrow.setImageDrawable(typeDrawables.getDrawable(0)); + } else { + arrow.setImageDrawable(typeDrawables.getDrawable(1)); + } + } + + @Override + public void onClick(View v) { + isExpanded = !isExpanded; + refreshArrowState(); + } + +} |