Android Open Source - no-cloud-share Checkable Relative Layout






From Project

Back to project page no-cloud-share.

License

The source code is released under:

GNU General Public License

If you think the Android project no-cloud-share 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 de.ub0r.android.nocloudshare.views;
/*w w  w .j a  v a2 s  . c  o  m*/
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.RelativeLayout;

/**
 * A checkable RelativeLayout.
 *
 * @author flx
 */
public class CheckableRelativeLayout extends RelativeLayout implements Checkable {

    private static final int[] STATE_CHECKABLE = {android.R.attr.state_checked};

    private boolean mIsChecked;

    @SuppressWarnings("UnusedDeclaration")
    public CheckableRelativeLayout(final Context context) {
        super(context);
    }

    @SuppressWarnings("UnusedDeclaration")
    public CheckableRelativeLayout(final Context context, final AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean isChecked() {
        return mIsChecked;
    }

    @Override
    public void setChecked(final boolean checked) {
        mIsChecked = checked;
        setChecked(this, checked);
        refreshDrawableState();
    }

    private void setChecked(final View child, final boolean checked) {
        if (child != this) {
            if (child instanceof Checkable) {
                ((Checkable) child).setChecked(checked);
            }
            child.setSelected(checked);
        }
        if (child instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) child;
            int l = vg.getChildCount();
            for (int i = 0; i < l; i++) {
                setChecked(vg.getChildAt(i), checked);
            }
        }
    }

    @Override
    public void toggle() {
        setChecked(!mIsChecked);
    }

    @Override
    protected int[] onCreateDrawableState(final int extraSpace) {
        int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
        if (mIsChecked) {
            mergeDrawableStates(drawableState, STATE_CHECKABLE);
        }
        return drawableState;
    }
}




Java Source Code List

de.ub0r.android.nocloudshare.AboutActivity.java
de.ub0r.android.nocloudshare.HttpService.java
de.ub0r.android.nocloudshare.IntroActivity.java
de.ub0r.android.nocloudshare.SettingsActivity.java
de.ub0r.android.nocloudshare.ShareActivity.java
de.ub0r.android.nocloudshare.ShareFragment.java
de.ub0r.android.nocloudshare.ShareListActivity.java
de.ub0r.android.nocloudshare.http.BitmapLruCache.java
de.ub0r.android.nocloudshare.http.Httpd.java
de.ub0r.android.nocloudshare.model.GsonFactory.java
de.ub0r.android.nocloudshare.model.ShareItemContainer.java
de.ub0r.android.nocloudshare.model.ShareItem.java
de.ub0r.android.nocloudshare.views.CheckableRelativeLayout.java
de.ub0r.android.nocloudshare.views.MeasuringRelativeLayout.java
fi.iki.elonen.NanoHTTPD.java