Created
December 20, 2022 05:57
-
-
Save ChuuMong/014bcba724e7d79c28384a2b28614dcc to your computer and use it in GitHub Desktop.
select_image_position.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cursor c = null; | |
| SubwayDatabaseHelper myDbHelper = new SubwayDatabaseHelper(MainActivity.this); // Reading SQLite database. | |
| try { | |
| myDbHelper.createDataBase(); | |
| } catch (IOException ioe) { | |
| throw new Error("Unable to create database"); | |
| } | |
| try { | |
| myDbHelper.openDataBase(); | |
| } catch (SQLException sqle) { | |
| throw sqle; | |
| } | |
| c = myDbHelper.query("subwayData", null, null, null, null, null, null); // SQLDataRead | |
| final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) findViewById(R.id.subwayMap); // 지하철역 이미지뷰 | |
| //Refer to ID value. | |
| final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { // gesture 디텍팅으로 지하철 위치 읽기 | |
| @Override | |
| public boolean onSingleTapUp(MotionEvent ev) { | |
| if (imageView.isReady()) { | |
| PointF sCoord = imageView.viewToSourceCoord(ev.getX(), ev.getY()); | |
| int x_cor = (int) sCoord.x; | |
| int y_cor = (int) sCoord.y; | |
| // Loop for finding the station. | |
| if (c.moveToFirst()) { | |
| do { | |
| if ((x_cor > c.getInt(2)) && (x_cor < c.getInt(4)) && (y_cor > c.getInt(3)) && (y_cor < c.getInt(5))) { | |
| String targetStation = c.getString(1)); // 유저가 클릭한 지하철역 | |
| } // send Station Name (column 1) | |
| } while (c.moveToNext()); | |
| } | |
| } | |
| return super.onSingleTapUp(ev); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment