66import java .util .Map .Entry ;
77import java .util .Set ;
88
9- import org . apache . cordova . CordovaWebView ;
9+ import android . view . View ;
1010
1111import android .annotation .SuppressLint ;
1212import android .app .Activity ;
1919import android .os .Build .VERSION ;
2020import android .view .Gravity ;
2121import android .view .MotionEvent ;
22- import android .view .View ;
2322import android .view .ViewGroup ;
2423import android .widget .AbsoluteLayout ;
2524import android .widget .FrameLayout ;
2827
2928@ SuppressWarnings ("deprecation" )
3029public class MyPluginLayout extends FrameLayout {
31- private CordovaWebView webView ;
30+ private View view ;
3231 private ViewGroup root ;
3332 private RectF drawRect = new RectF ();
3433 private Context context ;
@@ -46,15 +45,15 @@ public class MyPluginLayout extends FrameLayout {
4645 private Activity mActivity = null ;
4746
4847 @ SuppressLint ("NewApi" )
49- public MyPluginLayout (CordovaWebView webView , Activity activity ) {
50- super (webView .getContext ());
48+ public MyPluginLayout (View view , Activity activity ) {
49+ super (view .getContext ());
5150 mActivity = activity ;
52- this .webView = webView ;
53- this .root = (ViewGroup ) webView .getParent ();
54- this .context = webView .getContext ();
55- webView .setBackgroundColor (Color .TRANSPARENT );
51+ this .view = view ;
52+ this .root = (ViewGroup ) view .getParent ();
53+ this .context = view .getContext ();
54+ view .setBackgroundColor (Color .TRANSPARENT );
5655 if (VERSION .SDK_INT >= Build .VERSION_CODES .HONEYCOMB ) {
57- webView .setLayerType (View .LAYER_TYPE_SOFTWARE , null );
56+ view .setLayerType (View .LAYER_TYPE_SOFTWARE , null );
5857 }
5958 frontLayer = new FrontLayerLayout (this .context );
6059
@@ -129,7 +128,7 @@ public void updateViewPosition() {
129128 return ;
130129 }
131130 ViewGroup .LayoutParams lParams = this .myView .getLayoutParams ();
132- int scrollY = webView .getScrollY ();
131+ int scrollY = view .getScrollY ();
133132
134133 if (lParams instanceof AbsoluteLayout .LayoutParams ) {
135134 AbsoluteLayout .LayoutParams params = (AbsoluteLayout .LayoutParams ) lParams ;
@@ -177,7 +176,7 @@ public void detachMyView() {
177176 }
178177 root .removeView (this );
179178 this .removeView (frontLayer );
180- frontLayer .removeView (webView );
179+ frontLayer .removeView (view );
181180
182181 scrollFrameLayout .removeView (myView );
183182 myView .removeView (this .touchableWrapper );
@@ -188,7 +187,7 @@ public void detachMyView() {
188187 myView .setLayoutParams (orgLayoutParams );
189188 }
190189
191- root .addView (webView );
190+ root .addView (view );
192191 myView = null ;
193192 mActivity .getWindow ().getDecorView ().requestFocus ();
194193 }
@@ -197,28 +196,28 @@ public void attachMyView(ViewGroup pluginView) {
197196 scrollView .setHorizontalScrollBarEnabled (false );
198197 scrollView .setVerticalScrollBarEnabled (false );
199198
200- scrollView .scrollTo (webView .getScrollX (), webView .getScrollY ());
199+ scrollView .scrollTo (view .getScrollX (), view .getScrollY ());
201200 if (myView == pluginView ) {
202201 return ;
203202 } else {
204203 this .detachMyView ();
205204 }
206- //backgroundView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, (int) (webView .getContentHeight() * webView .getScale() + webView .getHeight())));
205+ //backgroundView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, (int) (view .getContentHeight() * view .getScale() + view .getHeight())));
207206
208207 myView = pluginView ;
209208 ViewGroup .LayoutParams lParams = myView .getLayoutParams ();
210209 orgLayoutParams = null ;
211210 if (lParams != null ) {
212211 orgLayoutParams = new ViewGroup .LayoutParams (lParams );
213212 }
214- root .removeView (webView );
213+ root .removeView (view );
215214 scrollView .addView (scrollFrameLayout );
216215 this .addView (scrollView );
217216
218217 pluginView .addView (this .touchableWrapper );
219218 scrollFrameLayout .addView (pluginView );
220219
221- frontLayer .addView (webView );
220+ frontLayer .addView (view );
222221 this .addView (frontLayer );
223222 root .addView (this );
224223 mActivity .getWindow ().getDecorView ().requestFocus ();
@@ -258,12 +257,12 @@ public FrontLayerLayout(Context context) {
258257 @ Override
259258 public boolean onInterceptTouchEvent (MotionEvent event ) {
260259 if (isClickable == false || myView == null || myView .getVisibility () != View .VISIBLE ) {
261- webView .requestFocus (View .FOCUS_DOWN );
260+ view .requestFocus (View .FOCUS_DOWN );
262261 return false ;
263262 }
264263 int x = (int )event .getX ();
265264 int y = (int )event .getY ();
266- int scrollY = webView .getScrollY ();
265+ int scrollY = view .getScrollY ();
267266 boolean contains = drawRect .contains (x , y );
268267 int action = event .getAction ();
269268 isScrolling = (contains == false && action == MotionEvent .ACTION_DOWN ) ? true : isScrolling ;
@@ -289,7 +288,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
289288 }
290289 }
291290 if (!contains ) {
292- webView .requestFocus (View .FOCUS_DOWN );
291+ view .requestFocus (View .FOCUS_DOWN );
293292 }
294293 return contains ;
295294 }
@@ -300,7 +299,7 @@ protected void onDraw(Canvas canvas) {
300299 }
301300 int width = canvas .getWidth ();
302301 int height = canvas .getHeight ();
303- int scrollY = webView .getScrollY ();
302+ int scrollY = view .getScrollY ();
304303
305304 Paint paint = new Paint ();
306305 paint .setColor (Color .argb (100 , 0 , 255 , 0 ));
0 commit comments