Search in sources :

Example 1 with CityORM

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);
            }
        });
    }
}
Also used : DialogInterface(android.content.DialogInterface) WhereBuilder(com.litesuits.orm.db.assit.WhereBuilder) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) MultiCityAdapter(com.xiecc.seeWeather.modules.main.adapter.MultiCityAdapter) CityORM(com.xiecc.seeWeather.modules.main.domain.CityORM) WhereBuilder(com.litesuits.orm.db.assit.WhereBuilder)

Example 2 with CityORM

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();
        }
    });
}
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)2 CityORM (com.xiecc.seeWeather.modules.main.domain.CityORM)2 DialogInterface (android.content.DialogInterface)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 WhereBuilder (com.litesuits.orm.db.assit.WhereBuilder)1 CityAdapter (com.xiecc.seeWeather.modules.city.adapter.CityAdapter)1 MultiCityAdapter (com.xiecc.seeWeather.modules.main.adapter.MultiCityAdapter)1 ChangeCityEvent (com.xiecc.seeWeather.modules.main.domain.ChangeCityEvent)1 MultiUpdate (com.xiecc.seeWeather.modules.main.domain.MultiUpdate)1