Guest User

Untitled

a guest
Dec 17th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. HttpClient client = new HttpClient(new OnHttpRequestComplete() {
  2. @Override
  3. public void onComplete(Response status) {
  4. if(status.isSuccess()){
  5. Gson gson = new GsonBuilder().create();
  6. try {
  7. JSONObject jsono = new JSONObject(status.getResult());
  8. // Se llamaría es al UID del usuario, para efectos de esta prueba llamo directamente
  9. // el uid.
  10. JSONArray jsonarray = jsono.getJSONArray("Io0TUxDWdNXjdzoaBiXsC8Qh77b2");
  11. ArrayList<Person> personas = new ArrayList<Person>();
  12. for (int i = 0; i < jsonarray.length(); i++){
  13. String person = jsonarray.getString(i);
  14. System.out.println(person);
  15. Person p = gson.fromJson(person, Person.class);
  16. personas.add(p);
  17. System.err.println(p.getCreatedAt());
  18. //TextView t = new TextView(mainActivity.this);
  19. TextView t = new TextView(getBaseContext());
  20. t.setText(p.getCreatedAt());
  21. stackContent.addView(t);
  22. }
  23.  
  24. }catch (Exception e){
  25. System.out.println("Falla Presente");
  26. e.printStackTrace();
  27. }
  28. Toast.makeText(mainActivity.this, status.getResult(), Toast.LENGTH_SHORT);
  29. }
  30. }
  31. });
  32.  
  33. client.excecute("https://console.firebase.google.com/u/0/project/akibaap2/database/akibaap2/data/users");
  34. }
  35.  
  36. @Override
  37. public boolean onCreateOptionsMenu(Menu menu) {
  38. // Inflate the menu; this adds items to the action bar if it is present.
  39. getMenuInflater().inflate(R.menu.menu_main, menu);
  40. return true;
  41. }
  42.  
  43. @Override
  44. public boolean onOptionsItemSelected(MenuItem item) {
  45. // Handle action bar item clicks here. The action bar will
  46. // automatically handle clicks on the Home/Up button, so long
  47. // as you specify a parent activity in AndroidManifest.xml.
  48. int id = item.getItemId();
  49.  
  50. //noinspection SimplifiableIfStatement
  51. if (id == R.id.action_settings) {
  52. return true;
  53. }
  54.  
  55. return super.onOptionsItemSelected(item);
  56. }
Add Comment
Please, Sign In to add comment