Search in sources :

Example 1 with CommonDialog

use of cn.nicolite.palm300heroes.view.customView.CommonDialog in project Palm300Heroes by nicolite.

the class SearchActivity method doBusiness.

@Override
protected void doBusiness() {
    recyclerView.setLayoutManager(new GridLayoutManager(context, 3, OrientationHelper.VERTICAL, false));
    adapter = new SearchAdapter(context, searchHistoryList);
    recyclerView.setAdapter(adapter);
    adapter.setOnItemClickListener(new SearchAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position, long itemId) {
            SearchHistory searchHistory = searchHistoryList.get(position);
            toolbarSearchEdit.setText(searchHistory.getHistory());
            startSearchResult();
        }
    });
    searchPresenter = new SearchPresenter(this, this);
    searchPresenter.showHistory(type);
    adapter.setOnItemLongClickListener(new SearchAdapter.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(View view, final int position, long itemId) {
            final CommonDialog commonDialog = new CommonDialog(context);
            commonDialog.setMessage("确定删除该条记录?").setPositiveButton("确认", new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    searchPresenter.deleteHistoryItem(searchHistoryList.get(position));
                    searchHistoryList.remove(position);
                    adapter.notifyItemRemoved(position);
                    commonDialog.dismiss();
                }
            }).setNegativeButton("取消", null).show();
            return true;
        }
    });
    toolbarSearchEdit.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if (i == KeyEvent.KEYCODE_ENTER && keyEvent.getAction() == KeyEvent.ACTION_UP) {
                KeyBoardUtils.hideSoftInput(context, getWindow());
                searchPresenter.addHistory(type, toolbarSearchEdit.getText().toString());
                startSearchResult();
                return true;
            }
            return false;
        }
    });
}
Also used : SearchAdapter(cn.nicolite.palm300heroes.view.adapter.SearchAdapter) SearchPresenter(cn.nicolite.palm300heroes.presenter.SearchPresenter) CommonDialog(cn.nicolite.palm300heroes.view.customView.CommonDialog) ISearchView(cn.nicolite.palm300heroes.view.iview.ISearchView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) KeyEvent(android.view.KeyEvent) GridLayoutManager(android.support.v7.widget.GridLayoutManager) SearchHistory(cn.nicolite.palm300heroes.model.bean.SearchHistory)

Example 2 with CommonDialog

use of cn.nicolite.palm300heroes.view.customView.CommonDialog in project Palm300Heroes by nicolite.

the class ThemeMusicFragment method doBusiness.

@Override
protected void doBusiness() {
    lRecyclerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.VERTICAL, false));
    lRecyclerViewAdapter = new LRecyclerViewAdapter(new ThemeMusicAdapter(context, dataList));
    lRecyclerView.setAdapter(lRecyclerViewAdapter);
    lRecyclerView.setLoadMoreEnabled(false);
    themeMusicPresenter = new ThemeMusicPresenter(this, this);
    lRecyclerView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            themeMusicPresenter.showThemeMusicList();
        }
    });
    lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            ThemeMusic.InfoBean.SoundsBean soundsBean = dataList.get(position);
            Intent intent = new Intent(context, WebViewActivity.class);
            Bundle bundle = new Bundle();
            bundle.putInt("type", WebViewActivity.TYPE_THEME_MUSIC);
            bundle.putString("url", Constants.MISSEVAN_MUSIC_DETIAL_URL + soundsBean.getId());
            bundle.putString("title", soundsBean.getSoundstr());
            intent.putExtras(bundle);
            startActivity(intent);
        }
    });
    lRecyclerViewAdapter.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public void onItemLongClick(View view, final int position) {
            final CommonDialog commonDialog = new CommonDialog(context);
            commonDialog.setMessage("确认下载?").setPositiveButton("确认", new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    commonDialog.dismiss();
                    ThemeMusic.InfoBean.SoundsBean soundsBean = dataList.get(position);
                    DownLoadUtils.downLoadManager(context, Constants.MISSEVAN_MUSIC_URL + soundsBean.getSoundurl(), "/P300Heroes/Sound", "audio/mpeg");
                }
            }).setNegativeButton("取消", null).show();
        }
    });
    if (isFirstVisible && ListUtils.isEmpty(dataList)) {
        lRecyclerView.forceToRefresh();
    }
}
Also used : OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) Bundle(android.os.Bundle) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) WebViewActivity(cn.nicolite.palm300heroes.view.activity.WebViewActivity) CommonDialog(cn.nicolite.palm300heroes.view.customView.CommonDialog) IThemeMusicView(cn.nicolite.palm300heroes.view.iview.IThemeMusicView) BindView(butterknife.BindView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) ThemeMusic(cn.nicolite.palm300heroes.model.bean.ThemeMusic) OnItemLongClickListener(com.github.jdsjlzx.interfaces.OnItemLongClickListener) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) ThemeMusicPresenter(cn.nicolite.palm300heroes.presenter.ThemeMusicPresenter) ThemeMusicAdapter(cn.nicolite.palm300heroes.view.adapter.ThemeMusicAdapter) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Example 3 with CommonDialog

use of cn.nicolite.palm300heroes.view.customView.CommonDialog in project Palm300Heroes by nicolite.

the class SearchActivity method onViewClicked.

@OnClick({ R.id.toolbar_back, R.id.bt_submit, R.id.delete })
public void onViewClicked(View view) {
    switch(view.getId()) {
        case R.id.toolbar_back:
            finish();
            break;
        case R.id.bt_submit:
            KeyBoardUtils.hideSoftInput(context, getWindow());
            searchPresenter.addHistory(type, toolbarSearchEdit.getText().toString());
            startSearchResult();
            break;
        case R.id.delete:
            final CommonDialog commonDialog = new CommonDialog(context);
            commonDialog.setMessage("确认删除全部历史记录?").setPositiveButton("确认", new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    searchPresenter.deleteHistory(type);
                    commonDialog.dismiss();
                }
            }).setNegativeButton("取消", null).show();
            break;
    }
}
Also used : CommonDialog(cn.nicolite.palm300heroes.view.customView.CommonDialog) ISearchView(cn.nicolite.palm300heroes.view.iview.ISearchView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) OnClick(butterknife.OnClick)

Aggregations

View (android.view.View)3 BindView (butterknife.BindView)3 CommonDialog (cn.nicolite.palm300heroes.view.customView.CommonDialog)3 RecyclerView (android.support.v7.widget.RecyclerView)2 ISearchView (cn.nicolite.palm300heroes.view.iview.ISearchView)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 KeyEvent (android.view.KeyEvent)1 OnClick (butterknife.OnClick)1 SearchHistory (cn.nicolite.palm300heroes.model.bean.SearchHistory)1 ThemeMusic (cn.nicolite.palm300heroes.model.bean.ThemeMusic)1 SearchPresenter (cn.nicolite.palm300heroes.presenter.SearchPresenter)1 ThemeMusicPresenter (cn.nicolite.palm300heroes.presenter.ThemeMusicPresenter)1 WebViewActivity (cn.nicolite.palm300heroes.view.activity.WebViewActivity)1 SearchAdapter (cn.nicolite.palm300heroes.view.adapter.SearchAdapter)1 ThemeMusicAdapter (cn.nicolite.palm300heroes.view.adapter.ThemeMusicAdapter)1 IThemeMusicView (cn.nicolite.palm300heroes.view.iview.IThemeMusicView)1 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)1