<commit_before>package com.procleus.brime;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
import android.widget.EditText;
import android.widget.Toast;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

/**
 * Created by Ujjwal on 07-07-2016.
 */
public class AccountInfoFragment extends Fragment {
    private static String url;
    EditText Email;
    EditText first_name;
    EditText last_name;
    //textview birthDate;
    String name;
    String firstName = "";
    String lastName = "";
    String updatedFirstName;
    String updatedLastName;
    String updatedBirthDate = "1996-06-25";
    SharedPreferences sharedPreferences = null;
    int responseOp;
    ProgressDialog progressDialog;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        sharedPreferences = this.getActivity().getSharedPreferences("com.procleus.brime", Context.MODE_PRIVATE);
        final View v =inflater.inflate(R.layout.account_info_layout, container, false);
        Email = (EditText) v.findViewById(R.id.Email);
        name = sharedPreferences.getString("emailpref", "Guest");
        Email.setText(name);
        Email.setEnabled(false);
        url = "http://api.brime.tk/ShowUser.php?email=" + name;
        new JSONParse(v).execute();
        FloatingActionButton floatingActionButton = (FloatingActionButton) v.findViewById(R.id.fab);
        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                progressDialog = new ProgressDialog(getActivity(), R.style.Dialog);
                progressDialog.setIndeterminate(true);
                progressDialog.setMessage("Updating");
                progressDialog.show();
                updatedFirstName = first_name.getText().toString();
                updatedLastName = last_name.getText().toString();
            //    birthDate = (textview) v.findViewById(R.id.date_picker);
//                updatedBirthDate = birthDate.getText().toString();
                new UpdateUser(v).execute();
                new android.os.Handler().postDelayed(
                        new Runnable() {
                            public void run() {
                                if(responseOp==1) {
                                    Toast.makeText(getContext(), "Updated Successfully", Toast.LENGTH_LONG).show();
                                } else {
                                    Toast.makeText(getContext(), "Failed", Toast.LENGTH_LONG).show();
                                }
                                progressDialog.dismiss();
                            }
                        }, 3000);
            }
        });
        return v;
    }
    private class JSONParse extends AsyncTask<String, String, JSONObject> {

        View v;
        protected JSONParse(View v) {
            this.v = v;
        }
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected JSONObject doInBackground(String... args) {
            JSONParser jParser = new JSONParser();
            JSONObject json = jParser.getJSONFromUrl(url);
            return json;
        }
        @Override
        protected void onPostExecute(JSONObject json) {
            try {
                json = json.getJSONObject("user");
                firstName = json.getString("firstName");
                lastName = json.getString("lastName");
                first_name = (EditText) v.findViewById(R.id.first_name);
                last_name = (EditText) v.findViewById(R.id.last_name);
                first_name.setText(firstName);
                last_name.setText(lastName);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    private class UpdateUser extends AsyncTask<String, Void, Void> {

        View v;
        public UpdateUser(View v) {
            this.v = v;
        }
        protected void onPreExecute() { }

        @Override
        protected Void doInBackground(String... params) {
            try {<commit_msg>Issue Resolved #43<commit_after>package com.procleus.brime;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.support.v4.app.Fragment;
import android.widget.EditText;
import android.widget.Toast;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;

/**
 * Created by Ujjwal on 07-07-2016.
 */
public class AccountInfoFragment extends Fragment {
    private static String url;
    EditText Email;
    EditText first_name;
    EditText last_name;
    EditText birthDate;
    String name;
    String firstName = "";
    String lastName = "";
    String bdate;
    String updatedFirstName;
    String updatedLastName;
    String updatedBirthDate = "1996-06-25";
    SharedPreferences sharedPreferences = null;
    int responseOp;
    ProgressDialog progressDialog;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        sharedPreferences = this.getActivity().getSharedPreferences("com.procleus.brime", Context.MODE_PRIVATE);
        final View v =inflater.inflate(R.layout.account_info_layout, container, false);
        Email = (EditText) v.findViewById(R.id.Email);
        name = sharedPreferences.getString("emailpref", "Guest");
        Email.setText(name);
        Email.setEnabled(false);
        url = "http://api.brime.tk/ShowUser.php?email=" + name;
        new JSONParse(v).execute();
        FloatingActionButton floatingActionButton = (FloatingActionButton) v.findViewById(R.id.fab);
        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                progressDialog = new ProgressDialog(getActivity(), R.style.Dialog);
                progressDialog.setIndeterminate(true);
                progressDialog.setMessage("Updating");
                progressDialog.show();
                updatedFirstName = first_name.getText().toString();
                updatedLastName = last_name.getText().toString();
                updatedBirthDate = birthDate.getText().toString();
                new UpdateUser(v).execute();
                new android.os.Handler().postDelayed(
                        new Runnable() {
                            public void run() {
                                if(responseOp==1) {
                                    Toast.makeText(getContext(), "Updated Successfully", Toast.LENGTH_LONG).show();
                                } else {
                                    Toast.makeText(getContext(), "Failed", Toast.LENGTH_LONG).show();
                                }
                                progressDialog.dismiss();
                            }
                        }, 3000);
            }
        });
        return v;
    }
    private class JSONParse extends AsyncTask<String, String, JSONObject> {

        View v;
        protected JSONParse(View v) {
            this.v = v;
        }
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected JSONObject doInBackground(String... args) {
            JSONParser jParser = new JSONParser();
            JSONObject json = jParser.getJSONFromUrl(url);
            return json;
        }
        @Override
        protected void onPostExecute(JSONObject json) {
            try {
                json = json.getJSONObject("user");
                firstName = json.getString("firstName");
                lastName = json.getString("lastName");
                bdate = json.getString("birthDate");
                first_name = (EditText) v.findViewById(R.id.first_name);
                last_name = (EditText) v.findViewById(R.id.last_name);
                birthDate = (EditText) v.findViewById(R.id.date_picker);
                first_name.setText(firstName);
                last_name.setText(lastName);
                birthDate.setText(bdate);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    private class UpdateUser extends AsyncTask<String, Void, Void> {

        View v;
        public UpdateUser(View v) {
            this.v = v;
        }
        protected void onPreExecute() { }

        @Override
        protected Void doInBackground(String... params) {
            try {
{'fraction_non_alphanumeric': 0.09760380086758934, 'fraction_numerical': 0.004751084486676307, 'mean_word_length': 2.0593996840442337, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6344409', 'n_tokens_mistral': 2561, 'n_tokens_neox': 2420, 'n_words': 509}