Exemplo n.º 1
1
    @Override
    protected DatosUsuario doInBackground(Void... voids) {

      DatosUsuario du = new DatosUsuario();
      SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
      String username = settings.getString("username", "");
      String password = settings.getString("password", "");

      Euri euri = new Euri(username, password);
      String imageUrl = "http://www.eurielec.etsit.upm.es/images/miembro.php?m=" + username;
      URL url;
      try {
        url = new URL(imageUrl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        InputStream is = connection.getInputStream();
        Log.d("image", is.toString());
        Bitmap img = BitmapFactory.decodeStream(is);
        du.setFoto(img);
        PictUtil.saveToCacheFile(img);

      } catch (Exception e) {
        e.printStackTrace();
      }

      du.setDatos(euri.get("userinfo"));
      du.setDeuda(euri.get("deuda"));

      return du;
    }
Exemplo n.º 2
0
  @Override
  public void onActivityCreated(Bundle state) {
    super.onActivityCreated(state);
    context = this.getActivity();
    nombre = (TextView) getView().findViewById(R.id.nombre);
    deuda = (TextView) getView().findViewById(R.id.euros);
    foto = (ImageView) getView().findViewById(R.id.foto);

    dbHelper = new DatosDBHelper(context);
    database = dbHelper.getWritableDatabase();
    Datos datos = this.getDatosDB();

    nombre.setText(datos.getName() + " " + datos.getSurname());
    deuda.setText(String.valueOf(datos.getDeuda()));
    foto.setImageBitmap(PictUtil.loadFromCacheFile());

    loadContent();
  }