|
@@ -38,6 +38,7 @@ import com.cooleshow.teacher.ui.web.HtmlActivity;
|
|
|
import com.cooleshow.teacher.widgets.DialogUtils;
|
|
|
import com.cooleshow.usercenter.helper.UserHelper;
|
|
|
import com.google.android.material.tabs.TabLayout;
|
|
|
+import com.google.android.material.tabs.TabLayoutMediator;
|
|
|
import com.umeng.socialize.ShareAction;
|
|
|
import com.umeng.socialize.UMShareAPI;
|
|
|
import com.umeng.socialize.UMShareListener;
|
|
@@ -53,6 +54,8 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import androidx.viewpager2.adapter.FragmentStateAdapter;
|
|
|
+import androidx.viewpager2.widget.ViewPager2;
|
|
|
import io.rong.imkit.utils.StatusBarUtil;
|
|
|
import io.rong.imkit.utils.helper.OpenChatHelper;
|
|
|
import io.rong.imlib.model.Conversation;
|
|
@@ -74,7 +77,7 @@ public class MineScoreActivity extends BaseMVPActivity<ActivityMineScoreBinding,
|
|
|
private String currentSubjectId = "";
|
|
|
private String currentSearchStr = "";
|
|
|
private TabLayout tabLayout;
|
|
|
- private ViewPager viewPager;
|
|
|
+ private ViewPager2 viewPager;
|
|
|
private List<String> titles = new ArrayList<String>(Arrays.asList("已购买", "已上架", "审核中", "审核失败", "已下架"));
|
|
|
private List<String> auditStatusList = new ArrayList<String>(Arrays.asList(TYPE_BUY, TYPE_PASS, TYPE_DOING, TYPE_UNPASS, TYPE_OUT_SALE));
|
|
|
private List<Fragment> fragments = new ArrayList<>();
|
|
@@ -211,8 +214,24 @@ public class MineScoreActivity extends BaseMVPActivity<ActivityMineScoreBinding,
|
|
|
Fragment adFragment = MineScoreFragment.newInstance(auditStatusList.get(i));
|
|
|
fragments.add(adFragment);
|
|
|
}
|
|
|
- viewPager.setAdapter(new MineLiveCoursePagerAdapter(getSupportFragmentManager(), fragments, titles));
|
|
|
- tabLayout.setupWithViewPager(viewPager);
|
|
|
+ viewPager.setAdapter(new FragmentStateAdapter(this) {
|
|
|
+ @NonNull
|
|
|
+ @Override
|
|
|
+ public Fragment createFragment(int position) {
|
|
|
+ return fragments.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getItemCount() {
|
|
|
+ return fragments != null ? fragments.size() : 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ TabLayoutMediator tabLayoutMediator=new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
|
|
|
+ //这里需要根据position修改tab的样式和文字等
|
|
|
+ tab.setText(titles.get(position));
|
|
|
+ tab.select();
|
|
|
+ });
|
|
|
+ tabLayoutMediator.attach();
|
|
|
}
|
|
|
|
|
|
@Override
|