{"action":"created","comment":{"url":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/comments/23222041","id":23222041,"diff_hunk":"@@ -0,0 +1,106 @@\n+package com.example.valeriaserber.trainingapp.activities;\n+\n+import android.app.Activity;\n+import android.content.Intent;\n+import android.os.Bundle;\n+import android.text.method.LinkMovementMethod;\n+import android.view.Gravity;\n+import android.view.View;\n+import android.widget.EditText;\n+import android.widget.TextView;\n+import android.widget.Toast;\n+\n+import com.example.valeriaserber.trainingapp.R;\n+import com.example.valeriaserber.trainingapp.TrainingApplication;\n+import com.example.valeriaserber.trainingapp.model.SessionObject;\n+import com.example.valeriaserber.trainingapp.utilities.RestError;\n+import com.example.valeriaserber.trainingapp.utilities.UserUtility;\n+import com.example.valeriaserber.trainingapp.utilities.Validator;\n+\n+import retrofit.Callback;\n+import retrofit.RetrofitError;\n+import retrofit.client.Response;\n+\n+public class LoginActivity extends Activity {\n+\n+    private EditText mEmail;\n+    private EditText mPassword;\n+    private TextView mTermsConditions;\n+\n+    @Override\n+    protected void onCreate(Bundle savedInstanceState) {\n+        super.onCreate(savedInstanceState);\n+        setContentView(R.layout.activity_login);\n+        setUi();\n+        setListeners();\n+        SessionObject session = UserUtility.getUserData(this);\n+        if (session != null) {\n+            startUserActivity(session);\n+        }\n+    }\n+\n+    private void setUi() {\n+        mTermsConditions = (TextView) findViewById(R.id.activity_login_terms_text_view);\n+        mEmail = (EditText) findViewById(R.id.activity_login_email_text_edit);\n+        mPassword = (EditText) findViewById(R.id.activity_login_password_text_edit);\n+    }\n+\n+    private void setListeners() {\n+        mTermsConditions.setMovementMethod(LinkMovementMethod.getInstance());\n+    }\n+\n+    private void startUserActivity(SessionObject sessionObject) {\n+        Intent intent = new Intent(this, UserActivity.class);\n+        intent.putExtra(UserActivity.USER_EMAIL, sessionObject.getUsername());\n+        startActivity(intent);\n+    }\n+\n+    public void logInButton(View view) {\n+        String email = mEmail.getText().toString().trim();\n+        String password = mPassword.getText().toString().trim();\n+        boolean requiredEmail = Validator.validateRequiredField(mEmail, getString(R.string.email_required));\n+        boolean requiredPassword = Validator.validateRequiredField(mPassword, getString(R.string.password_required));\n+        if (!requiredEmail && !requiredPassword) {\n+            showToast(getString(R.string.all_required));\n+        } else if (requiredEmail) {\n+            if (Validator.validateEmail(mEmail, this)) {\n+                logIn(email, password);\n+            }\n+        }\n+    }\n+\n+    private void logIn(String email, String password){\n+        TrainingApplication.sUserService.logIn(email, password, new Callback<SessionObject>() {\n+            @Override\n+            public void success(SessionObject sessionObject, Response response) {\n+                UserUtility.saveUserData(sessionObject, getApplicationContext());\n+                startUserActivity(sessionObject);\n+            }\n+\n+            @Override\n+            public void failure(RetrofitError error) {\n+                if (error.getResponse() != null) {\n+                    RestError body = (RestError) error.getBodyAs(RestError.class);\n+                    switch (body.code) {\n+                        case 101:\n+                            showToast(getString(R.string.invalid_login));\n+                            return;\n+                        default:\n+                            showToast(getString(R.string.network_error));\n+                            return;\n+                    }\n+                }\n+            }\n+        });\n+    }\n+\n+    private void showToast(CharSequence text){\n+            int duration = Toast.LENGTH_SHORT;\n+            Toast toast = Toast.makeText(this, text, duration);\n+            toast.setGravity(Gravity.CENTER, 0, 0);\n+            toast.show();\n+    }\n+\n+    public void signUpButton(View view) {","path":"app/src/main/java/com/example/valeriaserber/trainingapp/activities/LoginActivity.java","position":104,"original_position":104,"commit_id":"ef50c5eb04a39ece8875594a022dbc327d04c2e5","original_commit_id":"ef50c5eb04a39ece8875594a022dbc327d04c2e5","user":{"login":"ConcoMB","id":1123168,"avatar_url":"https://avatars.githubusercontent.com/u/1123168?v=3","gravatar_id":"","url":"https://api.github.com/users/ConcoMB","html_url":"https://github.com/ConcoMB","followers_url":"https://api.github.com/users/ConcoMB/followers","following_url":"https://api.github.com/users/ConcoMB/following{/other_user}","gists_url":"https://api.github.com/users/ConcoMB/gists{/gist_id}","starred_url":"https://api.github.com/users/ConcoMB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ConcoMB/subscriptions","organizations_url":"https://api.github.com/users/ConcoMB/orgs","repos_url":"https://api.github.com/users/ConcoMB/repos","events_url":"https://api.github.com/users/ConcoMB/events{/privacy}","received_events_url":"https://api.github.com/users/ConcoMB/received_events","type":"User","site_admin":false},"body":"este metodo que hace?","created_at":"2015-01-20T13:38:58Z","updated_at":"2015-01-20T13:38:58Z","html_url":"https://github.com/valeserber/Training-Base-Vale/pull/1#discussion_r23222041","pull_request_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/comments/23222041"},"html":{"href":"https://github.com/valeserber/Training-Base-Vale/pull/1#discussion_r23222041"},"pull_request":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/1","id":27521729,"html_url":"https://github.com/valeserber/Training-Base-Vale/pull/1","diff_url":"https://github.com/valeserber/Training-Base-Vale/pull/1.diff","patch_url":"https://github.com/valeserber/Training-Base-Vale/pull/1.patch","issue_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues/1","number":1,"state":"open","locked":false,"title":"Login","user":{"login":"valeserber","id":5674142,"avatar_url":"https://avatars.githubusercontent.com/u/5674142?v=3","gravatar_id":"","url":"https://api.github.com/users/valeserber","html_url":"https://github.com/valeserber","followers_url":"https://api.github.com/users/valeserber/followers","following_url":"https://api.github.com/users/valeserber/following{/other_user}","gists_url":"https://api.github.com/users/valeserber/gists{/gist_id}","starred_url":"https://api.github.com/users/valeserber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valeserber/subscriptions","organizations_url":"https://api.github.com/users/valeserber/orgs","repos_url":"https://api.github.com/users/valeserber/repos","events_url":"https://api.github.com/users/valeserber/events{/privacy}","received_events_url":"https://api.github.com/users/valeserber/received_events","type":"User","site_admin":false},"body":"Layout, validaciones del formulario e implementación del login.\r\nValidaciones hechas: que el email sea válido, que el formulario no esté vacío, y se muestra un error si el email ingresado no existe o si la contraseña es incorrecta.\r\nLos datos de login se persisten, incluso si se cierra y se mata la aplicación.\r\nSi el usuario ya está logueado, al abrir la app se recuperan sus datos y se redirige a la activity de usuario.\r\nPara testearlo, un usuario de prueba es: email: valeserber@hotmail.com, contraseña: lala\r\n![screenshot_2015-01-19-10-24-58](https://cloud.githubusercontent.com/assets/5674142/5801092/e77ddcd6-9fc5-11e4-880e-165a1b7d292c.png)\r\n","created_at":"2015-01-16T17:27:39Z","updated_at":"2015-01-20T13:38:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ce2eabd4ea1f1f9ded21bc7a83aff14fe3e7d5c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/1/commits","review_comments_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/1/comments","review_comment_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/comments/{number}","comments_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues/1/comments","statuses_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/statuses/ef50c5eb04a39ece8875594a022dbc327d04c2e5","head":{"label":"valeserber:login","ref":"login","sha":"ef50c5eb04a39ece8875594a022dbc327d04c2e5","user":{"login":"valeserber","id":5674142,"avatar_url":"https://avatars.githubusercontent.com/u/5674142?v=3","gravatar_id":"","url":"https://api.github.com/users/valeserber","html_url":"https://github.com/valeserber","followers_url":"https://api.github.com/users/valeserber/followers","following_url":"https://api.github.com/users/valeserber/following{/other_user}","gists_url":"https://api.github.com/users/valeserber/gists{/gist_id}","starred_url":"https://api.github.com/users/valeserber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valeserber/subscriptions","organizations_url":"https://api.github.com/users/valeserber/orgs","repos_url":"https://api.github.com/users/valeserber/repos","events_url":"https://api.github.com/users/valeserber/events{/privacy}","received_events_url":"https://api.github.com/users/valeserber/received_events","type":"User","site_admin":false},"repo":{"id":29193649,"name":"Training-Base-Vale","full_name":"valeserber/Training-Base-Vale","owner":{"login":"valeserber","id":5674142,"avatar_url":"https://avatars.githubusercontent.com/u/5674142?v=3","gravatar_id":"","url":"https://api.github.com/users/valeserber","html_url":"https://github.com/valeserber","followers_url":"https://api.github.com/users/valeserber/followers","following_url":"https://api.github.com/users/valeserber/following{/other_user}","gists_url":"https://api.github.com/users/valeserber/gists{/gist_id}","starred_url":"https://api.github.com/users/valeserber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valeserber/subscriptions","organizations_url":"https://api.github.com/users/valeserber/orgs","repos_url":"https://api.github.com/users/valeserber/repos","events_url":"https://api.github.com/users/valeserber/events{/privacy}","received_events_url":"https://api.github.com/users/valeserber/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/valeserber/Training-Base-Vale","description":"","fork":false,"url":"https://api.github.com/repos/valeserber/Training-Base-Vale","forks_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/forks","keys_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/keys{/key_id}","collaborators_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/teams","hooks_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/hooks","issue_events_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues/events{/number}","events_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/events","assignees_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/assignees{/user}","branches_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/branches{/branch}","tags_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/tags","blobs_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/refs{/sha}","trees_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/trees{/sha}","statuses_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/statuses/{sha}","languages_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/languages","stargazers_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/stargazers","contributors_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/contributors","subscribers_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/subscribers","subscription_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/subscription","commits_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/commits{/sha}","git_commits_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/commits{/sha}","comments_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/comments{/number}","issue_comment_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues/comments/{number}","contents_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/contents/{+path}","compare_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/compare/{base}...{head}","merges_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/merges","archive_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/downloads","issues_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues{/number}","pulls_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls{/number}","milestones_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/milestones{/number}","notifications_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/labels{/name}","releases_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/releases{/id}","created_at":"2015-01-13T14:31:54Z","updated_at":"2015-01-16T17:18:06Z","pushed_at":"2015-01-20T13:18:33Z","git_url":"git://github.com/valeserber/Training-Base-Vale.git","ssh_url":"git@github.com:valeserber/Training-Base-Vale.git","clone_url":"https://github.com/valeserber/Training-Base-Vale.git","svn_url":"https://github.com/valeserber/Training-Base-Vale","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"valeserber:master","ref":"master","sha":"f682fb0b51f9e580f062a4d43a1138699c353d53","user":{"login":"valeserber","id":5674142,"avatar_url":"https://avatars.githubusercontent.com/u/5674142?v=3","gravatar_id":"","url":"https://api.github.com/users/valeserber","html_url":"https://github.com/valeserber","followers_url":"https://api.github.com/users/valeserber/followers","following_url":"https://api.github.com/users/valeserber/following{/other_user}","gists_url":"https://api.github.com/users/valeserber/gists{/gist_id}","starred_url":"https://api.github.com/users/valeserber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valeserber/subscriptions","organizations_url":"https://api.github.com/users/valeserber/orgs","repos_url":"https://api.github.com/users/valeserber/repos","events_url":"https://api.github.com/users/valeserber/events{/privacy}","received_events_url":"https://api.github.com/users/valeserber/received_events","type":"User","site_admin":false},"repo":{"id":29193649,"name":"Training-Base-Vale","full_name":"valeserber/Training-Base-Vale","owner":{"login":"valeserber","id":5674142,"avatar_url":"https://avatars.githubusercontent.com/u/5674142?v=3","gravatar_id":"","url":"https://api.github.com/users/valeserber","html_url":"https://github.com/valeserber","followers_url":"https://api.github.com/users/valeserber/followers","following_url":"https://api.github.com/users/valeserber/following{/other_user}","gists_url":"https://api.github.com/users/valeserber/gists{/gist_id}","starred_url":"https://api.github.com/users/valeserber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valeserber/subscriptions","organizations_url":"https://api.github.com/users/valeserber/orgs","repos_url":"https://api.github.com/users/valeserber/repos","events_url":"https://api.github.com/users/valeserber/events{/privacy}","received_events_url":"https://api.github.com/users/valeserber/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/valeserber/Training-Base-Vale","description":"","fork":false,"url":"https://api.github.com/repos/valeserber/Training-Base-Vale","forks_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/forks","keys_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/keys{/key_id}","collaborators_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/teams","hooks_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/hooks","issue_events_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues/events{/number}","events_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/events","assignees_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/assignees{/user}","branches_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/branches{/branch}","tags_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/tags","blobs_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/refs{/sha}","trees_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/trees{/sha}","statuses_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/statuses/{sha}","languages_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/languages","stargazers_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/stargazers","contributors_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/contributors","subscribers_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/subscribers","subscription_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/subscription","commits_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/commits{/sha}","git_commits_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/git/commits{/sha}","comments_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/comments{/number}","issue_comment_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues/comments/{number}","contents_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/contents/{+path}","compare_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/compare/{base}...{head}","merges_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/merges","archive_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/downloads","issues_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues{/number}","pulls_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls{/number}","milestones_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/milestones{/number}","notifications_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/labels{/name}","releases_url":"https://api.github.com/repos/valeserber/Training-Base-Vale/releases{/id}","created_at":"2015-01-13T14:31:54Z","updated_at":"2015-01-16T17:18:06Z","pushed_at":"2015-01-20T13:18:33Z","git_url":"git://github.com/valeserber/Training-Base-Vale.git","ssh_url":"git@github.com:valeserber/Training-Base-Vale.git","clone_url":"https://github.com/valeserber/Training-Base-Vale.git","svn_url":"https://github.com/valeserber/Training-Base-Vale","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/1"},"html":{"href":"https://github.com/valeserber/Training-Base-Vale/pull/1"},"issue":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues/1"},"comments":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/valeserber/Training-Base-Vale/statuses/ef50c5eb04a39ece8875594a022dbc327d04c2e5"}}}}