/**
  * 设置新闻详情
  *
  * @param index
  */
 public void ShowNewsDetail(NewsDetailModel model) {
   this.model = model;
   if (model.isFavorate) {
     favoritBtn.setText("取消收藏");
   } else {
     favoritBtn.setText("收藏");
   }
   scrollView.scrollTo(0, 0);
   scrollView.smoothScrollTo(0, 0);
   LogInfo.LogOut("OnlineNewsAdapter", "ShowNews-->pos:" + pos);
   final NewsDetailModel news = model;
   mTitle.setText(news.title);
   mTimeProvenance.setText(
       (TextUtils.isEmpty(news.cFrom) ? "" : "    来源: " + news.cFrom) + "\t" + news.cTime);
   LogInfo.LogOut("字数:" + (news.content == null ? 0 : news.content.length()));
   mDetails.setText("");
   postDelayed(
       new Runnable() {
         @Override
         public void run() {
           setChangeLine(news.content);
         }
       },
       50);
   if (TextUtils.isEmpty(news.imgUrl)) {
     mNewsImage.setVisibility(GONE);
   } else {
     mNewsImage.setVisibility(VISIBLE);
     ImageEngine.setImageBitmap(news.imgUrl, mNewsImage, R.drawable.ic_launcher, -1);
   }
 }
 @Override
 protected void onResume() {
   super.onResume();
   if (viewPager != null) {
     viewPager.startAutoScroll();
   }
   if (container != null) {
     container.smoothScrollTo(0, 0);
   }
   HttpUtils.getpertemcount(
       new HttpErrorHandler() {
         @Override
         public void onRecevieSuccess(JSONObject json) {
           String jishi = json.getJSONObject(UrlContants.jsonData).getString("jishi");
           String yongjiu = json.getJSONObject(UrlContants.jsonData).getString("yongjiu");
           if (CommonUtils.CheckLogin() && Integer.valueOf(StringUtil.toString(jishi, "0")) > 0) {
             badgeView1.show();
             badgeView1.setText(jishi);
           } else {
             badgeView1.hide();
           }
           if (CommonUtils.CheckLogin()
               && Integer.valueOf(StringUtil.toString(yongjiu, "0")) > 0) {
             badgeView2.show();
             badgeView2.setText(yongjiu);
           } else {
             badgeView2.hide();
           }
         }
       });
 }
  private void updateStep() {
    if (stepIndex >= steps.size()) {
      hideSoftInput();

      View finishedView = onCreateFinishedView(getLayoutInflater(), container);
      if (finishedView != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
          finishedView.setAlpha(0);
          finishedView.setVisibility(View.VISIBLE);
          container.addView(finishedView);
          finishedView
              .animate()
              .alpha(1)
              .setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));
        } else {
          finishedView.setVisibility(View.VISIBLE);
          container.addView(finishedView);
        }
      }

      onFormFinished(setupData);
      return;
    }
    updateViews();
    containerScrollView.smoothScrollTo(0, 0);
  }
示例#4
0
  @Test
  public void shouldSmoothScrollTo() throws Exception {
    ScrollView scrollView = new ScrollView(null);
    scrollView.smoothScrollTo(7, 6);

    assertEquals(7, scrollView.getScrollX());
    assertEquals(6, scrollView.getScrollY());
  }
        @Override
        public void onClick(View v) {
          switch (v.getId()) {
            case R.id.btn_sleep_quality:
              _svComparison.smoothScrollTo(0, 0);
              break;

            case R.id.btn_daytime_activity:
              _svComparison.smoothScrollTo(0, _llSleepQualityComparison.getHeight() - 10);
              break;

            case R.id.btn_before_bed_activity:
              _svComparison.smoothScrollTo(
                  0,
                  _llSleepQualityComparison.getHeight() + _llDaytimeActivityComparison.getHeight());
              break;
          }
        }
  private void updateStep() {
    if (mStepIndex >= stepsSize()) {
      hideSoftInput();
      onFormFinished(setupData);

      mStepIndex--; // reset stepIndex to last step
      finish();
      return;
    }
    updateViews();
    mContainerScrollView.smoothScrollTo(0, 0);
  }
示例#7
0
 @Override
 public View initView() {
   View inflate = mLayoutInflater.inflate(R.layout.news_detail_content, null);
   ScrollView scrollView = (ScrollView) inflate.findViewById(R.id.scrollView);
   scrollView.smoothScrollTo(0, 0);
   scrollView.setVerticalScrollBarEnabled(false);
   scrollView.setOverScrollMode(View.OVER_SCROLL_NEVER);
   titleContainer = (RelativeLayout) inflate.findViewById(R.id.title_container);
   titleContainer.setBackgroundColor(
       changeBackgroundColor(mSharedPreferences.getInt(Constracts.KEY_THEME, 0)));
   return inflate;
 }
  @Override
  protected void initData(View view) {
    baseContext = view.getContext();
    cacheUtil = new CacheUtil(baseContext);
    imageLoader = ImageLoader.getInstance(baseContext);
    myProgressDialog = new MyProgressDialog(baseContext);

    btn_add_medicine = (Button) view.findViewById(R.id.btn_add_medicine);
    lv_medicine = (ListViewForScrollView) view.findViewById(R.id.lv_medicine);
    sv_medicine = (ScrollView) view.findViewById(R.id.sv_medicine);
    sv_medicine.smoothScrollTo(0, 0);
  }
 private void handleHighlightAyah(int sura, int ayah) {
   if (mImageView == null) {
     return;
   }
   mImageView.highlightAyah(sura, ayah);
   if (mScrollView != null) {
     AyahBounds yBounds = mImageView.getYBoundsForCurrentHighlight();
     if (yBounds != null) {
       int screenHeight = QuranScreenInfo.getInstance().getHeight();
       int y = yBounds.getMinY() - (int) (0.05 * screenHeight);
       mScrollView.smoothScrollTo(mScrollView.getScrollX(), y);
     }
   }
   mImageView.invalidate();
 }
示例#10
0
  /**
   * 显示图片
   *
   * @param path
   */
  private void setPicture(String path) {
    if (StringUtil.isFilePath(path) == false) {
      Log.e(
          TAG, "setPicture  StringUtil.isFilePath(path) == false >> showShortToast(找不到图片);return;");
      showShortToast("找不到图片");
      return;
    }
    this.picturePath = path;

    svDemoMain.smoothScrollTo(0, 0);
    try {
      ivDemoMainHead.setImageDrawable(new BitmapDrawable(getResources(), picturePath));
    } catch (Exception e) {
      showShortToast("设置图片失败了,再试一次吧^_^");
    }
  }
 @Override
 public void onReadSuccess(List<Gift> list) {
   news = list;
   index_list.setAdapter(
       new CommonAdapter<Gift>(
           IndexActivity.this,
           R.layout.ui_item_new,
           list.size() > 5 ? list.subList(0, 5) : list) {
         @Override
         public void convert(ViewHolder holder, Gift newinfo) {
           String imgurl = newinfo.getGoods_image();
           imgurl = imgurl.substring(0, imgurl.indexOf("_"));
           if (holder.getPosition() < 5) {
             try {
               String date =
                   DateUtil.longToString(
                       Long.valueOf(newinfo.getGoods_selltime() + "000"), "yyyy-MM-dd");
               holder
                   .setImageUrl(
                       R.id.new_img,
                       UrlContants.GIFTIMGURL
                           + imgurl
                           + File.separator
                           + newinfo.getGoods_image(),
                       10f)
                   .setText(R.id.new_title, newinfo.getGoods_name())
                   .setText(R.id.new_createtime, date)
                   .setText(
                       R.id.new_content,
                       newinfo.getGoods_jingle().length() > 50
                           ? newinfo.getGoods_jingle().substring(0, 50)
                           : newinfo.getGoods_jingle());
             } catch (ParseException e) {
               e.printStackTrace();
             }
           }
         }
       });
   container.smoothScrollTo(0, 0);
 }
示例#12
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode != RESULT_OK) {
      return;
    }
    switch (requestCode) {
      case REQUEST_TO_SELECT_PICTURE:
        if (data != null) {
          cutPicture(data.getStringExtra(SelectPictureActivity.RESULT_PICTURE_PATH));
        }
        break;
      case REQUEST_TO_CUT_PICTURE: // 返回的结果
        if (data != null) {
          setPicture(data.getStringExtra(CutPictureActivity.RESULT_PICTURE_PATH));
        }
        break;
      case REQUEST_TO_EDIT_TEXT_INFO:
        if (data != null) {
          svDemoMain.smoothScrollTo(0, 0);
          tvDemoMainHeadName.setText(
              StringUtil.getTrimedString(data.getStringExtra(EditTextInfoWindow.RESULT_VALUE)));
        }
        break;
      case REQUEST_TO_SERVER_SETTING:
        if (data != null) {
          // TODO
        }
        break;
      case REQUEST_TO_TOP_MENU:
        if (data != null) {
          switch (data.getIntExtra(TopMenuWindow.RESULT_POSITION, -1)) {
            case 0:
              showItemOnlyDialog();
              break;
            case 1:
              selectPicture();
              break;
            default:
              break;
          }
        }
        break;
      case REQUEST_TO_BOTTOM_MENU:
        if (data != null) {
          int selectedPosition = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
          if (selectedPosition >= 0 && selectedPosition < topbarColorResIds.length) {
            rlDemoMainTopbar.setBackgroundResource(topbarColorResIds[selectedPosition]);
          }
        }
        break;
      case REQUEST_TO_DATE_PICKER:
        if (data != null) {
          //					List<Integer> selectedPositionList = data.getIntegerArrayListExtra(
          //							GridPickerWindow.RESULT_SELECTED_POSITIONS);
          //					showShortToast("selectedPositionList.size() = " + (selectedPositionList == null
          //							? "null" : selectedPositionList.size()));

          ArrayList<Integer> dateList =
              data.getIntegerArrayListExtra(DatePickerWindow.RESULT_DATE_DETAIL_LIST);
          if (dateList != null && dateList.size() >= 3) {
            showShortToast(
                "选择的日期为" + dateList.get(0) + "-" + (dateList.get(1) + 1) + "-" + dateList.get(2));
          }
        }
        break;
      case REQUEST_TO_PLACE_PICKER:
        if (data != null) {
          ArrayList<String> placeList =
              data.getStringArrayListExtra(PlacePickerWindow.RESULT_PLACE_LIST);
          if (placeList != null) {
            String place = "";
            for (String s : placeList) {
              place += StringUtil.getTrimedString(s);
            }
            showShortToast("选择的地区为: " + place);
          }
        }
        break;
      default:
        break;
    }
  }
 @Override
 public void scrollToTop() {
   ScrollView scrollView = (ScrollView) this.getActivity().findViewById(R.id.scrollView);
   scrollView.smoothScrollTo(0, scrollView.getPaddingTop());
 }
示例#14
0
  @Override
  public boolean dispatchTouchEvent(MotionEvent ev) {
    switch (ev.getAction()) {
      case MotionEvent.ACTION_DOWN:
        /*
         * 记录起始信息
         */
        mStartY = ev.getY();
        mLastY = ev.getY();
        mDispatched = true;
        mCanceledScroll = false;
        break;
      case MotionEvent.ACTION_MOVE:
        float dy = ev.getY() - mLastY;
        float dySinceStart = (ev.getY() - mStartY) / RATIO;
        mLastY = ev.getY();

        /*
         * 自动切换卡片事件触发
         */
        if ((mMovingAnimation == null || mMovingAnimation.isAnimationEnded())
            && mDispatched
            && mCurrentCardView != null
            && Math.abs(dySinceStart) > mCurrentCardView.getCardShrinkHeight()) {
          int indexNext = -1;
          if (dySinceStart > 0) {
            indexNext = mCardLayouts.indexOf(mCurrentCardView) - 1;
          } else {
            indexNext = mCardLayouts.indexOf(mCurrentCardView) + 1;
          }

          if (indexNext >= 0 && indexNext < mCardLayouts.size()) {
            onCardClick(mCardLayouts.get(indexNext));
            mDispatched = false;
            mCanceledScroll = true;
          }
        }

        /*
         * 操作滚动条
         */
        if (!mCanceledScroll) {
          mContainerScrollView.scrollBy(0, -(int) (dy / RATIO));
        }
        break;
      case MotionEvent.ACTION_UP:
        /*
         * 松开手指,自动回弹效果
         */
        if ((mMovingAnimation == null || mMovingAnimation.isAnimationEnded())
            && mCurrentCardView != null) {
          mContainerScrollView.smoothScrollTo(
              0,
              mCardLayouts.indexOf(mCurrentCardView) * mCurrentCardView.getCardShrinkHeight()
                  - (getMeasuredHeight() - mCurrentCardView.getCardExpandHeight()) / 2);
        }
        /*
         * 恢复初始状态
         */
        mDispatched = false;
        mCanceledScroll = false;
        break;
    }
    return super.dispatchTouchEvent(ev);
  }
 protected void scrollToTop() {
   ScrollView sv = (ScrollView) m_root.findViewById(R.id.MailboxScrollView);
   sv.smoothScrollTo(0, 0);
 }