Advertisement
Guest User

Untitled

a guest
Feb 24th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package nl.rigault.colormix.view;
  2.  
  3. import java.util.Observable;
  4. import java.util.Observer;
  5.  
  6. import nl.rigault.colormix.R;
  7. import nl.rigault.colormix.model.ColorModel;
  8.  
  9. import android.content.Context;
  10. import android.graphics.Color;
  11. import android.util.AttributeSet;
  12. import android.view.LayoutInflater;
  13. import android.widget.ImageView;
  14. import android.widget.LinearLayout;
  15.  
  16. public class RGBColorView extends LinearLayout implements Observer {
  17.  
  18.     private ColorModel model;
  19.    
  20.     private ImageView colorMixImage;
  21.    
  22.     public RGBColorView(Context context, AttributeSet attrs, int defStyle) {
  23.         super(context, attrs, defStyle);
  24.         init();
  25.     }
  26.    
  27.    
  28.    
  29.     private void init() {
  30.        
  31.        
  32.         LayoutInflater  inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  33.         inflater.inflate(R.layout.rgbcolorview, this);
  34.        
  35.         colorMixImage = (ImageView) findViewById(R.id.ColorMixView);
  36.        
  37.         model = ColorModel.getInstance();
  38.     }
  39.  
  40.  
  41.  
  42.     @Override
  43.     public void update(Observable arg0, Object arg1) {
  44.         colorMixImage.setBackgroundColor(Color.rgb(model.getR(), model.getG(), model.getB()));
  45.        
  46.     }
  47.    
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement