Java Code Examples for android.support.v7.widget.CardView#setUseCompatPadding()

The following examples show how to use android.support.v7.widget.CardView#setUseCompatPadding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SettingPopup.java    From KakaoBot with GNU General Public License v3.0 6 votes vote down vote up
private void init() {
    LinearLayout frame = new LinearLayout(context);
    CardView card = new CardView(context);

    card.setUseCompatPadding(true);
    card.setContentPadding(MainActivity.dp(8), MainActivity.dp(8), MainActivity.dp(8), MainActivity.dp(8));
    card.setCardElevation(12.f);

    card.addView(layout);
    frame.addView(card);

    this.setContentView(frame);
    this.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    this.setFocusable(true);
    this.setBackgroundDrawable(new BitmapDrawable());
    this.setOutsideTouchable(true);
}
 
Example 2
Source File: AboutAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
ContributorsViewHolder(View itemView) {
    super(itemView);
    TextView title = itemView.findViewById(R.id.title);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        if (card != null) card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_people, color), null, null, null);
    title.setText(mContext.getResources().getString(R.string.about_contributors_title));

    title.setOnClickListener(this);
}
 
Example 3
Source File: HomeAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
ContentViewHolder(View itemView) {
    super(itemView);
    container = itemView.findViewById(R.id.container);
    autoFitTitle = itemView.findViewById(R.id.title);
    subtitle = itemView.findViewById(R.id.subtitle);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    container.setOnClickListener(this);
}
 
Example 4
Source File: HomeAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
IconRequestViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    installedApps = itemView.findViewById(R.id.installed_apps);
    missedApps = itemView.findViewById(R.id.missed_apps);
    themedApps = itemView.findViewById(R.id.themed_apps);
    progress = itemView.findViewById(R.id.progress);
    container = itemView.findViewById(R.id.container);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_icon_request, color), null, null, null);

    int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
    progress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);

    container.setOnClickListener(this);
}
 
Example 5
Source File: HomeAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
WallpapersViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    TextView muzei = itemView.findViewById(R.id.muzei);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_wallpapers, color), null, null, null);

    muzei.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.get(
            mContext, R.drawable.ic_home_app_muzei), null, null, null);

    title.setOnClickListener(this);
    muzei.setOnClickListener(this);
}
 
Example 6
Source File: HomeAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
GooglePlayDevViewHolder(View itemView) {
    super(itemView);
    container = itemView.findViewById(R.id.container);
    title = itemView.findViewById(R.id.title);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_google_play_more_apps, color), null, null, null);

    container.setOnClickListener(this);
}
 
Example 7
Source File: RequestAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
ContentViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.name);
    content = itemView.findViewById(R.id.requested);
    icon = itemView.findViewById(R.id.icon);
    checkbox = itemView.findViewById(R.id.checkbox);
    container = itemView.findViewById(R.id.container);
    divider = itemView.findViewById(R.id.divider);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getRequestStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        if (card != null) card.setCardElevation(0);
    }

    container.setOnClickListener(this);
    container.setOnLongClickListener(this);
}
 
Example 8
Source File: LauncherAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
ViewHolder(View itemView, int viewType) {
    super(itemView);
    if (viewType == TYPE_HEADER) {
        name = itemView.findViewById(R.id.name);
        holderId = TYPE_HEADER;
    } else if (viewType == TYPE_CONTENT) {
        icon = itemView.findViewById(R.id.icon);
        name = itemView.findViewById(R.id.name);
        container = itemView.findViewById(R.id.container);

        CardView card = itemView.findViewById(R.id.card);
        if (CandyBarApplication.getConfiguration().getApplyGrid() == CandyBarApplication.GridStyle.FLAT) {
            if (card.getLayoutParams() instanceof GridLayoutManager.LayoutParams) {
                card.setRadius(0f);
                card.setUseCompatPadding(false);
                int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
                GridLayoutManager.LayoutParams params = (GridLayoutManager.LayoutParams) card.getLayoutParams();
                params.setMargins(0, 0, margin, margin);

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    params.setMarginEnd(margin);
                }
            }
        }
        if (!Preferences.get(mContext).isCardShadowEnabled()) {
            if (card != null) card.setCardElevation(0);
        }

        holderId = TYPE_CONTENT;

        container.setOnClickListener(this);
    }
}
 
Example 9
Source File: AboutAdapter.java    From candybar-library with Apache License 2.0 4 votes vote down vote up
FooterViewHolder(View itemView) {
    super(itemView);
    ImageView instagram = itemView.findViewById(R.id.about_dev_instagram);
    ImageView googlePlus = itemView.findViewById(R.id.about_dev_google_plus);
    ImageView github = itemView.findViewById(R.id.about_dev_github);
    TextView title = itemView.findViewById(R.id.about_dashboard_title);
    TextView licenses = itemView.findViewById(R.id.about_dashboard_licenses);
    TextView contributors = itemView.findViewById(R.id.about_dashboard_contributors);
    TextView translator = itemView.findViewById(R.id.about_dashboard_translator);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        if (card != null) card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_dashboard, color), null, null, null);

    color = ConfigurationHelper.getSocialIconColor(mContext,
            CandyBarApplication.getConfiguration().getSocialIconColor());
    instagram.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_instagram, color));
    googlePlus.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_google_plus, color));
    github.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_github, color));

    instagram.setOnClickListener(this);
    googlePlus.setOnClickListener(this);
    github.setOnClickListener(this);
    licenses.setOnClickListener(this);
    contributors.setOnClickListener(this);
    translator.setOnClickListener(this);
}
 
Example 10
Source File: RequestAdapter.java    From candybar-library with Apache License 2.0 4 votes vote down vote up
HeaderViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    content = itemView.findViewById(R.id.content);
    button = itemView.findViewById(R.id.buy);

    container = itemView.findViewById(R.id.premium_request);
    total = itemView.findViewById(R.id.premium_request_total);
    available = itemView.findViewById(R.id.premium_request_available);
    used = itemView.findViewById(R.id.premium_request_used);
    progress = itemView.findViewById(R.id.progress);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getRequestStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled() && card != null) {
        card.setCardElevation(0);
    }

    int padding = mContext.getResources().getDimensionPixelSize(R.dimen.content_margin) +
            mContext.getResources().getDimensionPixelSize(R.dimen.icon_size_small);
    content.setPadding(padding, 0, 0, 0);
    container.setPadding(padding, 0, padding, 0);

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(
            DrawableHelper.getTintedDrawable(mContext,
                    R.drawable.ic_toolbar_premium_request, color),
            null, null, null);

    int primary = ColorHelper.getAttributeColor(mContext, R.attr.colorPrimary);
    int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
    button.setTextColor(ColorHelper.getTitleTextColor(primary));

    progress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);

    button.setOnClickListener(this);
}