VDMActivity.java :  » UnTagged » qdm » com » ovhoo » vdm » vdm » Android Open Source

Android Open Source » UnTagged » qdm 
qdm » com » ovhoo » vdm » vdm » VDMActivity.java
package com.ovhoo.vdm.vdm;

import java.util.ArrayList;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class VDMActivity extends Activity implements Button.OnClickListener{
  private Button latesQuotes;
  private Button randomQuotes;
  private Button topQuotes;
  private Button flopQuotes;
  
  private Button loginButton;
  
  private Intent vdmQuotesList = null;
  private Intent vdmQuoteCommentsList = null;
  
  private VDMLoginManager loginManager = null;
  
    
  /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        this.loginManager = VDMLoginManager.getInstance();
                
        setContentView(R.layout.main);
        
        this.latesQuotes = (Button) findViewById(R.id.LATEST_QUOTES);
        this.randomQuotes = (Button) findViewById(R.id.RANDOM_QUOTES);
        this.topQuotes = (Button) findViewById(R.id.TOP_QUOTES);
        this.flopQuotes = (Button) findViewById(R.id.FLOP_QUOTES);
        
        this.loginButton = (Button) findViewById(R.id.LOGIN_BUTTON);
               
        
      
        //Start abonnement to  listener
        this.latesQuotes.setOnClickListener(this);
        this.randomQuotes.setOnClickListener(this);
        this.topQuotes.setOnClickListener(this);
        this.flopQuotes.setOnClickListener(this);
        
        this.loginButton.setOnClickListener(this);
        
    }
    
    
    public void onStart(){
      super.onStart();

    }
  @Override
  /**
   * Called when a button is clicked
   * @param v : the clicked button instance
   */
  public void onClick(View v) {
    
    if ( v == this.randomQuotes){
      this.startVDMQuoteCommentsList(VDMQuoteCommentsList.requestType.LOAD_RANDOM_QUOTES_COMMENT);
    }
    else if ( v == this.topQuotes){
      this.startVDMQuoteList( VDMQuotesList.requestType.VDM_QUOTE_TYPE_TOP);
    }
    else if ( v == this.flopQuotes){
      this.startVDMQuoteList( VDMQuotesList.requestType.VDM_QUOTE_TYPE_FLOP);
    }
    else if ( v == this.loginButton){
      this.loginManager.login("azalsup", "753123", this.getResources().getString(R.string.VDM_API_LANGAGE));
      this.loginButton.setText(this.loginManager.getToken());
    }
    else {
      this.startVDMQuoteList( VDMQuotesList.requestType.VDM_QUOTE_TYPE_LATEST);
    }       
  }
  
  /**
   * Start a VDMQuotesList with the specified parameter
   * @param type
   */
  protected void startVDMQuoteList(VDMQuotesList.requestType type){
    
    //If the Activity was not already instanciated
    if (this.vdmQuotesList == null){
      this.vdmQuotesList = new Intent(this,VDMQuotesList.class);
    }
    
    
    this.vdmQuotesList = this.vdmQuotesList.putExtra("com.ovhoo.vdm.vdm.VDM_QUOTES_LIST_TYPE", type.ordinal());
    startActivity(this.vdmQuotesList);

  }
  
  /**
   * Start a VDMQuoteCommentsList with the specified parameter
   * @param type
   */
  protected void startVDMQuoteCommentsList(VDMQuoteCommentsList.requestType type){
    
    //If the Activity was not already instanciated
    if (this.vdmQuoteCommentsList == null){
      this.vdmQuoteCommentsList = new Intent(this,VDMQuoteCommentsList.class);
    }
        
    this.vdmQuoteCommentsList = this.vdmQuoteCommentsList.putExtra("com.ovhoo.vdm.vdm.VDM_QUOTE_COMMENTS_LIST_TYPE", type.ordinal());
    startActivity(this.vdmQuoteCommentsList);

  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.