[1833] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
| 15 | package de.ugoe.cs.autoquest.androidmonitor;
|
---|
| 16 |
|
---|
| 17 | import java.util.ArrayList;
|
---|
| 18 | import java.util.List;
|
---|
| 19 |
|
---|
| 20 | import android.view.View;
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * <p>
|
---|
| 24 | * TODO comment
|
---|
| 25 | * </p>
|
---|
| 26 | *
|
---|
| 27 | * @author Florian Unger
|
---|
| 28 | * @version 1.0
|
---|
| 29 | */
|
---|
| 30 | public class AndroidMonitorCompositeOnClickListener implements
|
---|
| 31 | View.OnClickListener {
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * <p>
|
---|
| 35 | * Save all listeners which belongs to a single view in a list.
|
---|
| 36 | * </p>
|
---|
| 37 | */
|
---|
| 38 | private List<View.OnClickListener> listeners;
|
---|
| 39 |
|
---|
| 40 | /**
|
---|
| 41 | *
|
---|
| 42 | * <p>
|
---|
| 43 | * Constructor. Creates a new AndroidMonitorCompositeOnClickListener.
|
---|
| 44 | * </p>
|
---|
| 45 | *
|
---|
| 46 | */
|
---|
| 47 | public AndroidMonitorCompositeOnClickListener() {
|
---|
| 48 | listeners = new ArrayList<View.OnClickListener>();
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | /**
|
---|
| 52 | * <p>
|
---|
| 53 | * Add a listener to a single view.
|
---|
| 54 | * </p>
|
---|
| 55 | *
|
---|
| 56 | * @param listener
|
---|
| 57 | */
|
---|
| 58 | public void addOnClickListener(View.OnClickListener listener) {
|
---|
| 59 | listeners.add(listener);
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | /* (non-Javadoc)
|
---|
| 63 | * @see android.view.View.OnClickListener#onClick(android.view.View)
|
---|
| 64 | */
|
---|
| 65 | public void onClick(View v) {
|
---|
| 66 | for (View.OnClickListener listener : listeners) {
|
---|
| 67 | listener.onClick(v);
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | /*
|
---|
| 73 | * (non-Javadoc)
|
---|
| 74 | * In Android it is not possible to have multiple onCliclListener for one view.
|
---|
| 75 | * This is also stated in
|
---|
| 76 | * http://books.google.de/books?id=bKo_1uED72EC&pg=PA178&lpg
|
---|
| 77 | * =PA178&dq=android+setonclicklistener
|
---|
| 78 | * +call+old+listener&source=bl&ots=g45T5ikRVK
|
---|
| 79 | * &sig=blIqJGMywqJEGNATe3WW5DZyS6M&hl
|
---|
| 80 | * =de&sa=X&ei=cl3rU6_8Ec2KOIzqgNgM&ved=0CEYQ6AEwBA
|
---|
| 81 | * #v=onepage&q=android%20setonclicklistener%20call%20old%20listener&f=false
|
---|
| 82 | *
|
---|
| 83 | * Therefore it is necessary to have a custom class to handle a single onClick()
|
---|
| 84 | * and pass in handlers for it to call.
|
---|
| 85 | * http://stackoverflow.com/questions/7587299
|
---|
| 86 | * /android-multi-onclick-listener-in-one-button
|
---|
| 87 | */ |
---|