Android Open Source - EasyVote User Data






From Project

Back to project page EasyVote.

License

The source code is released under:

Apache License

If you think the Android project EasyVote 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 com.llanox.mobile.easyvote.data;
/* w  w  w .ja v a 2 s  .com*/
import java.util.List;

import android.content.Context;
import android.database.SQLException;

import com.backendless.Backendless;
import com.backendless.BackendlessCollection;
import com.backendless.async.callback.AsyncCallback;
import com.backendless.async.callback.BackendlessCallback;
import com.backendless.exceptions.BackendlessFault;
import com.backendless.persistence.BackendlessDataQuery;
import com.llanox.mobile.easyvote.model.User;

public class UserData implements DataSession<User> {

  
  public UserData(Context ctx) {
    DataLayerManager.getInstance(ctx).startBackend();
  }

  @Override
  public void open() throws SQLException {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void close() {
    // TODO Auto-generated method stub
    
  }

  @Override
  public void insert(User item) {  
    Backendless.Persistence.save(item);
  }

  @Override
  public void asyncInsert(User item, final ResponseHandler<User> handler) {
    
    Backendless.Persistence.save( item, new BackendlessCallback<User>()
          {
                @Override
             public void handleResponse( User user ) {
                       handler.succesfull(user);
            
              }

            @Override
            public void handleFault(BackendlessFault fault) {
              super.handleFault(fault);
              handler.error(fault.getMessage());
            }
                
                
                
      } );
    
  }

  @Override
  public void update(User item) {
    insert(item);
    
  }

  @Override
  public void asyncUpdate(User item, com.llanox.mobile.easyvote.data.DataSession.ResponseHandler<User> handler) {
    asyncInsert(item,handler);
    
  }

  @Override
  public User findById(String id) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public User asyncFindById(String id,final com.llanox.mobile.easyvote.data.DataSession.ResponseHandler<User> handler) {
    
    String whereClause = "id like '"+id+"'";
    BackendlessDataQuery dataQuery = new BackendlessDataQuery();
    dataQuery.setWhereClause( whereClause );
    
    Backendless.Persistence.of( User.class ).find( dataQuery, 
                new AsyncCallback<BackendlessCollection<User>>(){

          @Override
          public void handleFault(BackendlessFault fault) {          
            handler.error(fault.getMessage());            
          }

          @Override
          public void handleResponse(  BackendlessCollection<User> response) {            
            handler.succesfull(response.getData()!=null && response.getTotalObjects()>0?response.getData().get(0):null);
            
      }} );
    return null;
  }

  @Override
  public List<User> findAll() {

    return null;
  }

  @Override
  public List<User> asyncFindAll(com.llanox.mobile.easyvote.data.DataSession.ResponseHandler<List<User>> handler) {
    // TODO Auto-generated method stub
    return null;
  }

  

}




Java Source Code List

com.llanox.mobile.easyvote.AnswerQuestionDetailActivity.java
com.llanox.mobile.easyvote.AnswerQuestionDetailFragment.java
com.llanox.mobile.easyvote.AnswerQuestionListActivity.java
com.llanox.mobile.easyvote.AnswerQuestionListFragment.java
com.llanox.mobile.easyvote.AppCredentials.java
com.llanox.mobile.easyvote.AppSessionManager.java
com.llanox.mobile.easyvote.AskQuestion.java
com.llanox.mobile.easyvote.ConstantsEasyVote.java
com.llanox.mobile.easyvote.EntryPointActivity.java
com.llanox.mobile.easyvote.PlusBaseActivity.java
com.llanox.mobile.easyvote.QuestionDetailActivity.java
com.llanox.mobile.easyvote.QuestionDetailFragment.java
com.llanox.mobile.easyvote.QuestionListActivity.java
com.llanox.mobile.easyvote.QuestionListFragment.java
com.llanox.mobile.easyvote.data.DataException.java
com.llanox.mobile.easyvote.data.DataLayerManager.java
com.llanox.mobile.easyvote.data.DataSession.java
com.llanox.mobile.easyvote.data.QuestionData.java
com.llanox.mobile.easyvote.data.UserData.java
com.llanox.mobile.easyvote.data.util.DateTimeUtils.java
com.llanox.mobile.easyvote.model.AnswerQuestion.java
com.llanox.mobile.easyvote.model.Question.java
com.llanox.mobile.easyvote.model.User.java