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 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 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(); } 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; } }