Added OnClickListener for header view
This commit is contained in:
parent
bf14dced03
commit
96aa72c0ab
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -4,15 +4,26 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/borderless_button" >
|
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
|
<TextView
|
||||||
android:id="@+id/txtvHeaderTitle"
|
android:id="@+id/txtvHeaderTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginBottom="24dp"
|
android:layout_marginBottom="24dp"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_toRightOf="@id/imgvHeaderArrow"
|
||||||
android:textColor="@color/bright_blue"
|
android:textColor="@color/bright_blue"
|
||||||
android:textSize="@dimen/text_size_large"
|
android:textSize="@dimen/text_size_large"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<attr name="navigation_accept" format="reference" />
|
<attr name="navigation_accept" format="reference" />
|
||||||
<attr name="navigation_cancel" format="reference" />
|
<attr name="navigation_cancel" format="reference" />
|
||||||
<attr name="navigation_expand" format="reference" />
|
<attr name="navigation_expand" format="reference" />
|
||||||
|
<attr name="navigation_collapse" format="reference" />
|
||||||
<attr name="navigation_refresh" format="reference" />
|
<attr name="navigation_refresh" format="reference" />
|
||||||
<attr name="navigation_up" format="reference" />
|
<attr name="navigation_up" format="reference" />
|
||||||
<attr name="social_share" format="reference" />
|
<attr name="social_share" format="reference" />
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<item name="attr/navigation_accept">@drawable/navigation_accept</item>
|
<item name="attr/navigation_accept">@drawable/navigation_accept</item>
|
||||||
<item name="attr/navigation_cancel">@drawable/navigation_cancel</item>
|
<item name="attr/navigation_cancel">@drawable/navigation_cancel</item>
|
||||||
<item name="attr/navigation_expand">@drawable/navigation_expand</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_refresh">@drawable/navigation_refresh</item>
|
||||||
<item name="attr/navigation_up">@drawable/navigation_up</item>
|
<item name="attr/navigation_up">@drawable/navigation_up</item>
|
||||||
<item name="attr/social_share">@drawable/social_share</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_accept">@drawable/navigation_accept_dark</item>
|
||||||
<item name="attr/navigation_cancel">@drawable/navigation_cancel_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_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_refresh">@drawable/navigation_refresh_dark</item>
|
||||||
<item name="attr/navigation_up">@drawable/navigation_up_dark</item>
|
<item name="attr/navigation_up">@drawable/navigation_up_dark</item>
|
||||||
<item name="attr/social_share">@drawable/social_share_dark</item>
|
<item name="attr/social_share">@drawable/social_share_dark</item>
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue