コード例 #1
0
 // 隐藏 menu
 private void hideMeun() {
   if (runingAnimation) {
     return;
   } else {
     AutoAnimation(level1, 0, -180, 0);
     AutoAnimation(level2, 0, -180, 100);
     AutoAnimation(level3, 0, -180, 200);
     new Thread() {
       public void run() {
         try {
           Thread.sleep(500);
         } catch (InterruptedException e) {
           e.printStackTrace();
         }
       };
     }.start();
     switchMeun = false;
     runingAnimation = false;
     // 3.点击事件,因为是补间动画 解决方法: i:补间动画换成属性动画 ii:setclickble(false/true);
     for (int i = 0; i < level3.getChildCount(); i++) {
       level3.getChildAt(i).setClickable(false);
     }
     for (int i = 0; i < level2.getChildCount(); i++) {
       level2.getChildAt(i).setClickable(false);
     }
     for (int i = 0; i < level1.getChildCount(); i++) {
       level1.getChildAt(i).setClickable(false);
     }
   }
 }
コード例 #2
0
  // 显示 menu
  private void showMeun() {

    if (runingAnimation) {
      return;
    } else {
      AutoAnimation(level1, -180, 0, 0);
      AutoAnimation(level2, -180, 0, 100);
      AutoAnimation(level3, -180, 0, 200);
      new Thread() {
        public void run() {
          try {
            Thread.sleep(500);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        };
      }.start();
      switchMeun = true;
      runingAnimation = false;
      for (int i = 0; i < level3.getChildCount(); i++) {
        level3.getChildAt(i).setClickable(true);
      }
      for (int i = 0; i < level2.getChildCount(); i++) {
        level2.getChildAt(i).setClickable(true);
      }
      for (int i = 0; i < level1.getChildCount(); i++) {
        level1.getChildAt(i).setClickable(true);
      }
    }
  }
コード例 #3
0
ファイル: ViewsTest.java プロジェクト: Topface/mopub-client
  @Test
  public void removeFromParent_shouldRemoveViewFromParent() throws Exception {
    assertThat(parent.getChildCount()).isEqualTo(0);

    parent.addView(subject);
    assertThat(parent.getChildCount()).isEqualTo(1);
    assertThat(subject.getParent()).isEqualTo(parent);

    Views.removeFromParent(subject);

    assertThat(parent.getChildCount()).isEqualTo(0);
    assertThat(subject.getParent()).isNull();
  }
コード例 #4
0
ファイル: ViewsTest.java プロジェクト: Topface/mopub-client
  @Test
  public void removeFromParent_withMultipleChildren_shouldRemoveCorrectChild() throws Exception {
    parent.addView(new TextView(context));

    assertThat(parent.getChildCount()).isEqualTo(1);

    parent.addView(subject);

    assertThat(parent.getChildCount()).isEqualTo(2);

    Views.removeFromParent(subject);
    assertThat(parent.getChildCount()).isEqualTo(1);

    assertThat(parent.getChildAt(0)).isInstanceOf(TextView.class);
  }
コード例 #5
0
  // /防止内存不够用
  @Override
  protected void onSaveInstanceState(Bundle outState) {

    // 内容
    outState.putString("content", contentEditText.getText().toString());
    // 地点
    outState.putString("location", locationString);
    // 图片
    ArrayList<String> imageList = new ArrayList<String>();
    int subviewsCount = addImageLayout.getChildCount();
    for (int i = 0; i < subviewsCount; i++) {
      View view = addImageLayout.getChildAt(i);
      if (null != view.getTag() && view != addImageView) {
        if (view.getTag() instanceof String) {
          imageList.add((String) view.getTag());
        }
      }
    }
    outState.putStringArrayList("images", imageList);
    if (null != tmpImageName && tmpImageName.length() > 0) {
      // 刚拍的照片
      outState.putString("tmpImageName", tmpImageName);
    }

    super.onSaveInstanceState(outState);
  }
コード例 #6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    setContentView(R.layout.activity_kierunki);

    body = (RelativeLayout) findViewById(R.id.main_holder);
    animationElements = new View[body.getChildCount()];
    for (int i = 0; i < animationElements.length; i++) {
      animationElements[i] = body.getChildAt(i);
    }

    fadeIn = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fadein_with_rotate);
    fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fadeout_with_rotate);

    TextView appTitle = (TextView) findViewById(R.id.app_title);

    if (appTitle != null) {
      appTitle.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              overridePendingTransition(R.anim.fadeout, R.anim.fadein);
              onBackPressed();
            }
          });
    }
  }
コード例 #7
0
 private void createPreview() {
   Activity activity = getActivity();
   if (activity == null) return;
   if (mWindowSize == null) mWindowSize = new Point();
   activity.getWindowManager().getDefaultDisplay().getSize(mWindowSize);
   mPreviewView = new CameraPreview(getActivity(), mCamera);
   if (mPreviewFrame.getChildCount() > 0 && mPreviewFrame.getChildAt(0) instanceof CameraPreview)
     mPreviewFrame.removeViewAt(0);
   mPreviewFrame.addView(mPreviewView, 0);
   mPreviewView.setAspectRatio(mWindowSize.x, mWindowSize.y);
 }
コード例 #8
0
  private TextView getTextViewFromTab(RelativeLayout tab) {
    TextView tv = null;

    for (int i = 0, size = tab.getChildCount(); i < size; i++) {
      if (tab.getChildAt(i) instanceof TextView) {
        tv = (TextView) tab.getChildAt(i);
        break;
      }
    }

    return tv;
  }
コード例 #9
0
  // 删除状态图片
  private void deleteNewsImageView(String tag) {
    // 删除
    int subviewsCount = addImageLayout.getChildCount();
    for (int i = 0; i < subviewsCount; i++) {
      View view = addImageLayout.getChildAt(i);
      if (null != view.getTag() && view.getTag().equals(tag)) {
        addImageLayout.removeViewAt(i);
        break;
      }
    }

    // 添加按钮位置重置
    MarginLayoutParams addlp = (MarginLayoutParams) addImageView.getLayoutParams();
    addlp.setMargins(oriMarginLeft, 0, 0, 0);
    // 删除之后重新排序
    subviewsCount = addImageLayout.getChildCount();
    for (int i = 1; i < subviewsCount; i++) {
      View view = addImageLayout.getChildAt(i);
      moveImageView((ImageView) view, i);
    }
  }
コード例 #10
0
  private void setListener() {
    // 给大按钮设置点击事件
    composerButtonsShowHideButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (!areButtonsShowing) {
              // 图标的动画
              MyAnimations.startAnimationsIn(composerButtonsWrapper, 300);
              // 加号的动画
              composerButtonsShowHideButtonIcon.startAnimation(
                  MyAnimations.getRotateAnimation(0, -225, 300));
            } else {
              // 图标的动画
              MyAnimations.startAnimationsOut(composerButtonsWrapper, 300);
              // 加号的动画
              composerButtonsShowHideButtonIcon.startAnimation(
                  MyAnimations.getRotateAnimation(-225, 0, 300));
            }
            areButtonsShowing = !areButtonsShowing;
          }
        });

    // 给小图标设置点击事件
    for (int i = 0; i < composerButtonsWrapper.getChildCount(); i++) {
      final ImageView smallIcon = (ImageView) composerButtonsWrapper.getChildAt(i);
      final int position = i;
      smallIcon.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
              // 这里写各个item的点击事件
              // 1.加号按钮缩小后消失 缩小的animation
              // 2.其他按钮缩小后消失 缩小的animation
              // 3.被点击按钮放大后消失 透明度渐变 放大渐变的animation
              // composerButtonsShowHideButton.startAnimation(MyAnimations.getMiniAnimation(300));
              composerButtonsShowHideButtonIcon.startAnimation(
                  MyAnimations.getRotateAnimation(-225, 0, 300));
              areButtonsShowing = !areButtonsShowing;
              smallIcon.startAnimation(MyAnimations.getMaxAnimation(400));
              for (int j = 0; j < composerButtonsWrapper.getChildCount(); j++) {
                if (j != position) {
                  final ImageView smallIcon = (ImageView) composerButtonsWrapper.getChildAt(j);
                  smallIcon.startAnimation(MyAnimations.getMiniAnimation(300));
                }
              }
            }
          });
    }
  }
コード例 #11
0
 /**
  * 为格子设置标记
  *
  * @param cell 格子
  */
 public void addMarker(RelativeLayout cell) {
   int childCount = cell.getChildCount();
   if (childCount < 2) {
     RelativeLayout.LayoutParams params =
         new RelativeLayout.LayoutParams((int) (tb * 0.7), (int) (tb * 0.7)); // 7dp
     // 右下角
     params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
     params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
     params.setMargins(0, 0, 1, 1);
     ImageView markView = new ImageView(getContext());
     //            markView.setImageResource(marksMap.get(dates[x][y]));
     markView.setLayoutParams(params);
     markView.setBackgroundResource(R.drawable.calendar_bg_tag);
     cell.addView(markView);
   }
 }
コード例 #12
0
  public void toggleUi() {
    for (int i = 0; i < mLayout.getChildCount(); i++) {
      if (mLayout.getChildAt(i).getTag() != null
          && mLayout.getChildAt(i).getTag().equals("dontHide")) {
        continue;
      }
      mLayout.getChildAt(i).setVisibility(mShowingUi ? View.GONE : View.VISIBLE);
    }

    if (mShowingUi) {
      getActionBar().hide();
    } else {
      getActionBar().show();
    }

    mShowingUi = !mShowingUi;
  }
コード例 #13
0
 public void setUnread(int count, int position) {
   if (unreads != null && unreads.length > position) {
     unreads[position] = count;
   }
   if (layout_tabs != null && layout_tabs.getChildCount() > position) {
     RelativeLayout rl_tab = (RelativeLayout) layout_tabs.getChildAt(position);
     if (rl_tab.getChildCount() >= 2) {
       TextView tv_mask = (TextView) rl_tab.getChildAt(1);
       if (count > 0) {
         tv_mask.setText("" + count);
         tv_mask.setVisibility(View.VISIBLE);
       } else {
         tv_mask.setVisibility(View.GONE);
       }
     }
   }
 }
コード例 #14
0
  @Override
  // 销毁的时候清空缓存
  protected void onDestroy() {
    super.onDestroy();

    // 清除缓存
    for (int i = 0; i < addImageLayout.getChildCount(); i++) {
      View view = addImageLayout.getChildAt(i);
      // 如果不是添加按钮
      if (view != addImageView) {
        // 图片
        File file = new File((String) view.getTag());
        if (file.exists()) {
          file.delete();
        }
      }
    }
  }
コード例 #15
0
ファイル: KCalendar.java プロジェクト: kzhouyijin/zack.ui
 // 设置标记
 private void setMarker(RelativeLayout group, int i, int j) {
   int childCount = group.getChildCount();
   if (marksMap.get(dates[i][j]) != null) {
     if (childCount < 2) {
       RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(-2, -2);
       params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
       params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
       params.setMargins(0, 5, 5, 0);
       ImageView markView = new ImageView(getContext());
       markView.setImageResource(marksMap.get(dates[i][j]));
       markView.setLayoutParams(params);
       group.addView(markView);
     }
   } else {
     if (childCount > 1) {
       group.removeView(group.getChildAt(1));
     }
   }
 }
コード例 #16
0
  private void updateHeader(Fragment fragment) {
    try {
      RelativeLayout placeholder = findView(R.id.activity_main_layout_header_placeholder);
      if (placeholder.getChildCount() > 0) {
        placeholder.removeAllViews();
      }

      if (fragment instanceof MainFragment) {
        View header = ((MainFragment) fragment).getHeader(this);
        if (header != null) {
          RelativeLayout.LayoutParams params =
              new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
          params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
          placeholder.addView(header, params);
        }
      }
    } catch (Throwable e) {
      LOG.error("Error updating main header", e);
    }
  }
コード例 #17
0
  public Youky_Menu(Context context, AttributeSet attrs) {
    super(context, attrs);
    View view = View.inflate(context, R.layout.activity_youky__menu, this);
    level3 = (RelativeLayout) findViewById(R.id.level3);
    level2 = (RelativeLayout) findViewById(R.id.level2);
    level1 = (RelativeLayout) findViewById(R.id.level1);

    for (int i = 0; i < level3.getChildCount(); i++) {
      level3
          .getChildAt(i)
          .setOnClickListener(
              new OnClickListener() {

                public void onClick(View v) {
                  if (l != null) {
                    l.onClick(v);
                  }
                }
              });
    }
  }
コード例 #18
0
 private void resize(RelativeLayout views, int width, int height) {
   for (int i = 0; i < views.getChildCount(); i++) {
     View child = views.getChildAt(i);
     child.setLayoutParams(new RelativeLayout.LayoutParams(width, height));
   }
 }
コード例 #19
0
 public void deleteMarker(RelativeLayout cell) {
   if (cell.getChildCount() > 1) {
     cell.removeView(cell.getChildAt(1));
   }
 }
コード例 #20
0
ファイル: ActivityMain.java プロジェクト: hihua/hihuacode
  private void addTime(
      final String sColor, final EntityLocations entityLocations, final int index) {
    if (mLayoutTime == null) return;

    final Resources res = getResources();
    TextView sTextView = null;
    TextView cTextView = null;
    int color = 0;

    if (sColor != null) {
      try {
        color = Color.parseColor(sColor);
      } catch (Exception e) {
        color = res.getColor(R.color.textview_clienttime);
      }
    } else color = res.getColor(R.color.textview_clienttime);

    int count = mLayoutTime.getChildCount();
    if (index < count) {
      View view = mLayoutTime.getChildAt(index);
      final RelativeLayout relativeLayout = (RelativeLayout) view;
      count = relativeLayout.getChildCount();
      if (count > 0) {
        view = relativeLayout.getChildAt(0);
        sTextView = (TextView) view;
      }

      if (count > 1) {
        view = relativeLayout.getChildAt(1);
        cTextView = (TextView) view;
      }
    } else {
      final RelativeLayout relativeLayout = new RelativeLayout(this);
      relativeLayout.setLayoutParams(
          new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
      RelativeLayout.LayoutParams layoutParams =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      sTextView = new TextView(this);
      sTextView.setId(R.id.tv_time);
      sTextView.setLayoutParams(layoutParams);
      sTextView.setTextColor(color);
      sTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12.0f);
      sTextView.setClickable(true);

      layoutParams =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      cTextView = new TextView(this);
      cTextView.setLayoutParams(layoutParams);
      cTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12.0f);
      cTextView.setClickable(true);

      relativeLayout.addView(sTextView);
      relativeLayout.addView(cTextView);
      mLayoutTime.addView(relativeLayout);
    }

    if (sTextView != null) {
      final long serverTime = entityLocations.getServerTime();
      final String time = DateTime.getTimeStamp(serverTime, "yyyy-MM-dd HH:mm:ss");
      sTextView.setTextColor(color);
      sTextView.setTag(entityLocations);
      sTextView.setText(time);
      sTextView.setOnClickListener(this);
    }

    if (cTextView != null) {
      final long clientTime = entityLocations.getClientTime();
      final String time = DateTime.getTimeStamp(clientTime, "yyyy-MM-dd HH:mm:ss");
      cTextView.setTextColor(color);
      cTextView.setTag(entityLocations);
      cTextView.setText(time);
      cTextView.setOnClickListener(this);
    }
  }
コード例 #21
0
  private void addNewsImageView(String filePath) {
    File file = new File(filePath);
    if (!file.exists()) {
      Toast.makeText(this, "文件异常", Toast.LENGTH_SHORT).show();
      LogUtils.i("不存在", 1);
      return;
    }

    View imageViewBack = View.inflate(this, R.layout.attrament_image, null);
    LinearLayout layout = (LinearLayout) imageViewBack.findViewById(R.id.attrament_image_layout);
    ImageView imageView = (ImageView) imageViewBack.findViewById(R.id.image_attrament);
    layout.removeAllViews();
    int imageCount = addImageLayout.getChildCount();
    // 移动位置
    moveImageView(imageView, imageCount);
    // 添加
    addImageLayout.addView(imageView);
    // 设置tag
    imageView.setTag(filePath);
    // 设置照片
    // bitmapUtils.display(imageView, filePath);
    ImageLoader.getInstance().displayImage("file://" + filePath, imageView, headImageOptions);

    // 设置点击查看大图事件
    imageView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            // 相册
            // final String tmpFilePath = (String) v.getTag();
            // new AlertDialog.Builder(PublishNewsActivity.this)
            // .setTitle("操作")
            // .setItems(new String[] { "删除", "查看大图", "滤镜处理" },
            // new OnClickListener() {
            //
            // @Override
            // public void onClick(DialogInterface dialog,int which) {
            //
            // switch (which) {
            // case 0:
            // // 删除
            // deleteNewsImageView(tmpFilePath);
            // break;
            // case 1:
            // // 查看大图
            // Intent intent = new
            // Intent(PublishNewsActivity.this,BigImgLookActivity.class);
            // intent.putExtra(BigImgLookActivity.INTENT_KEY,tmpFilePath);
            // startActivityWithBottom(intent);
            // break;
            // case 2:
            // // 滤镜
            // filterImage(tmpFilePath, false);
            // break;
            // default:
            // break;
            // }
            // }
            // }).setNegativeButton("取消", null).show();

            final String tmpFilePath = (String) v.getTag();

            Intent intent = new Intent(PublishNewsActivity.this, PublisPhotoHandelActivity.class);
            intent.putExtra(PublisPhotoHandelActivity.INTENT_KEY, tmpFilePath);
            startActivityForResult(intent, PHOTO_DELETE);

            // List<String> menuList = new ArrayList<String>();
            // menuList.add("删除");
            // menuList.add("查看大图");
            // // menuList.add("滤镜处理");
            // final CustomListViewDialog downDialog = new
            // CustomListViewDialog(
            // PublishNewsActivity.this, menuList);
            // downDialog.setClickCallBack(new ClickCallBack() {
            // @Override
            // public void Onclick(View view, int which) {
            // switch (which) {
            // case 0:
            // // 删除
            // deleteNewsImageView(tmpFilePath);
            // break;
            // case 1:
            // // 查看大图
            // Intent intent = new Intent(
            // PublishNewsActivity.this,
            // BigImgLookActivity.class);
            // intent.putExtra(BigImgLookActivity.INTENT_KEY,
            // tmpFilePath);
            // // startActivityWithBottom(intent);
            // startActivity(intent);
            // break;
            // case 2:
            // // 滤镜
            // // filterImage(tmpFilePath, false);
            //
            // break;
            // default:
            // break;
            // }
            // downDialog.cancel();
            // }
            // });
            // downDialog.show();

          }
        });
  }
コード例 #22
0
ファイル: KCalendar.java プロジェクト: kzhouyijin/zack.ui
  /** 填充日历(包含日期、标记、背景等) */
  protected void setCalendarDate() {
    // 根据日历的日子获取这一天是星期几
    int weekday = calendarday.getDay();
    // 每个月第一天
    int firstDay = 1;
    // 每个月中间号,根据循环会自动++
    int day = firstDay;
    // 每个月的最后一天
    int lastDay = getDateNum(calendarday.getYear(), calendarday.getMonth());
    // 下个月第一天
    int nextMonthDay = 1;
    int lastMonthDay = 1;
    // 填充每一个空格
    for (int i = 0; i < ROWS_TOTAL; i++) {
      for (int j = 0; j < COLS_TOTAL; j++) {
        // 这个月第一天不是礼拜天,则需要绘制上个月的剩余几天
        if (i == 0 && j == 0 && weekday != 0) {
          int year = 0;
          int month = 0;
          int lastMonthDays = 0;
          // 如果这个月是1月,上一个月就是去年的12月
          if (calendarday.getMonth() == 0) {
            year = calendarday.getYear() - 1;
            month = Calendar.DECEMBER;
          } else {
            year = calendarday.getYear();
            month = calendarday.getMonth() - 1;
          }
          // 上个月的最后一天是几号
          lastMonthDays = getDateNum(year, month);
          // 第一个格子展示的是几号
          int firstShowDay = lastMonthDays - weekday + 1;
          // 上月
          for (int k = 0; k < weekday; k++) {
            lastMonthDay = firstShowDay + k;
            RelativeLayout group = getDateView(0, k);
            group.setGravity(Gravity.CENTER);
            TextView view = null;
            if (group.getChildCount() > 0) {
              view = (TextView) group.getChildAt(0);
            } else {
              LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -1);
              view = new TextView(getContext());
              view.setLayoutParams(params);
              view.setGravity(Gravity.CENTER);
              group.addView(view);
            }
            view.setText(Integer.toString(lastMonthDay));
            view.setTextColor(COLOR_TX_OTHER_MONTH_DAY);
            dates[0][k] = format(new Date(year, month, lastMonthDay));

            // 设置日期背景色
            if (dayBgColorMap.get(dates[0][k]) != null) {
              view.setBackgroundColor(dayBgColorMap.get(dates[0][k]));
            } else {
              view.setBackgroundColor(Color.TRANSPARENT);
            }
            // 设置标记
            if (selectRow == 0 && selectCol == k) {
              view.setBackgroundColor(COLOR_BG_SELECT_DAY);
            }

            setMarker(group, 0, k);
          }
          j = weekday - 1;
          // 这个月第一天是礼拜天,不用绘制上个月的日期,直接绘制这个月的日期
        } else {
          RelativeLayout group = getDateView(i, j);
          group.setGravity(Gravity.CENTER);
          TextView view = null;
          if (group.getChildCount() > 0) {
            view = (TextView) group.getChildAt(0);
          } else {
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -1);
            view = new TextView(getContext());
            view.setLayoutParams(params);
            view.setGravity(Gravity.CENTER);
            group.addView(view);
          }
          // 本月
          if (day <= lastDay) {
            dates[i][j] = format(new Date(calendarday.getYear(), calendarday.getMonth(), day));
            view.setText(Integer.toString(day));

            // 当天
            if (thisday.getDate() == day
                && thisday.getMonth() == calendarday.getMonth()
                && thisday.getYear() == calendarday.getYear()) {
              view.setTextColor(COLOR_TX_THIS_DAY);
              view.setBackgroundColor(COLOR_BG_THIS_DAY);
            } else {
              view.setTextColor(COLOR_TX_THIS_MONTH_DAY);
              view.setBackgroundColor(Color.TRANSPARENT);
            }

            if (selectRow == i && selectCol == j) {
              view.setBackgroundColor(COLOR_BG_SELECT_DAY);
            }
            // 上面首先设置了一下默认的"当天"背景色,当有特殊需求时,才给当日填充背景色
            // 设置日期背景色
            if (dayBgColorMap.get(dates[i][j]) != null) {
              view.setBackgroundColor(dayBgColorMap.get(dates[i][j]));
            }
            // 设置标记
            setMarker(group, i, j);

            day++;
            // 下个月
          } else {
            if (calendarday.getMonth() == Calendar.DECEMBER) {
              dates[i][j] =
                  format(new Date(calendarday.getYear() + 1, Calendar.JANUARY, nextMonthDay));
            } else {
              dates[i][j] =
                  format(new Date(calendarday.getYear(), calendarday.getMonth() + 1, nextMonthDay));
            }
            view.setText(Integer.toString(nextMonthDay));
            view.setTextColor(COLOR_TX_OTHER_MONTH_DAY);
            // 设置日期背景色
            if (dayBgColorMap.get(dates[i][j]) != null) {
              view.setBackgroundColor(dayBgColorMap.get(dates[i][j]));
            } else {
              view.setBackgroundColor(Color.TRANSPARENT);
            }
            if (selectRow == i && selectCol == j) {
              view.setBackgroundColor(COLOR_BG_SELECT_DAY);
            }

            // 设置标记
            setMarker(group, i, j);
            nextMonthDay++;
          }
        }
      }
    }
  }
コード例 #23
0
  // 发布动态
  private void publishNews() {

    if ("".equals(contentEditText.getText().toString().trim())
        && addImageLayout.getChildCount() == 1) {
      ToastUtil.show(this, "内容和图片至少有一个不能为空=_=");
      return;
    }

    if (contentEditText.getText().toString().length() > 140) {
      ToastUtil.show(this, "内容不能超过140字=_=");
      return;
    }

    final UserModel userModel = UserManager.getInstance().getUser();
    showLoading("发布中,请稍候...", false);
    RequestParams params = new RequestParams();
    // 用户id
    params.addBodyParameter("uid", userModel.getUid() + "");
    // 内容
    params.addBodyParameter("content_text", contentEditText.getText().toString());
    // location
    params.addBodyParameter("location", locationString);
    // 哪个圈子里的
    if (topicId > 0) {
      params.addBodyParameter("topic_id", topicId + "");
    }

    // 图片
    for (int i = 0; i < addImageLayout.getChildCount(); i++) {
      View view = addImageLayout.getChildAt(i);
      // 如果不是添加按钮
      if (view != addImageView) {
        // 图片
        File file = new File((String) view.getTag());
        if (file.exists()) {
          params.addBodyParameter("image" + i, file);
        }
      }
    }

    // 姓名
    HttpManager.post(
        JLXCConst.PUBLISH_NEWS,
        params,
        new JsonRequestCallBack<String>(
            new LoadDataHandler<String>() {

              @Override
              public void onSuccess(JSONObject jsonResponse, String flag) {
                super.onSuccess(jsonResponse, flag);
                hideLoading();
                int status = jsonResponse.getIntValue("status");
                switch (status) {
                  case JLXCConst.STATUS_SUCCESS:
                    // toast
                    ToastUtil.show(
                        PublishNewsActivity.this, jsonResponse.getString(JLXCConst.HTTP_MESSAGE));
                    hideLoading();
                    finishWithRight();
                    publishFinishBroadcast();
                    break;
                  case JLXCConst.STATUS_FAIL:
                    hideLoading();
                    Toast.makeText(
                            PublishNewsActivity.this,
                            jsonResponse.getString(JLXCConst.HTTP_MESSAGE),
                            Toast.LENGTH_SHORT)
                        .show();
                    break;
                }
              }

              @Override
              public void onFailure(HttpException arg0, String arg1, String flag) {
                LogUtils.i(arg0.getMessage(), 1);
                super.onFailure(arg0, arg1, flag);
                hideLoading();
                Toast.makeText(PublishNewsActivity.this, "网络异常", Toast.LENGTH_SHORT).show();
              }
            },
            null));
  }