@Override public boolean onTouchEvent(MotionEvent event) { ((scouter) getContext()).hideKeyM(); boolean handled = super.onTouchEvent(event); requestFocus(); int ugh = 1; if (searched.size() == matches.size()) ugh = 0; float blah = getHeight() / (searched.size() + ugh); Log.v( "hello", "touched " + ((ScrollView) ((scouter) getContext()).findViewById(R.id.scrollView1)).getScrollY()); if (event.getAction() == MotionEvent.ACTION_DOWN) { rawY = event.getRawY(); y = event.getY(); int index = Math.round((y) / blah) - 1; ind = searched.get(index); } if (event.getAction() == MotionEvent.ACTION_MOVE) moving = true; if ((Math.abs(rawY - event.getRawY()) <= blah) && event.getAction() == MotionEvent.ACTION_UP) { moving = false; float y = event.getY(); int index = Math.round((y) / blah) - 1; Log.v("hello", searched.get(index) + " " + index); ind = searched.get(index); ((scouter) getContext()).viewMatch(searched.get(index)); } return handled; }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setStrokeWidth(0); paint.setTextSize(25); Rect bounds = new Rect(); float bottom = 0; paint.setARGB(255, 255, 255, 255); if (searched == null) return; for (Match m : searched) { float start = bottom; String s = "Match 216498464"; canvas.drawLine(5, bottom, getWidth() - 5, bottom, paint); paint.getTextBounds(s.toUpperCase(), 0, s.length(), bounds); paint.setARGB(255, 255, 255, 255); s = "Match " + m.getMatchNum(); canvas.drawText(s, 10, bottom + bounds.height() + 5, paint); bottom = bottom + bounds.height() + 10; s = "123654987"; paint.getTextBounds(s.toUpperCase(), 0, s.length(), bounds); paint.setARGB(255, 255, 0, 0); canvas.drawRoundRect( new RectF(getWidth() / 4 - 5, bottom, getWidth(), bottom + bounds.height() + 10), 6, 6, paint); paint.setARGB(255, 255, 255, 255); bottom = bottom + bounds.height() + 10; s = m.getRedTeam()[0].getNumber() + ""; canvas.drawText(s, getWidth() / 4, bottom - 5, paint); s = m.getRedTeam()[1].getNumber() + ""; canvas.drawText(s, getWidth() / 2, bottom - 5, paint); s = m.getRedTeam()[2].getNumber() + ""; canvas.drawText(s, getWidth() / 4 * 3, bottom - 5, paint); paint.setARGB(255, 0, 0, 255); canvas.drawRoundRect( new RectF(getWidth() / 4 - 5, bottom, getWidth(), bottom + bounds.height() + 10), 6, 6, paint); paint.setARGB(255, 255, 255, 255); bottom = bottom + bounds.height() + 10; canvas.drawText(s, getWidth() / 4, bottom - 5, paint); s = m.getBlueTeam()[0].getNumber() + ""; canvas.drawText(s, getWidth() / 2, bottom - 5, paint); s = m.getBlueTeam()[1].getNumber() + ""; canvas.drawText(s, getWidth() / 4 * 3, bottom - 5, paint); s = m.getBlueTeam()[2].getNumber() + ""; bottom += 5; } height = Math.round(bottom + 1); }