Search in sources :

Example 1 with LRecyclerViewAdapter

use of com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter in project Palm300Heroes by nicolite.

the class FightSkillActivity method doBusiness.

@Override
protected void doBusiness() {
    toolbarTitle.setText("战斗技能");
    setSupportActionBar(toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            finish();
        }
    });
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
    }
    lRecyclerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.VERTICAL, false));
    lRecyclerViewAdapter = new LRecyclerViewAdapter(new FightSkillAdapter(context, dataList));
    lRecyclerView.setAdapter(lRecyclerViewAdapter);
    lRecyclerView.addItemDecoration(new DividerItemDecoration(context, OrientationHelper.VERTICAL));
    lRecyclerView.setLoadMoreEnabled(false);
    fightSkillPresenter = new FightSkillPresenter(this, this);
    lRecyclerView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            fightSkillPresenter.showFightSkill(true);
        }
    });
    lRecyclerView.setOnNetWorkErrorListener(new OnNetWorkErrorListener() {

        @Override
        public void reload() {
            fightSkillPresenter.showFightSkill(true);
        }
    });
    fightSkillPresenter.showFightSkill(false);
}
Also used : OnNetWorkErrorListener(com.github.jdsjlzx.interfaces.OnNetWorkErrorListener) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) FightSkillPresenter(cn.nicolite.palm300heroes.presenter.FightSkillPresenter) FightSkillAdapter(cn.nicolite.palm300heroes.view.adapter.FightSkillAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) IFightSkillView(cn.nicolite.palm300heroes.view.iview.IFightSkillView) BindView(butterknife.BindView) TextView(android.widget.TextView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Example 2 with LRecyclerViewAdapter

use of com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter in project Palm300Heroes by nicolite.

the class HostRankFragment method doBusiness.

@Override
protected void doBusiness() {
    lRecyclerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.VERTICAL, false));
    lRecyclerViewAdapter = new LRecyclerViewAdapter(new HostRankAdapter(context, dataList));
    lRecyclerView.setAdapter(lRecyclerViewAdapter);
    if (type == TYPE_RANK_TITLE) {
        lRecyclerView.setLoadMoreEnabled(false);
    }
    hostRankPresenter = new HostRankPresenter(this, this);
    lRecyclerView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            switch(type) {
                case TYPE_RANK_TITLE:
                    hostRankPresenter.showRankTitle();
                    break;
                case TYPE_RANK_LIST:
                    hostRankPresenter.showRankList(index);
                    break;
            }
        }
    });
    lRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            switch(type) {
                case TYPE_RANK_TITLE:
                    break;
                case TYPE_RANK_LIST:
                    currentPage++;
                    hostRankPresenter.loadMore(index, currentPage);
                    break;
            }
        }
    });
    lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            RecordRank.RankBean.ListBean list = dataList.get(position);
            switch(type) {
                case TYPE_RANK_TITLE:
                    Bundle bundle = new Bundle();
                    bundle.putInt("type", ContainerActivity.TYPE_RECORD_RANK_LIST);
                    bundle.putString("title", list.getName());
                    bundle.putString("extra", String.valueOf(list.getIndex()));
                    startActivity(ContainerActivity.class, bundle);
                    break;
                case TYPE_RANK_LIST:
                    break;
            }
        }
    });
    if (isFirstVisible && ListUtils.isEmpty(dataList)) {
        lRecyclerView.forceToRefresh();
    }
}
Also used : OnLoadMoreListener(com.github.jdsjlzx.interfaces.OnLoadMoreListener) HostRankAdapter(cn.nicolite.palm300heroes.view.adapter.HostRankAdapter) RecordRank(cn.nicolite.palm300heroes.model.bean.RecordRank) OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) HostRankPresenter(cn.nicolite.palm300heroes.presenter.HostRankPresenter) Bundle(android.os.Bundle) ContainerActivity(cn.nicolite.palm300heroes.view.activity.ContainerActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) TextView(android.widget.TextView) IHostRankView(cn.nicolite.palm300heroes.view.iview.IHostRankView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Example 3 with LRecyclerViewAdapter

use of com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter 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 4 with LRecyclerViewAdapter

use of com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter in project Palm300Heroes by nicolite.

the class HeroSkillFragment method doBusiness.

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

        @Override
        public void onRefresh() {
            heroSkillPresenter.showSkill(unCode, true);
        }
    });
}
Also used : LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) HeroSkillPresenter(cn.nicolite.palm300heroes.presenter.HeroSkillPresenter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener) SkillAdapter(cn.nicolite.palm300heroes.view.adapter.SkillAdapter)

Example 5 with LRecyclerViewAdapter

use of com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter in project Palm300Heroes by nicolite.

the class HeroSoundFragment method doBusiness.

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

        @Override
        public void onRefresh() {
            heroSoundPresenter.showSound(unCode, true);
        }
    });
    soundAdapter.setOnItemClickListener(new SoundAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View view, final SoundAdapter.SoundViewHolder viewHolder, int position, List<Sound> soundList) {
            String url = Constants.HERO_SOUND_URL + Uri.encode(soundList.get(position).getUrl());
            if (mediaPlayer == null) {
                mediaPlayer = new MediaPlayer();
            }
            if (oldViewHolder != null && !oldViewHolder.equals(viewHolder)) {
                oldViewHolder.getPlaySound().setImageResource(R.drawable.ic_media_play);
            }
            oldViewHolder = viewHolder;
            try {
                if (dataList.get(position).getUrl().equals(soundList.get(position).getUrl())) {
                    viewHolder.getPlaySound().setImageResource(R.drawable.ic_media_pause);
                }
                mediaPlayer.reset();
                mediaPlayer.setDataSource(url);
                mediaPlayer.setAudioStreamType(STREAM_MUSIC);
                mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

                    @Override
                    public void onPrepared(MediaPlayer mp) {
                        mp.start();
                    }
                });
                mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

                    @Override
                    public void onCompletion(MediaPlayer mp) {
                        viewHolder.getPlaySound().setImageResource(R.drawable.ic_media_play);
                        mp.stop();
                        mp.reset();
                    }
                });
                mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {

                    @Override
                    public boolean onError(MediaPlayer mp, int what, int extra) {
                        viewHolder.getPlaySound().setImageResource(R.drawable.ic_media_play);
                        mp.stop();
                        mp.reset();
                        mp.release();
                        mediaPlayer = null;
                        Toast.makeText(getActivity(), "播放失败", Toast.LENGTH_SHORT).show();
                        return true;
                    }
                });
                mediaPlayer.prepareAsync();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : Sound(cn.nicolite.palm300heroes.model.bean.Sound) IOException(java.io.IOException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) IHeroSoundView(cn.nicolite.palm300heroes.view.iview.IHeroSoundView) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) HeroSoundPresenter(cn.nicolite.palm300heroes.presenter.HeroSoundPresenter) SoundAdapter(cn.nicolite.palm300heroes.view.oldAdapter.SoundAdapter) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener) MediaPlayer(android.media.MediaPlayer)

Aggregations

OnRefreshListener (com.github.jdsjlzx.interfaces.OnRefreshListener)13 LRecyclerViewAdapter (com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter)13 View (android.view.View)11 BindView (butterknife.BindView)11 LRecyclerView (com.github.jdsjlzx.recyclerview.LRecyclerView)11 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)10 Bundle (android.os.Bundle)9 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)8 OnNetWorkErrorListener (com.github.jdsjlzx.interfaces.OnNetWorkErrorListener)6 WebViewActivity (cn.nicolite.palm300heroes.view.activity.WebViewActivity)5 OnLoadMoreListener (com.github.jdsjlzx.interfaces.OnLoadMoreListener)5 TextView (android.widget.TextView)4 GridLayoutManager (android.support.v7.widget.GridLayoutManager)3 ActionBar (android.support.v7.app.ActionBar)2 ImageView (android.widget.ImageView)2 BGABanner (cn.bingoogolapple.bgabanner.BGABanner)2 News (cn.nicolite.palm300heroes.model.bean.News)2 ContainerActivity (cn.nicolite.palm300heroes.view.activity.ContainerActivity)2 NativeExpressADView (com.qq.e.ads.nativ.NativeExpressADView)2 Intent (android.content.Intent)1