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;
}
});
}
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();
}
}
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;
}
}
Aggregations