GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix bugs · FrankHongS/Sunny@9d0eaee

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • app/src/main
    • AndroidManifest.xml
    • java/com/hon/sunny
      • network
        • RetrofitSingleton.java
      • ui/main
        • MainActivity.java
        • adapter
          • WeatherAdapter.java
      • vo/bean/main
        • Weather.java
        • WeatherQuality.java
    • res/layout
      • item_now_temperature.xml
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎app/src/main/AndroidManifest.xml‎

Copy file name to clipboardExpand all lines: app/src/main/AndroidManifest.xml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
/>
6161
<activity android:name=".ui.city.SearchCityActivity"
6262
android:screenOrientation="portrait"
63+
android:launchMode="singleTop"
6364
/>
6465

6566
<provider android:name="androidx.core.content.FileProvider"
Collapse file

‎app/src/main/java/com/hon/sunny/network/RetrofitSingleton.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/hon/sunny/network/RetrofitSingleton.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public Flowable<Weather> fetchWeather(String city) {
157157
if (weatherQuality != null) {
158158
weather.quality = weatherQuality.qualityList.get(0).airNowCity.quality;
159159
weather.pm25 = weatherQuality.qualityList.get(0).airNowCity.pm25;
160+
weather.aqi = weatherQuality.qualityList.get(0).airNowCity.aqi;
160161
}
161162
return weather;
162163
})
Collapse file

‎app/src/main/java/com/hon/sunny/ui/main/MainActivity.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/hon/sunny/ui/main/MainActivity.java
+26-15Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.os.Build;
88
import android.os.Bundle;
99
import android.view.MenuItem;
10+
import android.view.View;
1011

1112
import androidx.annotation.NonNull;
1213
import androidx.annotation.Nullable;
@@ -55,11 +56,13 @@
5556
* Created by Frank on 2017/10/27.
5657
* E-mail:[email protected]
5758
*/
58-
5959
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
6060

6161
private static final String KEY_MULTI_CITY = "MULTI_CITY";
6262
private static final String KEY_WEATHER = "WEATHER";
63+
64+
private static final float OFFSET_THRESHOLD = 0.03f;
65+
6366
@BindView(R.id.viewPager)
6467
ViewPager viewPager;
6568
@BindView(R.id.toolbar)
@@ -72,6 +75,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
7275
NavigationView navigationView;
7376
@BindView(R.id.drawer_layout)
7477
DrawerLayout drawerLayout;
78+
7579
private Fragment mMultiCityFragment;
7680
private Fragment mWeatherFragment;
7781

@@ -224,23 +228,30 @@ private void initDrawer() {
224228
@Override
225229
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
226230

227-
drawerLayout.closeDrawer(GravityCompat.START);
228-
229-
switch (item.getItemId()) {
230-
case R.id.nav_set:
231-
launch(SettingActivity.class);
232-
break;
231+
// 使得drawerLayout关闭和切换Activity之间更流畅
232+
drawerLayout.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
233+
@Override
234+
public void onDrawerSlide(View drawerView, float slideOffset) {
235+
if (slideOffset < OFFSET_THRESHOLD) {
236+
switch (item.getItemId()) {
237+
case R.id.nav_set:
238+
launch(SettingActivity.class);
239+
break;
233240
// case R.id.nav_about:
234241
// launch(AboutActivity.class);
235242
// break;
236-
case R.id.nav_city:
237-
launch(SearchCityActivity.class);
238-
break;
239-
case R.id.nav_multi_cities:
240-
viewPager.setCurrentItem(1);
241-
break;
242-
}
243-
243+
case R.id.nav_city:
244+
launch(SearchCityActivity.class);
245+
break;
246+
case R.id.nav_multi_cities:
247+
viewPager.setCurrentItem(1);
248+
break;
249+
}
250+
drawerLayout.removeDrawerListener(this);
251+
}
252+
}
253+
});
254+
drawerLayout.closeDrawer(GravityCompat.START);
244255
return false;
245256
}
246257

Collapse file

‎app/src/main/java/com/hon/sunny/ui/main/adapter/WeatherAdapter.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/hon/sunny/ui/main/adapter/WeatherAdapter.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class NowWeatherViewHolder extends BaseViewHolder<Weather> {
101101
TextView tempPm;
102102
@BindView(R.id.tv_now_air_quality)
103103
TextView tempQuality;
104+
@BindView(R.id.tv_now_aqi)
105+
TextView tempAqi;
104106

105107
NowWeatherViewHolder(View itemView) {
106108
super(itemView);
@@ -121,6 +123,7 @@ public void bind(Weather weather) {
121123

122124
tempPm.setText(String.format("PM2.5: %s μg/m³", Util.safeText(weather.pm25)));
123125
tempQuality.setText(Util.safeText("空气质量: ", weather.quality));
126+
tempAqi.setText(Util.safeText("AQI: ", weather.aqi));
124127

125128
if (weather.now != null)
126129
ImageLoader.load(itemView.getContext(),
Collapse file

‎app/src/main/java/com/hon/sunny/vo/bean/main/Weather.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/hon/sunny/vo/bean/main/Weather.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class Weather implements Serializable {
4141
@Expose(serialize = false, deserialize = false)
4242
public String pm25;
4343

44+
@Expose(serialize = false, deserialize = false)
45+
public String aqi;
46+
4447
public static class BasicEntity implements Serializable {
4548
@SerializedName("cnty")
4649
public String cnty;
Collapse file

‎app/src/main/java/com/hon/sunny/vo/bean/main/WeatherQuality.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/hon/sunny/vo/bean/main/WeatherQuality.java
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ public static class AirNowCity {
2424

2525
@SerializedName("pm25")
2626
public String pm25;
27+
28+
public String aqi;
2729
}
2830
}
Collapse file

‎app/src/main/res/layout/item_now_temperature.xml‎

Copy file name to clipboardExpand all lines: app/src/main/res/layout/item_now_temperature.xml
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
app:layout_constraintBottom_toBottomOf="parent"
7575
app:layout_constraintEnd_toEndOf="parent"
7676
app:layout_constraintTop_toBottomOf="@+id/tv_now_temp_min"
77-
tools:text="空气质量: 优" />
77+
tools:text="空气质量: 优" />
7878

7979
<TextView
8080
android:id="@+id/tv_now_air_pm25"
@@ -86,5 +86,16 @@
8686
app:layout_constraintEnd_toStartOf="@+id/tv_now_air_quality"
8787
app:layout_constraintTop_toTopOf="@+id/tv_now_air_quality"
8888
tools:text="PM2.5: 65 μg/m³" />
89+
90+
<TextView
91+
android:id="@+id/tv_now_aqi"
92+
android:layout_width="wrap_content"
93+
android:layout_height="wrap_content"
94+
android:layout_marginEnd="12dp"
95+
android:layout_marginRight="12dp"
96+
tools:text="AQI: 65"
97+
android:textSize="12sp"
98+
app:layout_constraintEnd_toStartOf="@+id/tv_now_air_pm25"
99+
app:layout_constraintTop_toTopOf="@+id/tv_now_air_pm25" />
89100
</androidx.constraintlayout.widget.ConstraintLayout>
90101
</androidx.cardview.widget.CardView>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.