gonzalob

Untitled

Feb 24th, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.93 KB | None | 0 0
  1. package com.coffeeandcookies.edea.tasks;
  2.  
  3. import android.os.AsyncTask;
  4. import android.util.Log;
  5. import com.activeandroid.query.Delete;
  6. import com.coffeeandcookies.edea.app;
  7. import com.coffeeandcookies.edea.app.finish;
  8. import com.coffeeandcookies.edea.objetos.Noticia;
  9. import org.w3c.dom.Node;
  10. import org.w3c.dom.NodeList;
  11.  
  12. public class descargarNoticias extends AsyncTask<Void, Void, Integer> {
  13.     String cantidad;
  14.     finish inter;
  15.     String principales;
  16.  
  17.     public descargarNoticias(String str, String str2, finish finish) {
  18.         this.cantidad = str;
  19.         this.principales = str2;
  20.         this.inter = finish;
  21.     }
  22.  
  23.     /* access modifiers changed from: protected */
  24.     public Integer doInBackground(Void... voidArr) {
  25.         try {
  26.             new Delete().from(Noticia.class).execute();
  27.             NodeList elementsByTagName = app.loadXMLFromString(app.requestNoticias(app.metodos[9], this.cantidad, this.principales)).getDocumentElement().getElementsByTagName("TNoticiasWeb");
  28.             for (int i = 0; i < elementsByTagName.getLength(); i++) {
  29.                 NodeList childNodes = elementsByTagName.item(i).getChildNodes();
  30.                 Noticia noticia = new Noticia();
  31.                 for (int i2 = 0; i2 < childNodes.getLength(); i2++) {
  32.                     Node item = childNodes.item(i2);
  33.                     String nodeName = item.getNodeName();
  34.                     if (nodeName.equals("titulo")) {
  35.                         String obtenerTexto = app.obtenerTexto(item);
  36.                         StringBuilder sb = new StringBuilder();
  37.                         sb.append("titulo ");
  38.                         sb.append(obtenerTexto);
  39.                         Log.d("dump response: ", sb.toString());
  40.                         noticia.setTitulo(obtenerTexto);
  41.                     }
  42.                     if (nodeName.equals("fecha")) {
  43.                         String obtenerTexto2 = app.obtenerTexto(item);
  44.                         StringBuilder sb2 = new StringBuilder();
  45.                         sb2.append("fecha ");
  46.                         sb2.append(obtenerTexto2);
  47.                         Log.d("dump response: ", sb2.toString());
  48.                         noticia.setFecha(obtenerTexto2);
  49.                     }
  50.                     if (nodeName.equals("texto_breve")) {
  51.                         noticia.setTexto_breve(app.obtenerTexto(item));
  52.                     }
  53.                     if (nodeName.equals("imagen")) {
  54.                         noticia.setIamgen(app.obtenerTexto(item));
  55.                     }
  56.                 }
  57.                 noticia.save();
  58.             }
  59.             return Integer.valueOf(1);
  60.         } catch (Exception e) {
  61.             e.printStackTrace();
  62.             return Integer.valueOf(-1);
  63.         }
  64.     }
  65.  
  66.     /* access modifiers changed from: protected */
  67.     public void onPostExecute(Integer num) {
  68.         this.inter.onFinish(num.intValue());
  69.         super.onPostExecute(num);
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment