Android Open Source - ElyTheme Card Header






From Project

Back to project page ElyTheme.

License

The source code is released under:

GNU General Public License

If you think the Android project ElyTheme listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.afollestad.cardsui;
/*  ww w  .j a  va2 s.co  m*/
import android.content.Context;
import android.graphics.drawable.Drawable;

/**
 * Represents a header displayed at the top of a set of cards.
 *
 * @author Aidan Follestad (afollestad)
 */
public class CardHeader extends Card {

    private String mActionTitle;
    private ActionListener mCallback;

    public CardHeader(String title) {
        super(title, null, true);
    }

    public CardHeader(String title, String subtitle) {
        super(title, subtitle, true);
    }

    public CardHeader(Context context, int titleRes) {
        this(context.getString(titleRes));
    }

    public CardHeader(Context context, String title, int subtitleRes) {
        this(title, context.getString(subtitleRes));
    }

    public CardHeader(Context context, int titleRes, String subtitle) {
        this(context.getString(titleRes), subtitle);
    }

    public CardHeader(Context context, int titleRes, int subtitleRes) {
        this(context.getString(titleRes), context.getString(subtitleRes));
    }

    @Override
    public ActionListener getActionCallback() {
        return mCallback;
    }

    /**
     * Sets the cards action and uses the default action text ("See More").
     *
     * @param callback The action listener invoked when the header is tapped.
     */
    public CardHeader setAction(ActionListener callback) {
        mActionTitle = null;
        mCallback = callback;
        return this;
    }

    /**
     * Sets the cards action and action title.
     *
     * @param title    The text to be displayed on the action button (defaults to "See More").
     * @param callback The action listener invoked when the header is tapped.
     */
    public CardHeader setAction(String title, ActionListener callback) {
        mActionTitle = title;
        mCallback = callback;
        return this;
    }

    /**
     * Sets the cards action and action title.
     *
     * @param context  The context used to resolve the string resource ID.
     * @param titleRes The string resource to be displayed on the action button (defaults to "See More").
     * @param callback The action listener invoked when the header is tapped.
     */
    public CardHeader setAction(Context context, int titleRes, ActionListener callback) {
        setAction(context.getString(titleRes), callback);
        return this;
    }

    @Override
    public String getActionTitle() {
        return mActionTitle;
    }

    /**
     * @deprecated This method cannot be called for headers, it only works with regular {@link com.afollestad.cardsui.Card} objects.
     */
    @Override
    public Card setThumbnail(Drawable drawable) {
        throw new RuntimeException("Card headers do not support setThumbnail().");
    }

    /**
     * @deprecated This method cannot be called for headers, it only works with regular {@link com.afollestad.cardsui.Card} objects.
     */
    @Override
    public Card setLayout(int layoutRes) {
        throw new RuntimeException("Card headers do not support setLayout().");
    }

    public interface ActionListener {
        public void onHeaderActionClick(CardHeader header);
    }
}




Java Source Code List

com.afollestad.cardsui.ApplicationTest.java
com.afollestad.cardsui.CardAdapter.java
com.afollestad.cardsui.CardBase.java
com.afollestad.cardsui.CardCenteredHeader.java
com.afollestad.cardsui.CardCompressed.java
com.afollestad.cardsui.CardCursorAdapter.java
com.afollestad.cardsui.CardHeader.java
com.afollestad.cardsui.CardListView.java
com.afollestad.cardsui.CardTheme.java
com.afollestad.cardsui.Card.java
com.afollestad.silk.ApplicationTest.java
com.afollestad.silk.SilkComparable.java
com.afollestad.silk.SilkCursorItem.java
com.afollestad.silk.Silk.java
com.afollestad.silk.activities.SilkDrawerActivity.java
com.afollestad.silk.adapters.ScrollStatePersister.java
com.afollestad.silk.adapters.SilkAdapter.java
com.afollestad.silk.adapters.SilkCursorAdapter.java
com.afollestad.silk.adapters.SilkSpinnerAdapter.java
com.afollestad.silk.dialogs.SilkDialog.java
com.afollestad.silk.fragments.feed.SilkCursorFeedFragment.java
com.afollestad.silk.fragments.feed.SilkFeedFragment.java
com.afollestad.silk.fragments.list.SilkCursorListFragment.java
com.afollestad.silk.fragments.list.SilkListFragment.java
com.afollestad.silk.http.SilkHttpBase.java
com.afollestad.silk.http.SilkHttpBody.java
com.afollestad.silk.http.SilkHttpCallback.java
com.afollestad.silk.http.SilkHttpClient.java
com.afollestad.silk.http.SilkHttpException.java
com.afollestad.silk.http.SilkHttpHeader.java
com.afollestad.silk.http.SilkHttpResponse.java
com.afollestad.silk.utilities.IOUtils.java
com.afollestad.silk.utilities.TimeUtils.java
com.afollestad.silk.views.ClickableToast.java
com.afollestad.silk.views.list.OnSilkScrollListener.java
com.afollestad.silk.views.list.SilkGridView.java
com.afollestad.silk.views.list.SilkListView.java
com.afollestad.silk.views.time.SilkDatePicker.java
it.gcaliendo.elytheme.Adw.java
it.gcaliendo.elytheme.ApplicationTest.java
it.gcaliendo.elytheme.DocksProvider.java
it.gcaliendo.elytheme.Docks.java
it.gcaliendo.elytheme.IconActivity.java
it.gcaliendo.elytheme.IconPack.java
it.gcaliendo.elytheme.IconsProvider.java
it.gcaliendo.elytheme.Icons.java
it.gcaliendo.elytheme.RequestActivity.java
it.gcaliendo.elytheme.ThemeActivity.java
it.gcaliendo.elytheme.Wallpaper.java
it.gcaliendo.elytheme.fragments.FragmentAbout.java
it.gcaliendo.elytheme.fragments.FragmentContact.java
it.gcaliendo.elytheme.fragments.FragmentExtras.java
it.gcaliendo.elytheme.fragments.FragmentTheme.java
it.gcaliendo.elytheme.helper.AppInfo.java
it.gcaliendo.elytheme.iconfragment.IconFragmentGames.java
it.gcaliendo.elytheme.iconfragment.IconFragmentLatest.java
it.gcaliendo.elytheme.iconfragment.IconFragmentMisc.java
it.gcaliendo.elytheme.iconfragment.IconFragmentPlay.java
it.gcaliendo.elytheme.iconfragment.IconFragmentSystem.java