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