package co.globelist.atest;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;

import com.android.volley.Request;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONObject;

import java.util.Collections;

public class Profile extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profile);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);


        final RestService rest = new RestService();

        class UsersCallback extends Callback {
            @Override
            public void success(JSONObject jsonResponse) {
                super.success(jsonResponse);
                Log.d("UsersCallback", "my success" + jsonResponse);
            }

            @Override
            public void error(String error) {
                super.error(error);
                Log.d("UsersCallback", "my error: " + error);
            }
        }

        StringRequest getRequest = rest.getStringRequest(Request.Method.GET, "users/me", Collections.<String,String>emptyMap(), new UsersCallback());
        Volley.newRequestQueue(Profile.this).add(getRequest);

    }
}

@@ -295,16 +295,48 @@
 ew.View;
+%0Aimport android.widget.EditText;
 %0A%0Aimport
@@ -456,16 +456,47 @@
 olley;%0A%0A
+import org.json.JSONException;%0A
 import o
@@ -1533,32 +1533,740 @@
 (jsonResponse);%0A
+                try %7B%0A                    String name = jsonResponse.getString(%22name%22);%0A                    EditText fname = (EditText)findViewById(R.id.name);%0A                    fname.setText(name);%0A%0A                    String username = jsonResponse.getString(%22username%22);%0A                    EditText fusername = (EditText)findViewById(R.id.username);%0A                    fusername.setText(username);%0A%0A                    String country = jsonResponse.getString(%22country%22);%0A                    EditText fcountry = (EditText)findViewById(R.id.country);%0A                    fcountry.setText(country);%0A%0A                %7D catch (JSONException e) %7B%0A                    e.printStackTrace();%0A                %7D%0A%0A
                 

use the json response to fill the form