44import android .animation .ValueAnimator ;
55import android .content .DialogInterface ;
66import android .content .Intent ;
7+ import android .graphics .PorterDuff ;
78import android .os .Bundle ;
89import android .view .LayoutInflater ;
910import android .view .View ;
2021import com .loopj .android .http .RequestParams ;
2122import com .melnykov .fab .FloatingActionButton ;
2223
24+ import net .coding .program .MyApp ;
2325import net .coding .program .R ;
2426import net .coding .program .common .BlankViewDisplay ;
2527import net .coding .program .common .Global ;
@@ -173,7 +175,7 @@ protected void init() {
173175 fab .setVisibility (View .GONE );
174176// listView.setAnimExecutor(new AnimationExecutor());
175177 View footer = getActivity ().getLayoutInflater ().inflate (R .layout .divide_15_top , null );
176- listView .addFooterView (footer );
178+ listView .addFooterView (footer , null , false );
177179 listView .setAdapter (mAdapter );
178180
179181 listView .setOnItemClickListener (new AdapterView .OnItemClickListener () {
@@ -454,12 +456,14 @@ public View getView(int position, View convertView, ViewGroup parent) {
454456 holder .mCheckBox = (CheckBox ) convertView .findViewById (R .id .checkbox );
455457 holder .mTitle = (TextView ) convertView .findViewById (R .id .title );
456458 holder .mDeadline = (TextView ) convertView .findViewById (R .id .deadline );
459+ holder .mDeadline .setBackgroundResource (R .drawable .task_list_item_deadline_background );
457460 holder .mName = (TextView ) convertView .findViewById (R .id .name );
458461 holder .mTime = (TextView ) convertView .findViewById (R .id .time );
459462 holder .mDiscuss = (TextView ) convertView .findViewById (R .id .discuss );
460463 holder .mIcon = (ImageView ) convertView .findViewById (R .id .icon );
461464 holder .mTaskPriority = convertView .findViewById (R .id .taskPriority );
462465 holder .mTaskDes = convertView .findViewById (R .id .taskDes );
466+ holder .mLayoutDeadline = convertView .findViewById (R .id .layoutDeadline );
463467 holder .flowLabelLayout = (FlowLabelLayout ) convertView .findViewById (R .id .flowLayout );
464468 convertView .setTag (holder );
465469 } else {
@@ -474,7 +478,12 @@ public View getView(int position, View convertView, ViewGroup parent) {
474478 holder .mDiscuss .setText (String .valueOf (data .comments ));
475479 iconfromNetwork (holder .mIcon , data .owner .avatar );
476480
477- holder .flowLabelLayout .setLabels (data .labels );
481+
482+ int flowWidth = MyApp .sWidthPix - Global .dpToPx (100 + 12 ); // item 左边空 100 dp,右边空12dp
483+ if (!data .deadline .isEmpty ()) {
484+ flowWidth -= Global .dpToPx (55 );
485+ }
486+ holder .flowLabelLayout .setLabels (data .labels , flowWidth );
478487
479488 final int pos = position ;
480489
@@ -496,29 +505,43 @@ public View getView(int position, View convertView, ViewGroup parent) {
496505
497506 holder .mTaskPriority .setBackgroundResource (priorityIcons [data .priority ]);
498507
508+ if (data .deadline .isEmpty () && data .labels .isEmpty ()) {
509+ holder .mLayoutDeadline .setVisibility (View .GONE );
510+ } else {
511+ holder .mLayoutDeadline .setVisibility (View .VISIBLE );
512+ }
513+
514+ int [] taskColors = new int []{
515+ 0xfff49f31 ,
516+ 0xff97ba66 ,
517+ 0xfff24b4b ,
518+ 0xffb2c6d0 ,
519+ 0xffc7c8c7
520+ };
521+
499522 if (data .deadline .isEmpty ()) {
500523 holder .mDeadline .setVisibility (View .GONE );
501524 } else {
502525 holder .mDeadline .setVisibility (View .VISIBLE );
503526
504527 if (data .deadline .equals (mToday )) {
505528 holder .mDeadline .setText ("今天" );
506- holder .mDeadline . setBackgroundResource ( R . drawable . round_rect_shape_yellow );
529+ holder .setDeadlineColor ( taskColors [ 0 ] );
507530 } else if (data .deadline .equals (mTomorrow )) {
508531 holder .mDeadline .setText ("明天" );
509- holder .mDeadline . setBackgroundResource ( R . drawable . round_rect_shape_green );
532+ holder .setDeadlineColor ( taskColors [ 1 ] );
510533 } else {
511534 if (data .deadline .compareTo (mToday ) < 0 ) {
512- holder .mDeadline . setBackgroundResource ( R . drawable . round_rect_shape_red );
535+ holder .setDeadlineColor ( taskColors [ 2 ] );
513536 } else {
514- holder .mDeadline . setBackgroundResource ( R . drawable . round_rect_shape_gray_light );
537+ holder .setDeadlineColor ( taskColors [ 3 ] );
515538 }
516539 String num [] = data .deadline .split ("-" );
517540 holder .mDeadline .setText (String .format ("%s/%s" , num [1 ], num [2 ]));
518541 }
519542
520543 if (data .isDone ()) {
521- holder .mDeadline . setBackgroundResource ( R . drawable . round_rect_shape_gray );
544+ holder .setDeadlineColor ( taskColors [ 4 ] );
522545 }
523546 }
524547
@@ -589,16 +612,18 @@ class ViewHolder {
589612 TextView mTitle ;
590613
591614 TextView mDeadline ;
592-
593615 TextView mName ;
594616 TextView mTime ;
595617 TextView mDiscuss ;
596-
597618 View mTaskPriority ;
598-
599619 View mTaskDes ;
600-
620+ View mLayoutDeadline ;
601621 FlowLabelLayout flowLabelLayout ;
622+
623+ public void setDeadlineColor (int color ) {
624+ mDeadline .getBackground ().setColorFilter (color , PorterDuff .Mode .SRC_IN );
625+ mDeadline .setTextColor (color );
626+ }
602627 }
603628 }
604629
0 commit comments