Android Open Source - VisEQ Host Profile Activity






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;
//from  w w w . ja va  2 s .c  o m
import java.util.Random;

import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TabHost;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TabHost.TabSpec;

public class HostProfileActivity extends BackableActivity implements OnItemSelectedListener{
  public String mColor;
  Spinner spinner;
  LinearLayout customSearchLayout;
  OnClickListener submitListener;
  ActionBar actionBar;
  public MyApplication myapp;  
  
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
        // An item was selected. You can retrieve the selected item using parent.getItemAtPosition(pos)
    spinner.setSelection(pos);
    SharedPreferences memory = getSharedPreferences("VizEQ", MODE_PRIVATE);
    mColor = (String) parent.getItemAtPosition(pos);
    final SharedPreferences.Editor saver = memory.edit();
    saver.putString("color", mColor);
    saver.putInt("colorPos", pos);
    saver.commit();
    Log.d("Color", "item selected");
    Switch camFlash = (Switch) findViewById(R.id.CamFlash);
    Switch bgFlash = (Switch) findViewById(R.id.BGFlash);
    
    camFlash.setChecked(memory.getBoolean("cameraFlash", true));
    bgFlash.setChecked(memory.getBoolean("backgroundFlash", true));
    
    camFlash.setOnCheckedChangeListener(new OnCheckedChangeListener()
    {

      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
      {
        MyApplication.doFlash = isChecked;    
        saver.putBoolean("cameraFlash", isChecked);
        saver.commit();
      }
      
    });
    bgFlash.setOnCheckedChangeListener(new OnCheckedChangeListener(){

      @Override
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
      {
        MyApplication.doBackground = isChecked;
        saver.putBoolean("backgroundFlash", isChecked);
        saver.commit();
      }
      
    });
        
    actionBar = getActionBar();
    int posi = memory.getInt("colorPos", -1);
    if (posi != -1) 
    {
      VizEQ.numRand = posi;  
      if (VizEQ.numRand == 0){
        Random r = new Random();
        VizEQ.numRand = r.nextInt(5) + 1;
      }      
      
      switch (VizEQ.numRand)
      {
        case 1:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Red)));
          VizEQ.colorScheme = getResources().getColor(R.color.Red);
          break;
        case 2:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Green)));
          VizEQ.colorScheme = getResources().getColor(R.color.Green);
          break;
        case 3:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Blue)));
          VizEQ.colorScheme = getResources().getColor(R.color.Blue);
          break;
        case 4:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Purple)));  
          VizEQ.colorScheme = getResources().getColor(R.color.Purple);
          break;
        case 5:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Orange)));
          VizEQ.colorScheme = getResources().getColor(R.color.Orange);
          break;    
      }
    }
    }

    public void onNothingSelected(AdapterView<?> parent) {
        // Another interface callback
      actionBar = getActionBar();
      SharedPreferences memory = getSharedPreferences("VizEQ", MODE_PRIVATE);
    int posi = memory.getInt("colorPos", -1);
    spinner.setSelection(posi);
    Log.d("Color", "Nothing Selected");
    if (posi > 0) 
    {
      VizEQ.numRand = posi;  
      switch (VizEQ.numRand)
      {        
        case 1:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Red)));
          break;
        case 2:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Green)));        
          break;
        case 3:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Blue)));
          break;
        case 4:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Purple)));        
          break;
        case 5:
          actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Orange)));
          break;    
      }
    }
    }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_host_profile);
    
    actionBar = getActionBar();    
    SharedPreferences memory = getSharedPreferences("VizEQ", MODE_PRIVATE);
    myapp = (MyApplication) this.getApplicationContext();
    
    int posi = memory.getInt("colorPos", -1);
    if (posi > 0) VizEQ.numRand = posi;  
    
    switch (VizEQ.numRand)
    {
      case 1:
        actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Red)));
        break;
      case 2:
        actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Green)));        
        break;
      case 3:
        actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Blue)));
        break;
      case 4:
        actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Purple)));        
        break;
      case 5:
        actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.Orange)));
        break;          
    }    
    
    customSearchLayout = (LinearLayout) findViewById(R.id.customSearchLayout);
    final EditText searchText = (EditText) findViewById(R.id.CustomSearchField);
    final OnTouchListener rowTap;   
      
      // Color Spinner
      spinner = (Spinner) findViewById(R.id.colorspinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.color_spinner, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);  
    spinner.setOnItemSelectedListener(this);
    spinner.setAdapter(adapter);
    if (posi == -1) posi = 0;
    spinner.setSelection(posi);
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.host_profile, menu);
    return true;
  }

}




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