Java Code Examples for android.graphics.Color

The following are top voted examples for showing how to use android.graphics.Color. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: SingleRequestTest.java   View source code 8 votes vote down vote up
@Test
public void testDoesNotSetErrorDrawableIfRequestCoordinatorDoesntAllowIt() {
  harness.errorDrawable = new ColorDrawable(Color.RED);
  SingleRequest<List> request = harness.getRequest();
  when(harness.requestCoordinator.canNotifyStatusChanged(any(Request.class))).thenReturn(false);
  request.onLoadFailed(new GlideException("test"));

  verify(harness.target, never()).onLoadFailed(any(Drawable.class));
}
 
Example 2
Project: baselibrary-master   File: SmoothCheckBox.java   View source code 6 votes vote down vote up
private static int getGradientColor(int startColor, int endColor, float percent)
{
    int startA = Color.alpha(startColor);
    int startR = Color.red(startColor);
    int startG = Color.green(startColor);
    int startB = Color.blue(startColor);

    int endA = Color.alpha(endColor);
    int endR = Color.red(endColor);
    int endG = Color.green(endColor);
    int endB = Color.blue(endColor);

    int currentA = (int) (startA * (1 - percent) + endA * percent);
    int currentR = (int) (startR * (1 - percent) + endR * percent);
    int currentG = (int) (startG * (1 - percent) + endG * percent);
    int currentB = (int) (startB * (1 - percent) + endB * percent);
    return Color.argb(currentA, currentR, currentG, currentB);
}
 
Example 3
Project: XERUNG   File: Slider.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	super.onCreate(savedInstanceState);
	setContentView(R.layout.number_indicator_spinner);
	setCanceledOnTouchOutside(false);

	RelativeLayout content = (RelativeLayout) this.findViewById(R.id.number_indicator_spinner_content);
	indicator = new Indicator(this.getContext());
	content.addView(indicator);

	numberIndicator = new TextView(getContext());
	numberIndicator.setTextColor(Color.WHITE);
	numberIndicator.setGravity(Gravity.CENTER);
	content.addView(numberIndicator);

	indicator.setLayoutParams(new RelativeLayout.LayoutParams(
			RelativeLayout.LayoutParams.MATCH_PARENT,
			RelativeLayout.LayoutParams.MATCH_PARENT));
}
 
Example 4
Project: KernelAdiutor-Mod   File: ColorTable.java   View source code 6 votes vote down vote up
@Override
public void draw(Canvas canvas) {
    super.draw(canvas);

    float width = getMeasuredWidth();
    float height = getMeasuredHeight();

    for (int i = 0; i < sColors.length; i++) {
        float top = height / sColors.length * i;
        float bottom = height / sColors.length * (i + 1);
        for (int x = 0; x < sColors[i].length; x++) {
            float left = width / sColors[i].length * x;
            float right = width / sColors[i].length * (x + 1);
            mColorPaint.setColor(Color.parseColor(sColors[i][x]));
            canvas.drawRect(left, top, right, bottom, mColorPaint);
        }
    }
}
 
Example 5
Project: Hillffair17   File: HomeAdapter.java   View source code 6 votes vote down vote up
@Override
public void onBindViewHolder(viewHolder holder, int position) {

    HomeModel m=arrayList.get(position);
    holder.imageView.setImageResource(m.getPhoto_id());
    holder.textView.setText(m.getName());

    if(position==0)
        holder.cardView.setBackgroundColor(Color.rgb(255,205,210));
    else if(position==1)
        holder.cardView.setBackgroundColor(Color.rgb(157,255,164));
    else if(position==2)
        holder.cardView.setBackgroundColor(Color.rgb(209,196,233));
    else if(position==3)
        holder.cardView.setBackgroundColor(Color.rgb(187,222,251));
    else if(position==4)
        holder.cardView.setBackgroundColor(Color.rgb(255,204,128));
    else if(position==5)
        holder.cardView.setBackgroundColor(Color.rgb(255,245,157));
    else if(position==6)
        holder.cardView.setBackgroundColor(Color.rgb(248,187,208));
    else if(position==7)
        holder.cardView.setBackgroundColor(Color.rgb(198,193,250));

}
 
Example 6
Project: CCDownload   File: InputInfoActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	service = new Intent(this, UploadService.class);
	inputLayout = new RelativeLayout(this);
	inputLayout.setBackgroundColor(Color.WHITE);
	inputLayout.setHorizontalGravity(Gravity.CENTER_HORIZONTAL);
	inputLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	getCategory();
	initView();
	
       bindService(service, serviceConnection, Context.BIND_AUTO_CREATE);
	
       String path = getIntent().getStringExtra("filePath");
       if (path != null) {
       	filePath = path;
	}
       
       getActionBar().setDisplayHomeAsUpEnabled(true);
       uploadButton.setOnClickListener(this);
       
       setContentView(inputLayout);
}
 
Example 7
Project: boohee_v5.6   File: BooheeCircleProgressBar.java   View source code 6 votes vote down vote up
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int width = getWidth();
    int height = getHeight();
    if (width != height) {
        int min = Math.min(width, height);
        width = min;
        height = min;
    }
    this.paint.setAntiAlias(true);
    this.paint.setColor(-1);
    canvas.drawColor(0);
    this.paint.setStrokeWidth((float) this.progressStrokeWidth);
    this.paint.setStyle(Style.STROKE);
    this.oval.left = (float) (this.progressStrokeWidth / 2);
    this.oval.top = (float) (this.progressStrokeWidth / 2);
    this.oval.right = (float) (width - (this.progressStrokeWidth / 2));
    this.oval.bottom = (float) (height - (this.progressStrokeWidth / 2));
    this.paint.setColor(Color.parseColor("#4cd964"));
    canvas.drawArc(this.oval, -90.0f, 360.0f * (((float) this.progress) / ((float) this
            .maxProgress)), false, this.paint);
}
 
Example 8
Project: SmoothChartView   File: SmoothLineChartView.java   View source code 6 votes vote down vote up
public SmoothLineChartView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContext = context;
    float scale = context.getResources().getDisplayMetrics().density;
    mCircleSize = scale * CIRCLE_SIZE;
    mStrokeSize = scale * STROKE_SIZE;
    mSelectedCircleSize = scale * SELECTED_CIRCLE_SIZE;
    mEnableDrawArea = true;
    mEnableShowTag = true;
    mDrawAreaColor = (CHART_COLOR & 0xFFFFFF) | 0x10000000;
    mLineColor = CHART_COLOR;
    mCircleColor = CHART_COLOR;
    mInnerCircleColor = Color.WHITE;
    mTextColor = Color.WHITE;
    mTextSize = DensityUtils.sp2px(context, 12);
    mTextOffset = TEXT_POSITION_OFFSET;
    mNodeStyle = NODE_STYLE_CIRCLE;
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPath = new Path();
    mBorder = 2 * mCircleSize;
}
 
Example 9
Project: Mire   File: MorphTransform.java   View source code 6 votes vote down vote up
public static void setup(@NonNull Activity activity, @Nullable View targetView, @ColorInt int endColor, int endCornerRadius) 
{
       final Intent intent = activity.getIntent();
       if (intent == null || !intent.hasExtra(EXTRA_SHARED_ELEMENT_START_COLOR) || !intent.hasExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS))
	{
		return;
	}

       final int startColor = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_COLOR, Color.TRANSPARENT);
       final int startCornerRadius = intent.getIntExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, 0);

       final MorphTransform sharedEnter = new MorphTransform(startColor, endColor, startCornerRadius, endCornerRadius);
       final MorphTransform sharedReturn = new MorphTransform(endColor, startColor, endCornerRadius, startCornerRadius);
       if (targetView != null)
	{
           sharedEnter.addTarget(targetView);
           sharedReturn.addTarget(targetView);
       }
       activity.getWindow().setSharedElementEnterTransition(sharedEnter);
       activity.getWindow().setSharedElementReturnTransition(sharedReturn);
   }
 
Example 10
Project: Qeet-Remote   File: ToastListAdapter.java   View source code 6 votes vote down vote up
@Override
public void onBindViewHolder(ToastViewHolder holder, int position) {
    holder.name.setText(list.get(position).getName());
    holder.status.setText(list.get(position).getStatus());
    if(list.get(position).getStatus().toString().equals(this.context.getResources().getString(R.string.on).toString()) ){
        //holder.status.setBackgroundColor(Color.parseColor("#dff2bf"));
        holder.status.setBackgroundColor(context.getResources().getColor(R.color.colorAccent));

        holder.status.setTextColor(Color.parseColor("#4f8a10"));
    }
    else if(list.get(position).getStatus().toString().equals("off")){
        holder.status.setBackgroundColor(context.getResources().getColor(R.color.greyColor));
    }
    else {
        holder.status.setBackgroundColor(context.getResources().getColor(R.color.errorBackground));
        holder.status.setTextColor(context.getResources().getColor(R.color.errorTextColor));
    }
}
 
Example 11
Project: FastEc   File: ShopCartDelegate.java   View source code 6 votes vote down vote up
@OnClick(R2.id.icon_shop_cart_select_all)
void onClickSelectAll() {

    final int tag = (int) mIconSelectAll.getTag();
    if (tag == 0) {
        mIconSelectAll.setTextColor
                (ContextCompat.getColor(getContext(), R.color.app_main));
        mIconSelectAll.setTag(1);
        mAdapter.setIsSelectedAll(true);
        //更新RecyclerView的显示状态
        mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount());
    } else {
        mIconSelectAll.setTextColor(Color.GRAY);
        mIconSelectAll.setTag(0);
        mAdapter.setIsSelectedAll(false);
        mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount());
    }


}
 
Example 12
Project: Pocket-Plays-for-Twitch   File: Service.java   View source code 6 votes vote down vote up
public static Bitmap makeTransparent(Bitmap bit, int transparentColor) {
	int width =  bit.getWidth();
	int height = bit.getHeight();
	Bitmap myBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
	int [] allpixels = new int [ myBitmap.getHeight()*myBitmap.getWidth()];
	bit.getPixels(allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());
	myBitmap.setPixels(allpixels, 0, width, 0, 0, width, height);

	for(int i =0; i<myBitmap.getHeight()*myBitmap.getWidth();i++){
		if( allpixels[i] == transparentColor)
			allpixels[i] = Color.alpha(Color.TRANSPARENT);
	}

	myBitmap.setPixels(allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());
	return myBitmap;
}
 
Example 13
Project: MySelfDemo   File: MyView2.java   View source code 6 votes vote down vote up
/**
 * 画扇形
 *
 * @param canvas
 */
private void drawArc(Canvas canvas) {
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.RED);
    paint.setAntiAlias(true);
    float x = (getWidth() - getHeight() / 2) / 2;
    float y = getHeight() / 4;

    RectF oval = new RectF(x, y,
            getWidth() - x, getHeight() - y);
    canvas.drawRect(oval, paint);

    Paint paint_over = new Paint();
    paint_over.setStyle(Paint.Style.FILL);
    paint_over.setColor(Color.BLUE);

    canvas.drawArc(oval, -90, 90, true, paint_over);//其中的参数 : RectF oval 一个矩形  , float startAngle 开始的偏移量 正数代表顺时针  负数代表逆时针, float sweepAngle  画圈的大下, boolean useCenter 是否连接到圆心,@NonNull Paint paint
}
 
Example 14
Project: WaveAudioVizualization   File: VoiceWaveViewTV.java   View source code 6 votes vote down vote up
@Override   // will be called on UI thread
public void onSurfaceTextureAvailable(SurfaceTexture st, int width, int height) {
    Log.d(TAG, "onSurfaceTextureAvailable(" + width + "x" + height + ")");
    mWidth = width;
    mHeight = height;
    mMaxAmpl = height / 2;
    mPaints.get(0).setShader(new LinearGradient(0, 0, mWidth, mHeight, Color.parseColor("#CA67B7"), Color.parseColor("#C081C1"), Shader.TileMode.MIRROR));
    mPaints.get(0).setStrokeWidth(ScreenUtils.dp2px(getContext(), 2));
    mPaints.get(1).setColor(Color.parseColor("#D5E3FA"));
    mPaints.get(1).setStrokeWidth(ScreenUtils.dp2px(getContext(), 2));
    mPaints.get(2).setStrokeWidth(ScreenUtils.dp2px(getContext(), 1));
    mPaints.get(3).setStrokeWidth(ScreenUtils.dp2px(getContext(), 1));
    mPaints.get(2).setShader(new LinearGradient(0, 0, mWidth, mHeight, Color.parseColor("#E67EA5"), Color.parseColor("#7F7AE1"), Shader.TileMode.MIRROR));
    mPaints.get(3).setShader(new LinearGradient(0, 0, mWidth, mHeight, Color.parseColor("#E67EA5"), Color.parseColor("#7F7AE1"), Shader.TileMode.MIRROR));
    synchronized (mLock) {
        mSurfaceTexture = st;
        mLock.notify();
    }
}
 
Example 15
Project: SmartChart   File: PieChartRenderer.java   View source code 6 votes vote down vote up
public PieChartRenderer(Context context, Chart chart, PieChartDataProvider dataProvider) {
    super(context, chart);
    this.dataProvider = dataProvider;
    touchAdditional = ChartUtils.dp2px(density, DEFAULT_TOUCH_ADDITIONAL_DP);

    slicePaint.setAntiAlias(true);
    slicePaint.setStyle(Paint.Style.FILL);

    centerCirclePaint.setAntiAlias(true);
    centerCirclePaint.setStyle(Paint.Style.FILL);
    centerCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));

    centerCircleText1Paint.setAntiAlias(true);
    centerCircleText1Paint.setTextAlign(Align.CENTER);

    centerCircleText2Paint.setAntiAlias(true);
    centerCircleText2Paint.setTextAlign(Align.CENTER);

    separationLinesPaint.setAntiAlias(true);
    separationLinesPaint.setStyle(Paint.Style.STROKE);
    separationLinesPaint.setStrokeCap(Paint.Cap.ROUND);
    separationLinesPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    separationLinesPaint.setColor(Color.TRANSPARENT);
}
 
Example 16
Project: FastEc   File: TranslucentBehavior.java   View source code 6 votes vote down vote up
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, Toolbar child, View target, int dx, int dy, int[] consumed) {
    super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
    mDistanceY += dy;
    //toolbar的高度
    final int targetHeight = child.getBottom();

    //当滑动时,并且距离小于 toolbar 高度的时候,调整渐变色
    if (mDistanceY > 0 && mDistanceY <= targetHeight) {
        final float scale = (float) mDistanceY / targetHeight;
        final float alpha = scale * 255;
        child.setBackgroundColor(Color.argb((int) alpha, RGB_VALUE.red(), RGB_VALUE.green(), RGB_VALUE.blue()));
    } else if (mDistanceY > targetHeight) {
        child.setBackgroundColor(Color.rgb(RGB_VALUE.red(), RGB_VALUE.green(), RGB_VALUE.blue()));
    }

}
 
Example 17
Project: SimpleUILauncher   File: BaseRecyclerViewFastScrollBar.java   View source code 6 votes vote down vote up
public BaseRecyclerViewFastScrollBar(BaseRecyclerView rv, Resources res) {
    mRv = rv;
    mPopup = new BaseRecyclerViewFastScrollPopup(rv, res);
    mTrackPaint = new Paint();
    mTrackPaint.setColor(rv.getFastScrollerTrackColor(Color.BLACK));
    mTrackPaint.setAlpha(MAX_TRACK_ALPHA);
    mThumbActiveColor = mThumbInactiveColor = Utilities.getColorAccent(rv.getContext());
    mThumbPaint = new Paint();
    mThumbPaint.setAntiAlias(true);
    mThumbPaint.setColor(mThumbInactiveColor);
    mThumbPaint.setStyle(Paint.Style.FILL);
    mThumbWidth = mThumbMinWidth = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_min_width);
    mThumbMaxWidth = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_max_width);
    mThumbHeight = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_height);
    mThumbCurvature = mThumbMaxWidth - mThumbMinWidth;
    mTouchInset = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_touch_inset);
}
 
Example 18
Project: BookyMcBookface   File: GetBooksActivity.java   View source code 6 votes vote down vote up
private void displayWeb(String name, String url, boolean first) {
    TextView v = new TextView(this);
    v.setTextSize(24);
    v.setTextColor(Color.BLUE);
    v.setPadding(16,16,8,8);
    v.setText(name);
    v.setTag(url);
    v.setOnClickListener(this);
    v.setOnLongClickListener(this);
    if (first) {
        list.addView(v, 0);
    } else {
        list.addView(v);
    }

}
 
Example 19
Project: Mobike   File: ViewfinderView.java   View source code 6 votes vote down vote up
private void drawScanner(Canvas canvas, Rect frame) {
    if (showPossiblePoint) {
        // Draw getUrl red "laser scanner" line through the middle to show decoding is active
        paint.setColor(laserColor);
        paint.setAlpha(SCANNER_ALPHA[scannerAlpha]);
        scannerAlpha = (scannerAlpha + 1) % SCANNER_ALPHA.length;
        int middle = frame.height() / 2 + frame.top;
        canvas.drawRect(frame.left + 2, middle - 1, frame.right - 1, middle + 2, paint);
    } else {
        paint.setColor(Color.parseColor("#03A9F4"));
        scannerAlpha = (scannerAlpha + 1) % SCANNER_ALPHA.length;
        canvas.translate(0, translateY);
        canvas.drawRect(frame.left + 10, frame.top, frame.right - 10, frame.top + 10, paint);

        translateY += 5f;
        if (translateY >= 670) {
            translateY = 5f;
        }
    }
}
 
Example 20
Project: yyox   File: SwipeBackActivityHelper.java   View source code 6 votes vote down vote up
public void onActivityCreate() {
    Window window = mActivity.getWindow();
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    window.getDecorView().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    mSwipeBackLayout = new SwipeBackLayout(mActivity);
    mSwipeBackLayout.addSwipeListener(new SwipeBackLayout.SwipeListener() {
        @Override
        public void onScrollStateChange(int state, float scrollPercent) {

        }

        @Override
        public void onEdgeTouch(int edgeFlag) {
            Utils.convertActivityToTranslucent(mActivity);
        }

        @Override
        public void onScrollOverThreshold() {

        }
    });
}
 
Example 21
Project: IdeaTrackerPlus   File: HorizontalAdapter.java   View source code 6 votes vote down vote up
private void setupIdeaTile(MyViewHolder holder, LinearLayout container) {
    holder.txtView.setSingleLine();
    holder.txtView.setText(mIdea);
    holder.txtView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START);

    if (mDarkTheme) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            container.setBackgroundResource(R.drawable.grey_ripple);
        } else {
            container.setBackgroundResource(R.color.md_grey_800);
        }
        holder.txtView.setTextColor(Color.WHITE);
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            container.setBackgroundResource(R.drawable.white_ripple);
        } else {
            container.setBackgroundResource(R.color.white);
        }
        holder.txtView.setTextColor(Color.BLACK);
    }

    //Listeners
    RecyclerOnClickListener listener = new RecyclerOnClickListener(mRecyclerView, mTabNumber);
    container.setOnClickListener(listener);
    container.setOnLongClickListener(mListener);
}
 
Example 22
Project: Mire   File: ActivitySetWallpapers.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_set_image);
	Preferences.makeAppFullscreen(this, Color.TRANSPARENT);
	
	setEnter();
	if (savedInstanceState != null) 
	{
           image = savedInstanceState.getString(URL);
           title = savedInstanceState.getString(NAME);
		text = savedInstanceState.getString(TEXT);
       }
	
	Bundle bundle = getIntent().getExtras();
       if (bundle != null)
	{
           image = bundle.getString(URL);
           title = bundle.getString(NAME);
		text = bundle.getString(TEXT);
       }
	
	wallpaper = (DoubleTapImageView)findViewById(R.id.id_image);
	progress = (ProgressBar)findViewById(R.id.id_progress);
	apply = (ImageView)findViewById(R.id.id_apply);
	
	mColor = Preferences.getAttributeColor(this, R.attr.colorAccent);
	anim = AnimationUtils.loadAnimation(this, R.anim.slide_left_from_right);
	_anim = AnimationUtils.loadAnimation(this, R.anim.slide_right_from_left);
	
	exitTransition = ActivityTransition.with(this.getIntent())
	    .to(this, wallpaper, "walls")
	    .duration(300)
	    .start(savedInstanceState);
	
	apply.setOnLongClickListener(applyLongClick);
}
 
Example 23
Project: ElasticViews   File: ExampleActivity2.java   View source code 6 votes vote down vote up
@OnClick({R.id.example2_view0, R.id.example2_view1, R.id.example2_view2, R.id.example2_view3, R.id.example2_imv, R.id.example2_textView0, R.id.example2_fab})
public void Views(View v){
    if(v.getId() == R.id.example2_view3){
        // set your duration time
        int duration = 500;

        // ElasticAction : doAction
        ElasticAction.doAction(v, duration, 0.85f, 0.85f); // argument : ViewGroup, duration, scaleX, scaleY

        // PostDelayed : delay duration time
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                //Do something after duration time
            }
        }, duration);
    }
    else if(v.getId() == R.id.example2_imv)
        Snackbar.make(v, "This is ElasticImageView", Snackbar.LENGTH_LONG).setActionTextColor(Color.WHITE).show();
    else if(v.getId() == R.id.example2_textView0)
        ElasticAction.doAction(v, 500, 0.75f, 0.75f);
    else if(v.getId() == R.id.example2_fab)
        Snackbar.make(v, "This is ElasticFloatActionButton", Snackbar.LENGTH_LONG).setActionTextColor(Color.WHITE).show();
}
 
Example 24
Project: AndroFish   File: AndroidFishEatingFish.java   View source code 6 votes vote down vote up
@Override protected void onDraw(Canvas canvas) {
adjustDimensions(canvas);
canvas.drawColor(Color.WHITE);
Paint paint = new Paint();
         paint.setStrokeWidth(0);
         paint.setColor(Color.BLACK);
drawBackground(canvas, paint);
drawTargetMarker(canvas, paint);
drawFood(canvas, paint);
drawComputerFishs(canvas, paint, SIZE_1, playerFish.size);
drawPlayerFish(canvas, paint);
drawComputerFishs(canvas, paint, playerFish.size+1, SIZE_5);
drawGoodies(canvas, paint);
drawFrames(canvas, paint);
drawWaypoints(canvas, paint, mTouchedWaypoints);
     }
 
Example 25
Project: BrotherWeather   File: XStatusBar.java   View source code 6 votes vote down vote up
/**
 * 为 DrawerLayout 布局设置状态栏透明
 *
 * @param activity     需要设置的activity
 * @param drawerLayout DrawerLayout
 */
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    // 内容布局不是 LinearLayout 时,设置padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
        contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
    }

    // 设置属性
    setDrawerLayoutProperty(drawerLayout, contentLayout);
}
 
Example 26
Project: ShotsNewsApp   File: ModuleAdapter.java   View source code 6 votes vote down vote up
private void waveviews(WaveLoadingView mWaveLoadingView){
    mWaveLoadingView.setShapeType(WaveLoadingView.ShapeType.CIRCLE);
    //mWaveLoadingView.setTopTitle("Top Title");
    mWaveLoadingView.setCenterTitleColor(Color.GRAY);
    mWaveLoadingView.setBottomTitleSize(18);
    mWaveLoadingView.setProgressValue(60);
    mWaveLoadingView.setBorderWidth(7);
    mWaveLoadingView.setAmplitudeRatio(60);
    mWaveLoadingView.setWaveColor(Color.parseColor("#2AFFD4"));
    mWaveLoadingView.setBorderColor(Color.parseColor("#2BFFD4"));
    mWaveLoadingView.setTopTitleStrokeColor(Color.BLUE);
    mWaveLoadingView.setTopTitleStrokeWidth(2);
    mWaveLoadingView.setAnimDuration(2000);
    // mWaveLoadingView.pauseAnimation();
    // mWaveLoadingView.resumeAnimation();
    //   mWaveLoadingView.cancelAnimation();
    mWaveLoadingView.startAnimation();

}
 
Example 27
Project: FlickLauncher   File: BaseRecyclerViewFastScrollBar.java   View source code 6 votes vote down vote up
public BaseRecyclerViewFastScrollBar(BaseRecyclerView rv, Resources res) {
    mRv = rv;
    mPopup = new BaseRecyclerViewFastScrollPopup(rv, res);
    mTrackPaint = new Paint();
    mTrackPaint.setColor(rv.getFastScrollerTrackColor(Color.BLACK));
    mTrackPaint.setAlpha(MAX_TRACK_ALPHA);
    mThumbActiveColor = mThumbInactiveColor = Utilities.getColorAccent(rv.getContext());
    mThumbPaint = new Paint();
    mThumbPaint.setAntiAlias(true);
    mThumbPaint.setColor(mThumbInactiveColor);
    mThumbPaint.setStyle(Paint.Style.FILL);
    mThumbWidth = mThumbMinWidth = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_min_width);
    mThumbMaxWidth = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_max_width);
    mThumbHeight = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_height);
    mThumbCurvature = mThumbMaxWidth - mThumbMinWidth;
    mTouchInset = res.getDimensionPixelSize(R.dimen.container_fastscroll_thumb_touch_inset);
}
 
Example 28
Project: empty-state-recyclerview   File: ContentItemLoadingStateFactory.java   View source code 6 votes vote down vote up
@Override
public final void onDrawState(final EmptyStateRecyclerView rv, Canvas canvas) {
    final int width = rv.getMeasuredWidth();
    final int height = rv.getMeasuredHeight();

    // Draw all of our content items
    renderContent(numberOfContentItems, width, height, canvas, contentPaint);

    // Setup and start animation, if possible
    if (animateContentItems) {
        if (anim == null) {
            this.anim = ObjectAnimator.ofObject(contentPaint, "color", new ArgbEvaluator(),
                    Color.parseColor("#E0E0E0"), Color.parseColor("#BDBDBD"), Color.parseColor("#9E9E9E"));
            onInterceptAnimatorCreation(anim);
            this.anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    rv.invalidate();
                }
            });
            this.anim.start();
        }
    }
}
 
Example 29
Project: GitHub   File: LineChartActivityColored.java   View source code 5 votes vote down vote up
private LineData getData(int count, float range) {

        ArrayList<Entry> yVals = new ArrayList<Entry>();

        for (int i = 0; i < count; i++) {
            float val = (float) (Math.random() * range) + 3;
            yVals.add(new Entry(i, val));
        }

        // create a dataset and give it a type
        LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
        // set1.setFillAlpha(110);
        // set1.setFillColor(Color.RED);

        set1.setLineWidth(1.75f);
        set1.setCircleRadius(5f);
        set1.setCircleHoleRadius(2.5f);
        set1.setColor(Color.WHITE);
        set1.setCircleColor(Color.WHITE);
        set1.setHighLightColor(Color.WHITE);
        set1.setDrawValues(false);

        // create a data object with the datasets
        LineData data = new LineData(set1);

        return data;
    }
 
Example 30
Project: JInOne   File: BasePresenterActivity.java   View source code 5 votes vote down vote up
protected void hideNavBar(){
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    }
}
 
Example 31
Project: kognitivo   File: WebDialog.java   View source code 5 votes vote down vote up
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    if (!isDetached) {
        spinner.dismiss();
    }
    /*
     * Once web view is fully loaded, set the contentFrameLayout background to be transparent
     * and make visible the 'x' image.
     */
    contentFrameLayout.setBackgroundColor(Color.TRANSPARENT);
    webView.setVisibility(View.VISIBLE);
    crossImageView.setVisibility(View.VISIBLE);
    isPageFinished = true;
}
 
Example 32
Project: GitHub   File: CombinedChartActivity.java   View source code 5 votes vote down vote up
private BarData generateBarData() {

        ArrayList<BarEntry> entries1 = new ArrayList<BarEntry>();
        ArrayList<BarEntry> entries2 = new ArrayList<BarEntry>();

        for (int index = 0; index < itemcount; index++) {
            entries1.add(new BarEntry(0, getRandom(25, 25)));

            // stacked
            entries2.add(new BarEntry(0, new float[]{getRandom(13, 12), getRandom(13, 12)}));
        }

        BarDataSet set1 = new BarDataSet(entries1, "Bar 1");
        set1.setColor(Color.rgb(60, 220, 78));
        set1.setValueTextColor(Color.rgb(60, 220, 78));
        set1.setValueTextSize(10f);
        set1.setAxisDependency(YAxis.AxisDependency.LEFT);

        BarDataSet set2 = new BarDataSet(entries2, "");
        set2.setStackLabels(new String[]{"Stack 1", "Stack 2"});
        set2.setColors(new int[]{Color.rgb(61, 165, 255), Color.rgb(23, 197, 255)});
        set2.setValueTextColor(Color.rgb(61, 165, 255));
        set2.setValueTextSize(10f);
        set2.setAxisDependency(YAxis.AxisDependency.LEFT);

        float groupSpace = 0.06f;
        float barSpace = 0.02f; // x2 dataset
        float barWidth = 0.45f; // x2 dataset
        // (0.45 + 0.02) * 2 + 0.06 = 1.00 -> interval per "group"

        BarData d = new BarData(set1, set2);
        d.setBarWidth(barWidth);

        // make this BarData object grouped
        d.groupBars(0, groupSpace, barSpace); // start at x = 0

        return d;
    }
 
Example 33
Project: xlight_android_native   File: SVBar.java   View source code 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
	Bundle savedState = (Bundle) state;

	Parcelable superState = savedState.getParcelable(STATE_PARENT);
	super.onRestoreInstanceState(superState);

	setColor(Color.HSVToColor(savedState.getFloatArray(STATE_COLOR)));
	if (savedState.containsKey(STATE_SATURATION)) {
		setSaturation(savedState.getFloat(STATE_SATURATION));
	} else {
		setValue(savedState.getFloat(STATE_VALUE));
	}
}
 
Example 34
Project: Selector   File: GoodSAttrRvNAdapter10.java   View source code 5 votes vote down vote up
@Override public void onBindViewHolder(final GoodSAttrRvNAdapter10.MyAdapter holder, final int position) {
  holder.attr.setText(mlist.get(position));
  //强制禁止recycleview复用
  holder.setIsRecyclable(false);
  //用来接收综合界面传递过来的选择
  for (int i = 0; i < selectedlist.size(); i++) {
    if (selectedlist.contains(mlist.get(position))) {
      holder.attr.setBackgroundResource(R.drawable.goods_attr_selected_shape);
      holder.attr.setTextColor(Color.WHITE);
    }
  }
  /**
   * 根据选中状态来设置item的背景和字体颜色
   */
  holder.attr.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View v) {
      if (selectedlist.size() <= 0) {
        holder.attr.setBackgroundResource(R.drawable.goods_attr_selected_shape);
        holder.attr.setTextColor(Color.WHITE);
        EventBus.getDefault().post(new Eventil(mlist.get(position)));

      } else {
        if (!selectedlist.contains(mlist.get(position))) {
          holder.attr.setBackgroundResource(R.drawable.goods_attr_selected_shape);
          holder.attr.setTextColor(Color.WHITE);
          EventBus.getDefault().post(new Eventil(mlist.get(position)));
        } else {
          holder.attr.setBackgroundResource(R.drawable.goods_attr_unselected_shape);
          holder.attr.setTextColor(Color.BLACK);
        }
      }
      //保存
      DataPresenter.getSingleTon().saveSelect(mlist.get(position));
      EventBus.getDefault().post(new SecondEventil());
    }
  });
}
 
Example 35
Project: Artist   File: CategoryAdapter.java   View source code 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    CategoryViewHolder categoryViewHolder = (CategoryViewHolder)holder;
    categoryViewHolder.titleText.setText(datas.get(position).getTitle());
    categoryViewHolder.countText.setText(datas.get(position).getCount());
    int color = Color.parseColor(datas.get(position).getColor());
    categoryViewHolder.colorView.setBackgroundColor(color);
}
 
Example 36
Project: JZAndroidChart   File: App.java   View source code 5 votes vote down vote up
@Override public void onCreate() {
  super.onCreate();
  if (BuildConfig.DEBUG) {
    Takt.stock(this)
        .color(Color.WHITE)
        .seat(Seat.TOP_RIGHT)
        .play();
  }
}
 
Example 37
Project: MinimalismJotter   File: GalleryActivity.java   View source code 5 votes vote down vote up
public void isShowOkBt() {
    if (Bimp.tempSelectBitmap.size() > 0) {
        send_bt.setText("完成" + "(" + Bimp.tempSelectBitmap.size() + "/" + 9 + ")");
        send_bt.setPressed(true);
        send_bt.setClickable(true);
        send_bt.setTextColor(Color.WHITE);
    } else {
        send_bt.setPressed(false);
        send_bt.setClickable(false);
        send_bt.setTextColor(Color.parseColor("#E1E0DE"));
    }
}
 
Example 38
Project: simple-share-android   File: Utils.java   View source code 5 votes vote down vote up
public static int getComplementaryColor(int colorToInvert) {
    float[] hsv = new float[3];
    Color.RGBToHSV(Color.red(colorToInvert), Color.green(colorToInvert),
            Color.blue(colorToInvert), hsv);
    hsv[0] = (hsv[0] + 180) % 360;
    return Color.HSVToColor(hsv);
}
 
Example 39
Project: HeroVideo-master   File: BiliDanmukuParser.java   View source code 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
    String tagName = localName.length() != 0 ? localName : qName;
    tagName = tagName.toLowerCase(Locale.getDefault()).trim();
    if (tagName.equals("d")) {
        // <d p="23.826000213623,1,25,16777215,1422201084,0,057075e9,757076900">我从未见过如此厚颜无耻之猴</d>
        // 0:时间(弹幕出现时间)
        // 1:类型(1从右至左滚动弹幕|6从左至右滚动弹幕|5顶端固定弹幕|4底端固定弹幕|7高级弹幕|8脚本弹幕)
        // 2:字号
        // 3:颜色
        // 4:时间戳 ?
        // 5:弹幕池id
        // 6:用户hash
        // 7:弹幕id
        String pValue = attributes.getValue("p");
        // parse p value to danmaku
        String[] values = pValue.split(",");
        if (values.length > 0) {
            long time = (long) (Float.parseFloat(values[0]) * 1000); // 出现时间
            int type = Integer.parseInt(values[1]); // 弹幕类型
            float textSize = Float.parseFloat(values[2]); // 字体大小
            int color = (int) ((0x00000000ff000000 | Long.parseLong(values[3])) & 0x00000000ffffffff); // 颜色
            // int poolType = Integer.parseInt(values[5]); // 弹幕池类型(忽略
            item = mContext.mDanmakuFactory.createDanmaku(type, mContext);
            if (item != null) {
                item.setTime(time);
                item.textSize = textSize * (mDispDensity - 0.6f);
                item.textColor = color;
                item.textShadowColor = color <= Color.BLACK ? Color.WHITE : Color.BLACK;
            }
        }
    }
}
 
Example 40
Project: ZoomLayout   File: ColorGridDrawable.java   View source code 5 votes vote down vote up
private static int getColor(int row, int col) {
    if (COLOR_CACHE[row][col] == 0) {
        final int r = 140 + R.nextInt(100);
        final int g = 140 + R.nextInt(100);
        final int b = 50 + R.nextInt(100);
        COLOR_CACHE[row][col] = Color.rgb(r, g, b);
    }
    return COLOR_CACHE[row][col];
}