Back to project page SpunkyCharts.
The source code is released under:
GNU General Public License
If you think the Android project SpunkyCharts listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jogden.spunkycharts.misc; /* /*ww w . ja va 2 s. c o m*/ Copyright (C) 2014 Jonathon Ogden < jeog.dev@gmail.com > This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses. */ import com.jogden.spunkycharts.R; import android.app.Dialog; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.view.Window; /** Dialog consisting of 12 basic colors a user can select */ public class ColorPaletteDialog extends Dialog { private int colorId; public ColorPaletteDialog(Context context, int colorId) { super(context); this.colorId = colorId; this.requestWindowFeature( Window.FEATURE_NO_TITLE ); this.setContentView(R.layout.color_palette12); _setBoxClickHandlers( this.findViewById(R.id.color_paletted_12) ); } public int getColorId() { return colorId; } private void _setBoxClickHandlers(View view) { if( ViewGroup.class.isInstance(view) ) for(int i = ((ViewGroup)view).getChildCount(); i > 0; --i) _setBoxClickHandlers( ((ViewGroup)view).getChildAt(i-1) ); else if( (view.getClass()).equals( View.class) ) view.setOnClickListener( new View.OnClickListener(){ @Override public void onClick(View v) { colorId = Integer.valueOf((String) v.getTag()); dismiss(); } } ); } }