/** * 获得ScrollView最大垂直滚动距离 * * @param scrollView * @return */ private int getMaxScrollY() { int tmpY = mContentScrollView.getScrollY(); mContentScrollView.scrollTo(getScrollX(), 5000); int maxY = mContentScrollView.getScrollY(); mContentScrollView.scrollTo(mContentScrollView.getScrollX(), tmpY); return maxY; }
public final void aKY() { if (ipQ.iqA == 1) { izM.scrollTo(0, izM.getChildAt(0).getMeasuredHeight() - izM.getMeasuredHeight()); return; } izM.scrollTo(0, 0); }
@Override public void scrollTo(int x, int y) { if (mIsScrollFreeze) { // Actually I don't know why need this. super.scrollTo(0, 0); } else { super.scrollTo(x, y); } }
/** * 设置新闻详情 * * @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 public void run() { int off = mLayout.getMeasuredHeight() - sView.getHeight(); if (off > 0) { sView.scrollTo(0, off); // 改变滚动条的位置 } }
public void reset() { if (null != mScrollText) { mScrollText.setVisibility(View.GONE); } if (null != mImageView) { mImageView.setVisibility(View.GONE); } if (null != mAudioPlayer) { stopAudio(); } if (null != mVideoView) { stopVideo(); mVideoView.setVisibility(View.GONE); } if (null != mTextView) { mTextView.setVisibility(View.GONE); } if (mScrollViewPort != null) { mScrollViewPort.scrollTo(0, 0); mScrollViewPort.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0, 0)); } }
@Override public void onHistoryItemSelected(HistoryItem item) { TranslationDirection direction = new TranslationDirection(item.getLang()); App.getInstance().setTranslationDirection(direction); mLanguagePicker.updateDirection(); mOriginalTextInput.setText(item.getOriginal()); mScrollView.scrollTo(0, 0); }
public void someMethod(Item item) { setTag(item); table.removeAllViews(); scrollView.scrollTo(0, 0); header.render(item); for (Item child : item.getChildren()) { table.addView(getRowView(child)); } }
@Override public void run() { final Scroller scroller = mScroller; final ScrollView scrollView = mScrollView; scroller.computeScrollOffset(); scrollView.scrollTo(0, scroller.getCurrY()); if (!scroller.isFinished()) { scrollView.post(this); } }
/** 用来显示该popwindow,保证在调用该方法之前已经调用{@link #addItemToBottomPopWindow(int, int, String)}方法 */ protected void showBottomPopWindow() { if (Build.VERSION.SDK_INT >= 11) { // 如果上次的动画还在执行,直接停止 if (reverseAnimation != null) { reverseAnimation.end(); } sv_bottom_content.setVisibility(View.VISIBLE); ll_full_screen.setVisibility(View.VISIBLE); // 需要滚动到顶部 sv_bottom_content.scrollTo(0, 0); if (popAnimation == null) { popAnimation = ObjectAnimator.ofInt(sv_bottom_content, "bottomMargin", -scrollViewMeasureHeight, 0); popAnimation.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int value = (Integer) animation.getAnimatedValue(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv_bottom_content.getLayoutParams(); params.bottomMargin = value; sv_bottom_content.setLayoutParams(params); ((View) (sv_bottom_content.getParent())).invalidate(); ll_full_screen.setAlpha( (float) (((scrollViewMeasureHeight + value) * 1.0) / (scrollViewMeasureHeight * 1.0))); } }); popAnimation.setDuration(500); } popAnimation.start(); } else { ll_full_screen.setVisibility(View.VISIBLE); sv_bottom_content.setVisibility(View.VISIBLE); // 需要滚动到顶部 sv_bottom_content.scrollTo(0, 0); } }
/** 重新获取嵌套的内容视图 */ private void regetNestedContentView() { int currentItem = mDirectViewPager.getCurrentItem(); PagerAdapter adapter = mDirectViewPager.getAdapter(); if (adapter instanceof FragmentPagerAdapter || adapter instanceof FragmentStatePagerAdapter) { Fragment item = (Fragment) adapter.instantiateItem(mDirectViewPager, currentItem); mNestedContentView = item.getView(); // 清空之前的 mNestedNormalView = null; mNestedAbsListView = null; mNestedRecyclerView = null; mNestedScrollView = null; mNestedWebView = null; if (mNestedContentView instanceof AbsListView) { mNestedAbsListView = (AbsListView) mNestedContentView; mNestedAbsListView.setOnScrollListener(mLvOnScrollListener); if (!isHeaderViewCompleteInvisible()) { mNestedAbsListView.setSelection(0); } } else if (mNestedContentView instanceof RecyclerView) { mNestedRecyclerView = (RecyclerView) mNestedContentView; mNestedRecyclerView.removeOnScrollListener(mRvOnScrollListener); mNestedRecyclerView.addOnScrollListener(mRvOnScrollListener); if (!isHeaderViewCompleteInvisible()) { mNestedRecyclerView.scrollToPosition(0); } } else if (mNestedContentView instanceof ScrollView) { mNestedScrollView = (ScrollView) mNestedContentView; if (!isHeaderViewCompleteInvisible()) { mNestedScrollView.scrollTo(mNestedScrollView.getScrollX(), 0); } } else if (mNestedContentView instanceof WebView) { mNestedWebView = (WebView) mNestedContentView; if (!isHeaderViewCompleteInvisible()) { mNestedWebView.scrollTo(mNestedWebView.getScrollX(), 0); } } else { mNestedNormalView = mNestedContentView; } } else { throw new IllegalStateException( BGAStickyNavLayout.class.getSimpleName() + "的第三个子控件为ViewPager时,其adapter必须是FragmentPagerAdapter或者FragmentStatePagerAdapter"); } }
private void setDefaultValues() { scrollview.scrollTo(0, scrollview.getTop()); trailertype.setText( getString(string.homepage_textview_trailertype) + " " + getString(string.trailer_type_own)); id.setText(getString(string.homepage_textview_ID)); place.setText(getString(string.homepage_textview_place)); sealed.setText(getString(string.homepage_textview_sealed) + " " + getString(string.sealed_no)); plates.setText(getString(string.homepage_textview_plates)); straps.setText(getString(string.homepage_textview_straps)); trailerinventory.setVisibility(RelativeLayout.VISIBLE); submit.setEnabled(false); CoreComponent.trailerid = null; DamageClaimApp.trailer_type = Utility.getParsedString(trailertype.getText().toString()); DamageClaimApp.place = null; DamageClaimApp.straps = null; DamageClaimApp.plates = null; DamageClaimApp.sealed = Utility.getParsedString(sealed.getText().toString()); }
// 获取到饲料配方类型成功 public void onSuccess(String result) { // TODO Auto-generated method stub EntityDataPageVo edv = null; try { edv = new Gson().fromJson(result, new TypeToken<EntityDataPageVo>() {}.getType()); if ((edv != null) && (edv.getErrorCode().equals(CommonResultVo.ERROR_CODE_SUCCESS))) { List<NutritionVo> temps1 = new ArrayList<NutritionVo>(); // (ArrayList<NutritionVo>) edv.data; // List<String> temps=new ArrayList<String>(); try { temps1 = JsonUtil.fromJsonArray(JsonUtil.toJson(edv.data), NutritionVo.class); } catch (Exception e) { } if (temps1 != null && temps1.size() > 0) { listNus.addAll(temps1); } else { NutritionVo nv = new NutritionVo(); nv.id = null; nv.name = "无"; nv.systemUnitNum = "无"; nv.systemUnitName = "无"; listNus.add(nv); } nuAdapter = new NutritionListAdapter( listNus, getApplicationContext(), R.layout.fragment_fromula_nutrition_list_item); nuListView.setAdapter(nuAdapter); fixListViewHeight(nuListView); // 数据加载完成改变一下scrollview的显示位置 sv.scrollTo(0, 0); } else { UIHelper.ToastMessage( ActivityFormulaArtificial2.this, "获取配方营养素失败" + edv.getErrorMsg()); } } catch (Exception e) { e.printStackTrace(); UIHelper.ToastMessage( ActivityFormulaArtificial2.this, "获取配方营养素失败,请联系管理员:" + e.getMessage()); } // UIHelper.ToastMessage(_context,"总条数=" + result + ""); }
private void setNextSelectedPositionInt(int position) { if (mContentScrollView.getHeight() == 0) { setSelection(position); return; } mSelectedPosition = position; initItemViewsScrollYArr(); mContentScrollView.scrollTo( mContentScrollView.getScrollX(), mItemViewsScrollYArr[mSelectedPosition]); if (mOnItemSelectedListener != null) { mOnItemSelectedListener.onItemSelected( this, mCachedSubViewList.get(mSelectedPosition), mSelectedPosition, mAdapter.getItemId(mSelectedPosition)); } }
// Displays the contents of the file line by line private void showLogFile(File file) { // Store reference to file, so that it can be found on refresh currentLogFile = file; this.setContentView(R.layout.logfileview); currentContentView = R.layout.logfileview; // Set up TextViews TextView twDesc = (TextView) this.findViewById(R.id.textViewLogDescription); twDesc.setText(file.getName() + ":"); TextView twCont = (TextView) this.findViewById(R.id.textViewLogContents); // File does not exist if (!file.exists()) twCont.setText("File does not exist!"); else { // File exists, iterate through it try { BufferedReader r = new BufferedReader(new FileReader(file)); String line; twCont.setText(""); while ((line = r.readLine()) != null) { twCont.append(line + "\n"); } r.close(); } catch (Exception e) { // Log exception Log.e(Common.LOG_TAG, Common.LOG_EXCEPTION_READING_LOG_FILE, e); } } // Post event to scroll down to the bottom of the page final ScrollView sv = (ScrollView) this.findViewById(R.id.logFileScrollView); sv.post( new Runnable() { @Override public void run() { sv.fullScroll(View.FOCUS_DOWN); } }); sv.scrollTo(0, sv.getBottom()); }
private void setUpViews() { setUpPullRefresh(); mHolidayTextView.setText(getString(R.string.course_holiday, "\uD83D\uDE06")); Bitmap sourceBitmap = Utils.convertDrawableToBitmap( getResources().getDrawable(R.drawable.ic_keyboard_arrow_down_white_24dp)); int color = getResources().getColor(R.color.accent); mPickYmsImageView.setImageBitmap(Utils.changeImageColor(sourceBitmap, color)); mScrollView.scrollTo(0, mPos); mPickYmsView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (mSelectedModel == null) { return; } mTracker.send( new HitBuilders.EventBuilder().setCategory("pick yms").setAction("click").build()); Intent intent = new Intent(CourseActivity.this, PickSemesterActivity.class); intent.putExtra("mSemesterList", new Gson().toJson(mSemesterList)); intent.putExtra("mSelectedModel", new Gson().toJson(mSelectedModel)); startActivityForResult(intent, Constant.REQUEST_PICK_SEMESTER); } }); mNoCourseLinearLayout.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (isRetry) { mTracker.send( new HitBuilders.EventBuilder() .setCategory("retry") .setAction("click") .setLabel((mSemesterList == null) + "") .build()); isRetry = false; if (mSemesterList == null || mSelectedModel == null) { getSemester(); } else { getData(false); } } else { if (mSemesterList == null || mSelectedModel == null) { getSemester(); return; } mTracker.send( new HitBuilders.EventBuilder() .setCategory("pick yms") .setAction("click") .build()); Intent intent = new Intent(CourseActivity.this, PickSemesterActivity.class); intent.putExtra("mSemesterList", new Gson().toJson(mSemesterList)); intent.putExtra("mSelectedModel", new Gson().toJson(mSelectedModel)); startActivityForResult(intent, Constant.REQUEST_PICK_SEMESTER); } } }); if (mSelectedModel != null && mSemesterList != null) { mPickYmsTextView.setText(mSelectedModel.text); setUpCourseTable(); } else { mPickYmsView.setEnabled(false); getSemester(); } }
private void updateLog() { final String logContents = NativeHelper.log.toString(); if (logContents != null && logContents.trim().length() > 0) consoleText.setText(logContents); consoleScroll.scrollTo(0, consoleText.getHeight()); }
/** Write a string to the output window */ private void log(String string) { output.append(string + "\n"); int height = scrollView.getChildAt(0).getHeight(); Log.d(TAG, "scroll view height: " + height); scrollView.scrollTo(0, height + 2000); }
private void reset() { mScrollView.scrollTo(0, 0); mBadPinError.setVisibility(View.GONE); mMismatchError.setVisibility(View.GONE); }
@Override public void scrollTo(int x, int y) { super.scrollTo(x, y); progressUpdate(); }
public void scrollToTop() { mScrollView.scrollTo(0, 0); }
public void scrollToTop() { if (scrollView != null) { scrollView.scrollTo(0, 0); } }
public void scrollTo(int y) { if (mScrollView != null) { mScrollView.scrollTo(0, y); } }
public void setDashboardVisibility( boolean visible, DashboardType type, DashboardType prevItem, boolean animation) { if (visible == this.visible && type == visibleType) { return; } this.previousVisibleType = prevItem; this.visible = visible; boolean refresh = this.visibleType == type; this.visibleType = type; DashboardOnMap.staticVisible = visible; DashboardOnMap.staticVisibleType = type; mapActivity.enableDrawer(); if (visible) { mapViewLocation = mapActivity.getMapLocation(); mapRotation = mapActivity.getMapRotate(); mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation(); mapActivity.getMapViewTrackingUtilities().setDashboard(this); mapActivity.disableDrawer(); dashboardView.setVisibility(View.VISIBLE); if (isActionButtonVisible()) { actionButton.setVisibility(View.VISIBLE); } else { hideActionButton(); } updateDownloadBtn(); View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout); ScrollView scrollView = (ScrollView) dashboardView.findViewById(R.id.main_scroll); if (visibleType == DashboardType.DASHBOARD) { addOrUpdateDashboardFragments(); scrollView.setVisibility(View.VISIBLE); scrollView.scrollTo(0, 0); listViewLayout.setVisibility(View.GONE); onScrollChanged(scrollView.getScrollY(), false, false); } else { scrollView.setVisibility(View.GONE); listViewLayout.setVisibility(View.VISIBLE); if (listView instanceof ObservableListView) { onScrollChanged(listView.getScrollY(), false, false); } if (refresh) { refreshContent(false); } else { updateListAdapter(); updateListBackgroundHeight(); } } mapActivity .findViewById(R.id.toolbar_back) .setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE); mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE); updateToolbarActions(); // fabButton.showFloatingActionButton(); open(dashboardView.findViewById(R.id.animateContent), animation); updateLocation(true, true, false); // addOrUpdateDashboardFragments(); } else { mapActivity.getMapViewTrackingUtilities().setDashboard(null); hide(dashboardView.findViewById(R.id.animateContent), animation); mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE); hideActionButton(); for (WeakReference<DashBaseFragment> df : fragList) { if (df.get() != null) { df.get().onCloseDash(); } } } }
private void excute() { try { // 获取配方所含营养素组成 List<ArtificialNur> formulaNur = mPfDb.getFormulaNurs(ff.id + ""); if (formulaNur != null && formulaNur.size() > 0) { if (feedids != null && feedids.length() > 0) { // 遍历配方含的营养素组成,这里只取第一个 for (int f = 0; f < 1; f++) { ArtificialNur fn = formulaNur.get(f); try { // 获取在指定饲料中的,营养素大于number跟小于number的,饲料id的列表 List<Long> maxFeedIds = mPfDb.getMaxFeedIds( feedids.substring(0, feedids.length() - 1), fn.Cid, fn.UnitNumber); List<Long> minFeedIds = mPfDb.getMinFeedIds( feedids.substring(0, feedids.length() - 1), fn.Cid, fn.UnitNumber); // 存distinct的feedid List<Long> distinctfeedids = new ArrayList<Long>(); for (Long id : maxFeedIds) { if (!distinctfeedids.contains(id)) { distinctfeedids.add(id); } } for (Long id : minFeedIds) { if (!distinctfeedids.contains(id)) { distinctfeedids.add(id); } } // 将大于跟小于的饲料列表数目对齐 if (maxFeedIds != null && maxFeedIds.size() > 0) { if (minFeedIds != null && minFeedIds.size() > 0) { if (maxFeedIds.size() > minFeedIds.size()) { Long temp = minFeedIds.get(0); for (int i = 0; i < (maxFeedIds.size() - minFeedIds.size()); i++) { minFeedIds.add(temp); } } else { Long temp = maxFeedIds.get(0); for (int i = 0; i < (minFeedIds.size() - maxFeedIds.size()); i++) { maxFeedIds.add(temp); } } // 拿一个总的feedid列表 List<Long> feeds = new ArrayList<Long>(); for (Long id : maxFeedIds) { feeds.add(id); } for (Long id : minFeedIds) { feeds.add(id); } // 计算比例中间过程,获取差值 // List<ArtificialNur> maxFeedNur=new ArrayList<ArtificialNur>(); // List<ArtificialNur> minFeedNur=new ArrayList<ArtificialNur>(); List<ArtificialNur> feedNur = new ArrayList<ArtificialNur>(); double totalNumber = 0; for (Long id : feeds) { try { ArtificialNur temp = mPfDb.getAri(id, fn.Cid); if (temp != null) { temp.UnitNumber = Math.abs(fn.UnitNumber - temp.UnitNumber); totalNumber += temp.UnitNumber; feedNur.add(temp); } } catch (Exception e) { } } // 计算比例 perFeedNur = new ArrayList<ArtificialNur>(); for (int i = 0; i < feedNur.size(); i++) { try { ArtificialNur temp = (ArtificialNur) feedNur.get(i).clone(); ArtificialNur temp1 = feedNur.get(feedNur.size() - i - 1); temp.UnitNumber = temp1.UnitNumber / totalNumber; perFeedNur.add(temp); } catch (Exception e) { } } // 合并重复饲料 for (Long id : distinctfeedids) { try { ArtificialNur tempav = new ArtificialNur(); double temp = 0; for (ArtificialNur av : perFeedNur) { try { if (id == av.Mid) { tempav = (ArtificialNur) av.clone(); temp += av.UnitNumber; } } catch (Exception e) { } } tempav.UnitNumber = temp; if (tempav != null && tempav.Mid > 0) { arFeedNur.add(tempav); } } catch (Exception e) { } } if (arFeedNur != null && arFeedNur.size() == 0) { ArtificialNur temp = new ArtificialNur(); temp.Mname = "无"; temp.UnitNumber = 0; arFeedNur.add(temp); } // 绑定数据展示控件 arFeedAdapter = new ArtificialAdapter( arFeedNur, getApplicationContext(), R.layout.item_list_artificial); lvFormulaAr.setAdapter(arFeedAdapter); fixListViewHeight(lvFormulaAr); // 数据加载完成改变一下scrollview的显示位置 sv.scrollTo(0, 0); } else { List<ArtificialNur> xx = mPfDb.getMinFeedNurs(fn.Cid, fn.UnitNumber); if (xx != null && xx.size() > 0) { String str = ""; for (ArtificialNur x : xx) { str = str + x.Mname + ","; } UIHelper.ToastLongMessage( ActivityFormulaArtificial2.this, "当前选择的饲料:" + fn.Cname + "含量过高,请将" + str + "一种或者几种选入!"); } else { UIHelper.ToastLongMessage( ActivityFormulaArtificial2.this, "由于配方的" + fn.Cname + "含量过低,数据库无法生成合适的饲料配比!"); } } } else { List<ArtificialNur> xx = mPfDb.getMaxFeedNurs(fn.Cid, fn.UnitNumber); if (xx != null && xx.size() > 0) { String str = ""; for (ArtificialNur x : xx) { str = str + x.Mname + ","; } UIHelper.ToastLongMessage( ActivityFormulaArtificial2.this, "当前选择的饲料:" + fn.Cname + "含量过低,请将" + str + "一种或者几种选入!"); } else { UIHelper.ToastLongMessage( ActivityFormulaArtificial2.this, "由于配方的" + fn.Cname + "含量过高,数据库无法生成合适的饲料配比!"); } } } catch (Exception e) { } } } else { UIHelper.ToastLongMessage(ActivityFormulaArtificial2.this, "请选择两种以上的饲料!"); } } else { UIHelper.ToastLongMessage(ActivityFormulaArtificial2.this, "没有获取到该配方的营养素组成情况,请重新选择配方!"); } } catch (Exception e) { UIHelper.ToastLongMessage( ActivityFormulaArtificial2.this, "智能计算出现问题,请联系管理员:" + e.getMessage()); } }