Changeset 104
- Timestamp:
- 02/04/09 00:17:11 (2 months ago)
- Location:
- trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/ChartData.java
r100 r104 92 92 mBroker= new FormDataBroker(wv, mForm, startDate,endDate); 93 93 } else if(extras.containsKey(CallParams.CHART_MESSAGES)) { 94 mBroker= new MessageDataBroker( wv,startDate,endDate);94 mBroker= new MessageDataBroker(this,wv,startDate,endDate); 95 95 } else if(extras.containsKey(CallParams.CHART_MONITORS)) { 96 96 … … 98 98 99 99 100 } 100 } 101 101 102 wv.getSettings().setJavaScriptEnabled(true); 102 103 wv.addJavascriptInterface(mBroker, JAVASCRIPT_PROPERTYNAME); -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/chart/IChartBroker.java
r100 r104 2 2 3 3 import java.util.Date; 4 5 import android.app.Activity; 4 6 5 7 … … 23 25 String[] getVariables(); 24 26 void setVariable(int id); 25 void setRange(Date startTime, Date endTime); 26 27 void setRange(Date startTime, Date endTime); 27 28 } -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/chart/message/MessageDataBroker.java
r100 r104 10 10 import org.rapidsms.java.core.model.Message; 11 11 12 import android.app.Activity; 12 13 import android.app.ProgressDialog; 13 14 import android.database.Cursor; 14 15 import android.database.sqlite.SQLiteDatabase; 16 import android.os.Handler; 15 17 import android.webkit.WebView; 16 18 import android.widget.Toast; … … 29 31 private Date mEndDate = Constants.NULLDATE; 30 32 private ProgressDialog mProgress = null; 33 private Activity mParentActivity; 31 34 32 public MessageDataBroker(WebView appView, Date startDate, Date endDate) { 35 final Handler mTitleHandler = new Handler(); 36 final Runnable mUpdateActivityTitle = new Runnable() { 37 public void run() { 38 mParentActivity.setTitle(variables[variablechosen]); 39 } 40 }; 41 42 public MessageDataBroker(Activity activity, WebView appView, Date startDate, Date endDate) { 43 this.mParentActivity = activity; 33 44 this.mAppView = appView; 34 45 this.rawDB = new SmsDbHelper(appView.getContext()); 46 35 47 36 48 this.variables = new String[] { "Trends by day", "Receipt time of day" }; … … 290 302 } 291 303 304 mTitleHandler.post(mUpdateActivityTitle); 305 292 306 } 293 307 -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/data/controller/MessageDataReporter.java
r90 r104 10 10 import android.content.Context; 11 11 import android.database.Cursor; 12 import android.database.sqlite.SQLiteDatabase; 12 13 13 14 public class MessageDataReporter { … … 18 19 query.append(" from rapidandroid_message"); 19 20 SmsDbHelper mHelper = new SmsDbHelper(context); 20 21 Cursor cr = mHelper.getReadableDatabase().rawQuery(query.toString(), null);21 SQLiteDatabase db = mHelper.getReadableDatabase(); 22 Cursor cr = db.rawQuery(query.toString(), null); 22 23 cr.moveToFirst(); 23 24 String dateString = cr.getString(0); … … 30 31 } 31 32 cr.close(); 33 db.close(); 34 mHelper.close(); 32 35 return ret; 33 36 } -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/data/controller/ParsedDataReporter.java
r103 r104 22 22 import android.content.Context; 23 23 import android.database.Cursor; 24 import android.database.sqlite.SQLiteDatabase; 24 25 import android.net.Uri; 25 26 import android.os.Environment; … … 46 47 query.append(") "); 47 48 48 Cursor cr = mHelper.getReadableDatabase().rawQuery(query.toString(), null); 49 SQLiteDatabase db = mHelper.getReadableDatabase(); 50 Cursor cr = db.rawQuery(query.toString(), null); 49 51 if(cr.getCount() == 0) { 50 52 cr.close(); 53 db.close(); 51 54 mHelper.close(); 52 55 return Constants.NULLDATE; … … 56 59 String dateString = cr.getString(0); 57 60 58 if (dateString == null) {61 if (dateString == null) { 59 62 cr.close(); 60 mHelper.close(); 63 db.close(); 64 mHelper.close(); 61 65 return Constants.NULLDATE; 62 66 } 63 67 64 68 Date ret = new Date(); 65 69 try { … … 67 71 } catch (ParseException e) { 68 72 // TODO Auto-generated catch block 73 69 74 e.printStackTrace(); 70 } 75 try { 76 if (cr != null) { 77 cr.close(); 78 } 79 if(db!=null) { 80 db.close(); 81 } 82 if (mHelper != null) { 83 mHelper.close(); 84 } 85 } catch (Exception ex2) { 86 87 } 88 } 71 89 cr.close(); 90 db.close(); 72 91 mHelper.close(); 73 92 return ret;