1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.databinding.testapp.vo;
17 
18 import android.content.Context;
19 import android.databinding.ObservableBoolean;
20 import android.graphics.Outline;
21 import android.media.MediaPlayer;
22 import android.text.Editable;
23 import android.view.ActionMode;
24 import android.view.ContextMenu;
25 import android.view.DragEvent;
26 import android.view.KeyEvent;
27 import android.view.MenuItem;
28 import android.view.MotionEvent;
29 import android.view.View;
30 import android.view.ViewStub;
31 import android.view.WindowInsets;
32 import android.view.animation.Animation;
33 import android.widget.AbsListView;
34 import android.widget.AdapterView;
35 import android.widget.CalendarView;
36 import android.widget.Chronometer;
37 import android.widget.CompoundButton;
38 import android.widget.ExpandableListView;
39 import android.widget.NumberPicker;
40 import android.widget.RadioGroup;
41 import android.widget.RatingBar;
42 import android.widget.SeekBar;
43 import android.widget.TextView;
44 import android.widget.TimePicker;
45 
46 public class ListenerBindingObject {
47     public static int lastClick = 0;
48     public boolean inflateCalled;
49     private final Context mContext;
50 
51     public final ObservableBoolean clickable = new ObservableBoolean();
52     public final ObservableBoolean useOne = new ObservableBoolean();
53 
ListenerBindingObject(Context context)54     public ListenerBindingObject(Context context) {
55         clickable.set(true);
56         this.mContext = context;
57     }
58 
onMovedToScrapHeap(View view)59     public void onMovedToScrapHeap(View view) { }
60 
onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)61     public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
62             int totalItemCount) {}
63 
onScrollStateChanged(AbsListView view, int scrollState)64     public void onScrollStateChanged(AbsListView view, int scrollState) { }
65 
onMenuItemClick(MenuItem item)66     public boolean onMenuItemClick(MenuItem item) {
67         return false;
68     }
69 
onItemClick(AdapterView<?> parent, View view, int position, long id)70     public void onItemClick(AdapterView<?> parent, View view, int position, long id) { }
71 
onItemLongClick(AdapterView<?> parent, View view, int position, long id)72     public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
73         return true;
74     }
75 
onItemSelected(AdapterView<?> parent, View view, int position, long id)76     public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { }
77 
onNothingSelected(AdapterView<?> parent)78     public void onNothingSelected(AdapterView<?> parent) { }
79 
onDismiss()80     public void onDismiss() { }
81 
fixText(CharSequence invalidText)82     public CharSequence fixText(CharSequence invalidText) {
83         return invalidText;
84     }
85 
isValid(CharSequence text)86     public boolean isValid(CharSequence text) {
87         return true;
88     }
89 
onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth)90     public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) { }
91 
onChronometerTick(Chronometer chronometer)92     public void onChronometerTick(Chronometer chronometer) { }
93 
onCheckedChanged(CompoundButton buttonView, boolean isChecked)94     public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { }
95 
onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)96     public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
97             int childPosition, long id) {
98         return false;
99     }
100 
onGroupClick(ExpandableListView parent, View v, int groupPosition, long id)101     public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
102         return false;
103     }
104 
onGroupCollapse(int groupPosition)105     public void onGroupCollapse(int groupPosition) { }
106 
onGroupExpand(int groupPosition)107     public void onGroupExpand(int groupPosition) { }
108 
format(int value)109     public String format(int value) {
110         return null;
111     }
112 
onValueChange(NumberPicker picker, int oldVal, int newVal)113     public void onValueChange(NumberPicker picker, int oldVal, int newVal) { }
114 
onScrollStateChange(NumberPicker view, int scrollState)115     public void onScrollStateChange(NumberPicker view, int scrollState) { }
116 
onCheckedChanged(RadioGroup group, int checkedId)117     public void onCheckedChanged(RadioGroup group, int checkedId) { }
118 
onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser)119     public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { }
120 
onClose()121     public boolean onClose() {
122         return false;
123     }
124 
onQueryTextChange(String newText)125     public boolean onQueryTextChange(String newText) {
126         return false;
127     }
128 
onQueryTextSubmit(String query)129     public boolean onQueryTextSubmit(String query) {
130         return false;
131     }
132 
onSuggestionClick(int position)133     public boolean onSuggestionClick(int position) {
134         return false;
135     }
136 
onSuggestionSelect(int position)137     public boolean onSuggestionSelect(int position) {
138         return false;
139     }
140 
onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)141     public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { }
142 
onStartTrackingTouch(SeekBar seekBar)143     public void onStartTrackingTouch(SeekBar seekBar) { }
144 
onStopTrackingTouch(SeekBar seekBar)145     public void onStopTrackingTouch(SeekBar seekBar) { }
146 
onTabChanged(String tabId)147     public void onTabChanged(String tabId) { }
148 
onEditorAction(TextView v, int actionId, KeyEvent event)149     public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
150         return false;
151     }
152 
afterTextChanged(Editable s)153     public void afterTextChanged(Editable s) { }
154 
beforeTextChanged(CharSequence s, int start, int count, int after)155     public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
156 
onTextChanged(CharSequence s, int start, int before, int count)157     public void onTextChanged(CharSequence s, int start, int before, int count) { }
158 
onTimeChanged(TimePicker view, int hourOfDay, int minute)159     public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { }
160 
onClick(View view)161     public void onClick(View view) { }
162 
onCompletion(MediaPlayer mp)163     public void onCompletion(MediaPlayer mp) { }
164 
onError(MediaPlayer mp, int what, int extra)165     public boolean onError(MediaPlayer mp, int what, int extra) {
166         return true;
167     }
168 
onInfo(MediaPlayer mp, int what, int extra)169     public boolean onInfo(MediaPlayer mp, int what, int extra) {
170         return true;
171     }
172 
onPrepared(MediaPlayer mp)173     public void onPrepared(MediaPlayer mp) { }
174 
onApplyWindowInsets(View v, WindowInsets insets)175     public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
176         return null;
177     }
178 
onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)179     public void onCreateContextMenu(ContextMenu menu, View v,
180             ContextMenu.ContextMenuInfo menuInfo) { }
181 
onDrag(View v, DragEvent event)182     public boolean onDrag(View v, DragEvent event) {
183         return true;
184     }
185 
onFocusChange(View v, boolean hasFocus)186     public void onFocusChange(View v, boolean hasFocus) { }
187 
onGenericMotion(View v, MotionEvent event)188     public boolean onGenericMotion(View v, MotionEvent event) {
189         return true;
190     }
191 
onHover(View v, MotionEvent event)192     public boolean onHover(View v, MotionEvent event) {
193         return true;
194     }
195 
onKey(View v, int keyCode, KeyEvent event)196     public boolean onKey(View v, int keyCode, KeyEvent event) {
197         return true;
198     }
199 
onLongClick(View v)200     public boolean onLongClick(View v) {
201         return true;
202     }
203 
onSystemUiVisibilityChange(int visibility)204     public void onSystemUiVisibilityChange(int visibility) { }
205 
onTouch(View v, MotionEvent event)206     public boolean onTouch(View v, MotionEvent event) {
207         return true;
208     }
209 
getOutline(View view, Outline outline)210     public void getOutline(View view, Outline outline) { }
211 
onViewAttachedToWindow(View v)212     public void onViewAttachedToWindow(View v) { }
213 
onViewDetachedFromWindow(View v)214     public void onViewDetachedFromWindow(View v) { }
215 
onChildViewAdded(View parent, View child)216     public void onChildViewAdded(View parent, View child) { }
217 
onChildViewRemoved(View parent, View child)218     public void onChildViewRemoved(View parent, View child) { }
219 
onAnimationEnd(Animation animation)220     public void onAnimationEnd(Animation animation) { }
221 
onAnimationRepeat(Animation animation)222     public void onAnimationRepeat(Animation animation) { }
223 
onAnimationStart(Animation animation)224     public void onAnimationStart(Animation animation) { }
225 
onInflate(ViewStub stub, View inflated)226     public void onInflate(ViewStub stub, View inflated) {
227         inflateCalled = true;
228     }
229 
makeView()230     public View makeView() {
231         return new View(mContext);
232     }
233 
onClick1(View view)234     public void onClick1(View view) {
235         lastClick = 1;
236     }
237 
onClick2(View view)238     public static void onClick2(View view) {
239         lastClick = 2;
240     }
241 
onClick3(View view)242     public void onClick3(View view) {
243         lastClick = 3;
244     }
245 
onClick4(View view)246     public static void onClick4(View view) {
247         lastClick = 4;
248     }
249 
onFoo()250     public void onFoo() {
251     }
252 
253 }
254