Search in sources :

Example 1 with CityAdapter

use of com.xiecc.seeWeather.modules.city.adapter.CityAdapter 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();
        }
    });
}
Also used : CityORM(com.xiecc.seeWeather.modules.main.domain.CityORM) MultiUpdate(com.xiecc.seeWeather.modules.main.domain.MultiUpdate) CityAdapter(com.xiecc.seeWeather.modules.city.adapter.CityAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ChangeCityEvent(com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 CityAdapter (com.xiecc.seeWeather.modules.city.adapter.CityAdapter)1 ChangeCityEvent (com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent)1 CityORM (com.xiecc.seeWeather.modules.main.domain.CityORM)1 MultiUpdate (com.xiecc.seeWeather.modules.main.domain.MultiUpdate)1