Demo entry 4016797

Update

   

Submitted by anonymous on Mar 13, 2016 at 05:46
Language: Java. Code size: 2.4 kB.

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.google.gson.Gson;

import java.util.ArrayList;

public class Training extends AppCompatActivity {

    public static String LOG_TAG = "my log tag";
    private ArrayList<Entry> myClimbs = new ArrayList<Entry>();
    SavedData mySavedData;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        mySavedData = SavedData.getSavedData(this);
        mySavedData.addClimb(3, true, 2016, 3, 15);
        mySavedData.addClimb(4, true, 2016, 3, 10);
        mySavedData.addClimb(5, true, 2016, 3, 4);
        mySavedData.addClimb(8, true, 2016, 5, 1);
        mySavedData.addClimb(9, true, 2016, 5, 3);
        mySavedData.addClimb(10, true, 2016, 5, 14);

        myClimbs = mySavedData.getClimbs();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_training);
    }

    public void MainMenu(View v){
        Intent intent = new Intent(this, MainMenu.class);
        startActivity(intent);
    }

    public void EnterClimb(View v){

        Intent intent = new Intent(this, EnterClimb.class);

        Gson gson = new Gson();

        JsonClimbList temp = new JsonClimbList(myClimbs);
        String json = gson.toJson(temp);

        intent.putExtra("inputList", json);

        startActivityForResult(intent, 0);
    }

    public void Stats(View v){

        Intent intent = new Intent(this,Stats.class);
        startActivity(intent);
    }

    public void myPyramids(View v){

        Intent intent = new Intent(this, MyPyramids.class);
        startActivity(intent);
    }

    public void info(View v){
        Intent intent = new Intent(this, Info1.class);
        startActivity(intent);
    }

    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        Gson gson = new Gson();
        JsonClimbList myClimbList;
        Log.i(LOG_TAG,"OnActivityResult");
        if (resultCode == RESULT_OK) {
            String json = data.getStringExtra("outputList");
            myClimbList = gson.fromJson(json, JsonClimbList.class);
            myClimbs = myClimbList.getMyClimbs();
            mySavedData.setClimbs(myClimbs);
            mySavedData.writeData();
        }
    }
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).