@@ -71,7 +71,7 @@ public AnyChartView(Context context, @Nullable AttributeSet attrs, int defStyleA
71
71
public Parcelable onSaveInstanceState () {
72
72
Bundle bundle = new Bundle ();
73
73
bundle .putParcelable ("superState" , super .onSaveInstanceState ());
74
- bundle .putString ("js" , this . js .toString ());
74
+ bundle .putString ("js" , js .toString ());
75
75
76
76
return bundle ;
77
77
}
@@ -80,7 +80,7 @@ public Parcelable onSaveInstanceState() {
80
80
public void onRestoreInstanceState (Parcelable state ) {
81
81
if (state instanceof Bundle ) {
82
82
Bundle bundle = (Bundle ) state ;
83
- this . js .append (bundle .getString ("js" ));
83
+ js .append (bundle .getString ("js" ));
84
84
state = bundle .getParcelable ("superState" );
85
85
}
86
86
isRestored = true ;
@@ -128,6 +128,9 @@ public void onJsLineAdd(final String jsLine) {
128
128
webView .post (new Runnable () {
129
129
@ Override
130
130
public void run () {
131
+ if (isRestored ) {
132
+ return ;
133
+ }
131
134
if (isRendered ) {
132
135
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT ) {
133
136
webView .evaluateJavascript (jsLine , null );
@@ -149,14 +152,6 @@ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request
149
152
}
150
153
151
154
public void onPageFinished (WebView view , String url ) {
152
- if (chart != null ) {
153
- if (!isRestored ) { //!isRendered &&
154
- // js.append(chart.generateJs());
155
- }
156
- } else {
157
- throw new NullPointerException ();
158
- }
159
-
160
155
String resultJs = (isRestored )
161
156
? js .toString ()
162
157
: js .append (chart .getJsBase ()).append (".container(\" container\" );" )
@@ -178,20 +173,8 @@ public void onReceiveValue(String value) {
178
173
}
179
174
});
180
175
176
+ isRestored = false ;
181
177
isRendered = true ;
182
-
183
- // chart.setOnChangeListener(new Chart.OnChange() {
184
- // @Override
185
- // public void onChange(final String jsChange) {
186
- // js.append(jsChange);
187
- // webView.post(new Runnable() {
188
- // @Override
189
- // public void run() {
190
- // webView.evaluateJavascript(jsChange, null);
191
- // }
192
- // });
193
- // }
194
- // });
195
178
}
196
179
});
197
180
webView .addJavascriptInterface (ListenersInterface .getInstance (), "android" );
@@ -260,7 +243,6 @@ public void clear() {
260
243
}
261
244
262
245
public void setChart (Chart chart ) {
263
- js .setLength (0 );
264
246
isRestored = false ;
265
247
this .chart = chart ;
266
248
loadHtml ();
0 commit comments