use of com.xiecc.seeWeather.modules.main.domain.CityORM 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.setOnMultiCityLongClick(new MultiCityAdapter.onMultiCityLongClick() {
@Override
public void longClick(String city) {
new AlertDialog.Builder(getActivity()).setMessage("是否删除该城市?").setPositiveButton("删除", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
OrmLite.getInstance().delete(new WhereBuilder(CityORM.class).where("name=?", city));
OrmLite.OrmTest(CityORM.class);
multiLoad();
Snackbar.make(getView(), "已经将" + city + "删掉了 Ծ‸ Ծ", Snackbar.LENGTH_LONG).setAction("撤销", new View.OnClickListener() {
@Override
public void onClick(View v) {
OrmLite.getInstance().save(new CityORM(city));
multiLoad();
}
}).show();
}
}).show();
}
});
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(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mRefreshLayout.postDelayed(new Runnable() {
@Override
public void run() {
multiLoad();
}
}, 1000);
}
});
}
}
use of com.xiecc.seeWeather.modules.main.domain.CityORM in project SeeWeather by xcc3641.
the class ChoiceCityActivity method initRecyclerView.
private void initRecyclerView() {
mRecyclerview.setLayoutManager(new LinearLayoutManager(this));
mRecyclerview.setHasFixedSize(true);
//mRecyclerview.setItemAnimator(new FadeInUpAnimator());
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).CityName);
if (isChecked) {
OrmLite.getInstance().save(new CityORM(city));
RxBus.getDefault().post(new MultiUpdate());
PLog.d("是多城市管理模式");
} else {
SharedPreferenceUtil.getInstance().setCityName(city);
RxBus.getDefault().post(new ChangeCityEvent());
}
quit();
}
});
}
Aggregations