use of com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent in project SeeWeather by xcc3641.
the class SettingFragment method showIconDialog.
private void showIconDialog() {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogLayout = inflater.inflate(R.layout.dialog_icon, (ViewGroup) getActivity().findViewById(R.id.dialog_root));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setView(dialogLayout);
final AlertDialog alertDialog = builder.create();
LinearLayout layoutTypeOne = (LinearLayout) dialogLayout.findViewById(R.id.layout_one);
layoutTypeOne.setClickable(true);
RadioButton radioTypeOne = (RadioButton) dialogLayout.findViewById(R.id.radio_one);
LinearLayout layoutTypeTwo = (LinearLayout) dialogLayout.findViewById(R.id.layout_two);
layoutTypeTwo.setClickable(true);
RadioButton radioTypeTwo = (RadioButton) dialogLayout.findViewById(R.id.radio_two);
TextView done = (TextView) dialogLayout.findViewById(R.id.done);
radioTypeOne.setClickable(false);
radioTypeTwo.setClickable(false);
alertDialog.show();
switch(mSharedPreferenceUtil.getIconType()) {
case 0:
radioTypeOne.setChecked(true);
radioTypeTwo.setChecked(false);
break;
case 1:
radioTypeOne.setChecked(false);
radioTypeTwo.setChecked(true);
break;
}
layoutTypeOne.setOnClickListener(v -> {
radioTypeOne.setChecked(true);
radioTypeTwo.setChecked(false);
});
layoutTypeTwo.setOnClickListener(v -> {
radioTypeOne.setChecked(false);
radioTypeTwo.setChecked(true);
});
done.setOnClickListener(v -> {
mSharedPreferenceUtil.setIconType(radioTypeOne.isChecked() ? 0 : 1);
String[] iconsText = getResources().getStringArray(R.array.icons);
mChangeIcons.setSummary(radioTypeOne.isChecked() ? iconsText[0] : iconsText[1]);
alertDialog.dismiss();
Snackbar.make(getView(), "切换成功,重启应用生效", Snackbar.LENGTH_INDEFINITE).setAction("重启", v1 -> {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getActivity().startActivity(intent);
getActivity().finish();
RxBus.getDefault().post(new ChangeCityEvent());
}).show();
});
}
use of com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent in project SeeWeather by xcc3641.
the class ChoiceCityActivity method initRecyclerView.
private void initRecyclerView() {
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(true);
mAdapter = new CityAdapter(this, dataList);
mRecyclerView.setAdapter(mAdapter);
mAdapter.setOnItemClickListener((view, pos) -> {
if (currentLevel == LEVEL_PROVINCE) {
selectedProvince = provincesList.get(pos);
mRecyclerView.smoothScrollToPosition(0);
queryCities();
} else if (currentLevel == LEVEL_CITY) {
String city = Util.replaceCity(cityList.get(pos).mCityName);
if (isChecked) {
OrmLite.getInstance().save(new CityORM(city));
RxBus.getDefault().post(new MultiUpdateEvent());
} else {
SharedPreferenceUtil.getInstance().setCityName(city);
RxBus.getDefault().post(new ChangeCityEvent());
}
quit();
}
});
}
Aggregations