Android Open Source - Helpers Containers






From Project

Back to project page Helpers.

License

The source code is released under:

MIT License

If you think the Android project Helpers 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 at.wrdlbrnft.helpers;
//from w w w.j av  a  2  s  .  co  m
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Xaver on 26/08/14.
 */
public class Containers {

    public static Container<Context, String> string(int stringResId) {
        return new StringResourceContainer(stringResId);
    }

    public static <O extends View> Container<ViewGroup, O> view(int id) {
        return new ViewIdContainer<>(id);
    }

    public static <I, O> Container<I, O> item(final O item) {
        return new InstanceContainer<>(item);
    }

    private static class StringResourceContainer implements Container<Context, String> {

        private final int resId;

        private StringResourceContainer(int resId) {
            this.resId = resId;
        }

        @Override
        public String get(Context value) {
            return value.getString(resId);
        }
    }

    private static class ViewIdContainer<O extends View> implements Container<ViewGroup, O> {

        private final int id;

        private ViewIdContainer(int id) {
            this.id = id;
        }

        @Override
        public O get(ViewGroup value) {
            return (O) value.findViewById(this.id);
        }
    }

    private static class InstanceContainer<I, O> implements Container<I, O> {

        private final O instance;

        private InstanceContainer(O instance) {
            this.instance = instance;
        }

        @Override
        public O get(I value) {
            return this.instance;
        }
    }

}




Java Source Code List

at.wrdlbrnft.helpers.ApplicationTest.java
at.wrdlbrnft.helpers.AssetHelper.java
at.wrdlbrnft.helpers.Base64Coder.java
at.wrdlbrnft.helpers.BitHelper.java
at.wrdlbrnft.helpers.BitmapHelper.java
at.wrdlbrnft.helpers.Bundles.java
at.wrdlbrnft.helpers.CanvasHelper.java
at.wrdlbrnft.helpers.Container.java
at.wrdlbrnft.helpers.Containers.java
at.wrdlbrnft.helpers.Dates.java
at.wrdlbrnft.helpers.ExtrasBuilder.java
at.wrdlbrnft.helpers.IntentHelper.java
at.wrdlbrnft.helpers.LayoutHelper.java
at.wrdlbrnft.helpers.LogHelper.java
at.wrdlbrnft.helpers.Maps.java
at.wrdlbrnft.helpers.NetworkHelper.java
at.wrdlbrnft.helpers.Numbers.java
at.wrdlbrnft.helpers.PackageHelper.java
at.wrdlbrnft.helpers.ReflectionHelper.java
at.wrdlbrnft.helpers.SerializationHelper.java
at.wrdlbrnft.helpers.Sets.java
at.wrdlbrnft.helpers.StreamHelper.java
at.wrdlbrnft.helpers.Strings.java
at.wrdlbrnft.helpers.TypeHelper.java
at.wrdlbrnft.helpers.ViewHelper.java
at.wrdlbrnft.helpers.credentials.CredentialsFactory.java
at.wrdlbrnft.helpers.credentials.Credentials.java
at.wrdlbrnft.helpers.lists.Difference.java
at.wrdlbrnft.helpers.lists.Lists.java
at.wrdlbrnft.helpers.lists.UniqueIdProvider.java
at.wrdlbrnft.helpers.lists.UpdateInfo.java
at.wrdlbrnft.helpers.lists.UpdateValueContainer.java
at.wrdlbrnft.helpers.time.Time.java
at.wrdlbrnft.helpers.time.Times.java