|
@@ -19,8 +19,12 @@ import de.tudarmstadt.informatik.hostage.R;
|
|
*/
|
|
*/
|
|
public abstract class AbstractPopup {
|
|
public abstract class AbstractPopup {
|
|
|
|
|
|
- static final int ORIENTATION_LANDSCAPE = 2;
|
|
|
|
|
|
+ //static final int ORIENTATION_LANDSCAPE = 2;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * OnPopupItemClickListener
|
|
|
|
+ * The listener will be called if the user selects a table row
|
|
|
|
+ */
|
|
public interface OnPopupItemClickListener {
|
|
public interface OnPopupItemClickListener {
|
|
public void onItemClick(Object data);
|
|
public void onItemClick(Object data);
|
|
}
|
|
}
|
|
@@ -32,9 +36,23 @@ public abstract class AbstractPopup {
|
|
private LayoutInflater lInf;
|
|
private LayoutInflater lInf;
|
|
private View lastItemView;
|
|
private View lastItemView;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Override to return the layout id.
|
|
|
|
+ * @return int layoutID
|
|
|
|
+ */
|
|
abstract public int getLayoutId();
|
|
abstract public int getLayoutId();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Override to make additional stuff with the rootview.
|
|
|
|
+ * @param View rootview
|
|
|
|
+ */
|
|
abstract void configureView(View view);
|
|
abstract void configureView(View view);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Constructor
|
|
|
|
+ * @param Context context
|
|
|
|
+ * @param OnPopupItemClickListener listener
|
|
|
|
+ */
|
|
public AbstractPopup(Context context, OnPopupItemClickListener listener) {
|
|
public AbstractPopup(Context context, OnPopupItemClickListener listener) {
|
|
super();
|
|
super();
|
|
this.context = (Activity) context;
|
|
this.context = (Activity) context;
|
|
@@ -46,14 +64,26 @@ public abstract class AbstractPopup {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Override to return a linear layout to add a scrollview.
|
|
|
|
+ * @return LinearLayout
|
|
|
|
+ */
|
|
public abstract LinearLayout getScrollableItemLayout();
|
|
public abstract LinearLayout getScrollableItemLayout();
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns the root view
|
|
|
|
+ * @return View the rootview
|
|
|
|
+ */
|
|
public View getRootView(){
|
|
public View getRootView(){
|
|
return this.rootView;
|
|
return this.rootView;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Adds a table row item.
|
|
|
|
+ * @param AbstractPopupItem item
|
|
|
|
+ */
|
|
public void addItem(final AbstractPopupItem item) {
|
|
public void addItem(final AbstractPopupItem item) {
|
|
- View view = item.getItemView();
|
|
|
|
|
|
+ View view = item.getRootView();
|
|
|
|
|
|
if (this.rootView == null){
|
|
if (this.rootView == null){
|
|
this.rootView = (LinearLayout) this.lInf.inflate(this.getLayoutId(), null);
|
|
this.rootView = (LinearLayout) this.lInf.inflate(this.getLayoutId(), null);
|
|
@@ -83,6 +113,11 @@ public abstract class AbstractPopup {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns the rootview.
|
|
|
|
+ * If the root view is null, it initialises it with the layout id.
|
|
|
|
+ * @return View the root view
|
|
|
|
+ */
|
|
public View getPopupView(){
|
|
public View getPopupView(){
|
|
if (this.rootView == null){
|
|
if (this.rootView == null){
|
|
this.rootView = (LinearLayout) this.lInf.inflate(this.getLayoutId(), null);
|
|
this.rootView = (LinearLayout) this.lInf.inflate(this.getLayoutId(), null);
|
|
@@ -90,6 +125,10 @@ public abstract class AbstractPopup {
|
|
return this.rootView;
|
|
return this.rootView;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Opens the Popup View on top of the given anchor.
|
|
|
|
+ * @param View anchorView
|
|
|
|
+ */
|
|
public void showOnView(final View anchorView) {
|
|
public void showOnView(final View anchorView) {
|
|
if (this.rootView == null){
|
|
if (this.rootView == null){
|
|
this.rootView = (LinearLayout) this.lInf.inflate(this.getLayoutId(), null);
|
|
this.rootView = (LinearLayout) this.lInf.inflate(this.getLayoutId(), null);
|
|
@@ -103,7 +142,7 @@ public abstract class AbstractPopup {
|
|
|
|
|
|
Window window = this.context.getWindow();
|
|
Window window = this.context.getWindow();
|
|
window.getDecorView().getWindowVisibleDisplayFrame(windowFrame);
|
|
window.getDecorView().getWindowVisibleDisplayFrame(windowFrame);
|
|
- int orientation = this.context.getResources().getConfiguration().orientation;
|
|
|
|
|
|
+ //int orientation = this.context.getResources().getConfiguration().orientation;
|
|
int windowWidth = windowFrame.width();
|
|
int windowWidth = windowFrame.width();
|
|
int windowHeight = windowFrame.height();
|
|
int windowHeight = windowFrame.height();
|
|
|
|
|