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