Search in sources :

Example 1 with LikeBean

use of com.xxx.ency.model.bean.LikeBean in project Ency by xiarunhao123.

the class EyepetizerDetailActivity method onImgVideoCollectionClick.

@OnClick(R.id.img_video_collection)
public void onImgVideoCollectionClick() {
    if (isLiked) {
        imgVideoCollection.setImageResource(R.drawable.icon_uncollect);
        txtVideoCollection.setText("收藏");
        daoManager.deleteByGuid(videoBean.getHeader().getId() + "");
        isLiked = false;
        SnackBarUtils.show(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0), "成功从收藏中移除");
    } else {
        imgVideoCollection.setImageResource(R.drawable.icon_collect);
        txtVideoCollection.setText("已收藏");
        LikeBean bean = new LikeBean();
        bean.setId(null);
        bean.setGuid(videoBean.getHeader().getId() + "");
        bean.setImageUrl(videoBean.getContent().getData().getCover().getDetail());
        bean.setTitle(videoBean.getContent().getData().getTitle());
        bean.setUrl(videoBean.getContent().getData().getPlayUrl());
        bean.setType(Constants.TYPE_VIDEO);
        bean.setTime(System.currentTimeMillis());
        daoManager.insert(bean);
        isLiked = true;
        SnackBarUtils.show(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0), "成功添加到收藏");
    }
}
Also used : LikeBean(com.xxx.ency.model.bean.LikeBean) OnClick(butterknife.OnClick)

Example 2 with LikeBean

use of com.xxx.ency.model.bean.LikeBean in project Ency by xiarunhao123.

the class LikeFragment method initialize.

@Override
protected void initialize() {
    daoManager = EncyApplication.getAppComponent().getGreenDaoManager();
    likeAdapter = new LikeAdapter();
    likeAdapter.setNewData(daoManager.queryAll());
    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
    recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
    recyclerView.setAdapter(likeAdapter);
    likeAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            LikeBean bean = (LikeBean) adapter.getData().get(position);
            if (bean.getType() == Constants.TYPE_VIDEO) {
                JZVideoPlayer.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
                JZVideoPlayer.NORMAL_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
                JZVideoPlayerStandard.startFullscreen(mContext, JZVideoPlayerStandard.class, bean.getUrl(), bean.getTitle());
            } else {
                WebActivity.open(new WebActivity.Builder().setGuid(bean.getUrl()).setImgUrl(bean.getImageUrl()).setType(bean.getType()).setUrl(bean.getUrl()).setTitle(bean.getTitle()).setShowLikeIcon(true).setContext(mContext));
            }
        }
    });
    likeAdapter.setOnItemLongClickListener(new BaseQuickAdapter.OnItemLongClickListener() {

        @SuppressLint("ResourceAsColor")
        @Override
        public boolean onItemLongClick(BaseQuickAdapter adapter, View view, final int position) {
            final LikeBean bean = (LikeBean) adapter.getData().get(position);
            new MaterialDialog.Builder(mContext).content("确认要删除该收藏吗?").negativeText("取消").negativeColorRes(R.color.colorNegative).positiveText("确定").positiveColorRes(R.color.colorPositive).onPositive(new MaterialDialog.SingleButtonCallback() {

                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                    daoManager.delete(bean);
                    likeAdapter.remove(position);
                }
            }).show();
            return true;
        }
    });
    likeAdapter.setEmptyView(R.layout.view_empty, recyclerView);
}
Also used : LikeAdapter(com.xxx.ency.view.like.adapter.LikeAdapter) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) JZVideoPlayerStandard(cn.jzvd.JZVideoPlayerStandard) WebActivity(com.xxx.ency.view.web.WebActivity) LikeBean(com.xxx.ency.model.bean.LikeBean) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) DialogAction(com.afollestad.materialdialogs.DialogAction) SuppressLint(android.annotation.SuppressLint)

Example 3 with LikeBean

use of com.xxx.ency.model.bean.LikeBean in project Ency by xiarunhao123.

the class WebActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.item_like:
            if (isLiked) {
                item.setIcon(R.drawable.ic_notlike);
                daoManager.deleteByGuid(guid);
                isLiked = false;
                SnackBarUtils.show(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0), "成功从收藏中移除");
            } else {
                item.setIcon(R.drawable.ic_like);
                LikeBean bean = new LikeBean();
                bean.setId(null);
                bean.setGuid(guid);
                bean.setImageUrl(imageUrl);
                bean.setTitle(title);
                bean.setUrl(url);
                bean.setType(type);
                bean.setTime(System.currentTimeMillis());
                daoManager.insert(bean);
                isLiked = true;
                SnackBarUtils.show(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0), "成功添加到收藏");
            }
            break;
        case R.id.item_copy:
            ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            cm.setText(url);
            SnackBarUtils.show(webView, R.string.copy_msg, this);
            break;
        case R.id.item_browser:
            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
            break;
    }
    return super.onOptionsItemSelected(item);
}
Also used : ClipboardManager(android.text.ClipboardManager) Intent(android.content.Intent) LikeBean(com.xxx.ency.model.bean.LikeBean) Uri(android.net.Uri)

Aggregations

LikeBean (com.xxx.ency.model.bean.LikeBean)3 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ClipboardManager (android.text.ClipboardManager)1 View (android.view.View)1 BindView (butterknife.BindView)1 OnClick (butterknife.OnClick)1 JZVideoPlayerStandard (cn.jzvd.JZVideoPlayerStandard)1 DialogAction (com.afollestad.materialdialogs.DialogAction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 LikeAdapter (com.xxx.ency.view.like.adapter.LikeAdapter)1 WebActivity (com.xxx.ency.view.web.WebActivity)1