Skip to content

Commit

Permalink
refactor(main):refactor main code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCShou committed Oct 15, 2022
1 parent 6e94157 commit 676bddc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
11 changes: 5 additions & 6 deletions app/src/main/java/com/zcshou/gogogo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mOkHttpClient = new OkHttpClient();

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

Expand All @@ -195,11 +198,9 @@ protected void onCreate(Bundle savedInstanceState) {
drawer.addDrawerListener(toggle);
toggle.syncState();

XLog.i("MainActivity: onCreate");

sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
initNavigationView();

mOkHttpClient = new OkHttpClient();
XLog.i("MainActivity: onCreate");

//sqlite相关
initStoreHistory();
Expand All @@ -211,8 +212,6 @@ protected void onCreate(Bundle savedInstanceState) {
// 地图上按键的监听
initListenerMapBtn();

initNavigationView();

initSearchView();

setGoBtnListener();
Expand Down
18 changes: 10 additions & 8 deletions app/src/main/res/layout/content_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,22 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:minHeight="48dp"
android:text="@string/map_pic_normal" />

<RadioButton
android:id="@+id/mapSatellite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:minHeight="48dp"
android:text="@string/map_pic_sate" />
</RadioGroup>

<ImageButton
android:id="@+id/cur_position"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="350dp"
android:layout_marginEnd="10dp"
Expand All @@ -60,8 +62,8 @@

<ImageButton
android:id="@+id/zoom_in"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="383dp"
android:layout_marginEnd="10dp"
Expand All @@ -73,8 +75,8 @@

<ImageButton
android:id="@+id/zoom_out"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="416dp"
android:layout_marginEnd="10dp"
Expand All @@ -86,8 +88,8 @@

<ImageButton
android:id="@+id/input_pos"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_marginTop="240dp"
android:layout_marginEnd="10dp"
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/layout/input_position.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
android:id="@+id/joystick_longitude"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:autofillHints="longitude"
android:hint="@string/label_longitude"
android:inputType="numberDecimal" />
android:inputType="numberDecimal"
android:minHeight="48dp" />

<EditText
android:id="@+id/joystick_latitude"
Expand All @@ -23,7 +24,8 @@
android:layout_marginEnd="8dp"
android:autofillHints="latitude"
android:hint="@string/label_latitude"
android:inputType="numberDecimal" />
android:inputType="numberDecimal"
android:minHeight="48dp" />

<RadioGroup
android:id="@+id/RadioGroupMapType"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<string name="app_error_protocol">请先阅读并接收用户协议</string>
<string name="app_error_username">用户名不合法</string>
<string name="app_error_code">注册码不能为空</string>
<string name="app_error_longitude">纬度超出限制!\n取值:-180.0 ~ 180.0</string>
<string name="app_error_longitude">经度超出限制!\n取值:-180.0 ~ 180.0</string>
<string name="app_error_latitude">纬度超出限制!\n取值:-90.0 ~ 90.0</string>
<string name="app_search_null">没有匹配结果,请重新搜索</string>
<string name="app_location_ok">位置已传送</string>
Expand Down

0 comments on commit 676bddc

Please sign in to comment.