Search in sources :

Example 1 with ToolTip

use of com.github.xizzhu.simpletooltip.ToolTip in project simple-tool-tip by xizzhu.

the class MainActivity method createToolTip.

private ToolTip createToolTip(CharSequence text, int backgroundColor) {
    Resources resources = getResources();
    int padding = resources.getDimensionPixelSize(R.dimen.padding);
    int textSize = resources.getDimensionPixelSize(R.dimen.text_size);
    int radius = resources.getDimensionPixelSize(R.dimen.radius);
    return new ToolTip.Builder().withText(text).withTextColor(Color.WHITE).withTextSize(textSize).withBackgroundColor(backgroundColor).withPadding(padding, padding, padding, padding).withCornerRadius(radius).build();
}
Also used : ToolTip(com.github.xizzhu.simpletooltip.ToolTip) Resources(android.content.res.Resources)

Example 2 with ToolTip

use of com.github.xizzhu.simpletooltip.ToolTip in project WordPress-Android by wordpress-mobile.

the class MeFragment method showGravatarTooltipIfNeeded.

private void showGravatarTooltipIfNeeded() {
    if (!isAdded() || !mAccountStore.hasAccessToken() || !AppPrefs.isGravatarChangePromoRequired() || !mIsUserVisible || mGravatarToolTipView != null) {
        return;
    }
    ToolTip toolTip = createGravatarPromoToolTip(getString(R.string.gravatar_tip), ContextCompat.getColor(getActivity(), R.color.color_primary));
    mGravatarToolTipView = new ToolTipView.Builder(getActivity()).withAnchor(mAvatarTooltipAnchor).withToolTip(toolTip).withGravity(Gravity.END).build();
    mGravatarToolTipView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AnalyticsTracker.track(AnalyticsTracker.Stat.ME_GRAVATAR_TOOLTIP_TAPPED);
            mGravatarToolTipView.remove();
            AppPrefs.setGravatarChangePromoRequired(false);
        }
    });
    mGravatarToolTipView.showDelayed(500);
}
Also used : ToolTip(com.github.xizzhu.simpletooltip.ToolTip) ToolTipView(com.github.xizzhu.simpletooltip.ToolTipView) View(android.view.View) TextView(android.widget.TextView) WPNetworkImageView(org.wordpress.android.widgets.WPNetworkImageView) ToolTipView(com.github.xizzhu.simpletooltip.ToolTipView)

Example 3 with ToolTip

use of com.github.xizzhu.simpletooltip.ToolTip in project WordPress-Android by wordpress-mobile.

the class MeFragment method createGravatarPromoToolTip.

private ToolTip createGravatarPromoToolTip(CharSequence text, int backgroundColor) {
    Resources resources = getResources();
    int padding = resources.getDimensionPixelSize(R.dimen.tooltip_padding);
    int textSize = resources.getDimensionPixelSize(R.dimen.tooltip_text_size);
    int radius = resources.getDimensionPixelSize(R.dimen.tooltip_radius);
    return new ToolTip.Builder().withText(text).withTextColor(Color.WHITE).withTextSize(textSize).withBackgroundColor(backgroundColor).withPadding(padding, padding, padding, padding).withCornerRadius(radius).build();
}
Also used : ToolTip(com.github.xizzhu.simpletooltip.ToolTip) Resources(android.content.res.Resources)

Example 4 with ToolTip

use of com.github.xizzhu.simpletooltip.ToolTip in project simple-tool-tip by xizzhu.

the class MainActivity method showToolTipView.

private void showToolTipView(final View anchorView, int gravity, CharSequence text, int backgroundColor, long delay) {
    if (anchorView.getTag() != null) {
        ((ToolTipView) anchorView.getTag()).remove();
        anchorView.setTag(null);
        return;
    }
    ToolTip toolTip = createToolTip(text, backgroundColor);
    ToolTipView toolTipView = createToolTipView(toolTip, anchorView, gravity);
    if (delay > 0L) {
        toolTipView.showDelayed(delay);
    } else {
        toolTipView.show();
    }
    anchorView.setTag(toolTipView);
    toolTipView.setOnToolTipClickedListener(new ToolTipView.OnToolTipClickedListener() {

        @Override
        public void onToolTipClicked(ToolTipView toolTipView) {
            anchorView.setTag(null);
        }
    });
}
Also used : ToolTip(com.github.xizzhu.simpletooltip.ToolTip) ToolTipView(com.github.xizzhu.simpletooltip.ToolTipView)

Aggregations

ToolTip (com.github.xizzhu.simpletooltip.ToolTip)4 Resources (android.content.res.Resources)2 ToolTipView (com.github.xizzhu.simpletooltip.ToolTipView)2 View (android.view.View)1 TextView (android.widget.TextView)1 WPNetworkImageView (org.wordpress.android.widgets.WPNetworkImageView)1