写完了
This commit is contained in:
parent
b937c21923
commit
3e310813c4
|
@ -2,6 +2,7 @@ package com.hnucm.weather;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
@ -16,11 +17,13 @@ public class AirActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_air);
|
||||
Call<Weather7> weather7Call = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWearther7list("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
weather7Call.enqueue(new Callback<Weather7>() {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("data",MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token","");
|
||||
Call<Weather7Result> weather7ResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Weatherlist("Bearer "+ token);
|
||||
weather7ResultCall.enqueue(new Callback<Weather7Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather7> call, Response<Weather7> response) {
|
||||
public void onResponse(Call<Weather7Result> call, Response<Weather7Result> response) {
|
||||
TextView textView1,textView2,textView3,textView4,textView5,textView6,textView7;
|
||||
textView1 = findViewById(R.id.textView96);
|
||||
textView2 = findViewById(R.id.textView97);
|
||||
|
@ -29,17 +32,17 @@ public class AirActivity extends AppCompatActivity {
|
|||
textView5 = findViewById(R.id.textView100);
|
||||
textView6 = findViewById(R.id.textView102);
|
||||
textView7 = findViewById(R.id.textView103);
|
||||
textView1.setText(response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView2.setText(response.body().showapi_res_body.f1.day_weather);
|
||||
textView3.setText(response.body().showapi_res_body.f1.night_air_temperature+"/"+response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView4.setText(response.body().showapi_res_body.f1.day_wind_direction);
|
||||
textView5.setText(response.body().showapi_res_body.f1.day_wind_power);
|
||||
textView6.setText(response.body().showapi_res_body.f1.index.ls.title);
|
||||
textView7.setText(response.body().showapi_res_body.f1.index.ls.desc);
|
||||
textView1.setText(response.body().rows.get(0).dayAirTemperature);
|
||||
textView2.setText(response.body().rows.get(0).dayWeather);
|
||||
textView3.setText(response.body().rows.get(0).nightAirTemperature+"/"+response.body().rows.get(0).dayAirTemperature);
|
||||
textView4.setText(response.body().rows.get(0).dayWindDirection);
|
||||
textView5.setText(response.body().rows.get(0).dayWindPower);
|
||||
textView6.setText(response.body().rows.get(0).lstitle);
|
||||
textView7.setText(response.body().rows.get(0).lsdesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather7> call, Throwable t) {
|
||||
public void onFailure(Call<Weather7Result> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package com.hnucm.weather;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AirResult {
|
||||
|
||||
public Integer total;
|
||||
public Integer code;
|
||||
public String msg;
|
||||
public List<Rows> rows;
|
||||
|
||||
public static class Rows {
|
||||
public Object createBy;
|
||||
public Object createTime;
|
||||
public Object updateBy;
|
||||
public Object updateTime;
|
||||
public Object remark;
|
||||
public Integer id;
|
||||
public String c5;
|
||||
public String c6;
|
||||
public String f2DayWeather;
|
||||
public String f2NightAirTemperature;
|
||||
public String f2DayAirTemperature;
|
||||
public String nowWeather;
|
||||
public String aqidetailQuality;
|
||||
public String aqidetailAqi;
|
||||
public String aqidetailPm10;
|
||||
public String aqidetailCo;
|
||||
public String aqidetailO3;
|
||||
public String aqidetailNo2;
|
||||
public String aqidetailSo2;
|
||||
public String aqidetailPm25;
|
||||
public String f3DayWeather;
|
||||
public String f3NightAirTemperature;
|
||||
public String f3DayAirTemperature;
|
||||
public String f1DayWeather;
|
||||
public String f1NightAirTemperature;
|
||||
public String f1DayAirTemperature;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,13 @@
|
|||
package com.hnucm.weather;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.PATCH;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface Api {
|
||||
|
@ -14,4 +19,14 @@ public interface Api {
|
|||
Call<Hour> getHourlist(@Header("Authorization") String code, @Query("area")String area);
|
||||
@GET("area-to-weather-date")
|
||||
Call<Weather7> getWearther7list(@Header("Authorization") String code, @Query("area")String area);
|
||||
@POST("login")
|
||||
Call<LoginResult> login(@Body Map<String,String> map);
|
||||
@GET("system/hour24/list")
|
||||
Call<HourResult> Hourlist(@Header("Authorization") String token);
|
||||
@GET("system/day15/list")
|
||||
Call<DayResult> Daylist(@Header("Authorization") String token);
|
||||
@GET("system/weather/list")
|
||||
Call<AirResult> Airlist(@Header("Authorization") String token);
|
||||
@GET("system/weather7/list")
|
||||
Call<Weather7Result> Weatherlist(@Header("Authorization") String token);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.hnucm.weather;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
@ -16,11 +17,13 @@ public class BeautyActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_beauty);
|
||||
Call<Weather7> weather7Call = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWearther7list("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
weather7Call.enqueue(new Callback<Weather7>() {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("data",MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token","");
|
||||
Call<Weather7Result> weather7ResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Weatherlist("Bearer "+ token);
|
||||
weather7ResultCall.enqueue(new Callback<Weather7Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather7> call, Response<Weather7> response) {
|
||||
public void onResponse(Call<Weather7Result> call, Response<Weather7Result> response) {
|
||||
TextView textView1,textView2,textView3,textView4,textView5,textView6,textView7;
|
||||
textView1 = findViewById(R.id.textView96);
|
||||
textView2 = findViewById(R.id.textView97);
|
||||
|
@ -29,17 +32,16 @@ public class BeautyActivity extends AppCompatActivity {
|
|||
textView5 = findViewById(R.id.textView100);
|
||||
textView6 = findViewById(R.id.textView102);
|
||||
textView7 = findViewById(R.id.textView103);
|
||||
textView1.setText(response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView2.setText(response.body().showapi_res_body.f1.day_weather);
|
||||
textView3.setText(response.body().showapi_res_body.f1.night_air_temperature+"/"+response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView4.setText(response.body().showapi_res_body.f1.day_wind_direction);
|
||||
textView5.setText(response.body().showapi_res_body.f1.day_wind_power);
|
||||
textView6.setText(response.body().showapi_res_body.f1.index.beauty.title);
|
||||
textView7.setText(response.body().showapi_res_body.f1.index.beauty.desc);
|
||||
textView1.setText(response.body().rows.get(0).dayAirTemperature);
|
||||
textView2.setText(response.body().rows.get(0).dayWeather);
|
||||
textView3.setText(response.body().rows.get(0).nightAirTemperature+"/"+response.body().rows.get(0).dayAirTemperature);
|
||||
textView4.setText(response.body().rows.get(0).dayWindDirection);
|
||||
textView5.setText(response.body().rows.get(0).dayWindPower);
|
||||
textView6.setText(response.body().rows.get(0).betitle);
|
||||
textView7.setText(response.body().rows.get(0).bedesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather7> call, Throwable t) {
|
||||
public void onFailure(Call<Weather7Result> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.hnucm.weather;
|
||||
|
||||
import java.util.List;
|
||||
public class DayResult {
|
||||
|
||||
public Integer total;
|
||||
public Integer code;
|
||||
public String msg;
|
||||
public List<Rows> rows;
|
||||
|
||||
public static class Rows {
|
||||
public Object createBy;
|
||||
public Object createTime;
|
||||
public Object updateBy;
|
||||
public Object updateTime;
|
||||
public Object remark;
|
||||
public Integer id;
|
||||
public String nightWeatherPic;
|
||||
public String daytime;
|
||||
public String dayWindDirection;
|
||||
public String dayWeatherCode;
|
||||
public String area;
|
||||
public String nightWindPower;
|
||||
public String nightWeatherCode;
|
||||
public String areaCode;
|
||||
public String dayWeather;
|
||||
public String dayAirTemperature;
|
||||
public String nightWindDirection;
|
||||
public Integer areaid;
|
||||
public String nightWeather;
|
||||
public String nightAirTemperature;
|
||||
public String dayWeatherPic;
|
||||
public String dayWindPower;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.hnucm.weather;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
@ -16,11 +17,13 @@ public class DressActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_dress);
|
||||
Call<Weather7> weather7Call = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWearther7list("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
weather7Call.enqueue(new Callback<Weather7>() {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("data",MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token","");
|
||||
Call<Weather7Result> weather7ResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Weatherlist("Bearer "+ token);
|
||||
weather7ResultCall.enqueue(new Callback<Weather7Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather7> call, Response<Weather7> response) {
|
||||
public void onResponse(Call<Weather7Result> call, Response<Weather7Result> response) {
|
||||
TextView textView1,textView2,textView3,textView4,textView5,textView6,textView7;
|
||||
textView1 = findViewById(R.id.textView96);
|
||||
textView2 = findViewById(R.id.textView97);
|
||||
|
@ -29,17 +32,17 @@ public class DressActivity extends AppCompatActivity {
|
|||
textView5 = findViewById(R.id.textView100);
|
||||
textView6 = findViewById(R.id.textView102);
|
||||
textView7 = findViewById(R.id.textView104);
|
||||
textView1.setText(response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView2.setText(response.body().showapi_res_body.f1.day_weather);
|
||||
textView3.setText(response.body().showapi_res_body.f1.night_air_temperature+"/"+response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView4.setText(response.body().showapi_res_body.f1.day_wind_direction);
|
||||
textView5.setText(response.body().showapi_res_body.f1.day_wind_power);
|
||||
textView6.setText(response.body().showapi_res_body.f1.index.clothes.title);
|
||||
textView7.setText(response.body().showapi_res_body.f1.index.clothes.desc);
|
||||
textView1.setText(response.body().rows.get(0).dayAirTemperature);
|
||||
textView2.setText(response.body().rows.get(0).dayWeather);
|
||||
textView3.setText(response.body().rows.get(0).nightAirTemperature+"/"+response.body().rows.get(0).dayAirTemperature);
|
||||
textView4.setText(response.body().rows.get(0).dayWindDirection);
|
||||
textView5.setText(response.body().rows.get(0).dayWindPower);
|
||||
textView6.setText(response.body().rows.get(0).clotitle);
|
||||
textView7.setText(response.body().rows.get(0).clodesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather7> call, Throwable t) {
|
||||
public void onFailure(Call<Weather7Result> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.hnucm.weather;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HourResult {
|
||||
|
||||
|
||||
public Integer total;
|
||||
public Integer code;
|
||||
public String msg;
|
||||
public List<RowsBean> rows;
|
||||
|
||||
public static class RowsBean {
|
||||
public Object createBy;
|
||||
public Object createTime;
|
||||
public Object updateBy;
|
||||
public Object updateTime;
|
||||
public Object remark;
|
||||
public String time;
|
||||
public Integer id;
|
||||
public String windDirection;
|
||||
public String windPower;
|
||||
public Integer areaid;
|
||||
public String weatherCode;
|
||||
public String temperature;
|
||||
public String area;
|
||||
public String weather;
|
||||
}
|
||||
}
|
|
@ -2,4 +2,7 @@ package com.hnucm.weather;
|
|||
|
||||
public class LoginResult {
|
||||
|
||||
}
|
||||
public String msg;
|
||||
public Integer code;
|
||||
public String token;
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.hnucm.weather;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
@ -16,11 +17,13 @@ public class RoadActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_road);
|
||||
Call<Weather7> weather7Call = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWearther7list("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
weather7Call.enqueue(new Callback<Weather7>() {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("data",MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token","");
|
||||
Call<Weather7Result> weather7ResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Weatherlist("Bearer "+ token);
|
||||
weather7ResultCall.enqueue(new Callback<Weather7Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather7> call, Response<Weather7> response) {
|
||||
public void onResponse(Call<Weather7Result> call, Response<Weather7Result> response) {
|
||||
TextView textView1,textView2,textView3,textView4,textView5,textView6,textView7;
|
||||
textView1 = findViewById(R.id.textView96);
|
||||
textView2 = findViewById(R.id.textView97);
|
||||
|
@ -29,17 +32,17 @@ public class RoadActivity extends AppCompatActivity {
|
|||
textView5 = findViewById(R.id.textView100);
|
||||
textView6 = findViewById(R.id.textView102);
|
||||
textView7 = findViewById(R.id.textView103);
|
||||
textView1.setText(response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView2.setText(response.body().showapi_res_body.f1.day_weather);
|
||||
textView3.setText(response.body().showapi_res_body.f1.night_air_temperature+"/"+response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView4.setText(response.body().showapi_res_body.f1.day_wind_direction);
|
||||
textView5.setText(response.body().showapi_res_body.f1.day_wind_power);
|
||||
textView6.setText(response.body().showapi_res_body.f1.index.yh.title);
|
||||
textView7.setText(response.body().showapi_res_body.f1.index.yh.desc);
|
||||
textView1.setText(response.body().rows.get(0).dayAirTemperature);
|
||||
textView2.setText(response.body().rows.get(0).dayWeather);
|
||||
textView3.setText(response.body().rows.get(0).nightAirTemperature+"/"+response.body().rows.get(0).dayAirTemperature);
|
||||
textView4.setText(response.body().rows.get(0).dayWindDirection);
|
||||
textView5.setText(response.body().rows.get(0).dayWindPower);
|
||||
textView6.setText(response.body().rows.get(0).yhtitle);
|
||||
textView7.setText(response.body().rows.get(0).yhdesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather7> call, Throwable t) {
|
||||
public void onFailure(Call<Weather7Result> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.hnucm.weather;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
@ -16,11 +17,13 @@ public class SportsActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sports);
|
||||
Call<Weather7> weather7Call = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWearther7list("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
weather7Call.enqueue(new Callback<Weather7>() {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("data",MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token","");
|
||||
Call<Weather7Result> weather7ResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Weatherlist("Bearer "+ token);
|
||||
weather7ResultCall.enqueue(new Callback<Weather7Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather7> call, Response<Weather7> response) {
|
||||
public void onResponse(Call<Weather7Result> call, Response<Weather7Result> response) {
|
||||
TextView textView1,textView2,textView3,textView4,textView5,textView6,textView7;
|
||||
textView1 = findViewById(R.id.textView96);
|
||||
textView2 = findViewById(R.id.textView97);
|
||||
|
@ -29,17 +32,17 @@ public class SportsActivity extends AppCompatActivity {
|
|||
textView5 = findViewById(R.id.textView100);
|
||||
textView6 = findViewById(R.id.textView102);
|
||||
textView7 = findViewById(R.id.textView103);
|
||||
textView1.setText(response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView2.setText(response.body().showapi_res_body.f1.day_weather);
|
||||
textView3.setText(response.body().showapi_res_body.f1.night_air_temperature+"/"+response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView4.setText(response.body().showapi_res_body.f1.day_wind_direction);
|
||||
textView5.setText(response.body().showapi_res_body.f1.day_wind_power);
|
||||
textView6.setText(response.body().showapi_res_body.f1.index.cl.title);
|
||||
textView7.setText(response.body().showapi_res_body.f1.index.cl.desc);
|
||||
textView1.setText(response.body().rows.get(0).dayAirTemperature);
|
||||
textView2.setText(response.body().rows.get(0).dayWeather);
|
||||
textView3.setText(response.body().rows.get(0).nightAirTemperature+"/"+response.body().rows.get(0).dayAirTemperature);
|
||||
textView4.setText(response.body().rows.get(0).dayWindDirection);
|
||||
textView5.setText(response.body().rows.get(0).dayWindPower);
|
||||
textView6.setText(response.body().rows.get(0).cltitle);
|
||||
textView7.setText(response.body().rows.get(0).cldesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather7> call, Throwable t) {
|
||||
public void onFailure(Call<Weather7Result> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.hnucm.weather;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
@ -16,11 +17,13 @@ public class TourismActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_tourism);
|
||||
Call<Weather7> weather7Call = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWearther7list("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
weather7Call.enqueue(new Callback<Weather7>() {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("data",MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token","");
|
||||
Call<Weather7Result> weather7ResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Weatherlist("Bearer "+ token);
|
||||
weather7ResultCall.enqueue(new Callback<Weather7Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather7> call, Response<Weather7> response) {
|
||||
public void onResponse(Call<Weather7Result> call, Response<Weather7Result> response) {
|
||||
TextView textView1,textView2,textView3,textView4,textView5,textView6,textView7;
|
||||
textView1 = findViewById(R.id.textView96);
|
||||
textView2 = findViewById(R.id.textView97);
|
||||
|
@ -29,17 +32,16 @@ public class TourismActivity extends AppCompatActivity {
|
|||
textView5 = findViewById(R.id.textView100);
|
||||
textView6 = findViewById(R.id.textView102);
|
||||
textView7 = findViewById(R.id.textView103);
|
||||
textView1.setText(response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView2.setText(response.body().showapi_res_body.f1.day_weather);
|
||||
textView3.setText(response.body().showapi_res_body.f1.night_air_temperature+"/"+response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView4.setText(response.body().showapi_res_body.f1.day_wind_direction);
|
||||
textView5.setText(response.body().showapi_res_body.f1.day_wind_power);
|
||||
textView6.setText(response.body().showapi_res_body.f1.index.travel.title);
|
||||
textView7.setText(response.body().showapi_res_body.f1.index.travel.desc);
|
||||
textView1.setText(response.body().rows.get(0).dayAirTemperature);
|
||||
textView2.setText(response.body().rows.get(0).dayWeather);
|
||||
textView3.setText(response.body().rows.get(0).nightAirTemperature+"/"+response.body().rows.get(0).dayAirTemperature);
|
||||
textView4.setText(response.body().rows.get(0).dayWindDirection);
|
||||
textView5.setText(response.body().rows.get(0).dayWindPower);
|
||||
textView6.setText(response.body().rows.get(0).trtitle);
|
||||
textView7.setText(response.body().rows.get(0).trdesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather7> call, Throwable t) {
|
||||
public void onFailure(Call<Weather7Result> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.hnucm.weather;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
@ -16,11 +17,13 @@ public class WashActivity extends AppCompatActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_wash);
|
||||
Call<Weather7> weather7Call = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWearther7list("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
weather7Call.enqueue(new Callback<Weather7>() {
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("data",MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token","");
|
||||
Call<Weather7Result> weather7ResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Weatherlist("Bearer "+ token);
|
||||
weather7ResultCall.enqueue(new Callback<Weather7Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather7> call, Response<Weather7> response) {
|
||||
public void onResponse(Call<Weather7Result> call, Response<Weather7Result> response) {
|
||||
TextView textView1,textView2,textView3,textView4,textView5,textView6,textView7;
|
||||
textView1 = findViewById(R.id.textView96);
|
||||
textView2 = findViewById(R.id.textView97);
|
||||
|
@ -29,17 +32,17 @@ public class WashActivity extends AppCompatActivity {
|
|||
textView5 = findViewById(R.id.textView100);
|
||||
textView6 = findViewById(R.id.textView102);
|
||||
textView7 = findViewById(R.id.textView103);
|
||||
textView1.setText(response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView2.setText(response.body().showapi_res_body.f1.day_weather);
|
||||
textView3.setText(response.body().showapi_res_body.f1.night_air_temperature+"/"+response.body().showapi_res_body.f1.day_air_temperature);
|
||||
textView4.setText(response.body().showapi_res_body.f1.day_wind_direction);
|
||||
textView5.setText(response.body().showapi_res_body.f1.day_wind_power);
|
||||
textView6.setText(response.body().showapi_res_body.f1.index.wash_car.title);
|
||||
textView7.setText(response.body().showapi_res_body.f1.index.wash_car.desc);
|
||||
textView1.setText(response.body().rows.get(0).dayAirTemperature);
|
||||
textView2.setText(response.body().rows.get(0).dayWeather);
|
||||
textView3.setText(response.body().rows.get(0).nightAirTemperature+"/"+response.body().rows.get(0).dayAirTemperature);
|
||||
textView4.setText(response.body().rows.get(0).dayWindDirection);
|
||||
textView5.setText(response.body().rows.get(0).dayWindPower);
|
||||
textView6.setText(response.body().rows.get(0).watitle);
|
||||
textView7.setText(response.body().rows.get(0).wadesc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather7> call, Throwable t) {
|
||||
public void onFailure(Call<Weather7Result> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.hnucm.weather;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Weather7Result {
|
||||
|
||||
public Integer total;
|
||||
public Integer code;
|
||||
public String msg;
|
||||
public List<Rows> rows;
|
||||
|
||||
public static class Rows {
|
||||
public Object createBy;
|
||||
public Object createTime;
|
||||
public Object updateBy;
|
||||
public Object updateTime;
|
||||
public Object remark;
|
||||
public Integer id;
|
||||
public String c5;
|
||||
public String c6;
|
||||
public String dayWindPower;
|
||||
public String dayWeather;
|
||||
public String dayWindDirection;
|
||||
public String nightAirTemperature;
|
||||
public String dayWeatherPic;
|
||||
public String dayAirTemperature;
|
||||
public String yhdesc;
|
||||
public String yhtitle;
|
||||
public String cldesc;
|
||||
public String cltitle;
|
||||
public String trdesc;
|
||||
public String trtitle;
|
||||
public String bedesc;
|
||||
public String betitle;
|
||||
public String lsdesc;
|
||||
public String lstitle;
|
||||
public String clodesc;
|
||||
public String clotitle;
|
||||
public String wadesc;
|
||||
public String watitle;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package com.hnucm.weather;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -29,12 +32,14 @@ public class WeatherFragment extends Fragment {
|
|||
RecyclerView recyclerView,recyclerView1;
|
||||
MyAdapter myAdapter;
|
||||
MyAdapter1 myAdapter1;
|
||||
List<Weather.ShowapiResBodyDTO.DayListDTO> weatherList = new ArrayList<Weather.ShowapiResBodyDTO.DayListDTO>();
|
||||
List<Hour.ShowapiResBodyDTO.HourListDTO> hourList = new ArrayList<Hour.ShowapiResBodyDTO.HourListDTO>();
|
||||
List<DayResult.Rows> weatherList = new ArrayList<DayResult.Rows>();
|
||||
List<HourResult.RowsBean> hourList = new ArrayList<HourResult.RowsBean>();
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_weather, container, false);
|
||||
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("data",MODE_PRIVATE);
|
||||
String token = sharedPreferences.getString("token","");
|
||||
recyclerView = view.findViewById(R.id.recycleview);
|
||||
recyclerView1 = view.findViewById(R.id.recycleview1);
|
||||
myAdapter1 = new MyAdapter1();
|
||||
|
@ -50,65 +55,60 @@ public class WeatherFragment extends Fragment {
|
|||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
Call<Weather> weatherCall = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWeatherlist("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
Call<Air> airCall = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getAirlist("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
Call<Weather7> weather7Call = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getWearther7list("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
Call<Hour> hourCall = RetrofitUtils.getRetrofit("https://ali-weather.showapi.com/")
|
||||
.create(Api.class).getHourlist("APPCODE e1954955b4ca410c82c39b46677b95bd","长沙");
|
||||
hourCall.enqueue(new Callback<Hour>() {
|
||||
Call<Weather7Result> weather7ResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Weatherlist("Bearer "+ token);
|
||||
weather7ResultCall.enqueue(new Callback<Weather7Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Hour> call, Response<Hour> response) {
|
||||
hourList.addAll(response.body().showapi_res_body.hourList);
|
||||
myAdapter1.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Hour> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
weather7Call.enqueue(new Callback<Weather7>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather7> call, Response<Weather7> response) {
|
||||
public void onResponse(Call<Weather7Result> call, Response<Weather7Result> response) {
|
||||
ImageView imageView = view.findViewById(R.id.imageView50);
|
||||
TextView textView1,textView2,textView3;
|
||||
textView1 = view.findViewById(R.id.textView107);
|
||||
textView2 = view.findViewById(R.id.textView108);
|
||||
// textView3 = view.findViewById(R.id.textView110);
|
||||
textView1.setText(response.body().showapi_res_body.f1.day_weather);
|
||||
textView2.setText(response.body().showapi_res_body.f1.night_air_temperature+"/"+response.body().showapi_res_body.f1.day_air_temperature);
|
||||
// textView3 = view.findViewById(R.id.textView110);
|
||||
textView1.setText(response.body().rows.get(0).dayWeather);
|
||||
textView2.setText(response.body().rows.get(0).nightAirTemperature+"/"+response.body().rows.get(0).dayAirTemperature);
|
||||
Glide.with(getContext())
|
||||
.load(response.body().showapi_res_body.f1.day_weather_pic)
|
||||
.load(response.body().rows.get(0).dayWeatherPic)
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather7> call, Throwable t) {
|
||||
public void onFailure(Call<Weather7Result> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
weatherCall.enqueue(new Callback<Weather>() {
|
||||
Call<HourResult> hourResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Hourlist("Bearer "+ token);
|
||||
hourResultCall.enqueue(new Callback<HourResult>() {
|
||||
@Override
|
||||
public void onResponse(Call<Weather> call, Response<Weather> response) {
|
||||
|
||||
weatherList.addAll(response.body().showapi_res_body.dayList);
|
||||
|
||||
Log.i( "onResponse: ","123456789");
|
||||
myAdapter.notifyDataSetChanged();
|
||||
public void onResponse(Call<HourResult> call, Response<HourResult> response) {
|
||||
hourList.addAll(response.body().rows);
|
||||
myAdapter1.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Weather> call, Throwable t) {
|
||||
public void onFailure(Call<HourResult> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
airCall.enqueue(new Callback<Air>() {
|
||||
Call<DayResult> dayResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Daylist("Bearer "+ token);
|
||||
dayResultCall.enqueue(new Callback<DayResult>() {
|
||||
@Override
|
||||
public void onResponse(Call<Air> call, Response<Air> response) {
|
||||
// airList.add(response.body());
|
||||
public void onResponse(Call<DayResult> call, Response<DayResult> response) {
|
||||
weatherList.addAll(response.body().rows);
|
||||
myAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<DayResult> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
Call<AirResult> airResultCall =
|
||||
RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).Airlist("Bearer "+ token);
|
||||
airResultCall.enqueue(new Callback<AirResult>() {
|
||||
@Override
|
||||
public void onResponse(Call<AirResult> call, Response<AirResult> response) {
|
||||
TextView textView1,textView2,textView3,textView4,textView5,textView6,textView7,textView8;
|
||||
textView1=view.findViewById(R.id.textView71);
|
||||
textView2=view.findViewById(R.id.textView73);
|
||||
|
@ -118,18 +118,18 @@ public class WeatherFragment extends Fragment {
|
|||
textView6=view.findViewById(R.id.textView83);
|
||||
textView7=view.findViewById(R.id.textView86);
|
||||
textView8=view.findViewById(R.id.textView89);
|
||||
textView1.setText(response.body().showapi_res_body.now.aqiDetail.aqi);
|
||||
textView2.setText(response.body().showapi_res_body.now.aqiDetail.quality);
|
||||
textView3.setText(response.body().showapi_res_body.now.aqiDetail.pm2_5);
|
||||
textView4.setText(response.body().showapi_res_body.now.aqiDetail.no2);
|
||||
textView5.setText(response.body().showapi_res_body.now.aqiDetail.o3);
|
||||
textView6.setText(response.body().showapi_res_body.now.aqiDetail.pm10);
|
||||
textView7.setText(response.body().showapi_res_body.now.aqiDetail.co);
|
||||
textView8.setText(response.body().showapi_res_body.now.aqiDetail.so2);
|
||||
textView1.setText(response.body().rows.get(0).aqidetailAqi);
|
||||
textView2.setText(response.body().rows.get(0).aqidetailQuality);
|
||||
textView3.setText(response.body().rows.get(0).aqidetailPm25);
|
||||
textView4.setText(response.body().rows.get(0).aqidetailNo2);
|
||||
textView5.setText(response.body().rows.get(0).aqidetailO3);
|
||||
textView6.setText(response.body().rows.get(0).aqidetailPm10);
|
||||
textView7.setText(response.body().rows.get(0).aqidetailCo);
|
||||
textView8.setText(response.body().rows.get(0).aqidetailSo2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Air> call, Throwable t) {
|
||||
public void onFailure(Call<AirResult> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -211,11 +211,11 @@ public class WeatherFragment extends Fragment {
|
|||
Log.i("onBindViewHolder","onBindViewHolder");
|
||||
holder.daytime.setText(weatherList.get(position).daytime);
|
||||
//holder.day.setText(weatherList.get(position).daytime);
|
||||
holder.weather.setText(weatherList.get(position).day_weather);
|
||||
holder.weather.setText(weatherList.get(position).dayWeather);
|
||||
// holder.imageView.setImageURI(Uri.parse("https://app1.showapi.com/weather/icon/night/01.png"));
|
||||
holder.temp.setText(weatherList.get(position).night_air_temperature+"/"+weatherList.get(position).day_air_temperature);
|
||||
holder.temp.setText(weatherList.get(position).nightAirTemperature+"/"+weatherList.get(position).dayAirTemperature);
|
||||
Glide.with(getContext())
|
||||
.load(weatherList.get(position).day_weather_pic)
|
||||
.load(weatherList.get(position).dayWeatherPic)
|
||||
.into(holder.imageView);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,44 +12,42 @@ import android.util.Log;
|
|||
import com.gyf.immersionbar.ImmersionBar;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttp;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class WelcomeActivity extends AppCompatActivity {
|
||||
|
||||
//10.138.78.100
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_welcome);
|
||||
ImmersionBar.with(this).init();
|
||||
// Request request = new Request.Builder()
|
||||
// .url("https://test1265l.usemock.com/text3213")
|
||||
// .get()
|
||||
// .build();
|
||||
// OkHttpClient okHttpClient = new OkHttpClient();
|
||||
// Call call = okHttpClient.newCall(request);
|
||||
// call.enqueue(new Callback() {
|
||||
// @Override
|
||||
// public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
||||
// Log.i("errorTest",e.toString());
|
||||
// }
|
||||
// @Override
|
||||
// public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
||||
// String result = response.body().string();
|
||||
// Log.i("test",result);
|
||||
// runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("username","admin");
|
||||
map.put("password","admin123");
|
||||
Call<LoginResult> loginResultCall= RetrofitUtils.getRetrofit("http://10.138.78.100:8080/").create(Api.class).login(map);
|
||||
loginResultCall.enqueue(new Callback<LoginResult>() {
|
||||
@Override
|
||||
public void onResponse(Call<LoginResult> call, Response<LoginResult> response) {
|
||||
LoginResult loginResult = response.body();
|
||||
if(loginResult.code==200){
|
||||
SharedPreferences.Editor editor = getSharedPreferences("data",MODE_PRIVATE).edit();
|
||||
editor.putString("token",loginResult.token);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Call<LoginResult> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
Loading…
Reference in New Issue