Exemplo n.º 1
0
 // Receives callback from color chooser dialog
 @Override
 public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int color) {
   if (dialog.isAccentMode()) {
     accentPreselect = color;
     ThemeSingleton.get().positiveColor = DialogUtils.getActionTextStateList(this, color);
     ThemeSingleton.get().neutralColor = DialogUtils.getActionTextStateList(this, color);
     ThemeSingleton.get().negativeColor = DialogUtils.getActionTextStateList(this, color);
     ThemeSingleton.get().widgetColor = color;
   } else {
     primaryPreselect = color;
     if (getSupportActionBar() != null)
       getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
       getWindow().setStatusBarColor(CircleView.shiftColorDown(color));
       getWindow().setNavigationBarColor(color);
     }
   }
 }
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   if (convertView == null) {
     convertView = new CircleView(getContext());
     convertView.setLayoutParams(new GridView.LayoutParams(mCircleSize, mCircleSize));
   }
   CircleView child = (CircleView) convertView;
   final int color = isInSub() ? mColorsSub[topIndex()][position] : mColorsTop[position];
   child.setBackgroundColor(color);
   if (isInSub()) child.setSelected(subIndex() == position);
   else child.setSelected(topIndex() == position);
   child.setTag(position);
   child.setOnClickListener(ColorChooserDialog.this);
   return convertView;
 }