Android Open Source - android-tools View Collection






From Project

Back to project page android-tools.

License

The source code is released under:

MIT License

If you think the Android project android-tools 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 net.comfreeze.lib.views;
/*  w w  w  .ja va2  s. c  o  m*/
import android.view.View;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Set;

public class ViewCollection<E> {
    private static final String TAG = ViewCollection.class.getSimpleName();

    public static boolean silent = true;

    private Class<E> clazz;

    public LinkedHashMap<String, E> map = new LinkedHashMap<String, E>();

    public ViewCollection() {
        this.clazz = (Class<E>) this.getClass();
    }

    public E find(View parent, String name) {
        return (E) parent.findViewWithTag(name);
    }

    public ViewCollection add(String name, E view) {
        if (null != name && null != view)
            map.put(name, view);
        return this;
    }

    public ViewCollection add(String name, View parent, int resId) {
        return add(name, parent, resId, false);
    }

    public ViewCollection add(String name, View parent, int resId, boolean tag) {
        E target = (E) parent.findViewById(resId);
        if (null == target)
            target = find(parent, name);
        if (null != name && null != target)
            map.put(name, target);
        if (null != target && tag)
            ((View) target).setTag(name);
        return this;
    }

    public boolean contains(String name) {
        return map.containsKey(name);
    }

    public boolean contains(E value) {
        return map.containsValue(value);
    }

    public E get(String name) {
        if (map.containsKey(name))
            return (E) map.get(name);
        return null;
    }

    public int count() {
        return map.size();
    }

    public ViewCollection clear() {
        map.clear();
        return this;
    }

    public Collection<E> getViews() {
        return map.values();
    }

    public Set<String> getNames() {
        return map.keySet();
    }

    public static final class InvalidCollectionNameException extends Exception {
    }

    ;

    public static final class InvalidViewException extends Exception {
    }

    ;

    public static final class InvalidResourceException extends Exception {
    }

    ;
}




Java Source Code List

net.comfreeze.lib.BundleBuilder.java
net.comfreeze.lib.CFZApplication.java
net.comfreeze.lib.ContentValueBuilder.java
net.comfreeze.lib.FragmentMap.java
net.comfreeze.lib.adapter.HeaderListAdapter.java
net.comfreeze.lib.adapter.IHeaderListAdapter.java
net.comfreeze.lib.adapter.SeparatedListAdapter.java
net.comfreeze.lib.api.BaseAPI.java
net.comfreeze.lib.api.RestAPI.java
net.comfreeze.lib.api.XMLAPI.java
net.comfreeze.lib.api.helper.CursorHelper.java
net.comfreeze.lib.api.helper.JSONHelper.java
net.comfreeze.lib.api.helper.ModelHelper.java
net.comfreeze.lib.api.xml.WordpressAPI.java
net.comfreeze.lib.audio.SoundManager.java
net.comfreeze.lib.db.DatabaseHelper.java
net.comfreeze.lib.db.DatabaseTable.java
net.comfreeze.lib.db.helper.HelperCursor.java
net.comfreeze.lib.db.model.CFZModel.java
net.comfreeze.lib.db.model.FieldColumnMap.java
net.comfreeze.lib.fragments.CFZListFragment.java
net.comfreeze.lib.provider.CFZSimpleProvider.java
net.comfreeze.lib.service.CFZService.java
net.comfreeze.lib.ui.SupportFragmentActivity.java
net.comfreeze.lib.ui.dialog.CFZDialogProgress.java
net.comfreeze.lib.ui.fragment.CFZFragmentBase.java
net.comfreeze.lib.views.BiScrollView.java
net.comfreeze.lib.views.CFZViewHelper.java
net.comfreeze.lib.views.FlowLayout.java
net.comfreeze.lib.views.GestureHelper.java
net.comfreeze.lib.views.HeaderListView.java
net.comfreeze.lib.views.ResizingView.java
net.comfreeze.lib.views.ViewCollection.java
net.comfreeze.lib.views.ViewUtils.java
net.comfreeze.lib.xml.XMLParser.java
net.comfreeze.lib.xml.wordpress.FeedXmlParser.java