use of com.xiecc.seeWeather.modules.main.adapter.MultiCityAdapter in project SeeWeather by xcc3641.
the class MultiCityFragment method initView.
private void initView() {
mWeathers = new ArrayList<>();
mAdapter = new MultiCityAdapter(mWeathers);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mRecyclerView.setAdapter(mAdapter);
mAdapter.setMultiCityClick(new MultiCityAdapter.onMultiCityClick() {
@Override
public void longClick(String city) {
new AlertDialog.Builder(getActivity()).setMessage("是否删除该城市?").setPositiveButton("删除", (dialog, which) -> {
OrmLite.getInstance().delete(new WhereBuilder(CityORM.class).where("name=?", city));
multiLoad();
Snackbar.make(getView(), String.format(Locale.CHINA, "已经将%s删掉了 Ծ‸ Ծ", city), Snackbar.LENGTH_LONG).setAction("撤销", v -> {
OrmLite.getInstance().save(new CityORM(city));
multiLoad();
}).show();
}).show();
}
@Override
public void click(Weather weather) {
DetailCityActivity.launch(getActivity(), weather);
}
});
if (mRefreshLayout != null) {
mRefreshLayout.setColorSchemeResources(android.R.color.holo_orange_light, android.R.color.holo_red_light, android.R.color.holo_green_light, android.R.color.holo_blue_bright);
mRefreshLayout.setOnRefreshListener(() -> mRefreshLayout.postDelayed(this::multiLoad, 1000));
}
}
Aggregations