diff --git a/app/src/main/java/com/uiui/aios/activity/weather/WeatherPresenter.java b/app/src/main/java/com/uiui/aios/activity/weather/WeatherPresenter.java index 73d5a98..c0c65f9 100644 --- a/app/src/main/java/com/uiui/aios/activity/weather/WeatherPresenter.java +++ b/app/src/main/java/com/uiui/aios/activity/weather/WeatherPresenter.java @@ -82,7 +82,9 @@ public class WeatherPresenter implements WeatherContact.Presenter { @Override public void onError(Throwable throwable) { Log.e("getWeather", "onError: " + throwable.getMessage()); - mView.setWeather(null); + if (mView != null) { + mView.setWeather(null); + } } @Override @@ -90,7 +92,9 @@ public class WeatherPresenter implements WeatherContact.Presenter { String jsonString = new Gson().toJson(weatherDailyBean); Log.d("getWeather", "onSuccess: " + jsonString); mMMKV.encode(WEATHER_DAILY_KEY, jsonString); - mView.setWeather(weatherDailyBean); + if (mView != null) { + mView.setWeather(weatherDailyBean); + } } }); } diff --git a/app/src/main/java/com/uiui/aios/adapter/WeatherDayApdapter.java b/app/src/main/java/com/uiui/aios/adapter/WeatherDayApdapter.java index e8b65f0..d19ee49 100644 --- a/app/src/main/java/com/uiui/aios/adapter/WeatherDayApdapter.java +++ b/app/src/main/java/com/uiui/aios/adapter/WeatherDayApdapter.java @@ -16,6 +16,9 @@ import androidx.recyclerview.widget.RecyclerView; import com.qweather.sdk.bean.weather.WeatherDailyBean; import com.uiui.aios.R; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; public class WeatherDayApdapter extends RecyclerView.Adapter { @@ -40,17 +43,25 @@ public class WeatherDayApdapter extends RecyclerView.Adapter + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_weather_sun.xml b/app/src/main/res/drawable/background_weather_sun.xml new file mode 100644 index 0000000..1094952 --- /dev/null +++ b/app/src/main/res/drawable/background_weather_sun.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_weather_sunny.xml b/app/src/main/res/drawable/background_weather_sunny.xml new file mode 100644 index 0000000..b057981 --- /dev/null +++ b/app/src/main/res/drawable/background_weather_sunny.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-land/activity_weather.xml b/app/src/main/res/layout-land/activity_weather.xml index fd3af79..a7a3c76 100644 --- a/app/src/main/res/layout-land/activity_weather.xml +++ b/app/src/main/res/layout-land/activity_weather.xml @@ -69,7 +69,7 @@ android:layout_height="wrap_content" android:text="位置" android:textColor="@color/white" - android:textSize="20sp" + android:textSize="@dimen/sp_18" app:layout_constraintBottom_toBottomOf="@+id/imageView" app:layout_constraintStart_toEndOf="@+id/imageView" app:layout_constraintTop_toTopOf="@+id/imageView" /> diff --git a/app/src/main/res/layout-land/item_weather.xml b/app/src/main/res/layout-land/item_weather.xml index 7e3e275..ba1ad16 100644 --- a/app/src/main/res/layout-land/item_weather.xml +++ b/app/src/main/res/layout-land/item_weather.xml @@ -25,10 +25,12 @@ android:id="@+id/tv_date" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="36dp" - android:text="2022-01-21 17:48:48" + android:layout_marginBottom="@dimen/dp_8" + android:maxLines="1" + android:singleLine="true" + android:text="17:48" android:textColor="@color/black" - android:textSize="20sp" + android:textSize="@dimen/sp_20" app:layout_constraintBottom_toTopOf="@+id/iv_weather" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> @@ -49,9 +51,9 @@ android:id="@+id/tv_weather" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="36dp" + android:layout_marginTop="@dimen/dp_8" android:textColor="@color/black" - android:textSize="20sp" + android:textSize="@dimen/sp_20" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/iv_weather" /> @@ -60,7 +62,7 @@ android:id="@+id/tv_temp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="@dimen/dp_8" android:text="15-22" android:textColor="@color/black" android:textSize="26sp" diff --git a/app/src/main/res/layout-port/activity_weather.xml b/app/src/main/res/layout-port/activity_weather.xml index fd3af79..1892692 100644 --- a/app/src/main/res/layout-port/activity_weather.xml +++ b/app/src/main/res/layout-port/activity_weather.xml @@ -10,12 +10,13 @@ android:id="@+id/constraintLayout3" android:layout_width="match_parent" android:layout_height="wrap_content"> + diff --git a/app/src/main/res/layout-port/item_weather.xml b/app/src/main/res/layout-port/item_weather.xml index df7047c..e78cccf 100644 --- a/app/src/main/res/layout-port/item_weather.xml +++ b/app/src/main/res/layout-port/item_weather.xml @@ -29,24 +29,24 @@ android:id="@+id/tv_date" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="36dp" - android:text="2022-01-21 17:48:48" + android:layout_marginStart="@dimen/dp_32" + android:layout_marginTop="@dimen/dp_32" + android:text="17:48" android:textColor="@color/black" - android:textSize="20sp" - app:layout_constraintBottom_toTopOf="@+id/iv_weather" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" /> + android:textSize="@dimen/sp_20" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="@+id/iv_bg" /> + app:layout_constraintEnd_toEndOf="@+id/iv_weather" + app:layout_constraintStart_toStartOf="@+id/iv_weather" + app:layout_constraintTop_toBottomOf="@+id/iv_weather" /> \ No newline at end of file