Browse Source

日历更新

Bitliker 9 years ago
parent
commit
8a63507329

+ 1 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/calendar/views/TaskMonthView.java

@@ -22,9 +22,9 @@ import android.view.animation.AccelerateInterpolator;
 import android.view.animation.DecelerateInterpolator;
 import android.widget.Scroller;
 
-import com.xzjmyk.pm.activity.ui.calendar.bizs.themes.DPTManager;
 import com.xzjmyk.pm.activity.ui.calendar.bizs.calendars.DPCManager;
 import com.xzjmyk.pm.activity.ui.calendar.bizs.decors.DPDecor;
+import com.xzjmyk.pm.activity.ui.calendar.bizs.themes.DPTManager;
 import com.xzjmyk.pm.activity.ui.calendar.cons.DPMode;
 import com.xzjmyk.pm.activity.ui.calendar.entities.DPInfo;
 

+ 0 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/AddTaskActivity.java

@@ -264,7 +264,6 @@ public class AddTaskActivity extends BaseActivity implements OnClickListener {
         TaskDatePicker picker = new TaskDatePicker(this);
         picker.setDate(year, month);
         picker.setMode(DPMode.SINGLE);
-
         picker.setOnDatePickedListener(new TaskDatePicker.OnDatePickedListener() {
             @Override
             public void onDatePicked(String date) {

+ 26 - 4
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/OAActivity.java

@@ -87,6 +87,7 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
     @ViewInject(R.id.my_log_tag)
     private View my_log_tag;//我的工作日志标识
     private int tag = 2;
+    private int selectDay = -1;
     private ArrayList<OABean> meBeans = null;
     private ArrayList<OABean> otherBeans = null;
     private List<OABean> showOtherBeans = null;
@@ -317,6 +318,8 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
         mEmptyLayout.setShowErrorButton(false);
         initData();
         setListener();
+        selectDay = picker.getDownIndex();
+        Log.i("gongpengming", "selectDay=" + selectDay);
         loadNetData();
         listview.setFocusable(false);
     }
@@ -472,9 +475,11 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
         picker.setOnItemClickListener(new CalendarView.OnItemClickListener() {
             @Override
             public void OnItemClick(int downDate) {
+                selectDay = downDate;
                 String chche = TimeUtils.long2str(System.currentTimeMillis(), "yyyy-MM") + "-" + (downDate < 10 ? "0" : "") + downDate;
                 date_tv.setText(chche + "  " + TimeUtils.getWeek(chche));
                 Calendar c = Calendar.getInstance();
+                selectDay = downDate;
                 List<OABean> beans = new ArrayList<>();
                 try {
                     List<OABean> b;
@@ -564,15 +569,32 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
         private List<OABean> getBeans(List<OABean> beans) {
             List<OABean> chche = new ArrayList<>();
             if (beans == null) return null;
+            Calendar c = Calendar.getInstance();
+            int day = 0;
             if (getIntent() == null || getIntent().getIntExtra("type", 0) != 1) {
-                chche = beans;
-
+                if (selectDay > 0) {
+                    for (OABean e : beans) {
+                        if (e.getStartdate() == null) continue;
+                        c.setTimeInMillis(TimeUtils.f_str_2_long(e.getStartdate()));
+                        day = c.get(Calendar.DAY_OF_MONTH);
+                        if (day == selectDay) {//选择那天的任务
+                            chche.add(e);
+                        }
+                    }
+                } else {
+                    chche = beans;
+                }
             } else {//crm
                 //只显示拜访
-                for (OABean e : beans)
+                for (OABean e : beans) {
+                    if (e.getStartdate() == null) continue;
+                    c.setTimeInMillis(TimeUtils.f_str_2_long(e.getStartdate()));
+                    day = c.get(Calendar.DAY_OF_MONTH);
                     if (e != null && e.getClient() != null) {
-                        chche.add(e);
+                        if (selectDay <= 0 || day == selectDay)
+                            chche.add(e);
                     }
+                }
             }
             setPoithNum(chche);
             return chche;

+ 11 - 14
WeiChat/src/main/java/com/xzjmyk/pm/activity/view/CalendarView.java

@@ -40,11 +40,16 @@ public class CalendarView extends View implements View.OnTouchListener {
         init();
     }
 
+    public int getDownIndex() {
+        return downIndex;
+    }
+
     private void init() {
         //获取当前日期对象
-        curDate = today = new Date();
+        downDate = curDate = today = new Date();
         calendar = Calendar.getInstance();
         calendar.setTime(curDate);
+        downIndex = calendar.get(Calendar.DAY_OF_MONTH);
         surface = new Surface();
         surface.density = getResources().getDisplayMetrics().density;
         setBackgroundColor(surface.bgColor);
@@ -82,7 +87,6 @@ public class CalendarView extends View implements View.OnTouchListener {
 
     @Override
     protected void onDraw(Canvas canvas) {
-        // 画框
         float weekTextY = surface.monthHeight + surface.weekHeight * 3 / 4f;
         for (int i = 0; i < surface.weekText.length; i++) {
             float weekTextX = i
@@ -117,6 +121,8 @@ public class CalendarView extends View implements View.OnTouchListener {
                 if (todayIndex != -1 && i == todayIndex) {
                     color = surface.todayNumberColor;
                     drawCellText(canvas, i, "今", color);
+                    if (downDate == null)
+                        drawCellBg(canvas, i, surface.cellDownColor);
                 } else {
                     drawCellText(canvas, i, date[i] + "", color);
                 }
@@ -223,13 +229,6 @@ public class CalendarView extends View implements View.OnTouchListener {
     private void drawCellBg(Canvas canvas, int index, int color) {
         int x = getXByIndex(index);
         int y = getYByIndex(index);
-//        surface.cellBgPaint.setColor(color);
-//        float left = surface.cellWidth * (x - 1) + surface.borderWidth;
-//        float top = surface.monthHeight + surface.weekHeight + (y - 1)
-//                * surface.cellHeight + surface.borderWidth;
-//        canvas.drawRect(left, top, left + surface.cellWidth
-//                - surface.borderWidth, top + surface.cellHeight
-//                - surface.borderWidth, surface.cellBgPaint);
         float cellY = surface.monthHeight + surface.weekHeight + (y - 1)
                 * surface.cellHeight + //当前日期框最上方
                 surface.cellHeight * 9 / 16f;//当前框的中心Y
@@ -238,14 +237,13 @@ public class CalendarView extends View implements View.OnTouchListener {
         float radius = Math.min(surface.cellHeight, surface.cellWidth) * (3 / 8f);//获取最短的长度的
 // 绘制圆,参数一是中心点的x轴,参数二是中心点的y轴,参数三是半径,参数四是paint对象;
         canvas.drawCircle(cellX, cellY, radius, surface.cellBgPaint);
-
     }
 
     private void drawDownOrSelectedBg(Canvas canvas) {
-        // down and not up
         if (downDate != null) {
             drawCellBg(canvas, downIndex, surface.cellDownColor);
         }
+
     }
 
     private boolean isLastMonth(int i) {
@@ -320,9 +318,8 @@ public class CalendarView extends View implements View.OnTouchListener {
     private void setSelectedDateByCoor(float x, float y) {
         if (y > surface.monthHeight + surface.weekHeight) {
             int m = (int) (Math.floor(x / surface.cellWidth) + 1);
-            int n = (int) (Math
-                    .floor((y - (surface.monthHeight + surface.weekHeight))
-                            / Float.valueOf(surface.cellHeight)) + 1);
+            int n = (int) (Math.floor((y - (surface.monthHeight + surface.weekHeight))
+                    / Float.valueOf(surface.cellHeight)) + 1);
             int index = (n - 1) * 7 + m - 1;
             if (index < curStartIndex || curEndIndex <= index) return;
             downIndex = index;

+ 1 - 2
WeiChat/src/main/res/layout/activity_oa.xml

@@ -259,12 +259,11 @@
             android:numColumns="7"
             android:visibility="gone" />
 
-
-
         <com.xzjmyk.pm.activity.view.CalendarView
             android:id="@+id/oa_picker"
             android:layout_width="match_parent"
             android:layout_height="wrap_content" />
+
         <View
             android:layout_width="match_parent"
             android:layout_height="1px"