十大信誉网赌博

帮助与文档
热搜关键词:十大信誉网赌博短视频源码一对一
Android直播APP源码中排行榜功能如何实现
发布来源:十大信誉网赌博    发布人:十大信誉网赌博    Date:2021-01-15 10:10:03

刚进企业的时候,听技术人员说起直播APP源码中的“排行榜”功能,小编最先想到的是学生时期的成绩排行,上榜的沾沾自喜到下次考试,下榜的哭哭啼啼,其实就算上榜也并没有什么实质性的奖励,且上榜的第十名和下榜的第十一名,区别也不大,但大家还是尽量争夺使自己“榜上有名”,以满足心理需求。

在直播APP中,排行榜对于“土豪”的作用同样是满足其心理需求,刺激用户打赏上榜而设置的,对于主播而言,则有增加知名度的用处,为主播接广告等流量变现活动做参考。

本文主要讲述,如何在Android端直播APP源码中实现排行榜功能,如下图所示,在云豹直播app十大信誉网赌博上有收益榜和贡献榜两个按钮,点击即可分别进入对应的排行榜列表页面。


 直播APP源码直播APP源码


无论是进入收益榜还是贡献榜,均可以再次(双向)切换到另一列表。收益榜列表顶部显示前三名收益最高的主播,贡献榜顶部显示了消费最多的三个用户。下面的用户按收益和消费倒序排列。点击头像可进入个人主页,点击关注可以关注对应的用户。

部分直播app源码如下:


public class RankActivity extends AbsActivity {
 
    public static void forward(Context context, int position) {
        Intent intent = new Intent(context, RankActivity.class);
        intent.putExtra(Constants.LIVE_POSITION, position);
        context.startActivity(intent);
    }
 
    @Override
    protected boolean isStatusBarWhite() {
        return true;
    }
 
    @Override
    protected int getLayoutId() {
        return R.layout.activity_rank;
    }
 
    @Override
    protected void main() {
        int position = getIntent().getIntExtra(Constants.LIVE_POSITION, 0);
        MainListViewHolder viewHolder = new MainListViewHolder(mContext, (ViewGroup) findViewById(R.id.container));
        viewHolder.addToParent();
        viewHolder.subscribeActivityLifeCycle();
        viewHolder.loadData(position);
    }
}
public class MainListViewHolder extends AbsMainViewHolder {
 
    private static final int PAGE_COUNT = 2;
    private List<FrameLayout> mViewList;
    private AbsMainListChildViewHolder[] mViewHolders;
    private MainListProfitViewHolder mProfitViewHolder;//收益榜
    private MainListContributeViewHolder mContributeViewHolder;//贡献榜
    private MagicIndicator mIndicator;
    private ViewPager mViewPager;
 
    public MainListViewHolder(Context context, ViewGroup parentView) {
        super(context, parentView);
    }
 
    @Override
    protected int getLayoutId() {
        return R.layout.view_main_list;
    }
 
    @Override
    public void init() {
        mViewList = new ArrayList<>();
        for (int i = 0; i < PAGE_COUNT; i++) {
            FrameLayout frameLayout = new FrameLayout(mContext);
            frameLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            mViewList.add(frameLayout);
        }
        mViewHolders = new AbsMainListChildViewHolder[PAGE_COUNT];
        mViewPager = (ViewPager) findViewById(R.id.viewPager);
        mViewPager.setOffscreenPageLimit(PAGE_COUNT - 1);
        mViewPager.setAdapter(new ViewPagerAdapter(mViewList));
        mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
 
            }
 
            @Override
            public void onPageSelected(int position) {
                loadPageData(position);
            }
 
            @Override
            public void onPageScrollStateChanged(int state) {
 
            }
        });
        mIndicator = (MagicIndicator) findViewById(R.id.indicator);
        final String[] titles = new String[]{
                WordUtil.getString(R.string.main_list_profit),
                WordUtil.getString(R.string.main_list_contribute)
        };
        CommonNavigator commonNavigator = new CommonNavigator(mContext);
        commonNavigator.setAdapter(new CommonNavigatorAdapter() {
 
            @Override
            public int getCount() {
                return titles.length;
            }
 
            @Override
            public IPagerTitleView getTitleView(Context context, final int index) {
                SimplePagerTitleView simplePagerTitleView = new ColorTransitionPagerTitleView(context);
                simplePagerTitleView.setNormalColor(0xccffffff);
                simplePagerTitleView.setSelectedColor(ContextCompat.getColor(mContext, R.color.white));
                simplePagerTitleView.setText(titles[index]);
                simplePagerTitleView.setTextSize(18);
                simplePagerTitleView.getPaint().setFakeBoldText(true);
                simplePagerTitleView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (mViewPager != null) {
                            mViewPager.setCurrentItem(index);
                        }
                    }
                });
                return simplePagerTitleView;
            }
 
            @Override
            public IPagerIndicator getIndicator(Context context) {
                LinePagerIndicator linePagerIndicator = new LinePagerIndicator(context);
                linePagerIndicator.setMode(LinePagerIndicator.MODE_WRAP_CONTENT);
                linePagerIndicator.setXOffset(DpUtil.dp2px(13));
                linePagerIndicator.setRoundRadius(DpUtil.dp2px(2));
                linePagerIndicator.setColors(ContextCompat.getColor(mContext, R.color.white));
                return linePagerIndicator;
            }
        });
        mIndicator.setNavigator(commonNavigator);
        ViewPagerHelper.bind(mIndicator, mViewPager);
        EventBus.getDefault().register(MainListViewHolder.this);
    }
 
    private void loadPageData(int position) {
        if (mViewHolders == null) {
            return;
        }
        AbsMainListChildViewHolder vh = mViewHolders[position];
        if (vh == null) {
            if (mViewList != null && position < mViewList.size()) {
                FrameLayout parent = mViewList.get(position);
                if (parent == null) {
                    return;
                }
                if (position == 0) {
                    mProfitViewHolder = new MainListProfitViewHolder(mContext, parent);
                    vh = mProfitViewHolder;
                } else if (position == 1) {
                    mContributeViewHolder = new MainListContributeViewHolder(mContext, parent);
                    vh = mContributeViewHolder;
                }
                if (vh == null) {
                    return;
                }
                mViewHolders[position] = vh;
                vh.addToParent();
                vh.subscribeActivityLifeCycle();
            }
        }
        if (vh != null) {
            vh.loadData();
        }
    }
 
    public void loadData(int position) {
        if (mViewPager != null) {
            int curPosition = mViewPager.getCurrentItem();
            if (curPosition == position) {
                loadPageData(curPosition);
            } else {
                mViewPager.setCurrentItem(position);
            }
        }
    }
 
 
    @Override
    public void loadData() {
        if (mViewPager != null) {
            loadPageData(mViewPager.getCurrentItem());
        }
    }
 
 
    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(MainListViewHolder.this);
    }
 
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onFollowEvent(FollowEvent e) {
        if (mViewHolders != null) {
            for (AbsMainListChildViewHolder vh : mViewHolders) {
                if (vh != null) {
                    vh.onFollowEvent(e.getToUid(), e.getIsAttention());
                }
            }
        }
    }
 
}
public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder implements OnItemClickListener<ListBean>, View.OnClickListener {
 
    public static final String DAY = "day";
    public static final String WEEK = "week";
    public static final String MONTH = "month";
    public static final String TOTAL = "total";
    protected String mType;
    protected CommonRefreshView mRefreshView;
    protected MainListAdapter mAdapter;
 
    public AbsMainListChildViewHolder(Context context, ViewGroup parentView) {
        super(context, parentView);
        mType = DAY;
    }
 
    @Override
    protected int getLayoutId() {
        return R.layout.view_main_list_page;
    }
 
    @Override
    public void init() {
        mRefreshView = (CommonRefreshView) findViewById(R.id.refreshView);
        mRefreshView.setEmptyLayoutId(R.layout.view_no_data_list);
        mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        findViewById(R.id.btn_day).setOnClickListener(this);
        findViewById(R.id.btn_week).setOnClickListener(this);
        findViewById(R.id.btn_month).setOnClickListener(this);
        findViewById(R.id.btn_total).setOnClickListener(this);
    }
 
    @Override
    public void loadData() {
        if (!isFirstLoadData()) {
            return;
        }
        if (mRefreshView != null) {
            mRefreshView.initData();
        }
    }
 
    @Override
    public void onDestroy() {
        super.onDestroy();
        CommonHttpUtil.cancel(CommonHttpConsts.SET_ATTENTION);
    }
 
    public void onFollowEvent(String touid, int isAttention) {
        if (mAdapter != null) {
            mAdapter.updateItem(touid, isAttention);
        }
    }
 
    @Override
    public void onItemClick(ListBean bean, int position) {
        RouteUtil.forwardUserHome(mContext, bean.getUid());
    }
 
    @Override
    public void onClick(View v) {
        int i = v.getId();
        String type = null;
        if (i == R.id.btn_day) {
            type = DAY;
        } else if (i == R.id.btn_week) {
            type = WEEK;
        } else if (i == R.id.btn_month) {
            type = MONTH;
        } else if (i == R.id.btn_total) {
            type = TOTAL;
        }
        if (!TextUtils.isEmpty(type) && !type.equals(mType)) {
            mType = type;
            if (mRefreshView != null) {
                mRefreshView.initData();
            }
        }
    }
 
}
/**
* 十大信誉网赌博 排行 收益榜
 */
public class MainListProfitViewHolder extends AbsMainListChildViewHolder {
 
    public MainListProfitViewHolder(Context context, ViewGroup parentView) {
        super(context, parentView);
    }
 
    @Override
    public void init() {
        super.init();
        mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<ListBean>() {
            @Override
            public RefreshAdapter<ListBean> getAdapter() {
                if (mAdapter == null) {
                    mAdapter = new MainListAdapter(mContext, MainListAdapter.TYPE_PROFIT);
                    mAdapter.setOnItemClickListener(MainListProfitViewHolder.this);
                }
                return mAdapter;
            }
 
            @Override
            public void loadData(int p, HttpCallback callback) {
                if(!mType.isEmpty()){
                    MainHttpUtil.profitList(mType, p, callback);
                }
            }
 
            @Override
            public List<ListBean> processData(String[] info) {
                return JSON.parseArray(Arrays.toString(info), ListBean.class);
            }
 
            @Override
            public void onRefreshSuccess(List<ListBean> list, int listCount) {
 
            }
 
            @Override
            public void onRefreshFailure() {
 
            }
 
            @Override
            public void onLoadMoreSuccess(List<ListBean> loadItemList, int loadItemCount) {
 
            }
 
            @Override
            public void onLoadMoreFailure() {
 
            }
        });
    }
 
    @Override
    public void onDestroy() {
        super.onDestroy();
        MainHttpUtil.cancel(MainHttpConsts.PROFIT_LIST);
    }
 
 
}
/**
* 十大信誉网赌博 排行 贡献榜
 */
public class MainListContributeViewHolder extends AbsMainListChildViewHolder {
 
    public MainListContributeViewHolder(Context context, ViewGroup parentView) {
        super(context, parentView);
    }
 
    @Override
    public void init() {
        super.init();
        mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<ListBean>() {
            @Override
            public RefreshAdapter<ListBean> getAdapter() {
                if (mAdapter == null) {
                    mAdapter = new MainListAdapter(mContext, MainListAdapter.TYPE_CONTRIBUTE);
                    mAdapter.setOnItemClickListener(MainListContributeViewHolder.this);
                }
                return mAdapter;
            }
 
            @Override
            public void loadData(int p, HttpCallback callback) {
                if (!mType.isEmpty()) {
                    MainHttpUtil.consumeList(mType, p, callback);
                }
            }
 
            @Override
            public List<ListBean> processData(String[] info) {
                return JSON.parseArray(Arrays.toString(info), ListBean.class);
            }
 
            @Override
            public void onRefreshSuccess(List<ListBean> list, int listCount) {
 
            }
 
            @Override
            public void onRefreshFailure() {
 
            }
 
            @Override
            public void onLoadMoreSuccess(List<ListBean> loadItemList, int loadItemCount) {
 
            }
 
            @Override
            public void onLoadMoreFailure() {
 
            }
        });
    }
 
    @Override
    public void onDestroy() {
        super.onDestroy();
        MainHttpUtil.cancel(MainHttpConsts.CONSUME_LIST);
    }
 
}


以上便是本文《Android直播APP源码中排行榜功能如何实现》的全部内容,除排行榜功能外,还有云豹直播app源码中还有很多功能用于促进用户打赏,推进平台盈利,具体内容会在以后逐步放出,敬请期待。

声明:以上内容由十大信誉网赌博原创,未经企业同意,禁止转载,否则将追究相关法律责任www.yunbaokj.com

本文标签: 直播APP源码
相关阅读
XML 地图 | Sitemap 地图