Android Open Source - VisEQ Preference Circle






From Project

Back to project page VisEQ.

License

The source code is released under:

Copyright (c) 2012, Spotify AB All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:...

If you think the Android project VisEQ listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lsu.vizeq;
/*  w w w  .j ava 2 s. co m*/
import java.util.List;
import java.util.Random;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.Paint.Align;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

  public class PreferenceCircle extends View
  {
    Random r = new Random();
    Typeface font;
    public PreferenceCircle(Context context) {
      super(context);
      font = Typeface.createFromAsset(context.getAssets(), "Mission Gothic Regular.otf");
    }
    public List<Track> tracks;
    String text;
    int x;
    int y;
    int radius;
    int color;
    String name;
    final float scale = getResources().getDisplayMetrics().density;
    final float width = getResources().getDisplayMetrics().widthPixels;
    final float height = getResources().getDisplayMetrics().heightPixels;
    
    //Code for working with bitmaps and density pixels
    //int twentyFiveDP = (int) (25 * scale + 0.5f);
    // Bitmap sub8 = BitmapFactory.decodeResource(getResources(), R.drawable.eighth);
    //Bitmap sub4 = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.quarter), twentyFiveDP, twentyFiveDP, true);
    Paint paint = new Paint();

    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
      animate().setDuration(600);      
      animate().scaleX(9);
      animate().scaleY(9);
      animate().translationY(height/2 - y);
      animate().translationX(width/2 - x);
      //((View) this.getParent()).animate().setDuration(600).scaleX(9);
      //((View)this.getParent()).animate().setDuration(600).scaleY(5);
      return super.onTouchEvent(event);
    }

    @Override
    protected void onDraw(Canvas canvas)
    {
      //Color paintColor = new Color();
      super.onDraw(canvas);
      switch (r.nextInt(5) + 1)
      {
        case 1:
          paint.setColor(getResources().getColor(R.color.Red));
          break;
        case 2:
          paint.setColor(getResources().getColor(R.color.Green));
          break;
        case 3:
          paint.setColor(getResources().getColor(R.color.Blue));
          break;
        case 4:
          paint.setColor(getResources().getColor(R.color.Purple));
          break;
        case 5:
          paint.setColor(getResources().getColor(R.color.Orange));
          break;
      }
      
      //paint.setColor(Color.MAGENTA);
      canvas.drawCircle(x, y, radius, paint);
      paint.setTypeface(font);
      paint.setTextSize(50);
        paint.setColor(Color.WHITE);
        paint.setTextAlign(Align.CENTER);
        canvas.drawText(text, x, y, paint);
    }

    public PreferenceCircle(Context context, int x, int y, int radius, String a, List<Track> tracks)
    {
      super(context);
      this.tracks = tracks;
      //super.setX(x);
      //super.setY(y);
      this.name = a;
      this.text = a;
      this.x = x;
      this.y = y;
      this.radius = radius;
      this.setPadding(0, 0, 0, 0);
      this.setTag(text);
    }

    public PreferenceCircle(Context context, AttributeSet attrs)
    {
      super(context, attrs);
      // TODO Auto-generated constructor stub
    }

    public PreferenceCircle(Context context, AttributeSet attrs, int defStyle)
    {
      super(context, attrs, defStyle);
      // TODO Auto-generated constructor stub
    }

  }




Java Source Code List

com.lsu.vizeq.AboutActivity.java
com.lsu.vizeq.Artist.java
com.lsu.vizeq.BackableActivity.java
com.lsu.vizeq.HostActivity.java
com.lsu.vizeq.HostMenuActivity.java
com.lsu.vizeq.HostProfileActivity.java
com.lsu.vizeq.HostSoundVisualizationActivity.java
com.lsu.vizeq.Installation.java
com.lsu.vizeq.LibSpotifyWrapper.java
com.lsu.vizeq.LoginActivity.java
com.lsu.vizeq.MyApplication.java
com.lsu.vizeq.MyCanvas.java
com.lsu.vizeq.PVCircle.java
com.lsu.vizeq.PacketParser.java
com.lsu.vizeq.PlayerActivity.java
com.lsu.vizeq.PreferenceCircle.java
com.lsu.vizeq.PreferenceVisualizationActivity.java
com.lsu.vizeq.PreferenceVisualizer.java
com.lsu.vizeq.ProfileActivity.java
com.lsu.vizeq.RemoteControlReceiver.java
com.lsu.vizeq.RequestDetailsActivity.java
com.lsu.vizeq.RoleActivity.java
com.lsu.vizeq.SearchActivity.java
com.lsu.vizeq.SearchPartyActivity.java
com.lsu.vizeq.ServiceBinder.java
com.lsu.vizeq.SettingsActivity.java
com.lsu.vizeq.SoundVisualizationActivity.java
com.lsu.vizeq.SpotifyService.java
com.lsu.vizeq.TrackRow.java
com.lsu.vizeq.Track.java
com.lsu.vizeq.VisualizerView.java
com.lsu.vizeq.VizEQ.java
com.lsu.vizeq.WebService.java
com.lsu.vizeq.util.SystemPropertiesProxy.java
com.lsu.vizeq.util.SystemUiHiderBase.java
com.lsu.vizeq.util.SystemUiHiderHoneycomb.java
com.lsu.vizeq.util.SystemUiHider.java
com.lsu.vizeq.util.TunnelPlayerWorkaround.java