Search in sources :

Example 1 with OnLoadMoreListener

use of com.scwang.smart.refresh.layout.listener.OnLoadMoreListener in project wanandroid by KnightAndroid.

the class SquareFragment method initView.

@Override
protected void initView(Bundle savedInstanceState) {
    mDatabind.setClick(new ProcyClick());
    loadLoading(mDatabind.squareSharearticleFreshlayout);
    mHotKeyAdapter = new HotKeyAdapter(new ArrayList<SearchHotKeyEntity>());
    mSquareArticleAdapter = new SquareArticleAdapter(new ArrayList<SquareArticleEntity>());
    initListener();
    FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(getActivity());
    // 方向 主轴为水平方向,起点在左端
    flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
    // 左对齐
    flexboxLayoutManager.setJustifyContent(JustifyContent.FLEX_START);
    // flexboxLayoutManager.setAlignItems(AlignItems.CENTER);
    SetInitCustomView.initSwipeRecycleview(mDatabind.squareSearchhotRv, flexboxLayoutManager, mHotKeyAdapter, false);
    SetInitCustomView.initSwipeRecycleview(mDatabind.squareArticleRv, new LinearLayoutManager(getActivity()), mSquareArticleAdapter, true);
    mDatabind.squareSharearticleFreshlayout.setOnRefreshListener(this);
    mDatabind.squareSharearticleFreshlayout.setOnLoadMoreListener(this);
    EventBus.getDefault().register(this);
    View QuestionMenu = LayoutInflater.from(getActivity()).inflate(R.layout.square_question_activity, null);
    mSquareQuestionAdapter = new SquareQuestionAdapter(new ArrayList<>());
    initAdapterListener();
    baserecycleview = QuestionMenu.findViewById(R.id.base_body_rv);
    smartRefreshLayout = (SmartRefreshLayout) QuestionMenu.findViewById(R.id.include_square_question);
    tv_question_title = ((TextView) QuestionMenu.findViewById(R.id.square_question_tv_title));
    tv_question_title.setText(getString(R.string.square_question));
    smartRefreshLayout.setOnRefreshListener(refreshLayout -> {
        questionPage = 1;
        mPresenter.requestSquareQuestion(questionPage);
    });
    smartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
            mPresenter.requestSquareQuestion(questionPage);
        }
    });
    SetInitCustomView.initSwipeRecycleview(baserecycleview, new LinearLayoutManager(getActivity()), mSquareQuestionAdapter, true);
    mDatabind.squareRoot.addView(QuestionMenu);
    LoadSir loadSir = LoadSir.getDefault();
    mViewLoadService = loadSir.register(QuestionMenu.findViewById(R.id.include_square_question), new Callback.OnReloadListener() {

        @Override
        public void onReload(View v) {
            mViewLoadService.showCallback(LoadCallBack.class);
        }
    });
    mViewLoadService.showCallback(LoadCallBack.class);
    mRightLottieAnimation = new RightLottieAnimation.GuillotineBuilder(QuestionMenu, QuestionMenu.findViewById(R.id.square_question_lefticon), mDatabind.squareIvQuestion, mSquareQuestionAdapter).setStartDelay(RIPPLE_DURATION).setActionBarViewForAnimation(mDatabind.squareToolbar).setClosedOnStart(true).setGuillotineListener(new RightLottieListener() {

        @Override
        public void onRightLottieOpened() {
            mDatabind.squareFabUp.setVisibility(View.GONE);
            mViewLoadService.showCallback(LoadCallBack.class);
            mPresenter.requestSquareQuestion(questionPage);
        }

        @Override
        public void onRightLottieClosed() {
            questionPage = 1;
            mDatabind.squareFabUp.setVisibility(View.VISIBLE);
        }
    }).build();
}
Also used : OnLoadMoreListener(com.scwang.smart.refresh.layout.listener.OnLoadMoreListener) RightLottieListener(com.knight.wanandroid.library_widget.lottie.RightLottieListener) HotKeyAdapter(com.knight.wanandroid.module_square.module_adapter.HotKeyAdapter) SquareArticleAdapter(com.knight.wanandroid.module_square.module_adapter.SquareArticleAdapter) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) ArrayList(java.util.ArrayList) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) TextView(android.widget.TextView) SetInitCustomView(com.knight.wanandroid.library_widget.SetInitCustomView) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) SquareQuestionAdapter(com.knight.wanandroid.module_square.module_adapter.SquareQuestionAdapter) RefreshLayout(com.scwang.smart.refresh.layout.api.RefreshLayout) SmartRefreshLayout(com.scwang.smart.refresh.layout.SmartRefreshLayout) LoadCallBack(com.knight.wanandroid.library_base.loadsir.LoadCallBack) TextView(android.widget.TextView) LoadSir(com.kingja.loadsir.core.LoadSir)

Example 2 with OnLoadMoreListener

use of com.scwang.smart.refresh.layout.listener.OnLoadMoreListener in project iot-device-java by tencentyun.

the class TmeMainActivity method initView.

private void initView() {
    mGetSongBtn = findViewById(R.id.request_song);
    mSearchIv = findViewById(R.id.search);
    mPreIv = findViewById(R.id.iv_pre);
    mNextIv = findViewById(R.id.iv_next);
    mPlayIv = findViewById(R.id.iv_play);
    mPlayModeIv = findViewById(R.id.iv_play_mode);
    mInputEt = findViewById(R.id.input);
    mCurrentSongTv = findViewById(R.id.tv_current_song);
    mPlayList = findViewById(R.id.play_list);
    mSmartRefreshLayout = findViewById(R.id.smart_refreshLayout);
    mTimeTv = findViewById(R.id.tv_time);
    mSeekBar = findViewById(R.id.sb_seek_bar);
    mVolumeSeekBar = findViewById(R.id.sb_volume);
    mSwitch = findViewById(R.id.tb_switch);
    mSpinner = findViewById(R.id.sp_quality);
    mSmartRefreshLayout.setEnableLoadMore(true);
    mSmartRefreshLayout.setRefreshFooter(new ClassicsFooter(this));
    mGetSongBtn.setOnClickListener(this);
    mSearchIv.setOnClickListener(this);
    mPreIv.setOnClickListener(this);
    mNextIv.setOnClickListener(this);
    mPlayIv.setOnClickListener(this);
    mPlayModeIv.setOnClickListener(this);
    mPlayList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    mPlayList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    mAdapter = new SongListAdapter(this, mSongList);
    mAdapter.setOnItemClickListener(new SongListAdapter.ItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            Song song = mSongList.get(position);
            mCurrentSongTv.setText(song.songName + "-" + song.singerName);
            playSong(position);
        }
    });
    mPlayList.setAdapter(mAdapter);
    mSmartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(RefreshLayout refreshLayout) {
            refreshLayout.finishLoadMore();
            page++;
            if (operationType == TYPE_SEARCH) {
                doSearch(keyword);
            } else if (operationType == TYPE_SONG_LIST) {
                getSongListById(songListId, songListType);
            }
        }
    });
    mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                TXLog.d(TAG, "seek =" + seekValue);
                seekValue = progress;
                UltimateSongPlayer.getInstance().seekTo(seekValue * 1000);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            mIsSeekBarTouching = true;
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            if (seekValue >= 60) {
                SongInfo songInfo = UltimateSongPlayer.getInstance().getSongInfo();
                if (songInfo != null && songInfo.isTryListen()) {
                    TmeMainActivity.this.runOnUiThread(() -> ToastUtil.showS("当前歌曲只支持试听60秒~"));
                }
            }
            UltimateSongPlayer.getInstance().seekTo(seekValue * 1000);
            mIsSeekBarTouching = false;
            reportProperty(Common.PROPERTY_PLAY_POSITION, seekValue);
        }
    });
    mVolumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                TXLog.d(TAG, "seek =" + volumeSeekValue);
                volumeSeekValue = progress;
                mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_PLAY_SOUND);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            int volume = (int) ((volumeSeekValue / (maxVolume * 1.00)) * Common.TOTOAL_VOLUME_DURATION);
            reportProperty(Common.PROPERTY_VOLUME, volume);
        }
    });
    mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                if (mDataTemplateSample != null)
                    return;
                mDataTemplateSample = new TmeDataTemplateSample(TmeMainActivity.this, mBrokerURL, mProductID, mDevName, mDevPSK, new SelfMqttActionCallBack(mProductID, mDevName), JSON_FILE_NAME, new SelfDownStreamCallBack(), mAuthCallback);
                mDataTemplateSample.connect();
            } else {
                if (mDataTemplateSample == null)
                    return;
                mDataTemplateSample.disconnect();
                mDataTemplateSample = null;
            }
        }
    });
    mSpinner.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, qualityStrArray));
    mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (isGetStatusReply) {
                UltimateSongPlayer.getInstance().changeQuality(qualities[position]);
                isGetStatusReply = false;
            } else {
                if (UltimateSongPlayer.getInstance().getCurrentPlayQuality() == qualities[position]) {
                    return;
                }
                // 当前歌曲详情
                SongInfo songInfo = UltimateSongPlayer.getInstance().getSongInfo();
                if (songInfo == null) {
                    ToastUtil.showS("无法切换音质");
                    parent.setSelection(0);
                    return;
                }
                if (songInfo.isTryListen()) {
                    ToastUtil.showS("试听中,无法切换音质");
                    parent.setSelection(0);
                    return;
                }
                if (songInfo.getSupportQualities().contains(qualities[position])) {
                    UltimateSongPlayer.getInstance().changeQuality(qualities[position]);
                    reportProperty(Common.PROPERTY_RECOMMEND_QUALITY, position);
                } else {
                    parent.setSelection(0);
                    ToastUtil.showS(String.format("当前歌曲不支持%s音质", qualityStrArray[position]));
                }
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : OnLoadMoreListener(com.scwang.smart.refresh.layout.listener.OnLoadMoreListener) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ClassicsFooter(com.scwang.smart.refresh.footer.ClassicsFooter) Song(com.kugou.ultimatetv.entity.Song) RefreshLayout(com.scwang.smart.refresh.layout.api.RefreshLayout) SmartRefreshLayout(com.scwang.smart.refresh.layout.SmartRefreshLayout) SongListAdapter(com.tencent.iot.explorer.device.tme.adapter.SongListAdapter) SongInfo(com.kugou.ultimatetv.entity.SongInfo) TmeDataTemplateSample(com.tencent.iot.explorer.device.tme.data_template.TmeDataTemplateSample) SeekBar(android.widget.SeekBar) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton)

Example 3 with OnLoadMoreListener

use of com.scwang.smart.refresh.layout.listener.OnLoadMoreListener in project ManPinAPP by AnyMarvel.

the class BookRRecommendFImpl method notifyRecyclerView.

@Override
public void notifyRecyclerView(List<SourceListContent> recommendList, List<SourceListContent> hotRankingList, List<SourceListContent> contentList, boolean useCache) {
    if (useCache || recommendRecyclerAdapter == null) {
        recommendRecyclerAdapter = new BookRRecommendFRecyclerAdapter(getContext(), this, recommendList, hotRankingList, contentList);
        recommendRecyclerView.setAdapter(recommendRecyclerAdapter);
    } else {
        recommendRecyclerAdapter.setRecommendList(recommendList);
        recommendRecyclerAdapter.setHotRankingList(hotRankingList);
        recommendRecyclerAdapter.setContentList(contentList);
        recommendRecyclerAdapter.notifyDataSetChanged();
    }
    bookRrefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
            mPresenter.getNextPageContent(recommendRecyclerAdapter.getmContentListPage() + 1);
        }
    });
    bookRrefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(@NonNull RefreshLayout refreshLayout) {
            mPresenter.initBookRRcommendData();
        }
    });
    bookRrefreshLayout.finishRefresh();
}
Also used : OnLoadMoreListener(com.scwang.smart.refresh.layout.listener.OnLoadMoreListener) RefreshLayout(com.scwang.smart.refresh.layout.api.RefreshLayout) SmartRefreshLayout(com.scwang.smart.refresh.layout.SmartRefreshLayout) BookRRecommendFRecyclerAdapter(com.mp.android.apps.main.bookR.adapter.BookRRecommendFRecyclerAdapter) OnRefreshListener(com.scwang.smart.refresh.layout.listener.OnRefreshListener)

Example 4 with OnLoadMoreListener

use of com.scwang.smart.refresh.layout.listener.OnLoadMoreListener in project ManPinAPP by AnyMarvel.

the class BookRankListActivity method bindEvent.

@Override
protected void bindEvent() {
    super.bindEvent();
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    layoutManager.setOrientation(RecyclerView.VERTICAL);
    recommendRecyclerView.setLayoutManager(layoutManager);
    recommendRecyclerView.setItemAnimator(new DefaultItemAnimator());
    bookRrefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
            if (bookRankListAdapter != null) {
                mPresenter.getNextPageContent(bookRankUrl, bookRankListAdapter.getPageNumber() + 1);
            }
        }
    });
    bookRrefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(@NonNull RefreshLayout refreshLayout) {
            mPresenter.initBookRankListData(bookRankUrl);
        }
    });
}
Also used : OnLoadMoreListener(com.scwang.smart.refresh.layout.listener.OnLoadMoreListener) RefreshLayout(com.scwang.smart.refresh.layout.api.RefreshLayout) SmartRefreshLayout(com.scwang.smart.refresh.layout.SmartRefreshLayout) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) OnRefreshListener(com.scwang.smart.refresh.layout.listener.OnRefreshListener)

Aggregations

SmartRefreshLayout (com.scwang.smart.refresh.layout.SmartRefreshLayout)4 RefreshLayout (com.scwang.smart.refresh.layout.api.RefreshLayout)4 OnLoadMoreListener (com.scwang.smart.refresh.layout.listener.OnLoadMoreListener)4 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)3 View (android.view.View)2 TextView (android.widget.TextView)2 OnRefreshListener (com.scwang.smart.refresh.layout.listener.OnRefreshListener)2 AdapterView (android.widget.AdapterView)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 SeekBar (android.widget.SeekBar)1 DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)1 DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 FlexboxLayoutManager (com.google.android.flexbox.FlexboxLayoutManager)1 LoadSir (com.kingja.loadsir.core.LoadSir)1 LoadCallBack (com.knight.wanandroid.library_base.loadsir.LoadCallBack)1 SetInitCustomView (com.knight.wanandroid.library_widget.SetInitCustomView)1 RightLottieListener (com.knight.wanandroid.library_widget.lottie.RightLottieListener)1 HotKeyAdapter (com.knight.wanandroid.module_square.module_adapter.HotKeyAdapter)1