-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.java
More file actions
147 lines (115 loc) · 4.84 KB
/
Input.java
File metadata and controls
147 lines (115 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package com.example.hodu_navigation;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import org.json.JSONException;
import org.json.JSONObject;
// w 평일, a 토요일, u 일요일
// hh시 mm분
import com.github.chrisbanes.photoview.PhotoView;
//https://github.com/chrisbanes/PhotoView 라이브러리 가져와서씀
public class Input extends AppCompatActivity {
static String departure_text;
static String arrival_text;
static String formattedNow; //시간
static String week; //요일
String text;
static int count =0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.input);
EditText departure=(EditText) findViewById(R.id.Edit1);// 출발역 입력칸
EditText arrival=(EditText) findViewById(R.id.Edit2); // 도착역 입력칸
Intent intent = getIntent();
intent = getIntent();
text= intent.getStringExtra("selected_item"); //search 액티비티에서 역이름 받아오기
if(count==1) { //출발역
departure_text = text;
departure.setText(departure_text);
count = 0;
arrival.setText(arrival_text);
}
else if(count==2){ //도착역
departure.setText(departure_text);
arrival_text = text;
arrival.setText(arrival_text);
count = 0;
}
////////////////////////////////////////////////////////////////////////////////
// 이미지 줌인 줌 아웃
PhotoView photoView = findViewById(R.id.photoView);
photoView.setImageResource(R.drawable.map2);
// 출발역 텍스트박스 클릭시 액티비티 전환
departure.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
count=1;
Intent intent = new Intent(getApplicationContext(), Search.class); //search 액티비티로 전환
startActivity(intent);
}
});
// 도착역 텍스트박스 클릭시 액티비티 전환
arrival.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
count=2;
Intent intent = new Intent(getApplicationContext(), Search.class); //search 액티비티로 전환
startActivity(intent);
}
});
//검색 버튼 클릭시 액티비티 전환
ImageButton search_button=(ImageButton) findViewById(R.id.button1);
search_button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
//버튼 클릭하면 현재시간, 요일 구함
// 시간
Date now = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("HH시 mm분");
formattedNow = formatter.format(now);
//요일
Date currentDate = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
int e = calendar.get(Calendar.DAY_OF_WEEK);
//요일
if (e == 2 || e == 3 || e == 4 || e == 5 || e == 6)
week = "w";
else if (e == 7)
week = "a";
else week = "u";
Log.d("출발역","출발역: "+departure_text);
Log.d("도착역","도착역: "+arrival_text);
Log.d("현재시간날짜","now: "+ formattedNow);
Log.d("현재시간날짜","요일: "+week);
//////////////////////json 파싱/////////////////////////////////
/* ArrayList List =new ArrayList();
List.add(0,departure_text);
List.add(1,arrival_text);
List.add(2, formattedNow);
List.add(3,week);*/
JSONObject obj =new JSONObject();
try {
obj.put("departure",departure_text);
obj.put("arrival",arrival_text);
obj.put("now",formattedNow);
obj.put("week",week);
Log.d("json확인","확인: "+obj.toString());
} catch (JSONException ex) {
ex.printStackTrace();
}
Intent intent = new Intent(getApplicationContext(), RouteTime.class);
startActivity(intent);
}
});
}
}