Changeset 114
- Timestamp:
- 02/05/09 13:28:32 (16 months ago)
- Location:
- trunk/rapidandroid/org.rapidandroid
- Files:
-
- 1 added
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/ChartData.java
r109 r114 49 49 private static final String STATE_GRAPH_OPTION = "graphoption"; 50 50 51 private static final String CHART_FILE = "file:///android_asset/flot/html/basechart.html";52 private static final String JAVASCRIPT_PROPERTYNAME = "graphdata";53 54 51 private static final int MENU_DONE = Menu.FIRST; 55 52 private static final int MENU_CHANGE_VARIABLE = Menu.FIRST + 1; … … 108 105 109 106 } 110 mWebView.addJavascriptInterface(mBroker, JAVASCRIPT_PROPERTYNAME); 111 mWebView.loadUrl(CHART_FILE); 107 mBroker.loadChartPage(); 112 108 //mBroker.loadGraph(); 113 109 } … … 149 145 } 150 146 151 mWebView.addJavascriptInterface(mBroker, JAVASCRIPT_PROPERTYNAME); 152 mWebView.loadUrl(CHART_FILE); 147 mBroker.loadChartPage(); 153 148 //mBroker.loadGraph(); 154 149 //mWebView.debugDump(); … … 275 270 276 271 } 272 273 274 277 275 278 276 @Override -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/chart/ChartBroker.java
r112 r114 32 32 */ 33 33 public abstract class ChartBroker { 34 35 private static final String CHART_FILE = "file:///android_asset/flot/html/basechart.html"; 36 private static final String JAVASCRIPT_PROPERTYNAME = "graphdata"; 37 private static final String EMPTY_FILE = "file:///android_asset/flot/html/empty.html"; 34 38 35 39 /** … … 81 85 }; 82 86 87 protected boolean mGotData; 88 private boolean mChartPageLoaded; 89 private boolean mAlreadyLoading; 90 83 91 protected ChartBroker(Activity activity, WebView appView, Date startDate, Date endDate) { 84 92 mParentActivity = activity; … … 131 139 */ 132 140 public synchronized final void loadGraph() { 133 mToggleThinkerHandler.post(mToggleThinker); 134 if(mGraphData == null && mGraphOptions == null) { 135 doLoadGraph(); 136 } 137 loadGraphFinish(); 138 } 141 if (!mAlreadyLoading) { 142 mToggleThinkerHandler.post(mToggleThinker); 143 if(mGraphData == null && mGraphOptions == null) { 144 doLoadGraph(); 145 } 146 loadGraphFinish(); 147 } 148 mAlreadyLoading = false; 149 } 150 139 151 protected void loadGraphFinish(){ 152 if (!mGotData) { 153 mAppView.loadUrl(EMPTY_FILE); 154 mChartPageLoaded = false; 155 finishGraph(); 156 return; 157 } 158 else if (!mChartPageLoaded) { 159 mAlreadyLoading = true; 160 reloadChartPage(); 161 } 140 162 int width = mAppView.getWidth(); 141 163 int height = 0; … … 148 170 mAppView.loadUrl("javascript:SetGraph(\"" + width + "px\", \"" + height + "px\")"); 149 171 mAppView.loadUrl("javascript:GotGraph(" + mGraphData.toString() + "," + mGraphOptions.toString() + ")"); 172 } 173 174 private void reloadChartPage() { 175 // don't add the js interface 176 mAppView.loadUrl(CHART_FILE); 177 mChartPageLoaded = true; 178 } 179 180 public void loadChartPage() { 181 mAppView.addJavascriptInterface(this, JAVASCRIPT_PROPERTYNAME); 182 mAppView.loadUrl(CHART_FILE); 183 mChartPageLoaded = true; 150 184 } 151 185 -
trunk/rapidandroid/org.rapidandroid/src/org/rapidandroid/activity/chart/form/FormDataBroker.java
r113 r114 68 68 mGraphOptions = allData.getOptions(); 69 69 } 70 if (mGraphData.toString().equals(this.getEmptyData().toString())) { 71 this.mGotData = false; 72 } else { 73 this.mGotData = true; 74 } 70 75 Log.d("FormDataBroker",mGraphData.toString()); 71 76 Log.d("FormDataBroker",mGraphOptions.toString());