增加天气每小时显示,去掉autosize,增加svg显示
This commit is contained in:
1 parent
0f2adad060
commit
1977fd1cb2
575 files changed
+23756
-347
No files matched your search
@@ -29,8 +29,6 @@ import net.lucode.hackware.magicindicator.ViewPagerHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.jessyan.autosize.AutoSize;
|
||||
|
||||
public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBinding> {
|
||||
private static final String TAG = "MainActivity";
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
@@ -172,7 +170,6 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
//修补autozie fragment item大小不一致
|
||||
AutoSize.autoConvertDensityOfGlobal(this);
|
||||
Log.e(TAG, "onResume: ");
|
||||
mViewModel.getOutsideApp();
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||
import com.qweather.sdk.response.weather.WeatherDaily;
|
||||
import com.qweather.sdk.response.weather.WeatherHourly;
|
||||
import com.qweather.sdk.response.weather.WeatherNow;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.ttstd.dialer.R;
|
||||
import com.ttstd.dialer.adapter.HourlyWeatherAdapter;
|
||||
import com.ttstd.dialer.adapter.WeatherAdapter;
|
||||
import com.ttstd.dialer.base.mvvm.BaseMvvmActivity;
|
||||
import com.ttstd.dialer.config.CommonConfig;
|
||||
@@ -26,6 +28,7 @@ public class WeatherMainActivity extends BaseMvvmActivity<WeatherMainViewModel,
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
private WeatherAdapter mWeatherAdapter;
|
||||
private HourlyWeatherAdapter mHourlyWeatherAdapter;
|
||||
|
||||
// @Override
|
||||
// public boolean setfitWindow() {
|
||||
@@ -51,6 +54,13 @@ public class WeatherMainActivity extends BaseMvvmActivity<WeatherMainViewModel,
|
||||
mViewDataBinding.recyclerView.setAdapter(mWeatherAdapter);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(WeatherMainActivity.this, LinearLayoutManager.VERTICAL, false);
|
||||
mViewDataBinding.recyclerView.setLayoutManager(linearLayoutManager);
|
||||
|
||||
mHourlyWeatherAdapter = new HourlyWeatherAdapter();
|
||||
mViewDataBinding.rvHourly.setAdapter(mHourlyWeatherAdapter);
|
||||
LinearLayoutManager horizontalLinearLayoutManager = new LinearLayoutManager(WeatherMainActivity.this, LinearLayoutManager.HORIZONTAL, false);
|
||||
mViewDataBinding.rvHourly.setLayoutManager(horizontalLinearLayoutManager);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,6 +73,12 @@ public class WeatherMainActivity extends BaseMvvmActivity<WeatherMainViewModel,
|
||||
mViewDataBinding.setWeatherNow(weatherNow);
|
||||
}
|
||||
});
|
||||
mViewModel.mWeather24hData.observe(this, new Observer<List<WeatherHourly>>() {
|
||||
@Override
|
||||
public void onChanged(List<WeatherHourly> weatherHourlies) {
|
||||
mHourlyWeatherAdapter.setWeatherHourlyList(weatherHourlies);
|
||||
}
|
||||
});
|
||||
mViewModel.mWeatherDailyListData.observe(this, new Observer<List<WeatherDaily>>() {
|
||||
@Override
|
||||
public void onChanged(List<WeatherDaily> weatherDailies) {
|
||||
@@ -92,6 +108,7 @@ public class WeatherMainActivity extends BaseMvvmActivity<WeatherMainViewModel,
|
||||
public void onChanged(BDLocation bdLocation) {
|
||||
mViewDataBinding.tvLocation.setText(bdLocation.getDistrict());
|
||||
mViewModel.getWeatherNow(bdLocation.getAdCode());
|
||||
mViewModel.getWeather24h(bdLocation.getAdCode());
|
||||
mViewModel.getWeather10D(bdLocation.getAdCode());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.qweather.sdk.Callback;
|
||||
import com.qweather.sdk.response.error.ErrorResponse;
|
||||
import com.qweather.sdk.response.weather.WeatherDaily;
|
||||
import com.qweather.sdk.response.weather.WeatherDailyResponse;
|
||||
import com.qweather.sdk.response.weather.WeatherHourly;
|
||||
import com.qweather.sdk.response.weather.WeatherHourlyResponse;
|
||||
import com.qweather.sdk.response.weather.WeatherNow;
|
||||
import com.qweather.sdk.response.weather.WeatherNowResponse;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
@@ -47,6 +49,32 @@ public class WeatherMainViewModel extends BaseViewModel<ActivityWeatherMainBindi
|
||||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<List<WeatherHourly>> mWeather24hData = new MutableLiveData<>();
|
||||
|
||||
public void getWeather24h(String adCode) {
|
||||
Log.e(TAG, "getWeather24h: " + adCode);
|
||||
WeatherManager.getInstance().getWeather24h(adCode, new Callback<WeatherHourlyResponse>() {
|
||||
@Override
|
||||
public void onSuccess(WeatherHourlyResponse weatherHourlyResponse) {
|
||||
Log.e("getWeather24h", "onSuccess: " + weatherHourlyResponse);
|
||||
List<WeatherHourly> weatherHourlies = weatherHourlyResponse.getHourly();
|
||||
Log.e("getWeather24h", "onSuccess: " + GsonUtils.toJSONString(weatherHourlies));
|
||||
mWeather24hData.postValue(weatherHourlies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(ErrorResponse errorResponse) {
|
||||
Log.e("getWeather24h", "onFailure: " + errorResponse.getError().getStatus());
|
||||
Log.e("getWeather24h", "onFailure: " + errorResponse.getError().getDetail());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(Throwable throwable) {
|
||||
Log.e("getWeather24h", "onException: " + throwable.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public MutableLiveData<List<WeatherDaily>> mWeatherDailyListData = new MutableLiveData<>();
|
||||
|
||||
@@ -57,7 +85,7 @@ public class WeatherMainViewModel extends BaseViewModel<ActivityWeatherMainBindi
|
||||
public void onSuccess(WeatherDailyResponse weatherDailyResponse) {
|
||||
Log.e("getWeather10D", "onSuccess: ");
|
||||
List<WeatherDaily> weatherDailyList = weatherDailyResponse.getDaily();
|
||||
Log.e("getWeather10D", "onSuccess: "+ GsonUtils.toJSONString(weatherDailyList));
|
||||
Log.e("getWeather10D", "onSuccess: " + GsonUtils.toJSONString(weatherDailyList));
|
||||
mWeatherDailyListData.postValue(weatherDailyList);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user