// 显示 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);
      }
    }
  }
 // 隐藏 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);
     }
   }
 }
  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;
  }
  // /防止内存不够用
  @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);
  }
  @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();
            }
          });
    }
  }
Beispiel #6
0
  @Override
  public void onResume() {
    super.onResume();

    // Format the most recently clicked item upon returning from info page
    if (ListData.indexLastClicked != 99) {
      int idx = ListData.indexLastClicked;
      RelativeLayout lastClicked =
          (RelativeLayout)
              theListView.getChildAt(
                  ListData.indexLastClicked - theListView.getFirstVisiblePosition());
      TextView v = (TextView) lastClicked.getChildAt(0);
      TextView w = (TextView) lastClicked.getChildAt(1);
      boolean completed = ListData.getCompletedList().get(ListData.indexLastClicked);

      if (completed) {
        v.setTextColor(Color.LTGRAY);
        w.setText("DONE!");
        w.setTextColor(Color.parseColor("#73e600"));

      } else {
        v.setTextColor(Color.BLACK);
        w.setText("\u2705");
        w.setTextColor(Color.LTGRAY);
      }
    }
  }
Beispiel #7
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;
  }
 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);
 }
  // 删除状态图片
  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);
    }
  }
Beispiel #10
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   String functionId = columnEntries.get(position).getId();
   currentFunctionId = functionId;
   if (oldFunctionId.equals(currentFunctionId)) return;
   oldFunctionId = currentFunctionId;
   for (int i = 0; i < parent.getChildCount(); i++) {
     RelativeLayout rl = (RelativeLayout) parent.getChildAt(i);
     if (i == position) {
       ((ImageView) rl.getChildAt(0)).setImageResource(R.drawable.phone_study_menu_select);
       ((TextView) rl.getChildAt(1)).setTextColor(Color.WHITE);
     } else {
       ((ImageView) rl.getChildAt(0)).setImageDrawable(null);
       ((TextView) rl.getChildAt(1)).setTextColor(Color.BLUE);
     }
   }
   index = 0;
   courses.clear();
   coursewares.clear();
   loadDataForView(functionId);
 }
 public static void setTitleAlignment(Window window) {
   ViewGroup decorView = (ViewGroup) window.getDecorView();
   LinearLayout root = (LinearLayout) decorView.getChildAt(0);
   if (root.getChildAt(0).getClass() == FrameLayout.class) {
     FrameLayout titleContainer = (FrameLayout) root.getChildAt(0);
     TextView title = (TextView) titleContainer.getChildAt(0);
     title.setGravity(Gravity.CENTER);
   } else if (root.getChildAt(1).getClass() == FrameLayout.class) {
     FrameLayout titleContainer = (FrameLayout) root.getChildAt(1);
     if (titleContainer.getChildAt(0).getClass() == RelativeLayout.class) {
       RelativeLayout relativeLayout = (RelativeLayout) titleContainer.getChildAt(0);
       if (relativeLayout.getChildAt(0).getClass() == TextView.class) {
         TextView title = (TextView) relativeLayout.getChildAt(0);
         title.setGravity(Gravity.CENTER);
       }
     } else if (titleContainer.getChildAt(0).getClass() == TextView.class) {
       TextView title = (TextView) titleContainer.getChildAt(0);
       title.setGravity(Gravity.CENTER);
     }
   }
 }
  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));
                }
              }
            }
          });
    }
  }
Beispiel #13
0
  @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);
  }
Beispiel #14
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);
       }
     }
   }
 }
  @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();
        }
      }
    }
  }
Beispiel #16
0
 // 设置标记
 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));
     }
   }
 }
  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);
                  }
                }
              });
    }
  }
Beispiel #18
0
  public void expandOrContractTextView(View view) {
    TextView textView = (TextView) view;

    RelativeLayout relativeLayout = (RelativeLayout) textView.getParent();
    ImageButton expandOrContract = (ImageButton) relativeLayout.getChildAt(1);
    Drawable expandImage = getResources().getDrawable(R.drawable.ic_expand_more_black);
    Drawable contractImage = getResources().getDrawable(R.drawable.ic_expand_less_black);

    // Use Icons to RepresentState
    if (expandOrContract
        .getTag()
        .toString()
        .equals(getResources().getString(R.string.expand))) { // if Expand, then contract
      expandOrContract.setImageDrawable(contractImage);
      expandOrContract.setTag(getResources().getString(R.string.contract));
      if (expandOrContract.getId() == R.id.settings_general_image_button) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.settings_general_views_layout);
        layout.setVisibility(View.VISIBLE);
      } else if (expandOrContract.getId() == R.id.settings_synchronisation_image_button) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.settings_synchronisation_views);
        layout.setVisibility(View.VISIBLE);
      }

    } else {
      expandOrContract.setImageDrawable(expandImage);
      expandOrContract.setTag(getResources().getString(R.string.expand));

      if (expandOrContract.getId() == R.id.settings_general_image_button) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.settings_general_views_layout);

        layout.setVisibility(View.GONE);
      } else if (expandOrContract.getId() == R.id.settings_synchronisation_image_button) {
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.settings_synchronisation_views);

        layout.setVisibility(View.GONE);
      }
    }
  }
  public SelectOneAutoAdvanceWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    LayoutInflater inflater = LayoutInflater.from(getContext());

    // SurveyCTO-added support for dynamic select content (from .csv files)
    XPathFuncExpr xPathFuncExpr =
        ExternalDataUtil.getSearchXPathExpression(prompt.getAppearanceHint());
    if (xPathFuncExpr != null) {
      mItems = ExternalDataUtil.populateExternalChoices(prompt, xPathFuncExpr);
    } else {
      mItems = prompt.getSelectChoices();
    }

    buttons = new ArrayList<RadioButton>();
    listener = (AdvanceToNextListener) context;

    String s = null;
    if (prompt.getAnswerValue() != null) {
      s = ((Selection) prompt.getAnswerValue().getValue()).getValue();
    }

    // use this for recycle
    Bitmap b =
        BitmapFactory.decodeResource(getContext().getResources(), R.drawable.expander_ic_right);

    if (mItems != null) {
      for (int i = 0; i < mItems.size(); i++) {

        RelativeLayout thisParentLayout =
            (RelativeLayout) inflater.inflate(R.layout.quick_select_layout, null);

        LinearLayout questionLayout = (LinearLayout) thisParentLayout.getChildAt(0);
        ImageView rightArrow = (ImageView) thisParentLayout.getChildAt(1);

        RadioButton r = new RadioButton(getContext());
        r.setText(prompt.getSelectChoiceText(mItems.get(i)));
        r.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
        r.setTag(Integer.valueOf(i));
        r.setId(QuestionWidget.newUniqueId());
        r.setEnabled(!prompt.isReadOnly());
        r.setFocusable(!prompt.isReadOnly());

        rightArrow.setImageBitmap(b);

        buttons.add(r);

        if (mItems.get(i).getValue().equals(s)) {
          r.setChecked(true);
        }

        r.setOnCheckedChangeListener(this);

        String audioURI = null;
        audioURI =
            prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO);

        String imageURI;
        if (mItems.get(i) instanceof ExternalSelectChoice) {
          imageURI = ((ExternalSelectChoice) mItems.get(i)).getImage();
        } else {
          imageURI =
              prompt.getSpecialFormSelectChoiceText(
                  mItems.get(i), FormEntryCaption.TEXT_FORM_IMAGE);
        }

        String videoURI = null;
        videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

        String bigImageURI = null;
        bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

        MediaLayout mediaLayout = new MediaLayout(getContext());
        mediaLayout.setAVT(prompt.getIndex(), "", r, audioURI, imageURI, videoURI, bigImageURI);

        if (i != mItems.size() - 1) {
          // Last, add the dividing line (except for the last element)
          ImageView divider = new ImageView(getContext());
          divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
          mediaLayout.addDivider(divider);
        }
        questionLayout.addView(mediaLayout);
        addView(thisParentLayout);
      }
    }
  }
Beispiel #20
0
  /** 填充日历(包含日期、标记、背景等) */
  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++;
          }
        }
      }
    }
  }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

      RelativeLayout v;
      View child;

      // Log.d("mobeta",
      // "getView: position="+position+" convertView="+convertView);
      if (convertView != null) {

        v = (RelativeLayout) convertView;
        View oldChild = v.getChildAt(0);

        // child = super.getView(position, oldChild, v);
        child = mAdapter.getView(position, oldChild, v);
        if (child != oldChild) {
          // shouldn't get here if user is reusing convertViews
          // properly
          v.removeViewAt(0);
          v.addView(child);
          // check that tags are equal too?
          v.setTag(child.findViewById(R.id.drag));
        }

      } else {
        AbsListView.LayoutParams params =
            new AbsListView.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        v = new RelativeLayout(getContext());
        v.setLayoutParams(params);
        child = mAdapter.getView(position, null, v);
        v.addView(child);

        v.setTag(child.findViewById(R.id.drag));
      }

      ViewGroup.LayoutParams lp = v.getLayoutParams();
      final int numHeaders = getHeaderViewsCount();

      final int srcAdapter = mSrcDragPos - numHeaders;
      final int expAdapter = mExpDragPos - numHeaders;

      boolean itemIsNormal = position != srcAdapter && position != expAdapter;
      boolean listHasExpPos = mDragState == SRC_ABOVE || mDragState == SRC_BELOW;
      boolean itemNeedsWC = itemIsNormal || !listHasExpPos;

      int oldHeight = lp.height;
      if (itemNeedsWC && lp.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
        // items that have a user-provided height
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
      } else if (listHasExpPos) {
        if (position == srcAdapter && lp.height != mItemHeightCollapsed) {
          // collapsed items
          lp.height = mItemHeightCollapsed;
        } else if (position == expAdapter) {
          // what if a previously-expanded wrapper view is used
          // as a convertView for a different expanded item?
          // Always measure child
          int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
          child.measure(spec, spec);

          mExpandedChildHeight = child.getMeasuredHeight();
          // Log.d("mobeta",
          // "childh="+mExpandedChildHeight+" pos="+position);
          int height = mExpandedChildHeight + mFloatViewHeight;
          if (lp.height != height) {
            lp.height = height;
          }

          // set gravity
          if (mDragState == SRC_ABOVE) {
            v.setGravity(Gravity.TOP);
          } else {
            v.setGravity(Gravity.BOTTOM);
          }
        }
      }

      if (lp.height != oldHeight) {
        v.setLayoutParams(lp);
      }

      int oldVis = v.getVisibility();
      int vis = oldVis;

      if (position == srcAdapter && mDragState != NO_DRAG) {
        if (vis == View.VISIBLE) {
          vis = View.INVISIBLE;
        }
      } else if (vis == View.INVISIBLE) {
        vis = View.VISIBLE;
      }

      if (vis != oldVis) {
        v.setVisibility(vis);
      }

      return v;
    }
 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));
   }
 }
  // 发布动态
  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));
  }
Beispiel #24
0
  /**
   * Add player to a given view (most likely the root view). This should also be applied last, since
   * it will insert an overlaying view.
   */
  private void addControls() {
    // Inflate the overlay from XML specification and set the initial view
    // to be invisible.
    LayoutInflater inflater = getLayoutInflater();
    RelativeLayout ctrl_overlay =
        (RelativeLayout) inflater.inflate(R.layout.play_controls_yt, null);
    Animation animation = new AlphaAnimation(1.0f, 0.0f);
    animation.setFillAfter(true);
    ctrl_overlay.startAnimation(animation);
    ctrl_overlay.setVisibility(View.INVISIBLE);

    // Set the onTouch event listener such that it will hide and
    ctrl_overlay.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            // write code to add other controls and what not (the fade in /
            // fade out)
            if (!hasBeenTouched) {
              (new ShowControls(v)).call();
              Log.i("Main Activity", "control overlay has been touched");
              hasBeenTouched = true;
            } else {
              (new HideControls(v)).call();
              hasBeenTouched = false;
              Log.i(
                  "Main Activity", "controlOverlay has been pressed but has already been touched");
            }
            return false;
          }
        });
    /*
     * Get the references to all the controls we will be using in the Player
     */
    ImageButton play = (ImageButton) (((ViewGroup) ctrl_overlay.getChildAt(0)).getChildAt(0));
    ImageButton rewind = (ImageButton) (((ViewGroup) ctrl_overlay.getChildAt(0)).getChildAt(1));
    ImageButton pause = (ImageButton) (((ViewGroup) ctrl_overlay.getChildAt(0)).getChildAt(2));
    pb = (ProgressBar) (((ViewGroup) ctrl_overlay.getChildAt(0)).getChildAt(3));

    /*
     * For each control that we will be using for the Player we will define
     * the on touch events.
     */
    play.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!hasBeenTouched) {
              (new ShowControls((View) v.getParent().getParent())).call();
              Log.i("Main Activity", "playPause has been pressed");
              hasBeenTouched = true;
            } else {
              /*
               * Play the video... really I'm just settting a flag and
               * hoping that the play-loop code above notices it.
               */
              playerControlPause = false;
              Log.i("Main Activity", "playPause has been pressed but has already been touched");
            }
          }
        });

    rewind.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!hasBeenTouched) {
              (new ShowControls((View) v.getParent().getParent())).call();
              Log.i("Main Activity", "rewind has been pressed");
              hasBeenTouched = true;
            } else {
              /*
               * reset the video... not a true rewind
               */
              if (root.getTimePlayed() >= root.getDuration()) {
                root.reset();
                root.getSubject().reset();
                startPlayback();
              } else {
                playbackReset = true;
              }
              pb.setProgress(0);
              Log.i("Main Activity", "rewind has been pressed but has already been touched");
            }
          }
        });

    pause.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!hasBeenTouched) {
              (new ShowControls((View) v.getParent().getParent())).call();
              Log.i("Main Activity", "fastForward has been pressed");
              hasBeenTouched = true;
            } else {
              /*
               * Set the falg to pause and hope that the playloop notices
               * what is going on.
               */
              playerControlPause = true;
              Log.i("Main Activity", "fastforward has been pressed but has already been touched");
            }
          }
        });

    pb.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (!hasBeenTouched) {
              (new ShowControls((View) v.getParent().getParent())).call();
              Log.i("Main Activity", "seekBar has been pressed");
              hasBeenTouched = true;
            } else {
              /*
               * Really don't need to do anything but display the
               * controls... so yeah.
               */
            }
          }
        });

    /*
     * Apply the (totally pimp'd out) controls to the page
     */
    ctrl_overlay.setId(CONTROL_ID);
    this.rootView.addView(ctrl_overlay);
  }
 public void deleteMarker(RelativeLayout cell) {
   if (cell.getChildCount() > 1) {
     cell.removeView(cell.getChildAt(1));
   }
 }
Beispiel #26
0
  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);
    }
  }