Example usage for android.support.v4.view ViewPager setTag

List of usage examples for android.support.v4.view ViewPager setTag

Introduction

In this page you can find the example usage for android.support.v4.view ViewPager setTag.

Prototype

public void setTag(final Object tag) 

Source Link

Document

Sets the tag associated with this view.

Usage

From source file:com.sun.toy.widget.CalendarView.java

public void setCurrentSelectedView(View view) {
    if (getParent() instanceof ViewPager) {
        ViewPager pager = (ViewPager) getParent();
        View tagView = (View) pager.getTag();
        if (tagView != null) {
            long time = (long) tagView.getTag();
            Calendar c = Calendar.getInstance();
            c.setTimeInMillis(time);/*from   w  w  w  .  j a  v  a  2  s. c  o  m*/
            for (int i = 0; i < pager.getChildCount(); i++) {
                for (int j = 0; j < getChildCount(); j++) {
                    CalendarItemView child = (CalendarItemView) ((CalendarView) pager.getChildAt(i))
                            .getChildAt(j);
                    if (child == null) {
                        continue;
                    }
                    if (child.isStaticText()) {
                        continue;
                    }
                    if (child.isSameDay((Long) child.getTag(), (Long) tagView.getTag())) {
                        child.invalidate();
                        break;
                    }
                }
            }
        }
        if (tagView == view) {
            pager.setTag(null);
            return;
        }
        long time = (long) view.getTag();
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(time);
        pager.setTag(view);
        view.invalidate();

    }
}

From source file:org.roxomi.roxy.snapdiary.widget.CalendarView.java

public void setCurrentSelectedView(View view) {
    if (getParent() instanceof ViewPager) {
        ViewPager pager = (ViewPager) getParent();
        View tagView = (View) pager.getTag();
        if (tagView != null) {
            long time = (long) tagView.getTag();
            Calendar c = Calendar.getInstance();
            c.setTimeInMillis(time);// w ww. j a  v a  2 s . co m
            for (int i = 0; i < pager.getChildCount(); i++) {
                for (int j = 0; j < getChildCount(); j++) {
                    CalendarItemView child = (CalendarItemView) ((CalendarView) pager.getChildAt(i))
                            .getChildAt(j);
                    if (child == null) {
                        continue;
                    }
                    if (child.isStaticText()) {
                        continue;
                    }
                    if (child.isSameDay((Long) child.getTag(), (Long) tagView.getTag())) {
                        child.invalidate();
                        break;
                    }
                }
            }
        }
        if (tagView == view) {
            pager.setTag(null);
            return;
        }
        long time = (long) view.getTag();
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(time);
        pager.setTag(view);
        view.invalidate();
    }
}