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