File was renamed from app/src/main/java/com/dayu/pipirrapp/fragment/MainFragment.java |
| | |
| | | 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.Nullable; |
| | | import androidx.lifecycle.Observer; |
| | | |
| | | import com.dayu.pipirrapp.bean.LatLonBean; |
| | | import com.dayu.pipirrapp.bean.WeatherResponse; |
| | | import com.dayu.pipirrapp.bean.db.LatLonBean; |
| | | import com.dayu.pipirrapp.bean.net.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.dayu.pipirrapp.view.TitleBar; |
| | | 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; |
| | |
| | | * Time: 10:12 |
| | | * 备注:首页 |
| | | */ |
| | | public class MainFragment extends BaseFragment { |
| | | public class OrderFragment extends BaseFragment { |
| | | |
| | | FragmentMainBinding binding; |
| | | WeatherResponse weatherResponse; |
| | |
| | | @Override |
| | | public void onChanged(LatLonBean latLonBean) { |
| | | |
| | | String jsonStr = SharedPreferencesHelper.getInstance(MainFragment.this.getActivity()).get("WeatherResponse", ""); |
| | | String jsonStr = SharedPreferencesHelper.getInstance(OrderFragment.this.getActivity()).get("WeatherResponse", ""); |
| | | weatherResponse = MyJsonParser.getBeanFromJson(jsonStr, WeatherResponse.class); |
| | | if (weatherResponse == null) { |
| | | weatherResponse = new WeatherResponse(); |
| | |
| | | |
| | | if (response.isSuccessful()) { |
| | | weatherResponse.setResults(response.body().getResults()); |
| | | SharedPreferencesHelper.getInstance(MainFragment.this.getActivity()).put("WeatherResponse", weatherResponse); |
| | | SharedPreferencesHelper.getInstance(OrderFragment.this.getActivity()).put("WeatherResponse", weatherResponse); |
| | | setWeatherData(weatherResponse); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | binding = FragmentMainBinding.inflate(inflater, container, false); |
| | | |
| | | |
| | | //获取到经纬度后获取天气信息 |
| | | LiveEventBus |
| | | .get("location", LatLonBean.class) |
| | |
| | | return binding.getRoot(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | new TitleBar(OrderFragment.this.getActivity()).setTitleText("工单"); |
| | | } |
| | | } |