CMPUT301W15T12 / C301Project

Apache License 2.0
3 stars 2 forks source link

Elastic search client is ready to go. Time to integrate. #72

Closed qsjiang closed 9 years ago

qsjiang commented 9 years ago

After coding several versions of elastic search client, I end up picking the simplest and most straight forward approach. This approach leaves all controllers completely untouched, so no need for any major code surgery.

Most of the changes happen inside the login activity. The login activity will need to load the data from elastic search server on startup and show a spinner while loading.

Here is a preview of what needs to be done inside login activity. I will help you making the change in lab.

new LoadingOnlineRecordTask().execute();   //put this inside oncreate
turnOnSpinner();  //fake pseudo code

//AsyncTask For loading records from Elastic Server
private class LoadingOnlineRecordTask extends AsyncTask<Void, Void, Void> {
    @Override
    protected Void doInBackground(Void... optionalInputs) {
        new ESClient().loadRecordFromServer();
        return null;
    }
    @Override
    protected void onPostExecute(Void result) {
                    turnOffSpinner(); //fake pseudo code
        ClaimListController claimListController = new ClaimListController();
        Toast.makeText(LoginActivity.this,"Loaded: "+claimListController.size()+" claims "+UserList.users.size()+" users", Toast.LENGTH_SHORT).show();       
    }  
}