Ver código fonte

deselection in popups

Julien Clauter 10 anos atrás
pai
commit
b6f222c01d

+ 0 - 19
src/de/tudarmstadt/informatik/hostage/ui2/dialog/DateTimeDialogFragment.java

@@ -63,26 +63,7 @@ public class DateTimeDialogFragment extends DialogFragment implements OnDateChan
         mView = inflater.inflate(R.layout.date_time_dialog, null);
 
         this.setupRootView(mView);
-        /*
-        mCalendar = Calendar.getInstance();
-
-        datePicker = (DatePicker) mView.findViewById(R.id.DatePicker);
-        datePicker.init(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH), this);
-
-        timePicker = (TimePicker) mView.findViewById(R.id.TimePicker);
 
-        setIs24HourView(true);
-        setCalendarViewShown(false);
-
-        switch (DialogType) {
-        case DATE_PICKER:
-            timePicker.setVisibility(View.GONE);
-            break;
-        case TIME_PICKER:
-            datePicker.setVisibility(View.GONE);
-            break;
-        }
-        */
     }
 
 

+ 5 - 42
src/de/tudarmstadt/informatik/hostage/ui2/popup/AbstractPopup.java

@@ -63,10 +63,11 @@ public abstract class AbstractPopup {
                 @Override
                 public boolean onTouch(View view, MotionEvent event) {
 	                if(event.getAction() == MotionEvent.ACTION_DOWN){
-						item.onItemDown(event);
-	                } else if (event.getAction() == MotionEvent.ACTION_UP){
-	                    item.onItemUp(event);
-
+						item.onItemSelect(event);
+	                } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_MOVE){
+                        item.onItemDeselect(event);
+                    } else if (event.getAction() == MotionEvent.ACTION_UP){
+                        item.onItemDeselect(event);
                         AbstractPopup.this.onPopupItemClickListener.onItemClick(item.onClickedResult(event));
                         AbstractPopup.this.popupWindow.dismiss();
                     }
@@ -135,44 +136,6 @@ public abstract class AbstractPopup {
             this.popupWindow.setHeight(height);
             this.popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, x, y-smallBottomOffset);
 
-
-
-            /*
-            // TO SET THE REAL SIZE
-            ViewTreeObserver viewTreeObserver = this.rootView.getViewTreeObserver();
-            if (viewTreeObserver != null &&  viewTreeObserver.isAlive()) {
-                viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
-                    @Override
-                    public void onGlobalLayout() {
-                        ViewTreeObserver observer= AbstractPopup.this.rootView.getViewTreeObserver();
-                        if (observer != null)observer.removeOnGlobalLayoutListener(this);
-
-                        View rootView = AbstractPopup.this.rootView;
-
-                        int width = rootView.getWidth();
-                        int height = rootView.getHeight();
-
-                        int x = position[0] + (anchorWidth / 2) - (width / 2);
-                        int y = position[1] - height;
-
-                        x = Math.min(0,x);
-                        x = Math.max(windowFrame.width() - width, x);
-
-                        y = Math.min(0,y);
-                        y = Math.max(windowFrame.height() - height, y);
-
-                        AbstractPopup.this.configureView(rootView);
-
-                        int smallBottomOffset = 10;
-                        AbstractPopup.this.popupWindow.dismiss();
-                        AbstractPopup.this.popupWindow.setWidth(width);
-                        AbstractPopup.this.popupWindow.setHeight(height + smallBottomOffset);
-                        AbstractPopup.this.popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, x, y-smallBottomOffset);
-
-                    }
-                });
-            }
-            */
         }
     }
 

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/ui2/popup/AbstractPopupItem.java

@@ -75,10 +75,10 @@ public abstract class AbstractPopupItem {
         return this;
     }
 
-	public void onItemDown(MotionEvent event){
+	public void onItemSelect(MotionEvent event){
 	}
 
-	public void onItemUp(MotionEvent event){
+	public void onItemDeselect(MotionEvent event){
 
 	}
 }

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/ui2/popup/SimplePopupItem.java

@@ -56,12 +56,12 @@ public class SimplePopupItem extends AbstractPopupItem {
         return this.selected;
     }
 
-	public void onItemDown(MotionEvent event){
+	public void onItemSelect(MotionEvent event){
 		getContainer().setBackgroundColor(
 				context.getResources().getColor(android.R.color.holo_blue_light));
 	}
 
-	public void onItemUp(MotionEvent event){
+	public void onItemDeselect(MotionEvent event){
 		getContainer().setBackgroundColor(context.getResources().getColor(android.R.color.transparent));
 	}
 }

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/ui2/popup/SplitPopupItem.java

@@ -85,7 +85,7 @@ public class SplitPopupItem extends AbstractPopupItem {
 		return right_container;
 	}
 
-	public void onItemDown(MotionEvent event){
+	public void onItemSelect(MotionEvent event){
 		int blue_color = context.getResources().getColor(android.R.color.holo_blue_light);
 		int trans_color = context.getResources().getColor(android.R.color.transparent);
 
@@ -98,7 +98,7 @@ public class SplitPopupItem extends AbstractPopupItem {
 		}
 	}
 
-	public void onItemUp(MotionEvent event){
+	public void onItemDeselect(MotionEvent event){
 		int trans_color = context.getResources().getColor(android.R.color.transparent);
 
 		getLeftContainer().setBackgroundColor(trans_color);