From 8a8f1359d1a3fbb3abde1fecb97ffd9bd2d80026 Mon Sep 17 00:00:00 2001 From: RicomenPL Date: Wed, 5 Apr 2017 12:05:49 +0200 Subject: [PATCH] #2 Add checking corect password and e-mail --- .../wulkanowy/activity/main/CheckPass.java | 30 +++++++++++++++++++ .../wulkanowy/activity/main/Login.java | 12 ++++++-- build.gradle | 2 +- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/leszcz_team/wulkanowy/activity/main/CheckPass.java diff --git a/app/src/main/java/leszcz_team/wulkanowy/activity/main/CheckPass.java b/app/src/main/java/leszcz_team/wulkanowy/activity/main/CheckPass.java new file mode 100644 index 000000000..030348bd0 --- /dev/null +++ b/app/src/main/java/leszcz_team/wulkanowy/activity/main/CheckPass.java @@ -0,0 +1,30 @@ +package leszcz_team.wulkanowy.activity.main; + +import org.jsoup.Connection; +import org.jsoup.nodes.Document; +import org.jsoup.select.Elements; + +import java.io.IOException; + +public class CheckPass { + + Connection.Response page; + + public CheckPass (Connection.Response pageT){ + page = pageT; + } + + public String start (){ + try{ + Document document = page.parse(); + Elements mesageAlert = document.getElementsByClass("ErrorMessage center"); + return mesageAlert.text(); + } + catch (IOException e){ + return e.toString(); + } + + + } + +} diff --git a/app/src/main/java/leszcz_team/wulkanowy/activity/main/Login.java b/app/src/main/java/leszcz_team/wulkanowy/activity/main/Login.java index feefa4025..f2b73a47c 100644 --- a/app/src/main/java/leszcz_team/wulkanowy/activity/main/Login.java +++ b/app/src/main/java/leszcz_team/wulkanowy/activity/main/Login.java @@ -6,6 +6,8 @@ import android.widget.Toast; import org.jsoup.Connection; import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.select.Elements; import java.io.IOException; import java.util.Map; @@ -16,7 +18,7 @@ public class Login extends AsyncTask { String password; String county; Activity activity; - String test; + String userMesage; public Login(String emailT, String passwordT, String countyT, Activity mainAC){ @@ -42,9 +44,11 @@ public class Login extends AsyncTask { Map loginCookies = initial.cookies(); + CheckPass checkPass = new CheckPass(initial); + userMesage = checkPass.start(); } catch (IOException e){ - test = e.toString(); + userMesage = e.toString(); } return null; @@ -52,6 +56,8 @@ public class Login extends AsyncTask { protected void onPostExecute(Void result) { super.onPostExecute(result); - Toast.makeText(activity, test, Toast.LENGTH_LONG).show(); + if (!userMesage.isEmpty()){ + Toast.makeText(activity, userMesage, Toast.LENGTH_LONG).show(); + } } } diff --git a/build.gradle b/build.gradle index 1ea4bd055..b78a0b86c 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:2.3.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files