Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onClick(View v) {
- // findViewbyId coba pakai butterknife
- //kenap gagal, karena ketika klik pertama belum dapet return dari server
- //klik kedua berhasil Karena sudah dapet return
- // volley itu asycrounous silakan googling
- EditText jb = (EditText) findViewById(R.id.jawaban);//
- final String gjb = jb.getText().toString();
- final TextView tv = (TextView) findViewById(R.id.get_jawab);
- final String tvv = tv.getText().toString();
- tv.setText("");
- StringRequest stringRequest = new StringRequest(Request.Method.GET, URLs.URL_GET_VERIFIKASI, new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- //response api Nya bentuk nya bagaimana ?
- //
- try {
- JSONObject jsonObject = new JSONObject(response);
- JSONArray jsonArray = jsonObject.getJSONArray("verifikasi");
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject jo = jsonArray.getJSONObject(i);
- // Do you fancy stuff
- String j= jo.getString("jawab");
- tv.append(j);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- //validasi pindahin kesini Aja
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- }
- });
- RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
- requestQueue.add(stringRequest);
- //proses validasi di pindahin ke on resspone aja
- if (gjb.equals(tvv)){
- registerUser();
- }else {
- AlertDialog.Builder vm = new AlertDialog.Builder(MainActivity.this);
- vm.setTitle("KESALAHAN ! ");
- vm.setMessage("Kode Verifikasi Tidak Tepat, Silahkan Hubungi Admin Untuk Bantuan! ");
- vm.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface arg0, int arg1) {
- }
- });
- // show it
- vm.show();
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement