12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package de.tudarmstadt.informatik.hostage.ui2.popup;
- import android.content.Context;
- import android.view.LayoutInflater;
- import android.view.MotionEvent;
- import android.view.View;
- import java.util.HashMap;
- /**
- * Created by Julien on 13.02.14.
- */
- public abstract class AbstractPopupItem {
- private int itemId;
- private String title;
- private View itemView;
- private LayoutInflater lInf;
- public HashMap<Object, Object> data;
- abstract public int getLayoutId();
- abstract public void configureItemView(View view);
- public void setValue(String key, Object value){
- if (key != null && value != null){
- this.data.put(key, value);
- if (this.itemView != null) this.configureItemView(this.itemView);
- }
- }
- public void setMultipleData(HashMap<Object, Object> map){
- if (map != null){
- for(Object key : map.keySet()){
- this.data.put(key, map.get(key));
- }
- if (this.itemView != null) this.configureItemView(this.itemView);
- }
- }
- public void setTitle(String title){
- this.title = title;
- if (this.itemView != null) this.configureItemView(this.itemView);
- }
- public String getTitle(){
- return this.title;
- }
- public void setItemId(int id){
- this.itemId = id;
- if (this.itemView != null) this.configureItemView(this.itemView);
- }
- public int getItemId() {
- return this.itemId;
- }
- public AbstractPopupItem(Context context) {
- super();
- this.lInf = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- this.data = new HashMap<Object, Object>();
- }
- public View getItemView(){
- if (this.itemView == null){
- this.itemView = this.lInf.inflate(this.getLayoutId(), null);
- }
- this.configureItemView(this.itemView);
- return this.itemView;
- }
- public Object onClickedResult(MotionEvent event){
- return this;
- }
- }
|