Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.coffeeandcookies.edea.tasks;
- import android.os.AsyncTask;
- import android.util.Log;
- import com.activeandroid.query.Delete;
- import com.coffeeandcookies.edea.app;
- import com.coffeeandcookies.edea.app.finish;
- import com.coffeeandcookies.edea.objetos.Noticia;
- import org.w3c.dom.Node;
- import org.w3c.dom.NodeList;
- public class descargarNoticias extends AsyncTask<Void, Void, Integer> {
- String cantidad;
- finish inter;
- String principales;
- public descargarNoticias(String str, String str2, finish finish) {
- this.cantidad = str;
- this.principales = str2;
- this.inter = finish;
- }
- /* access modifiers changed from: protected */
- public Integer doInBackground(Void... voidArr) {
- try {
- new Delete().from(Noticia.class).execute();
- NodeList elementsByTagName = app.loadXMLFromString(app.requestNoticias(app.metodos[9], this.cantidad, this.principales)).getDocumentElement().getElementsByTagName("TNoticiasWeb");
- for (int i = 0; i < elementsByTagName.getLength(); i++) {
- NodeList childNodes = elementsByTagName.item(i).getChildNodes();
- Noticia noticia = new Noticia();
- for (int i2 = 0; i2 < childNodes.getLength(); i2++) {
- Node item = childNodes.item(i2);
- String nodeName = item.getNodeName();
- if (nodeName.equals("titulo")) {
- String obtenerTexto = app.obtenerTexto(item);
- StringBuilder sb = new StringBuilder();
- sb.append("titulo ");
- sb.append(obtenerTexto);
- Log.d("dump response: ", sb.toString());
- noticia.setTitulo(obtenerTexto);
- }
- if (nodeName.equals("fecha")) {
- String obtenerTexto2 = app.obtenerTexto(item);
- StringBuilder sb2 = new StringBuilder();
- sb2.append("fecha ");
- sb2.append(obtenerTexto2);
- Log.d("dump response: ", sb2.toString());
- noticia.setFecha(obtenerTexto2);
- }
- if (nodeName.equals("texto_breve")) {
- noticia.setTexto_breve(app.obtenerTexto(item));
- }
- if (nodeName.equals("imagen")) {
- noticia.setIamgen(app.obtenerTexto(item));
- }
- }
- noticia.save();
- }
- return Integer.valueOf(1);
- } catch (Exception e) {
- e.printStackTrace();
- return Integer.valueOf(-1);
- }
- }
- /* access modifiers changed from: protected */
- public void onPostExecute(Integer num) {
- this.inter.onFinish(num.intValue());
- super.onPostExecute(num);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment