@@ -128,7 +128,6 @@ public class RemoteViews implements Parcelable, Filter {
128128 private boolean mIsWidgetCollectionChild = false ;
129129
130130 private static final OnClickHandler DEFAULT_ON_CLICK_HANDLER = new OnClickHandler ();
131- private OnClickHandler mOnClickHandler = DEFAULT_ON_CLICK_HANDLER ;
132131
133132 /**
134133 * This annotation indicates that a subclass of View is alllowed to be used
@@ -185,8 +184,8 @@ public boolean onClickHandler(View view, PendingIntent pendingIntent,
185184 * SUBCLASSES MUST BE IMMUTABLE SO CLONE WORKS!!!!!
186185 */
187186 private abstract static class Action implements Parcelable {
188- public abstract void apply (RemoteViews owner , View root ,
189- ViewGroup rootParent ) throws ActionException ;
187+ public abstract void apply (View root , ViewGroup rootParent ,
188+ OnClickHandler handler ) throws ActionException ;
190189
191190 public int describeContents () {
192191 return 0 ;
@@ -229,7 +228,7 @@ public void writeToParcel(Parcel out, int flags) {
229228 }
230229
231230 @ Override
232- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
231+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
233232 final View view = root .findViewById (viewId );
234233 if (!(view instanceof AdapterView <?>)) return ;
235234
@@ -260,7 +259,7 @@ public void writeToParcel(Parcel dest, int flags) {
260259 }
261260
262261 @ Override
263- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
262+ public void apply (View root , ViewGroup rootParent , final OnClickHandler handler ) {
264263 final View target = root .findViewById (viewId );
265264 if (target == null ) return ;
266265
@@ -272,7 +271,6 @@ public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
272271 if (target == root ) {
273272 target .setTagInternal (com .android .internal .R .id .fillInIntent , fillInIntent );
274273 } else if (target != null && fillInIntent != null ) {
275- final OnClickHandler clicker = owner .mOnClickHandler ;
276274 OnClickListener listener = new OnClickListener () {
277275 public void onClick (View v ) {
278276 // Insure that this view is a child of an AdapterView
@@ -310,7 +308,7 @@ public void onClick(View v) {
310308 rect .bottom = (int ) ((pos [1 ] + v .getHeight ()) * appScale + 0.5f );
311309
312310 fillInIntent .setSourceBounds (rect );
313- clicker .onClickHandler (v , pendingIntent , fillInIntent );
311+ handler .onClickHandler (v , pendingIntent , fillInIntent );
314312 }
315313
316314 };
@@ -342,14 +340,13 @@ public void writeToParcel(Parcel dest, int flags) {
342340 }
343341
344342 @ Override
345- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
343+ public void apply (View root , ViewGroup rootParent , final OnClickHandler handler ) {
346344 final View target = root .findViewById (viewId );
347345 if (target == null ) return ;
348346
349347 // If the view isn't an AdapterView, setting a PendingIntent template doesn't make sense
350348 if (target instanceof AdapterView <?>) {
351349 AdapterView <?> av = (AdapterView <?>) target ;
352- final OnClickHandler clicker = owner .mOnClickHandler ;
353350 // The PendingIntent template is stored in the view's tag.
354351 OnItemClickListener listener = new OnItemClickListener () {
355352 public void onItemClick (AdapterView <?> parent , View view ,
@@ -389,7 +386,7 @@ public void onItemClick(AdapterView<?> parent, View view,
389386
390387 final Intent intent = new Intent ();
391388 intent .setSourceBounds (rect );
392- clicker .onClickHandler (view , pendingIntentTemplate , fillInIntent );
389+ handler .onClickHandler (view , pendingIntentTemplate , fillInIntent );
393390 }
394391 }
395392 };
@@ -426,7 +423,7 @@ public void writeToParcel(Parcel dest, int flags) {
426423 }
427424
428425 @ Override
429- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
426+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
430427 final View target = root .findViewById (viewId );
431428 if (target == null ) return ;
432429
@@ -494,7 +491,7 @@ public void writeToParcel(Parcel dest, int flags) {
494491 }
495492
496493 @ Override
497- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
494+ public void apply (View root , ViewGroup rootParent , final OnClickHandler handler ) {
498495 final View target = root .findViewById (viewId );
499496 if (target == null ) return ;
500497
@@ -515,7 +512,6 @@ public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
515512
516513 if (target != null ) {
517514 // If the pendingIntent is null, we clear the onClickListener
518- final OnClickHandler clicker = owner .mOnClickHandler ;
519515 OnClickListener listener = null ;
520516 if (pendingIntent != null ) {
521517 listener = new OnClickListener () {
@@ -535,7 +531,7 @@ public void onClick(View v) {
535531
536532 final Intent intent = new Intent ();
537533 intent .setSourceBounds (rect );
538- clicker .onClickHandler (v , pendingIntent , intent );
534+ handler .onClickHandler (v , pendingIntent , intent );
539535 }
540536 };
541537 }
@@ -602,7 +598,7 @@ public void writeToParcel(Parcel dest, int flags) {
602598 }
603599
604600 @ Override
605- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
601+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
606602 final View target = root .findViewById (viewId );
607603 if (target == null ) return ;
608604
@@ -662,7 +658,7 @@ public void writeToParcel(Parcel out, int flags) {
662658 }
663659
664660 @ Override
665- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
661+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
666662 final View view = root .findViewById (viewId );
667663 if (view == null ) return ;
668664
@@ -786,11 +782,11 @@ public void writeToParcel(Parcel dest, int flags) {
786782 }
787783
788784 @ Override
789- public void apply (RemoteViews owner , View root ,
790- ViewGroup rootParent ) throws ActionException {
785+ public void apply (View root , ViewGroup rootParent ,
786+ OnClickHandler handler ) throws ActionException {
791787 ReflectionAction ra = new ReflectionAction (viewId , methodName , ReflectionAction .BITMAP ,
792788 bitmap );
793- ra .apply (owner , root , rootParent );
789+ ra .apply (root , rootParent , handler );
794790 }
795791
796792 @ Override
@@ -1006,7 +1002,7 @@ private Class getParameterType() {
10061002 }
10071003
10081004 @ Override
1009- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
1005+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
10101006 final View view = root .findViewById (viewId );
10111007 if (view == null ) return ;
10121008
@@ -1108,13 +1104,13 @@ public void writeToParcel(Parcel dest, int flags) {
11081104 }
11091105
11101106 @ Override
1111- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
1107+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
11121108 final Context context = root .getContext ();
11131109 final ViewGroup target = (ViewGroup ) root .findViewById (viewId );
11141110 if (target == null ) return ;
11151111 if (nestedViews != null ) {
11161112 // Inflate nested views and add as children
1117- target .addView (nestedViews .apply (owner , context , target ));
1113+ target .addView (nestedViews .apply (context , target , handler ));
11181114 } else {
11191115 // Clear all children when nested views omitted
11201116 target .removeAllViews ();
@@ -1175,7 +1171,7 @@ public void writeToParcel(Parcel dest, int flags) {
11751171 }
11761172
11771173 @ Override
1178- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
1174+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
11791175 final Context context = root .getContext ();
11801176 final TextView target = (TextView ) root .findViewById (viewId );
11811177 if (target == null ) return ;
@@ -1217,7 +1213,7 @@ public void writeToParcel(Parcel dest, int flags) {
12171213 }
12181214
12191215 @ Override
1220- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
1216+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
12211217 final Context context = root .getContext ();
12221218 final TextView target = (TextView ) root .findViewById (viewId );
12231219 if (target == null ) return ;
@@ -1261,7 +1257,7 @@ public void writeToParcel(Parcel dest, int flags) {
12611257 }
12621258
12631259 @ Override
1264- public void apply (RemoteViews owner , View root , ViewGroup rootParent ) {
1260+ public void apply (View root , ViewGroup rootParent , OnClickHandler handler ) {
12651261 final Context context = root .getContext ();
12661262 final View target = root .findViewById (viewId );
12671263 if (target == null ) return ;
@@ -2099,11 +2095,6 @@ private RemoteViews getRemoteViewsToApply(Context context) {
20992095 return this ;
21002096 }
21012097
2102- /** @hide */
2103- public void setOnClickHandler (OnClickHandler handler ) {
2104- mOnClickHandler = handler ;
2105- }
2106-
21072098 /**
21082099 * Inflates the view hierarchy represented by this object and applies
21092100 * all of the actions.
@@ -2116,10 +2107,11 @@ public void setOnClickHandler(OnClickHandler handler) {
21162107 * @return The inflated view hierarchy
21172108 */
21182109 public View apply (Context context , ViewGroup parent ) {
2119- return apply (this , context , parent );
2110+ return apply (context , parent , DEFAULT_ON_CLICK_HANDLER );
21202111 }
21212112
2122- View apply (RemoteViews owner , Context context , ViewGroup parent ) {
2113+ /** @hide */
2114+ public View apply (Context context , ViewGroup parent , OnClickHandler handler ) {
21232115 RemoteViews rvToApply = getRemoteViewsToApply (context );
21242116
21252117 View result ;
@@ -2134,7 +2126,7 @@ View apply(RemoteViews owner, Context context, ViewGroup parent) {
21342126
21352127 result = inflater .inflate (rvToApply .getLayoutId (), parent , false );
21362128
2137- rvToApply .performApply (owner , result , parent );
2129+ rvToApply .performApply (result , parent , handler );
21382130
21392131 return result ;
21402132 }
@@ -2148,6 +2140,11 @@ View apply(RemoteViews owner, Context context, ViewGroup parent) {
21482140 * the {@link #apply(Context,ViewGroup)} call.
21492141 */
21502142 public void reapply (Context context , View v ) {
2143+ reapply (context , v , DEFAULT_ON_CLICK_HANDLER );
2144+ }
2145+
2146+ /** @hide */
2147+ public void reapply (Context context , View v , OnClickHandler handler ) {
21512148 RemoteViews rvToApply = getRemoteViewsToApply (context );
21522149
21532150 // In the case that a view has this RemoteViews applied in one orientation, is persisted
@@ -2161,15 +2158,15 @@ public void reapply(Context context, View v) {
21612158 }
21622159
21632160 prepareContext (context );
2164- rvToApply .performApply (this , v , (ViewGroup ) v .getParent ());
2161+ rvToApply .performApply (v , (ViewGroup ) v .getParent (), handler );
21652162 }
21662163
2167- private void performApply (RemoteViews owner , View v , ViewGroup parent ) {
2164+ private void performApply (View v , ViewGroup parent , OnClickHandler handler ) {
21682165 if (mActions != null ) {
21692166 final int count = mActions .size ();
21702167 for (int i = 0 ; i < count ; i ++) {
21712168 Action a = mActions .get (i );
2172- a .apply (owner , v , parent );
2169+ a .apply (v , parent , handler );
21732170 }
21742171 }
21752172 }
0 commit comments