private void calculateMaxViewport() { this.tempMaximumViewport.set(AutoScrollHelper.NO_MAX, Float.MIN_VALUE, Float.MIN_VALUE, AutoScrollHelper.NO_MAX); for (Line line : this.dataProvider.getLineChartData().getLines()) { for (PointValue pointValue : line.getValues()) { if (pointValue.getX() < this.tempMaximumViewport.left) { this.tempMaximumViewport.left = pointValue.getX(); } if (pointValue.getX() > this.tempMaximumViewport.right) { this.tempMaximumViewport.right = pointValue.getX(); } if (pointValue.getY() < this.tempMaximumViewport.bottom) { this.tempMaximumViewport.bottom = pointValue.getY(); } if (pointValue.getY() > this.tempMaximumViewport.top) { this.tempMaximumViewport.top = pointValue.getY(); } } } }
private static int getClosestDecodedValue(int[] moduleBitCount) { int bitCountSum = PDF417Common.getBitCountSum(moduleBitCount); float[] bitCountRatios = new float[8]; for (int i = 0; i < bitCountRatios.length; i++) { bitCountRatios[i] = ((float) moduleBitCount[i]) / ((float) bitCountSum); } float bestMatchError = AutoScrollHelper.NO_MAX; int bestMatch = -1; for (int j = 0; j < RATIOS_TABLE.length; j++) { float error = 0.0f; float[] ratioTableRow = RATIOS_TABLE[j]; for (int k = 0; k < 8; k++) { float diff = ratioTableRow[k] - bitCountRatios[k]; error += diff * diff; if (error >= bestMatchError) { break; } } if (error < bestMatchError) { bestMatchError = error; bestMatch = PDF417Common.SYMBOL_TABLE[j]; } } return bestMatch; }
private void init() { listView = (ListView) findViewById(R.id.list_view); String[] strs = getData(100); List<Map<String, Object>> list = new ArrayList<>(); for (String str : strs) { Map<String, Object> map = new HashMap<>(); map.put("text", str); list.add(map); } SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.item_simple, new String[]{"text"}, new int[]{R.id.text_view}); listView.setAdapter(adapter); AutoScrollHelper autoScrollHelper = new ListViewAutoScrollHelper(listView); listView.setOnTouchListener(autoScrollHelper); autoScrollHelper.setEnabled(true); // autoScrollHelper.setActivationDelay(3000); // autoScrollHelper.setRampDownDuration(3000); Toast.makeText(this, "长按上或下边缘", Toast.LENGTH_SHORT).show(); }
private void setScrollHelpers() { mScrollHelper = new ListBuddiesAutoScrollHelper(mListViewLeft) { @Override public void scrollTargetBy(int deltaX, int deltaY) { mListViewLeft.smoothScrollBy(mSpeedLeft, 0); mListViewRight.smoothScrollBy(mSpeedRight, 0); } @Override public boolean canTargetScrollHorizontally(int i) { return false; } @Override public boolean canTargetScrollVertically(int i) { return true; } }; mScrollHelper.setEnabled(isEnable()); mScrollHelper.setEdgeType(AutoScrollHelper.EDGE_TYPE_OUTSIDE); }
private void calculateMaxViewport() { float maxZ = Float.MIN_VALUE; this.tempMaximumViewport.set(AutoScrollHelper.NO_MAX, Float.MIN_VALUE, Float.MIN_VALUE, AutoScrollHelper.NO_MAX); BubbleChartData data = this.dataProvider.getBubbleChartData(); for (BubbleValue bubbleValue : data.getValues()) { if (Math.abs(bubbleValue.getZ()) > maxZ) { maxZ = Math.abs(bubbleValue.getZ()); } if (bubbleValue.getX() < this.tempMaximumViewport.left) { this.tempMaximumViewport.left = bubbleValue.getX(); } if (bubbleValue.getX() > this.tempMaximumViewport.right) { this.tempMaximumViewport.right = bubbleValue.getX(); } if (bubbleValue.getY() < this.tempMaximumViewport.bottom) { this.tempMaximumViewport.bottom = bubbleValue.getY(); } if (bubbleValue.getY() > this.tempMaximumViewport.top) { this.tempMaximumViewport.top = bubbleValue.getY(); } } this.maxRadius = (float) Math.sqrt(((double) maxZ) / 3.141592653589793d); this.bubbleScaleX = this.tempMaximumViewport.width() / (this.maxRadius * aj.hA); if (this.bubbleScaleX == 0.0f) { this.bubbleScaleX = 1.0f; } this.bubbleScaleY = this.tempMaximumViewport.height() / (this.maxRadius * aj.hA); if (this.bubbleScaleY == 0.0f) { this.bubbleScaleY = 1.0f; } this.bubbleScaleX *= data.getBubbleScale(); this.bubbleScaleY *= data.getBubbleScale(); this.tempMaximumViewport.inset((-this.maxRadius) * this.bubbleScaleX, (-this.maxRadius) * this.bubbleScaleY); this.minRawRadius = (float) ChartUtils.dp2px(this.density, this.dataProvider.getBubbleChartData().getMinBubbleRadius()); }
private void init() { recyclerView = (RecyclerView) findViewById(R.id.recyler_view); linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); staggeredGridLayoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL); recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setAdapter(new SimpleRecylerViewAdapter(this, getData(100))); AutoScrollHelper autoScrollHelper = new RecyclerViewAutoScrollHelper(recyclerView); autoScrollHelper.setEnabled(true); recyclerView.setOnTouchListener(autoScrollHelper); }
private void init() { scrollView = (ScrollView) findViewById(R.id.scroll_view); AutoScrollHelper autoScrollHelper = new ScrollViewAutoScrollHelper(scrollView); autoScrollHelper.setEnabled(true); scrollView.setOnTouchListener(autoScrollHelper); }