Android Open Source - on-the-hook Main Menu Activity






From Project

Back to project page on-the-hook.

License

The source code is released under:

MIT License

If you think the Android project on-the-hook 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.yoandinkov.onthehook;
//w  w  w . j ava2  s . co m
import com.yoandinkov.onthehook.models.HttpResponseWrapper;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
import android.content.SharedPreferences;

public class MainMenuActivity extends RequestActivity{

  private Button ButtonStartFishing;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_menu);
    
    this.setButtonStartFishing((Button)findViewById(R.id.mainMenuButtonStartFishing));
    
    this.getButtonStartFishing().setOnClickListener(this);
    
    String sessionKey = "";
    
    if(getIntent().getExtras() != null) {
      sessionKey = getIntent().getExtras().getString("sessionKey");
    }
    
    if (sessionKey != null) {
      this.setSessionKey(sessionKey);
      
      this.setCredentials(sessionKey);
    }
  }
  
  private void setCredentials(String sessionKey) {
    SharedPreferences credentials = getSharedPreferences("credentials", MODE_PRIVATE);
    SharedPreferences.Editor credentialsEditor = credentials.edit();
    
    credentialsEditor.putString("sessionKey", sessionKey);
    
    credentialsEditor.commit();
  }

  private String getCredentials() {
    String result = "";
    
    SharedPreferences credentials = getSharedPreferences("credentials", MODE_PRIVATE);
    
    result = credentials.getString("sessionKey", null);
    
    return result;
  }
  
  @Override
  public void onClick(View clickedView) {
    int clickedViewId = clickedView.getId();
    
    switch(clickedViewId) {
    case R.id.mainMenuButtonStartFishing:
      this.startFishingActivity(clickedView);
      break;
    }
  }
  
  private void startFishingActivity(View currentView) {
    Intent startFishingIntent = new Intent(this, FishingActivity.class);
    
    if (getIntent().getExtras() != null) {    
      startFishingIntent.putExtra("sessionKey", getIntent().getExtras().getString("sessionKey"));
    } else {
      startFishingIntent.putExtra("sessionKey", this.getCredentials());
    }
    
    startActivity(startFishingIntent);
  }
  
  public Button getButtonStartFishing() {
    return ButtonStartFishing;
  }

  public void setButtonStartFishing(Button buttonStartFishing) {
    ButtonStartFishing = buttonStartFishing;
  }

  @Override
  protected void handleResponse(HttpResponseWrapper response) {
  }

}




Java Source Code List

com.yoandinkov.onthehook.DraughtActivity.java
com.yoandinkov.onthehook.FishActivity.java
com.yoandinkov.onthehook.FishingActivity.java
com.yoandinkov.onthehook.LoginActivity.java
com.yoandinkov.onthehook.MainMenuActivity.java
com.yoandinkov.onthehook.RegisterActivity.java
com.yoandinkov.onthehook.RequestActivity.java
com.yoandinkov.onthehook.adapters.FishAdapter.java
com.yoandinkov.onthehook.crypt.JsonConverter.java
com.yoandinkov.onthehook.crypt.SHA1Converter.java
com.yoandinkov.onthehook.db.DatabaseHelper.java
com.yoandinkov.onthehook.db.DatabaseManager.java
com.yoandinkov.onthehook.db.models.FishDbModel.java
com.yoandinkov.onthehook.models.Coordinates.java
com.yoandinkov.onthehook.models.Credentials.java
com.yoandinkov.onthehook.models.FishButton.java
com.yoandinkov.onthehook.models.FishSpecies.java
com.yoandinkov.onthehook.models.Fish.java
com.yoandinkov.onthehook.models.Fishing.java
com.yoandinkov.onthehook.models.HttpResponseWrapper.java
com.yoandinkov.onthehook.models.HttpType.java
com.yoandinkov.onthehook.models.Login.java
com.yoandinkov.onthehook.models.NewFishing.java
com.yoandinkov.onthehook.models.Registration.java
com.yoandinkov.onthehook.models.RequestPurpose.java
com.yoandinkov.onthehook.models.Response.java
com.yoandinkov.onthehook.models.WaterLocation.java