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