From 3a161aeef6dfe08aa80fca6fb2c1650ebdd31d59 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期四, 01 二月 2024 15:29:19 +0800
Subject: [PATCH] 天气相关
---
app/src/main/java/com/dayu/pipirrapp/bean/WeatherResponse.java | 249 +++++++++++
app/src/main/res/mipmap-xhdpi/weather_24.png | 0
app/src/main/java/com/dayu/pipirrapp/fragment/MyFragment.java | 16
app/src/main/res/mipmap-xhdpi/weather_6.png | 0
app/src/main/java/com/dayu/pipirrapp/fragment/MainFragment.java | 108 +++++
app/src/main/res/mipmap-xhdpi/weather_33.png | 0
app/src/main/res/mipmap-xhdpi/weather_5.png | 0
app/src/main/res/mipmap-xhdpi/weather_16.png | 0
app/src/main/res/mipmap-xhdpi/weather_7.png | 0
app/src/main/res/mipmap-xhdpi/weather_31.png | 0
app/src/main/res/mipmap-xhdpi/weather_25.png | 0
app/src/main/res/mipmap-xhdpi/weather_34.png | 0
app/src/main/java/com/dayu/pipirrapp/bean/LatLonBean.java | 28 +
app/src/main/res/mipmap-xhdpi/weather_26.png | 0
app/build.gradle | 3
app/src/main/java/com/dayu/pipirrapp/view/TitleBar.java | 367 +++++++----------
app/src/main/res/mipmap-xhdpi/weather_17.png | 0
app/src/main/res/values/dimens.xml | 1
app/src/main/res/mipmap-xhdpi/weather_30.png | 0
app/src/main/res/values/strings.xml | 2
app/src/main/res/layout/activity_change_pass_word.xml | 24
app/src/main/res/mipmap-xhdpi/weather_35.png | 0
app/src/main/res/mipmap-xhdpi/weather_22.png | 0
app/src/main/res/mipmap-xhdpi/weather_8.png | 0
app/src/main/res/mipmap-xhdpi/weather_18.png | 0
app/src/main/res/drawable/bg_fillet_blue.xml | 8
app/src/main/res/mipmap-xhdpi/weather_10.png | 0
app/src/main/res/mipmap-xhdpi/weather_23.png | 0
app/src/main/res/mipmap-xhdpi/weather_9.png | 0
app/src/main/res/mipmap-xhdpi/weather_36.png | 0
app/src/main/res/mipmap-xhdpi/weather_0.png | 0
app/src/main/java/com/dayu/pipirrapp/net/ApiService.java | 8
app/src/main/res/mipmap-xhdpi/weather_19.png | 0
app/src/main/res/mipmap-xhdpi/weather_1.png | 0
app/src/main/res/mipmap-xhdpi/weather_29.png | 0
app/src/main/res/mipmap-xhdpi/weather_11.png | 0
app/src/main/res/values/styles.xml | 10
app/src/main/res/mipmap-xhdpi/weather_37.png | 0
app/src/main/java/com/dayu/pipirrapp/MyApplication.java | 4
app/src/main/java/com/dayu/pipirrapp/activity/ChangePSActivity.java | 27 +
app/src/main/res/drawable/vector_arrows_left_white.xml | 16
app/src/main/res/mipmap-xhdpi/weather_2.png | 0
app/src/main/res/mipmap-xhdpi/weather_12.png | 0
app/src/main/res/layout/fragment_main.xml | 80 +++
app/src/main/res/mipmap-xhdpi/weather_38.png | 0
app/src/main/res/mipmap-xhdpi/weather_21.png | 0
app/src/main/res/mipmap-xhdpi/weather_99.png | 0
app/src/main/res/mipmap-xhdpi/weather_13.png | 0
app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java | 24 +
app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java | 49 +
app/src/main/AndroidManifest.xml | 6
app/src/main/java/com/dayu/pipirrapp/utils/ImageUtils.java | 103 ++++
app/src/main/res/mipmap-xhdpi/weather_14.png | 0
app/src/main/res/mipmap-xhdpi/weather_27.png | 0
app/src/main/res/mipmap-xhdpi/weather_3.png | 0
app/src/main/java/com/dayu/pipirrapp/activity/LoginActivity.java | 1
app/src/main/res/mipmap-xhdpi/weather_20.png | 0
app/src/main/res/mipmap-xhdpi/weather_15.png | 0
app/src/main/res/layout/fragment_my.xml | 11
app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java | 2
app/src/main/res/mipmap-xhdpi/weather_32.png | 0
app/src/main/res/mipmap-xhdpi/weather_4.png | 0
app/src/main/res/mipmap-xhdpi/weather_28.png | 0
app/src/main/res/layout/top_title.xml | 55 ++
64 files changed, 932 insertions(+), 270 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 25c2156..fb73009 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -148,5 +148,6 @@
//鍦嗗舰澶村儚
implementation 'de.hdodenhof:circleimageview:3.1.0'
-
+ //骞挎挱閫氫俊
+ implementation 'io.github.jeremyliao:live-event-bus-x:1.8.0'
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b3716e8..18f83ca 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -33,16 +33,17 @@
<application
+ android:name=".MyApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
+ android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.PipIrrApp"
android:usesCleartextTraffic="true"
- android:hardwareAccelerated="true"
tools:targetApi="31">
<!-- 鍛婄煡 XXPermissions 褰撳墠椤圭洰宸茬粡閫傞厤浜嗗垎鍖哄瓨鍌ㄧ壒鎬� -->
<meta-data
@@ -58,7 +59,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-<!-- <activity android:name=".activity.MainActivity" />-->
+ <activity android:name=".activity.ChangePSActivity" />
+ <!-- <activity android:name=".activity.MainActivity" />-->
<!-- Required since 5.2.0 -->
<!-- 鏂扮殑 tag/alias 鎺ュ彛缁撴灉杩斿洖闇�瑕佸紑鍙戣�呴厤缃竴涓嚜瀹氫箟鐨凷ervice -->
<!-- 3.3.0寮�濮嬫墍鏈変簨浠跺皢閫氳繃璇ョ被鍥炶皟 -->
diff --git a/app/src/main/java/com/dayu/pipirrapp/MyApplication.java b/app/src/main/java/com/dayu/pipirrapp/MyApplication.java
index 8fc0407..6beaa1c 100644
--- a/app/src/main/java/com/dayu/pipirrapp/MyApplication.java
+++ b/app/src/main/java/com/dayu/pipirrapp/MyApplication.java
@@ -2,6 +2,7 @@
import android.app.Application;
+import com.dayu.pipirrapp.net.ApiManager;
import com.tencent.bugly.crashreport.CrashReport;
import cn.jpush.android.api.JPushInterface;
@@ -19,6 +20,9 @@
public void onCreate() {
super.onCreate();
myApplication = this;
+
+ ApiManager.init();
+
JPushInterface.setDebugMode(true);
JPushInterface.init(this);
CrashReport.initCrashReport(getApplicationContext(), "3d4bcf7046", false);
diff --git a/app/src/main/java/com/dayu/pipirrapp/activity/ChangePSActivity.java b/app/src/main/java/com/dayu/pipirrapp/activity/ChangePSActivity.java
new file mode 100644
index 0000000..c847219
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/activity/ChangePSActivity.java
@@ -0,0 +1,27 @@
+package com.dayu.pipirrapp.activity;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+
+import androidx.annotation.Nullable;
+
+import com.dayu.pipirrapp.databinding.ActivityChangePassWordBinding;
+import com.dayu.pipirrapp.view.TitleBar;
+
+/**
+ * author: zuo
+ * Date: 2024-01-29
+ * Time: 17:19
+ * 澶囨敞锛氫慨鏀瑰瘑鐮�
+ */
+public class ChangePSActivity extends BaseActivity {
+ ActivityChangePassWordBinding binding;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ binding = ActivityChangePassWordBinding.inflate(LayoutInflater.from(this));
+ new TitleBar(this).setTitleText("淇敼瀵嗙爜");
+ setContentView(binding.getRoot());
+ }
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/activity/LoginActivity.java b/app/src/main/java/com/dayu/pipirrapp/activity/LoginActivity.java
index 41a44b6..b5f543c 100644
--- a/app/src/main/java/com/dayu/pipirrapp/activity/LoginActivity.java
+++ b/app/src/main/java/com/dayu/pipirrapp/activity/LoginActivity.java
@@ -43,6 +43,7 @@
startActivity(intent);
this.finish();
});
+
}
private void togglePasswordVisibility() {
diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/LatLonBean.java b/app/src/main/java/com/dayu/pipirrapp/bean/LatLonBean.java
new file mode 100644
index 0000000..6631c27
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/bean/LatLonBean.java
@@ -0,0 +1,28 @@
+package com.dayu.pipirrapp.bean;
+
+/**
+ * author: zuo
+ * Date: 2024-01-26
+ * Time: 16:15
+ * 澶囨敞锛氱粡绾害
+ */
+public class LatLonBean {
+ double latitude;
+ double longitude;
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/WeatherResponse.java b/app/src/main/java/com/dayu/pipirrapp/bean/WeatherResponse.java
new file mode 100644
index 0000000..f85d944
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/bean/WeatherResponse.java
@@ -0,0 +1,249 @@
+package com.dayu.pipirrapp.bean;
+
+/**
+ * author: zuo
+ * Date: 2024-01-26
+ * Time: 10:23
+ * 澶囨敞锛氬ぉ姘旀帴鍙h繑鍥炵殑瀹炰緥
+ */
+public class WeatherResponse {
+
+
+ private Result[] results;
+
+ private String date;
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ public Result[] getResults() {
+ return results;
+ }
+
+ public void setResults(Result[] value) {
+ this.results = value;
+ }
+
+
+ public class Result {
+ public Daily[] daily; //杩斿洖鎸囧畾days澶╂暟鐨勭粨鏋�
+ public String last_update;
+ public Location location;
+
+ public Daily[] getDaily() {
+ return daily;
+ }
+
+ public void setDaily(Daily[] value) {
+ this.daily = value;
+ }
+
+ public String getLast_update() {
+ return last_update;
+ }
+
+ public void setLast_update(String last_update) {
+ this.last_update = last_update;
+ }
+
+ public Location getLocation() {
+ return location;
+ }
+
+ public void setLocation(Location value) {
+ this.location = value;
+ }
+
+ }
+
+ public class Daily {
+ private String code_day; //鐧藉ぉ澶╂皵鐜拌薄浠g爜
+ private String code_night;//鏅氶棿澶╂皵鐜拌薄浠g爜
+ private String date;//鏃ユ湡锛堣鍩庡競鐨勬湰鍦版椂闂达級
+ private String high;//褰撳ぉ鏈�楂樻俯搴�
+ private String humidity; //鐩稿婀垮害锛�0~100锛屽崟浣嶄负鐧惧垎姣�
+ private String low;//褰撳ぉ鏈�浣庢俯搴�
+ private String precip;//闄嶆按姒傜巼锛岃寖鍥�0~1锛屽崟浣嶇櫨鍒嗘瘮锛堢洰鍓嶄粎鏀寔鍥藉鍩庡競锛�
+ private String rainfall; //闄嶆按閲忥紝鍗曚綅mm
+ private String text_day; //鐧藉ぉ澶╂皵鐜拌薄鏂囧瓧
+ private String text_night;//鏅氶棿澶╂皵鐜拌薄鏂囧瓧
+ private String wind_direction;//椋庡悜鏂囧瓧
+ private String wind_direction_degree;//椋庡悜瑙掑害锛岃寖鍥�0~360
+ private String wind_scale;//椋庡姏绛夌骇
+ private String wind_speed;//椋庨�燂紝鍗曚綅km/h锛堝綋unit=c鏃讹級銆乵ph锛堝綋unit=f鏃讹級
+
+ public String getCode_day() {
+ return code_day;
+ }
+
+ public void setCode_day(String code_day) {
+ this.code_day = code_day;
+ }
+
+ public String getCode_night() {
+ return code_night;
+ }
+
+ public void setCode_night(String code_night) {
+ this.code_night = code_night;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ public String getHigh() {
+ return high;
+ }
+
+ public void setHigh(String high) {
+ this.high = high;
+ }
+
+ public String getHumidity() {
+ return humidity;
+ }
+
+ public void setHumidity(String humidity) {
+ this.humidity = humidity;
+ }
+
+ public String getLow() {
+ return low;
+ }
+
+ public void setLow(String low) {
+ this.low = low;
+ }
+
+ public String getPrecip() {
+ return precip;
+ }
+
+ public void setPrecip(String precip) {
+ this.precip = precip;
+ }
+
+ public String getRainfall() {
+ return rainfall;
+ }
+
+ public void setRainfall(String rainfall) {
+ this.rainfall = rainfall;
+ }
+
+ public String getText_day() {
+ return text_day;
+ }
+
+ public void setText_day(String text_day) {
+ this.text_day = text_day;
+ }
+
+ public String getText_night() {
+ return text_night;
+ }
+
+ public void setText_night(String text_night) {
+ this.text_night = text_night;
+ }
+
+ public String getWind_direction() {
+ return wind_direction;
+ }
+
+ public void setWind_direction(String wind_direction) {
+ this.wind_direction = wind_direction;
+ }
+
+ public String getWind_direction_degree() {
+ return wind_direction_degree;
+ }
+
+ public void setWind_direction_degree(String wind_direction_degree) {
+ this.wind_direction_degree = wind_direction_degree;
+ }
+
+ public String getWind_scale() {
+ return wind_scale;
+ }
+
+ public void setWind_scale(String wind_scale) {
+ this.wind_scale = wind_scale;
+ }
+
+ public String getWind_speed() {
+ return wind_speed;
+ }
+
+ public void setWind_speed(String wind_speed) {
+ this.wind_speed = wind_speed;
+ }
+ }
+
+ public class Location {
+ private String country;
+ private String id;
+ private String name;
+ private String path;
+ private String timezone;
+ private String timezoneOffset;
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String value) {
+ this.country = value;
+ }
+
+ public String getid() {
+ return id;
+ }
+
+ public void setid(String value) {
+ this.id = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String value) {
+ this.path = value;
+ }
+
+ public String getTimezone() {
+ return timezone;
+ }
+
+ public void setTimezone(String value) {
+ this.timezone = value;
+ }
+
+ public String getTimezoneOffset() {
+ return timezoneOffset;
+ }
+
+ public void setTimezoneOffset(String value) {
+ this.timezoneOffset = value;
+ }
+ }
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/fragment/MainFragment.java b/app/src/main/java/com/dayu/pipirrapp/fragment/MainFragment.java
index c1d0285..9ebd68f 100644
--- a/app/src/main/java/com/dayu/pipirrapp/fragment/MainFragment.java
+++ b/app/src/main/java/com/dayu/pipirrapp/fragment/MainFragment.java
@@ -1,15 +1,121 @@
package com.dayu.pipirrapp.fragment;
+import android.os.Bundle;
+import android.os.Looper;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.lifecycle.Observer;
+
+import com.dayu.pipirrapp.bean.LatLonBean;
+import com.dayu.pipirrapp.bean.WeatherResponse;
+import com.dayu.pipirrapp.databinding.FragmentMainBinding;
+import com.dayu.pipirrapp.net.ApiManager;
+import com.dayu.pipirrapp.utils.ImageUtils;
+import com.dayu.pipirrapp.utils.MyJsonParser;
+import com.dayu.pipirrapp.utils.SharedPreferencesHelper;
+import com.jeremyliao.liveeventbus.LiveEventBus;
+import com.tencent.bugly.crashreport.CrashReport;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+
/**
* author: zuo
* Date: 2023/12/20
* Time: 10:12
* 澶囨敞锛氶椤�
*/
-public class MainFragment extends BaseFragment{
+public class MainFragment extends BaseFragment {
+
+ FragmentMainBinding binding;
+ WeatherResponse weatherResponse;
+ //鏀跺埌瀹氫綅骞挎挱鍚庤幏鍙栧ぉ姘斾俊鎭�
+ Observer<LatLonBean> myObserver = new Observer<LatLonBean>() {
+ @Override
+ public void onChanged(LatLonBean latLonBean) {
+
+ String jsonStr = SharedPreferencesHelper.getInstance(MainFragment.this.getActivity()).get("WeatherResponse", "");
+ weatherResponse = MyJsonParser.getBeanFromJson(jsonStr, WeatherResponse.class);
+ if (weatherResponse == null) {
+ weatherResponse = new WeatherResponse();
+ }
+ // 鑾峰彇褰撳墠鏃堕棿
+ Calendar calendar = Calendar.getInstance();
+ // 鑾峰彇褰撳墠骞存湀鏃�
+ int year = calendar.get(Calendar.YEAR);
+ int month = calendar.get(Calendar.MONTH) + 1; // 娉ㄦ剰鏈堜唤鏄粠0寮�濮嬭鏁扮殑锛屾墍浠ヨ鍔�1
+ int day = calendar.get(Calendar.DAY_OF_MONTH);
+ String date = year + "骞�" + month + "鏈�" + day + "鏃�";
+ if (weatherResponse == null || !date.equals(weatherResponse.getDate())) {
+ weatherResponse.setDate(date);
+ ApiManager.getInstance().requestWeather(latLonBean.getLatitude() + ":" + latLonBean.getLongitude(), new Callback<WeatherResponse>() {
+ @Override
+ public void onResponse(Call<WeatherResponse> call, Response<WeatherResponse> response) {
+
+ if (response.isSuccessful()) {
+ weatherResponse.setResults(response.body().getResults());
+ SharedPreferencesHelper.getInstance(MainFragment.this.getActivity()).put("WeatherResponse", weatherResponse);
+ setWeatherData(weatherResponse);
+ }
+ }
+
+ @Override
+ public void onFailure(Call<WeatherResponse> call, Throwable t) {
+
+ }
+ });
+ } else {
+ setWeatherData(weatherResponse);
+ }
+ LiveEventBus.get("location", LatLonBean.class).removeObserver(myObserver);
+ }
+ };
+ /**
+ * 璁剧疆澶╂皵鐩稿叧淇℃伅
+ *
+ * @param data
+ */
+ private void setWeatherData(WeatherResponse data) {
+ try {
+ if (data.getResults() != null) {
+ binding.cityName.setText(data.getResults()[0].getLocation().getName());
+ binding.time.setText(data.getDate());
+ int weatherImg = ImageUtils.getWeatherDrawable(data.getResults()[0].getDaily()[0].getCode_day());
+ if (weatherImg != 0) {
+ binding.weatherImg.setImageDrawable(getResources().getDrawable(weatherImg));
+ }
+ binding.weatherName.setText(data.getResults()[0].getDaily()[0].getText_day());
+ binding.weatherTemperature.setText(data.getResults()[0].getDaily()[0].getLow() + "掳C 锝� " + data.getResults()[0].getDaily()[0].getHigh() + "掳C");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ CrashReport.postCatchedException(e);
+ }
+ }
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ binding = FragmentMainBinding.inflate(inflater, container, false);
+
+
+ //鑾峰彇鍒扮粡绾害鍚庤幏鍙栧ぉ姘斾俊鎭�
+ LiveEventBus
+ .get("location", LatLonBean.class)
+ .observeForever(myObserver);
+
+ return binding.getRoot();
+ }
+
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
index 0a5592d..6c07ea7 100644
--- a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
+++ b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
@@ -24,6 +24,7 @@
import com.dayu.pipirrapp.js.MyWebViewInterface;
import com.dayu.pipirrapp.observer.MapFragmenObserver;
import com.dayu.pipirrapp.service.MyLocationService;
+import com.dayu.pipirrapp.utils.MyLog;
import com.dayu.pipirrapp.utils.ToastUtil;
import java.util.List;
@@ -150,6 +151,7 @@
public void showWaterIntakeDetail(String data){
+ MyLog.i(data);
binding.bottomLL.setVisibility(View.VISIBLE);
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/fragment/MyFragment.java b/app/src/main/java/com/dayu/pipirrapp/fragment/MyFragment.java
index a906b1f..a0b8102 100644
--- a/app/src/main/java/com/dayu/pipirrapp/fragment/MyFragment.java
+++ b/app/src/main/java/com/dayu/pipirrapp/fragment/MyFragment.java
@@ -1,5 +1,6 @@
package com.dayu.pipirrapp.fragment;
+import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -8,8 +9,10 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import com.dayu.pipirrapp.activity.ChangePSActivity;
import com.dayu.pipirrapp.databinding.FragmentMapBinding;
import com.dayu.pipirrapp.databinding.FragmentMyBinding;
+import com.dayu.pipirrapp.view.TitleBar;
/**
* author: zuo
@@ -24,11 +27,20 @@
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = FragmentMyBinding.inflate(inflater, container, false);
+ initView();
return binding.getRoot();
}
-
-
+ private void initView() {
+ new TitleBar(this.getActivity()).setTitleText("鎴戠殑");
+ binding.changePS.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(MyFragment.this.getContext(), ChangePSActivity.class);
+ MyFragment.this.getActivity().startActivity(intent);
+ }
+ });
+ }
}
diff --git a/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java b/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
index e1e46c2..186cf43 100644
--- a/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
+++ b/app/src/main/java/com/dayu/pipirrapp/net/ApiManager.java
@@ -3,6 +3,7 @@
import android.content.Context;
+import com.dayu.pipirrapp.bean.WeatherResponse;
import com.dayu.pipirrapp.net.subscribers.BaseProgressSubscriber;
import com.dayu.pipirrapp.net.subscribers.ProgressSubscriber;
import com.dayu.pipirrapp.net.subscribers.SubscriberListener;
@@ -13,6 +14,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -47,6 +49,9 @@
ApiService apiService;
+ /**
+ * 鍒濆鍖栭�氫俊妗嗘灦
+ */
public static void init() {
if (apiManager == null) {
apiManager = new ApiManager();
@@ -152,4 +157,23 @@
}
+
+ /**
+ * 鑾峰彇澶╂皵
+ * @param data 缁忕含搴︼紙鏍煎紡鏄� 绾害:缁忓害锛岃嫳鏂囧啋鍙峰垎闅旓級
+ * @param callback
+ * @param <T>
+ */
+ public <T> void requestWeather(String data,Callback<WeatherResponse> callback) {
+ Map<String, Object> params = new HashMap<>();
+ params.put("key", "S6Tq4pvOakMuWRrg0");
+ params.put("location", data);
+ params.put("language", "zh-Hans");
+ params.put("unit", "c");
+ params.put("days", "3");
+ Call<WeatherResponse> call = apiService.requestWeather("https://api.seniverse.com/v3/weather/daily.json", params);
+ call.enqueue(callback);
+ }
+
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/dayu/pipirrapp/net/ApiService.java b/app/src/main/java/com/dayu/pipirrapp/net/ApiService.java
index 3f7e4df..5c29ff7 100644
--- a/app/src/main/java/com/dayu/pipirrapp/net/ApiService.java
+++ b/app/src/main/java/com/dayu/pipirrapp/net/ApiService.java
@@ -2,7 +2,8 @@
-import java.util.List;
+import com.dayu.pipirrapp.bean.WeatherResponse;
+
import java.util.Map;
import io.reactivex.rxjava3.core.Observable;
@@ -30,6 +31,11 @@
public interface ApiService {
+ //鑾峰彇澶╂皵
+ @GET()
+ Call<WeatherResponse> requestWeather(@Url String url, @QueryMap Map<String, Object> params);
+
+
// @FormUrlEncoded
@POST()
Observable<BaseResponse> requestPost(@Url String url, @Body Map<String, Object> params);
diff --git a/app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java b/app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java
index 61a4cf3..7eb9e0e 100644
--- a/app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java
+++ b/app/src/main/java/com/dayu/pipirrapp/service/MyLocationService.java
@@ -21,7 +21,9 @@
import com.baidu.location.LocationClientOption;
import com.dayu.pipirrapp.R;
import com.dayu.pipirrapp.activity.MainActivity;
+import com.dayu.pipirrapp.bean.LatLonBean;
import com.dayu.pipirrapp.utils.MyLog;
+import com.jeremyliao.liveeventbus.LiveEventBus;
import com.tencent.bugly.crashreport.CrashReport;
/**
@@ -41,7 +43,10 @@
/**
* 鏄惁涓�娆℃�у畾浣�
*/
- boolean isSingle;
+ boolean isSingle = false;
+
+ // 鏄惁宸茬粡瀹氫綅
+ boolean isPositioned = false;
@Nullable
@Override
@@ -82,16 +87,9 @@
super.onCreate();
createNativeLocation();
-// createBDLocation();
+ createBDLocation();
}
-// /**
-// * @param isSingle 鏄惁鏄崟娆″畾浣�
-// */
-// public MyLocationService(boolean isSingle) {
-// this.isSingle = isSingle;
-//
-// }
/**
* 鍘熺敓鐨勫畾浣嶆湇鍔�
@@ -176,6 +174,7 @@
String longitude = "Longitude:" + location.getLongitude();
String latitude = "Latitude:" + location.getLatitude();
MyLog.i("鍘熺敓瀹氫綅onLocationChanged: Latitude锛�" + latitude + " Longitude锛�" + longitude);
+ postPosition(location.getLatitude(), location.getLongitude());
// 鏄惁涓�娆℃�у畾浣�
if (isSingle) {
stopSelf(); // 鑾峰彇鍒扮粡绾害浠ュ悗锛屽仠姝㈣service
@@ -206,22 +205,42 @@
* 鐧惧害瀹氫綅鐨勭洃鍚�
*/
class MyBDLocationListener extends BDAbstractLocationListener {
-
@Override
public void onReceiveLocation(BDLocation location) {
-
double latitude = location.getLatitude(); //鑾峰彇绾害淇℃伅
double longitude = location.getLongitude(); //鑾峰彇缁忓害淇℃伅
// MyLog.i("鐧惧害鐨勭洃鍚� latitude锛�" + latitude);
// MyLog.i("鐧惧害鐨勭洃鍚� longitude锛�" + longitude);
MyLog.i("鐧惧害鐨勭洃鍚� onBaiduLocationChanged: latitude锛�" + latitude + " longitude锛�" + longitude);
- if (isSingle) {
- stopSelf(); // 鑾峰彇鍒扮粡绾害浠ュ悗锛屽仠姝㈣service
- }
- }
+
+ if (!String.valueOf(latitude).equals("4.9E-324")) {
+ //涓嶄负4.9E-324鏃舵墠鏄畾浣嶆垚鍔�
+ postPosition(latitude, longitude);
+ if (isSingle) {
+ stopSelf(); // 鑾峰彇鍒扮粡绾害浠ュ悗锛屽仠姝㈣service
+ }
+ }
+
+ }
}
+
+ /**
+ * @param latitude
+ * @param longitude
+ */
+ private void postPosition(double latitude, double longitude) {
+ if (isSingle && isPositioned) {
+ return;
+ }
+ LatLonBean latLonBean = new LatLonBean();
+ latLonBean.setLatitude(latitude);
+ latLonBean.setLongitude(longitude);
+ LiveEventBus.get("location").post(latLonBean);
+ }
+
+
@Override
public void onDestroy() {
MyLog.i("MyLocationService--onDestroy");
diff --git a/app/src/main/java/com/dayu/pipirrapp/utils/ImageUtils.java b/app/src/main/java/com/dayu/pipirrapp/utils/ImageUtils.java
new file mode 100644
index 0000000..42a6b64
--- /dev/null
+++ b/app/src/main/java/com/dayu/pipirrapp/utils/ImageUtils.java
@@ -0,0 +1,103 @@
+package com.dayu.pipirrapp.utils;
+
+import android.graphics.drawable.Drawable;
+
+import com.dayu.pipirrapp.R;
+
+/**
+ * author: zuo
+ * Date: 2024-01-29
+ * Time: 15:52
+ * 澶囨敞锛�
+ */
+public class ImageUtils {
+
+
+ public static int getWeatherDrawable(String imgName) {
+
+ switch (imgName) {
+ case "0":
+ return R.mipmap.weather_0;
+ case "1":
+ return R.mipmap.weather_1;
+ case "2":
+ return R.mipmap.weather_2;
+ case "3":
+ return R.mipmap.weather_3;
+ case "4":
+ return R.mipmap.weather_4;
+ case "5":
+ return R.mipmap.weather_5;
+ case "6":
+ return R.mipmap.weather_6;
+ case "7":
+ return R.mipmap.weather_7;
+ case "8":
+ return R.mipmap.weather_8;
+ case "9":
+ return R.mipmap.weather_9;
+ case "10":
+ return R.mipmap.weather_10;
+ case "11":
+ return R.mipmap.weather_11;
+ case "12":
+ return R.mipmap.weather_12;
+ case "13":
+ return R.mipmap.weather_13;
+ case "14":
+ return R.mipmap.weather_14;
+ case "15":
+ return R.mipmap.weather_15;
+ case "16":
+ return R.mipmap.weather_16;
+ case "17":
+ return R.mipmap.weather_17;
+ case "18":
+ return R.mipmap.weather_18;
+ case "19":
+ return R.mipmap.weather_19;
+ case "20":
+ return R.mipmap.weather_20;
+ case "21":
+ return R.mipmap.weather_21;
+ case "22":
+ return R.mipmap.weather_22;
+ case "23":
+ return R.mipmap.weather_23;
+ case "24":
+ return R.mipmap.weather_24;
+ case "25":
+ return R.mipmap.weather_25;
+ case "26":
+ return R.mipmap.weather_26;
+ case "27":
+ return R.mipmap.weather_27;
+ case "28":
+ return R.mipmap.weather_28;
+ case "29":
+ return R.mipmap.weather_29;
+ case "30":
+ return R.mipmap.weather_30;
+ case "31":
+ return R.mipmap.weather_31;
+ case "32":
+ return R.mipmap.weather_32;
+ case "33":
+ return R.mipmap.weather_33;
+ case "34":
+ return R.mipmap.weather_34;
+ case "35":
+ return R.mipmap.weather_35;
+ case "36":
+ return R.mipmap.weather_36;
+ case "37":
+ return R.mipmap.weather_37;
+ case "38":
+ return R.mipmap.weather_38;
+ case "99":
+ return R.mipmap.weather_99;
+ }
+ return 0;
+ }
+
+}
diff --git a/app/src/main/java/com/dayu/pipirrapp/view/TitleBar.java b/app/src/main/java/com/dayu/pipirrapp/view/TitleBar.java
index 0771c04..3422266 100644
--- a/app/src/main/java/com/dayu/pipirrapp/view/TitleBar.java
+++ b/app/src/main/java/com/dayu/pipirrapp/view/TitleBar.java
@@ -3,14 +3,18 @@
*/
package com.dayu.pipirrapp.view;
+import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import com.dayu.pipirrapp.R;
@@ -22,248 +26,177 @@
* @author shisl
* @time 2015-4-29
*/
-public class TitleBar extends LinearLayout {
+public class TitleBar {
+ /**
+ * 宸︿晶/鍙充晶鍥炬爣鍜屼腑闂存爣棰�
+ */
+ private View titleView;
- private static final String TAG = "CNavigationBar";
- public static final int LEFT = 0;
- public static final int CENTER = 1;
- public static final int RIGHT = 2;
- public static final int IMAGE = 3;
- public static final int TEXT = 4;
- public static final int ClickType_LEFT_TEXT = 1;
- public static final int ClickType_LEFT_IMAGE = 2;
- public static final int ClickType_CENTER_TEXT = 3;
- public static final int ClickType_CENTER_IMAGE = 4;
- public static final int ClickType_RIGHT_TEXT = 5;
- public static final int ClickType_RIGHT_IMAGE = 6;
+ /**
+ * 宸︿晶/鍙充晶鍥炬爣鍜屼腑闂存爣棰�
+ */
+ private RelativeLayout rl_title_bar;
- private TextView tvLeft;
- private ImageView ivLeft;
- private LinearLayout llLeft;
+ /**
+ * 璺熷竷灞�
+ */
+ private LinearLayout ll_title_bar;
- private ImageButton ibCenter;
- private TextView btnCenter;
+ /**
+ * 宸︿晶鍥炬爣
+ */
+ private ImageView iv_left_icon;
- private TextView tvRight;
- private ImageView ivRight;
- private LinearLayout llRight;
+ /**
+ * 鍙充晶鍥炬爣
+ */
+ private ImageView iv_rightIco;
+ /**
+ * 涓棿鏍囬
+ */
+ private TextView tv_title_middle;
- public TitleBar(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs);
- initView(context);
+ /**
+ * 鍙充晶鏍囬
+ */
+ private TextView tv_title_right;
+
+ /**
+ * 鏋勯�犳柟娉曪細鐢ㄤ簬鑾峰彇瀵硅薄
+ */
+ public TitleBar(Activity context) {
+ titleView = context.findViewById(R.id.rl_title_bar);
+ rl_title_bar = (RelativeLayout) titleView.findViewById(R.id.rl_title_bar);
+ ll_title_bar = (LinearLayout) context.findViewById(R.id.ll_title_bar);
+ tv_title_middle = (TextView) titleView.findViewById(R.id.tv_title_middle);
+ tv_title_right = (TextView) titleView.findViewById(R.id.tv_title_right);
+ iv_left_icon = (ImageView) titleView.findViewById(R.id.iv_left_icon);
+ iv_rightIco = (ImageView) titleView.findViewById(R.id.iv_rightIco);
}
/**
- * 鍒濆鍖栨垜浠嚜瀹氫箟鐨勭粍鍚堟帶浠�
+ * 鐢ㄤ簬璁剧疆鏍囬鏍忔枃瀛�
+ *
+ * @param titleText 浼犲叆瑕佽缃殑鏍囬
+ * @return
*/
- private void initView(Context context) {
- // 杞寲甯冨眬鏂囦欢鈥斺�斺�斺��>View瀵硅薄锛岃繖涓獀iew瀵硅薄鐩存帴鎸傝浇鍦ㄨ嚜宸憋紙缁勫悎鎺т欢锛夎韩涓�
- View.inflate(context, R.layout.custom_titlebar, this); // this浠h〃鎸傝浇鍒拌嚜宸辫韩涓�
- tvLeft = (TextView) this.findViewById(R.id.tv_titlebar_left);
- btnCenter = (TextView) this.findViewById(R.id.btn_titlebar_center);
- tvRight = (TextView) this.findViewById(R.id.tv_titlebar_right);
- ivLeft = (ImageView) this.findViewById(R.id.iv_titlebar_left);
- ibCenter = (ImageButton) this.findViewById(R.id.ib_titlebar_center);
- ivRight = (ImageView) this.findViewById(R.id.iv_titlebar_right);
- llLeft = (LinearLayout) this.findViewById(R.id.ll_left);
- llRight = (LinearLayout) this.findViewById(R.id.ll_right);
- }
-
- public TitleBar(Context context, AttributeSet attrs) {
- super(context, attrs);
- initView(context);
- try {
- /**
- * 璺焩alues/attrs.xml閲岄潰瀹氫箟鐨勫睘鎬х粦瀹�
- */
- // 浠巃ttrs.xml鑾峰彇鑷畾涔夌殑鎺т欢灞炴��
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitleBar);
- // //浠巃ttrs.xml鑾峰彇鑷畾涔夌殑value灞炴��(鎺т欢灞炴�у悕绉�+鈥淿鈥� + 鑷畾涔夌殑灞炴�у悕绉�)
- String leftText = a.getString(R.styleable.TitleBar_leftText);
- int leftImage = a.getResourceId(R.styleable.TitleBar_leftImage, 0);
- String centerText = a.getString(R.styleable.TitleBar_centerText);
- int centerImage = a.getResourceId(R.styleable.TitleBar_centerImage, 0);
- String rightText = a.getString(R.styleable.TitleBar_rightText);
- int rightImage = a.getResourceId(R.styleable.TitleBar_rightImage, 0);
- a.recycle();
- setLeftText(leftText);
- setRightText(rightText);
- setCenterText(centerText);
- setLeftImage(leftImage);
- setRightImage(rightImage);
- setCenterImage(centerImage);
- } catch (Exception e) {
- e.printStackTrace();
+ public TitleBar setTitleText(String titleText) {
+ if (!TextUtils.isEmpty(titleText)) {
+ tv_title_middle.setText(titleText);
}
+ return this;
}
- @Deprecated
- public void setOnItemclickListner(int type, int aligh, OnClickListener listner) {
- if (listner == null) {
- return;
+ /**
+ * 璁剧疆鏍囬鏍忔枃瀛楅鑹�
+ *
+ * @return
+ */
+ public TitleBar setTitleTextColor() {
+ tv_title_middle.setTextColor(Color.WHITE);
+ return this;
+ }
+
+ /**
+ * 璁剧疆鏍囬鏍忓彸杈圭殑鏂囧瓧
+ *
+ * @return
+ */
+ public TitleBar setTitleRight(String rightTitle) {
+ if (!TextUtils.isEmpty(rightTitle)) {
+ tv_title_right.setVisibility(View.VISIBLE);
+ iv_rightIco.setVisibility(View.GONE);
+ tv_title_right.setTextColor(Color.WHITE);
+ tv_title_right.setText(rightTitle);
}
- if (type == TEXT) {
- switch (aligh) {
- case LEFT:
- setOnItemclickListner(ClickType_LEFT_TEXT, listner);
+ return this;
+ }
- break;
- case CENTER:
- setOnItemclickListner(ClickType_CENTER_TEXT, listner);
- break;
- case RIGHT:
- setOnItemclickListner(ClickType_RIGHT_TEXT, listner);
+ /**
+ * 鐢ㄤ簬璁剧疆鏍囬鏍忓乏杈硅鏄剧ず鐨勫浘鐗�
+ *
+ * @param resId 鏍囬鏍忓乏杈圭殑鍥炬爣鐨刬d锛屼竴鑸负杩斿洖鍥炬爣
+ * @return
+ */
+ public TitleBar setLeftIco(int resId) {
+ iv_left_icon.setVisibility(resId > 0 ? View.VISIBLE : View.GONE);
+ iv_left_icon.setImageResource(resId);
+ return this;
+ }
- break;
+ /**
+ * 鐢ㄤ簬璁剧疆鏍囬鏍忓乏杈硅鏄剧ず鐨勫浘鐗�
+ *
+ * @return
+ */
+ public TitleBar setLeftIco() {
+ iv_left_icon.setVisibility(View.VISIBLE);
+ iv_left_icon.setImageResource(R.drawable.vector_arrows_left_white);
+ return this;
+ }
- default:
- break;
- }
- } else if (type == IMAGE) {
- switch (aligh) {
- case LEFT:
- setOnItemclickListner(ClickType_LEFT_IMAGE, listner);
- break;
- case CENTER:
- setOnItemclickListner(ClickType_CENTER_IMAGE, listner);
+ /**
+ * 鐢ㄤ簬璁剧疆鏍囬鏍忓彸杈硅鏄剧ず鐨勫浘鐗�
+ *
+ * @param resId 鏍囬鏍忓彸杈圭殑鍥炬爣id
+ * @return
+ */
+ public TitleBar setRightIco(int resId) {
+ iv_rightIco.setVisibility(resId > 0 ? View.VISIBLE : View.GONE);
+ iv_rightIco.setImageResource(resId);
+ return this;
+ }
- break;
- case RIGHT:
- setOnItemclickListner(ClickType_RIGHT_IMAGE, listner);
- break;
+ /**
+ * 鐢ㄦ埛璁剧疆 鏍囬鏍忓彸渚х殑鍥炬爣鐨勮儗鏅痙rawable
+ *
+ * @param resId drawable鐨刬d
+ * @return
+ */
+ public TitleBar setRightIconBgDr(int resId) {
+ iv_rightIco.setVisibility(resId > 0 ? View.VISIBLE : View.GONE);
+// iv_rightIco.setImageResource(R.drawable.ic_back_selector);
+ return this;
+ }
- default:
- break;
- }
+ /**
+ * 鐢ㄦ埛璁剧疆 鏍囬鏍忓彸渚х殑鍥炬爣鐨勮儗鏅痙rawable
+ *
+ * @return
+ */
+ public TitleBar setRightIconBgDr() {
+ iv_rightIco.setVisibility(View.GONE);
+// iv_rightIco.setImageResource(R.drawable.ic_back_selector);
+ return this;
+ }
+
+ /**
+ * 鐢ㄤ簬璁剧疆鏍囬鏍忓乏杈瑰浘鐗囩殑鍗曞嚮浜嬩欢
+ *
+ * @param listener 浼犲叆鐨勪簨浠跺璞�
+ * @return
+ */
+ public TitleBar setLeftIcoListening(View.OnClickListener listener) {
+ if (iv_left_icon.getVisibility() == View.VISIBLE) {
+ iv_left_icon.setOnClickListener(listener);
}
-
+ return this;
}
- public void setOnItemclickListner(int clickType, OnClickListener listner) {
- try {
- switch (clickType) {
- case ClickType_LEFT_TEXT:
- if (tvLeft.getVisibility() == View.VISIBLE) {
- llLeft.setOnClickListener(listner);
- }
- break;
- case ClickType_LEFT_IMAGE:
- if (ivLeft.getVisibility() == View.VISIBLE) {
- llLeft.setOnClickListener(listner);
- }
-
- break;
- case ClickType_CENTER_TEXT:
- if (btnCenter.getVisibility() == View.VISIBLE) {
- btnCenter.setOnClickListener(listner);
- }
-
- break;
- case ClickType_CENTER_IMAGE:
- if (ibCenter.getVisibility() == View.VISIBLE) {
- ibCenter.setOnClickListener(listner);
- }
-
- break;
- case ClickType_RIGHT_TEXT:
- if (tvRight.getVisibility() == View.VISIBLE) {
- llRight.setOnClickListener(listner);
- } else {
- llRight.setOnClickListener(null);
- }
-
- break;
- case ClickType_RIGHT_IMAGE:
- if (ivRight.getVisibility() == View.VISIBLE) {
- llRight.setOnClickListener(listner);
- }
- break;
-
- default:
- break;
- }
- } catch (Exception e) {
- e.printStackTrace();
+ /**
+ * 鐢ㄤ簬璁剧疆鏍囬鏍忓彸杈瑰浘鐗囩殑鍗曞嚮浜嬩欢
+ *
+ * @param listener 浼犲叆鐨勪簨浠跺璞�
+ * @return
+ */
+ public TitleBar setRightIcoListening(View.OnClickListener listener) {
+ if (iv_rightIco.getVisibility() == View.VISIBLE) {
+ iv_rightIco.setOnClickListener(listener);
}
-
+ return this;
}
-
- public void setLeftImage(int leftImage) {
- if (leftImage == 0) {
- ivLeft.setVisibility(View.GONE);
- return;
- }
- ivLeft.setVisibility(View.VISIBLE);
- ivLeft.setImageResource(leftImage);
-
- }
-
- public void setRightImage(int rightImage) {
- if (rightImage == 0) {
- ivRight.setVisibility(View.GONE);
- return;
- }
- ivRight.setVisibility(View.VISIBLE);
- ivRight.setImageResource(rightImage);
-
- }
-
- private void setCenterImage(int leftImage) {
- if (leftImage == 0) {
- return;
- }
- ivLeft.setBackgroundResource(leftImage);
-
- }
-
- public void setLeftText(String leftText) {
- if (leftText == null) {
- return;
- }
- tvLeft.setVisibility(View.VISIBLE);
- Log.i(TAG, "leftText--->" + leftText);
- tvLeft.setText(leftText);
- }
-
- public void setRightText(String rightText) {
- if (rightText == null) {
- return;
- }
- tvRight.setVisibility(View.VISIBLE);
- llRight.setVisibility(View.VISIBLE);
- tvRight.setText(rightText);
- }
-
- public void setCenterText(String centerText) {
- if (centerText == null) {
- return;
- }
- btnCenter.setVisibility(View.VISIBLE);
- Log.i(TAG, "centerText--->" + centerText);
- btnCenter.setText(centerText);
- }
-
- public void setRightStatus(boolean isable) {
- tvRight.setEnabled(isable);
- ivRight.setEnabled(isable);
- llRight.setEnabled(isable);
-
- }
-
- public void setRightIMGVisibility(int Visibility) {
- ivRight.setVisibility(Visibility);
- }
-
- public TextView getTitleTextView() {
- return btnCenter;
- }
-
- public LinearLayout getLlRight() {
- return llRight;
- }
-
}
diff --git a/app/src/main/res/drawable/bg_fillet_blue.xml b/app/src/main/res/drawable/bg_fillet_blue.xml
new file mode 100644
index 0000000..dc2bb5d
--- /dev/null
+++ b/app/src/main/res/drawable/bg_fillet_blue.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <solid android:color="@color/base_blue" />
+ <corners android:radius="5dp" />
+ <stroke
+ android:width="1dp"
+ android:color="@color/base_blue" />
+</shape>
\ No newline at end of file
diff --git a/app/src/main/res/drawable/vector_arrows_left_white.xml b/app/src/main/res/drawable/vector_arrows_left_white.xml
new file mode 100644
index 0000000..4add8ff
--- /dev/null
+++ b/app/src/main/res/drawable/vector_arrows_left_white.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="1024"
+ android:viewportHeight="1024">
+
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="M363.841,472.979 C336.939,497.359,337.302,537.486,364.73,561.486
+L673.952,832.055 C682.819,839.814,696.296,838.915,704.055,830.048
+C711.814,821.181,710.915,807.704,702.048,799.945 L392.827,529.376
+C384.596,522.174,384.502,511.835,392.492,504.594 L702.326,223.808
+C711.056,215.896,711.72,202.405,703.808,193.674
+C695.896,184.944,682.405,184.28,673.674,192.192 L363.841,472.979 Z" />
+</vector>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_change_pass_word.xml b/app/src/main/res/layout/activity_change_pass_word.xml
index cbd933c..517952b 100644
--- a/app/src/main/res/layout/activity_change_pass_word.xml
+++ b/app/src/main/res/layout/activity_change_pass_word.xml
@@ -6,12 +6,10 @@
android:background="@color/bg_color"
android:orientation="vertical">
- <com.dayu.pipirrapp.view.TitleBar
+ <include
android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="45dp"
- android:layout_alignParentTop="true"
- app:centerText="淇敼瀵嗙爜" />
+ layout="@layout/top_title" />
+
<EditText
@@ -25,9 +23,12 @@
<TextView
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="40dp"
+ android:gravity="bottom"
+ android:paddingLeft="20dp"
+ android:paddingBottom="3dp"
android:textColor="@color/grey"
-
+ android:text="瀵嗙爜涓�6-12浣嶆暟瀛楁垨瀛楁瘝"
/>
<EditText
@@ -51,17 +52,14 @@
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/item_height"
- android:background="@drawable/ic_blue_background"
- android:gravity="center"
- android:layout_marginRight="40dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="100dp"
+ android:layout_marginRight="40dp"
+ android:background="@drawable/ic_blue_background"
+ android:gravity="center"
android:text="淇� 鏀�"
android:textColor="@color/white"
android:textSize="@dimen/common_btn_text_size" />
-
-
-
</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_main.xml b/app/src/main/res/layout/fragment_main.xml
index 24f3d6b..7fb8cea 100644
--- a/app/src/main/res/layout/fragment_main.xml
+++ b/app/src/main/res/layout/fragment_main.xml
@@ -1,6 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:background="@color/bg_color">
+
+ <include
+ android:id="@+id/title"
+ layout="@layout/top_title" />
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/title"
+ android:layout_marginStart="10dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginEnd="10dp"
+ android:layout_marginBottom="10dp"
+ android:background="@drawable/bg_fillet_blue"
+ android:paddingLeft="15dp"
+ android:paddingTop="10dp"
+ android:paddingRight="25dp"
+ android:paddingBottom="10dp">
+
+
+ <TextView
+ android:id="@+id/cityName"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="鍩庡競"
+ android:textColor="@color/white"
+ android:textSize="18sp" />
+
+
+ <TextView
+ android:id="@+id/time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/cityName"
+ android:layout_alignParentRight="true"
+ android:text="鏃ユ湡"
+ android:textColor="@color/white"
+ android:textSize="16sp" />
+
+
+ <TextView
+ android:id="@+id/weather_name"
+ android:layout_width="wrap_content"
+ android:layout_height="30dp"
+ android:layout_below="@+id/time"
+ android:layout_alignParentRight="true"
+ android:layout_marginTop="10dp"
+ android:gravity="center"
+ android:text="澶╂皵"
+ android:textColor="@color/white"
+ android:textSize="16sp" />
+
+ <ImageView
+ android:id="@+id/weather_img"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_alignTop="@+id/weather_name"
+ android:layout_marginRight="10dp"
+ android:layout_toLeftOf="@+id/weather_name"
+ android:src="@mipmap/weather_99" />
+
+
+ <TextView
+ android:id="@+id/weather_temperature"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/weather_name"
+ android:layout_alignParentRight="true"
+ android:layout_marginTop="10dp"
+ android:text="娓╁害"
+ android:textColor="@color/white"
+ android:textSize="16sp" />
+
+
+ </RelativeLayout>
+
</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_my.xml b/app/src/main/res/layout/fragment_my.xml
index ab21108..4b443bb 100644
--- a/app/src/main/res/layout/fragment_my.xml
+++ b/app/src/main/res/layout/fragment_my.xml
@@ -6,14 +6,10 @@
android:layout_height="match_parent"
android:background="@color/bg_color">
- <com.dayu.pipirrapp.view.TitleBar
+
+ <include
android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="45dp"
- android:layout_alignParentTop="true"
-
- app:centerText="涓汉涓績" />
-
+ layout="@layout/top_title" />
<View
@@ -136,6 +132,7 @@
android:layout_marginTop="1dp">
<TextView
+ android:id="@+id/changePS"
android:layout_width="match_parent"
android:layout_height="@dimen/item_height"
diff --git a/app/src/main/res/layout/top_title.xml b/app/src/main/res/layout/top_title.xml
new file mode 100644
index 0000000..249aca8
--- /dev/null
+++ b/app/src/main/res/layout/top_title.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/ll_title_bar"
+
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/title_height"
+ android:background="@color/title_color"
+ android:gravity="center_vertical">
+
+ <RelativeLayout
+ android:id="@+id/rl_title_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical">
+
+ <ImageView
+ android:id="@+id/iv_left_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="30dp"
+ android:layout_centerVertical="true"
+ android:layout_marginLeft="5dp"
+ android:scaleType="centerCrop"
+ android:src="@drawable/vector_arrows_left_white"
+ android:visibility="gone" />
+
+ <TextView
+ android:id="@+id/tv_title_middle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+
+ android:layout_centerInParent="true"
+ android:textColor="@color/white"
+ android:textSize="@dimen/title_center_text_size" />
+
+ <ImageView
+ android:id="@+id/iv_rightIco"
+ android:layout_width="wrap_content"
+ android:layout_height="30dp"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:layout_marginRight="10dp"
+ android:src="@drawable/vector_loop"
+ android:visibility="gone" />
+
+ <TextView
+ android:id="@+id/tv_title_right"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_alignParentRight="true"
+ android:gravity="center_vertical"
+ android:visibility="gone" />
+
+ </RelativeLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-xhdpi/weather_0.png b/app/src/main/res/mipmap-xhdpi/weather_0.png
new file mode 100644
index 0000000..f2a0eb8
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_0.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_1.png b/app/src/main/res/mipmap-xhdpi/weather_1.png
new file mode 100644
index 0000000..448b797
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_1.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_10.png b/app/src/main/res/mipmap-xhdpi/weather_10.png
new file mode 100644
index 0000000..39b1b9b
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_10.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_11.png b/app/src/main/res/mipmap-xhdpi/weather_11.png
new file mode 100644
index 0000000..5e75aeb
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_11.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_12.png b/app/src/main/res/mipmap-xhdpi/weather_12.png
new file mode 100644
index 0000000..282684f
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_12.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_13.png b/app/src/main/res/mipmap-xhdpi/weather_13.png
new file mode 100644
index 0000000..24cfd26
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_13.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_14.png b/app/src/main/res/mipmap-xhdpi/weather_14.png
new file mode 100644
index 0000000..2bac8f7
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_14.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_15.png b/app/src/main/res/mipmap-xhdpi/weather_15.png
new file mode 100644
index 0000000..fedccdf
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_15.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_16.png b/app/src/main/res/mipmap-xhdpi/weather_16.png
new file mode 100644
index 0000000..465b9aa
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_16.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_17.png b/app/src/main/res/mipmap-xhdpi/weather_17.png
new file mode 100644
index 0000000..ed83fcb
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_17.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_18.png b/app/src/main/res/mipmap-xhdpi/weather_18.png
new file mode 100644
index 0000000..ed83fcb
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_18.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_19.png b/app/src/main/res/mipmap-xhdpi/weather_19.png
new file mode 100644
index 0000000..3bf63f4
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_19.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_2.png b/app/src/main/res/mipmap-xhdpi/weather_2.png
new file mode 100644
index 0000000..f2a0eb8
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_2.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_20.png b/app/src/main/res/mipmap-xhdpi/weather_20.png
new file mode 100644
index 0000000..ce08552
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_20.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_21.png b/app/src/main/res/mipmap-xhdpi/weather_21.png
new file mode 100644
index 0000000..cd1d596
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_21.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_22.png b/app/src/main/res/mipmap-xhdpi/weather_22.png
new file mode 100644
index 0000000..8abd8f8
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_22.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_23.png b/app/src/main/res/mipmap-xhdpi/weather_23.png
new file mode 100644
index 0000000..14de66b
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_23.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_24.png b/app/src/main/res/mipmap-xhdpi/weather_24.png
new file mode 100644
index 0000000..e1e20a6
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_24.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_25.png b/app/src/main/res/mipmap-xhdpi/weather_25.png
new file mode 100644
index 0000000..61d1420
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_25.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_26.png b/app/src/main/res/mipmap-xhdpi/weather_26.png
new file mode 100644
index 0000000..be0a36a
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_26.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_27.png b/app/src/main/res/mipmap-xhdpi/weather_27.png
new file mode 100644
index 0000000..be0a36a
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_27.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_28.png b/app/src/main/res/mipmap-xhdpi/weather_28.png
new file mode 100644
index 0000000..79c9b3b
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_28.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_29.png b/app/src/main/res/mipmap-xhdpi/weather_29.png
new file mode 100644
index 0000000..79c9b3b
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_29.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_3.png b/app/src/main/res/mipmap-xhdpi/weather_3.png
new file mode 100644
index 0000000..448b797
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_3.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_30.png b/app/src/main/res/mipmap-xhdpi/weather_30.png
new file mode 100644
index 0000000..a0bd2f4
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_30.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_31.png b/app/src/main/res/mipmap-xhdpi/weather_31.png
new file mode 100644
index 0000000..4cf6783
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_31.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_32.png b/app/src/main/res/mipmap-xhdpi/weather_32.png
new file mode 100644
index 0000000..358ec13
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_32.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_33.png b/app/src/main/res/mipmap-xhdpi/weather_33.png
new file mode 100644
index 0000000..358ec13
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_33.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_34.png b/app/src/main/res/mipmap-xhdpi/weather_34.png
new file mode 100644
index 0000000..6b26333
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_34.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_35.png b/app/src/main/res/mipmap-xhdpi/weather_35.png
new file mode 100644
index 0000000..6b26333
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_35.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_36.png b/app/src/main/res/mipmap-xhdpi/weather_36.png
new file mode 100644
index 0000000..ca95bca
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_36.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_37.png b/app/src/main/res/mipmap-xhdpi/weather_37.png
new file mode 100644
index 0000000..5501fb8
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_37.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_38.png b/app/src/main/res/mipmap-xhdpi/weather_38.png
new file mode 100644
index 0000000..f2a0eb8
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_38.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_4.png b/app/src/main/res/mipmap-xhdpi/weather_4.png
new file mode 100644
index 0000000..1d34291
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_4.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_5.png b/app/src/main/res/mipmap-xhdpi/weather_5.png
new file mode 100644
index 0000000..348a04c
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_5.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_6.png b/app/src/main/res/mipmap-xhdpi/weather_6.png
new file mode 100644
index 0000000..a516d7a
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_6.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_7.png b/app/src/main/res/mipmap-xhdpi/weather_7.png
new file mode 100644
index 0000000..348a04c
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_7.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_8.png b/app/src/main/res/mipmap-xhdpi/weather_8.png
new file mode 100644
index 0000000..a516d7a
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_8.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_9.png b/app/src/main/res/mipmap-xhdpi/weather_9.png
new file mode 100644
index 0000000..a3846ab
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_9.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/weather_99.png b/app/src/main/res/mipmap-xhdpi/weather_99.png
new file mode 100644
index 0000000..3e7753d
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/weather_99.png
Binary files differ
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index ec55a0e..5fe6e86 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -5,4 +5,5 @@
<dimen name="item_height">50dp</dimen>
<dimen name="my_item_text_size">17sp</dimen>
<dimen name="common_btn_text_size">20sp</dimen>
+ <dimen name="title_height">45dp</dimen>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5c27c6f..3991f8e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,3 @@
<resources>
- <string name="app_name">pipIrrApp</string>
+ <string name="app_name">宸℃绯荤粺</string>
</resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 38720b6..8e7946e 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -15,13 +15,5 @@
- <!-- 鏍囬瀵艰埅鏉� -->
- <declare-styleable name="TitleBar">
- <attr name="leftText" format="string" />
- <attr name="centerText" format="string" />
- <attr name="rightText" format="string" />
- <attr name="leftImage" format="integer"></attr>
- <attr name="centerImage" format="integer"></attr>
- <attr name="rightImage" format="integer"></attr>
- </declare-styleable>
+
</resources>
--
Gitblit v1.8.0