If you think the Android project chat.android 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 org.chat.android;
/*www.java2s.com*/import java.sql.SQLException;
import java.util.Date;
import org.chat.android.models.CHAAccessed;
import org.chat.android.models.Client;
import org.chat.android.models.Visit;
import com.j256.ormlite.dao.Dao;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
publicclass CHAOverviewActivity extends BaseActivity {
privateint visitId = 0;
privateint hhId = 0;
privateint clientId = 0;
@Override
publicvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = getApplicationContext();
setContentView(R.layout.activity_cha_overview);
Bundle b = getIntent().getExtras();
visitId = b.getInt("visitId");
hhId = b.getInt("hhId");
clientId = b.getInt("clientId");
}
publicvoid openCHADeliveryAsk(View v) {
setupCHAAccessedObject("health");
Intent i = new Intent(CHAOverviewActivity.this, CHADelivery.class);
Bundle b = new Bundle();
b.putInt("visitId",visitId);
b.putInt("hhId",hhId);
b.putInt("clientId",clientId);
i.putExtras(b);
startActivity(i);
}
publicvoid openImmunizationsReceived(View v) {
// TODO: put this back in for PROD
Client child = ModelHelper.getClientForId(getHelper(), clientId);
new AlertDialog.Builder(this)
.setMessage("Is " + child.getFirstName() + " " + child.getLastName() + "'s health card present?")
.setNegativeButton(R.string.action_no, new OnClickListener() {
publicvoid onClick(DialogInterface arg0, int arg1) {
alertUserToHealthCard();
}
})
.setPositiveButton(R.string.action_yes, new OnClickListener() {
publicvoid onClick(DialogInterface arg0, int arg1) {
setupCHAAccessedObject("immunization");
Intent i = new Intent(CHAOverviewActivity.this, ImmunizationsReceivedActivity.class);
Bundle b = new Bundle();
b.putInt("visitId",visitId);
b.putInt("hhId",hhId);
b.putInt("clientId",clientId);
i.putExtras(b);
startActivity(i);
}
}).create().show();
}
privatevoid setupCHAAccessedObject(String type) {
Date startTime = new Date();
CHAAccessed chaAccessed = new CHAAccessed(clientId, visitId, type, startTime, getHelper());
try {
Dao<CHAAccessed, Integer> chaaDao = getHelper().getCHAAccessedDao();
chaaDao.create(chaAccessed);
// FIXME: Colin Where does the visit object come from and why do we use the ID
visitId = visit.getId();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
privatevoid alertUserToHealthCard() {
// TODO: Zulu here
BaseActivity.toastHelper(this,"If possible please have the health card available at our next visit");
}
}