CarGuo / GSYVideoPlayer

视频播放器(IJKplayer、ExoPlayer、MediaPlayer),HTTPS,支持弹幕,外挂字幕,支持滤镜、水印、gif截图,片头广告、中间广告,多个同时播放,支持基本的拖动,声音、亮度调节,支持边播边缓存,支持视频自带rotation的旋转(90,270之类),重力旋转与手动旋转的同步支持,支持列表播放 ,列表全屏动画,视频加载速度,列表小窗口支持拖动,动画效果,调整比例,多分辨率切换,支持切换播放器,进度条小窗口预览,列表切换详情页面无缝播放,rtsp、concat、mpeg。
https://juejin.im/user/582aca2ba22b9d006b59ae68/posts
Apache License 2.0
19.91k stars 4.17k forks source link

大佬,刚刚以为解决了,没想到还是有点问题,请大佬再指点一下 #906

Closed DavaLc closed 6 years ago

DavaLc commented 6 years ago

大佬,如果只有一个fragment ,像demo里那么写没有问题。 但是多个fragment 还是会出现刚刚的报错。 Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.internal.view.ContextThemeWrapper"

我是这么添加的fragment

/**

//设置底部导航栏的改变 private void setBottomView(int i) { rljIv.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.tab_chat_2)); rljTv.setTextColor(ContextCompat.getColor(this, R.color.color_888888)); ysmIv.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.tab_fans_2)); ysmTv.setTextColor(ContextCompat.getColor(this, R.color.color_888888)); xsIv.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.tab_news_2)); xsTv.setTextColor(ContextCompat.getColor(this, R.color.color_888888)); myIv.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.tab_user_2)); myTv.setTextColor(ContextCompat.getColor(this, R.color.color_888888));

if (i == 0) {
    rljIv.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.tab_chat_1));
    rljTv.setTextColor(ContextCompat.getColor(this, R.color.color_f06868));
} else if (i == 1) {
    if (mainLll.getVisibility()== View.GONE){
        showFooter();
    }
    ysmIv.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.tab_fans_1));
    ysmTv.setTextColor(ContextCompat.getColor(this, R.color.color_f06868));
} else if (i == 2) {
    if (mainLll.getVisibility()==View.GONE){
        showFooter();
    }
    xsIv.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.tab_news_1));
    xsTv.setTextColor(ContextCompat.getColor(this, R.color.color_f06868));
} else if (i == 3) {
    if (mainLll.getVisibility()==View.GONE){
        showFooter();
    }
    myIv.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.tab_user_1));
    myTv.setTextColor(ContextCompat.getColor(this, R.color.color_f06868));
}

showFragment(i);

} private int lastPosition = -1;//最后选择的位置 private int curIndex = -1;// 当前选中的左侧菜单的下标 //展示fragment public void showFragment(int index){ if(index == lastPosition) return; FragmentManager fm = getSupportFragmentManager(); FragmentTransaction trx = fm.beginTransaction(); if(curIndex != -1) trx.hide(fragments.get(curIndex));

if (!fragments.get(index).isAdded()) {
    trx.add(R.id.layFrame, fragments.get(index),
            "fragment_" + index);
}
trx.show(fragments.get(index)).commitAllowingStateLoss();
curIndex = index;

}

public void hideFooter(){ mainLll.setVisibility(View.GONE); } public void showFooter(){ mainLll.setVisibility(View.VISIBLE); }

DavaLc commented 6 years ago

其中HotDramaFragment 就是demo里的VideoFragment,与VideoFragment完全一致

CarGuo commented 6 years ago

你需要看的是,哪个地方的context转化出现了问题,调用的层级依次是哪些

DavaLc commented 6 years ago

彻底解决这个问题了。我Activity之前继承的是FragmentActivity,可能是与module里v7包有冲突。改成AppCompatActivity就解决问题了。