Exemplo n.º 1
0
  public List<Map<String, Object>> getNoticias(String url, Context context) {
    ArrayList<Map<String, String>> json = this.JSON(url, context);
    List<Map<String, Object>> noticias = new ArrayList<Map<String, Object>>();
    Map<String, Object> data;
    if (json.get(0).get("internet").equals("true")) {
      for (int i = 0; i < json.size(); i++) {
        try {
          data = new HashMap<String, Object>();
          Log.i("JSON Lista Recebida", i + " -> " + json.get(i).toString());
          Noticias noticia =
              new Noticias(
                  json.get(i).get("title"),
                  json.get(i).get("description"),
                  json.get(i).get("author"),
                  json.get(i).get("link"),
                  json.get(i).get("image"),
                  json.get(i).get("datetime"));

          data.put("internet", true);
          data.put("title", noticia.getTitle());
          data.put("author", noticia.getAuthor());
          data.put("description", noticia.getDescription());
          data.put("image", noticia.getImage());
          data.put("datetime", noticia.getDate());
          data.put("link", noticia.getLink());

          noticias.add(data);
        } catch (Exception e) {
          Log.e("JSON - Noticias", e.getMessage() + " " + e.getStackTrace());
        }
      }
    } else {
      data = new HashMap<String, Object>();
      data.put("internet", false);
      noticias.add(data);
    }
    return noticias;
  }
Exemplo n.º 2
0
  private void selectItem(String title, Bundle argument) {
    // Enviar título como arguemento del fragmento
    Bundle args = new Bundle();
    Fragment fragment;
    drawerLayout.closeDrawers(); // Cerrar drawer

    switch (title) {
      case "Inicio":
        fragment = Noticias.newInstance(title);
        args.putString(Noticias.ARG_SECTION_TITLE, title);
        fragment.setArguments(args);
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Lista de Clase":
        fragment = new ListadoClasesFragment();
        args.putString(Noticias.ARG_SECTION_TITLE, title);
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Citas Médicas":
        fragment = new CitasFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Auto Evaluación":
        fragment = new AutoEvaluacionFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Facultades":
        fragment = new FacultadesFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Calendario":
        fragment = new CalendarioFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Horario de Clase":
        fragment = new HorarioFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Notas":
        fragment = new NotasFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Parciales":
        fragment = new ParcialesFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Asesoría Académica":
        fragment = new AsesoriaFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Acerca del Poli":
        fragment = new AcercaDeActivity();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      case "Recibos de Pago":
        fragment = new ComprobanteFragment();
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
      default:
        fragment = Noticias.newInstance(title);
        args.putString(Noticias.ARG_SECTION_TITLE, title);
        fragment.setArguments(args);
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.main_content, fragment)
            .commit();
        setTitle(title); // Setear título actual
        break;
    }
  }