Android Open Source - ArrecebaAndroid Interesse D A O






From Project

Back to project page ArrecebaAndroid.

License

The source code is released under:

GNU General Public License

If you think the Android project ArrecebaAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package br.com.projetointegrador.DAO;
/*from  w  w  w  .  j av a  2  s  .  co  m*/
import java.util.ArrayList;
import java.util.Hashtable;
import org.ksoap2.serialization.SoapObject;
import android.util.Log;
import br.com.projetointegrador.TO.Interesse;
import br.com.projetointegrador.TO.User;

public class InteresseDAO extends WebService {
  private static final String URL = "http://192.168.43.5/ArrecebaWS/Services/CategoriaWS.asmx";
  
  public static Interesse[] GetList(User user) {
    String MethodName = "ListSubcategoriasAndPreferences";
    
    Hashtable<String , Object> parameters = new Hashtable<String , Object>();
    parameters.put("login" , user.Login);
    parameters.put("password" , user.Password);
    
    Object response = InvokeMethod(URL , MethodName , parameters);
    
    if (hasError(response)) {
      Log.d("GetList" , "Error on response");
      return null;
    }
    
    return RetrieveListFromSoap((SoapObject) response);
  }
  
  public static boolean UpdatePreferences(User user , ArrayList<Integer> interesses) {
    String MethodName = "UpdateAndroidUserPreferences";
    
    SoapObject aux = new SoapObject("System.Int32" , "interesses");
    for (int i : interesses) {
      aux.addProperty("int" , i);
    }
    
    Hashtable<String , Object> parameters = new Hashtable<String , Object>();
    parameters.put("login" , user.Login);
    parameters.put("password" , user.Password);
    parameters.put("interesses" , aux);
    
    Object response = InvokeMethod(URL , MethodName , parameters);
    
    if (hasError(response)) {
      Log.d("UpdatePreferences" , "Error on response");
      return false;
    }
    
    return response.toString() == "true";
  }
  
  private static Interesse RetrieveFromSoap(SoapObject soap) {
    Interesse Interesse = new Interesse();
    Interesse.InteresseId = Integer.parseInt(soap.getProperty(0).toString());
    Interesse.Nome = soap.getProperty(1).toString();
    Interesse.checked = Boolean.parseBoolean(soap.getProperty(3).toString());
    
    return Interesse;
  }
  
  private static Interesse[] RetrieveListFromSoap(SoapObject soap) {
    Interesse[] AInteresse = new Interesse[soap.getPropertyCount()];
    
    for (int i = 0 ; i < AInteresse.length ; i++) {
      SoapObject so_Interesse = (SoapObject) soap.getProperty(i);
      
      Interesse Interesse = RetrieveFromSoap(so_Interesse);
      
      AInteresse[i] = Interesse;
    }
    
    return AInteresse;
  }
}




Java Source Code List

br.com.projetointegrador.ArrecebaAndroidActivity.java
br.com.projetointegrador.SplashActivity.java
br.com.projetointegrador.DAO.CrudDAO.java
br.com.projetointegrador.DAO.InteresseDAO.java
br.com.projetointegrador.DAO.ProdutoDAO.java
br.com.projetointegrador.DAO.SQLite.java
br.com.projetointegrador.DAO.SystemDAO.java
br.com.projetointegrador.DAO.UserDAO.java
br.com.projetointegrador.DAO.WebService.java
br.com.projetointegrador.Frm.FrmCrudList.java
br.com.projetointegrador.Frm.FrmInteresse.java
br.com.projetointegrador.Frm.FrmLogadoBase.java
br.com.projetointegrador.Frm.FrmLogin.java
br.com.projetointegrador.Frm.FrmProdutos.java
br.com.projetointegrador.Frm.FrmRegistrarse.java
br.com.projetointegrador.TO.Categoria.java
br.com.projetointegrador.TO.Crud.java
br.com.projetointegrador.TO.Interesse.java
br.com.projetointegrador.TO.Produto.java
br.com.projetointegrador.TO.User.java
br.com.projetointegrador.View.InteresseViewHolder.java
br.com.projetointegrador.View.ProdutoViewHolder.java
br.com.projetointegrador.table.TbUser.java