ShadowView.java revision eaadc83b187e31670dec8837d0851c0646522987
1package com.xtremelabs.droidsugar.view; 2 3import android.content.Context; 4import android.content.res.Resources; 5import android.view.View; 6 7import java.util.ArrayList; 8import java.util.List; 9 10@SuppressWarnings({"ALL"}) 11public class FakeView { 12 private View realView; 13 14 private int id; 15 private List<View> children = new ArrayList<View>(); 16 private Context context; 17 private int visibility; 18 public boolean selected; 19 20 public FakeView(View view) { 21 this.realView = view; 22 } 23 24 public void __constructor__(Context context) { 25 this.context = context; 26 } 27 28 public void setId(int id) { 29 this.id = id; 30 } 31 32 public int getId() { 33 return id; 34 } 35 36 public View findViewById(int id) { 37 if (id == this.id) { 38 return realView; 39 } 40 41 for (View child : children) { 42 View found = child.findViewById(id); 43 if (found != null) { 44 return found; 45 } 46 } 47 return null; 48 } 49 50 public void addView(View child) { 51 children.add(child); 52 } 53 54 public int getChildCount() { 55 return children.size(); 56 } 57 58 public View getChildAt(int index) { 59 return children.get(index); 60 } 61 62 public final Context getContext() { 63 return context; 64 } 65 66 public Resources getResources() { 67 return context.getResources(); 68 } 69 70 public int getVisibility() { 71 return visibility; 72 } 73 74 public void setVisibility(int visibility) { 75 this.visibility = visibility; 76 } 77 78 public void setSelected(boolean selected) { 79 this.selected = selected; 80 } 81} 82