Commit 5ea6e251 by 严久程

课程模块

parent 229096eb
......@@ -38,6 +38,10 @@ android {
ydl {}
xlzx {}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
......@@ -62,6 +66,7 @@ dependencies {
implementation modularPublication('com.ydl:m-user-api')
api project(":ydl-webview")
api project(":ydl-platform")
api project(":ydl-media")
} else {
//发布时使用
compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
......
package com.yidianling.course
import com.yidianling.ydlcommon.http.YdlRetrofitUtils
import com.yidianling.ydlcommon.router.YdlCommonOut
class CourseConstants {
companion object {
var EXPERT_HOME = YdlCommonOut.API_HOST_H5 + "experts/"
const val ALL_COURSE = YdlCommonOut.API_HOST + "course/list"
const val COURSE_PAGE_SIZE = 20
......
......@@ -4,8 +4,8 @@ import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.ydl.ydlcommon.adapter.CommonAdapter;
import com.yidianling.course.coursePlay.moudle.Course;
import com.yidianling.ydlcommon.adapter.CommonAdapter;
/**
* Created by zqk on 6/22/17.
......
......@@ -12,7 +12,6 @@ import com.ydl.ydl_router.manager.YDLRouterManager;
import com.yidianling.course.coursePlay.CourseCommentActivity;
import com.yidianling.course.coursePlay.moudle.Course;
import com.yidianling.course.widget.CourseItemNewView;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
......
......@@ -4,9 +4,9 @@ import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.ydl.ydlcommon.adapter.CommonAdapter;
import com.yidianling.course.coursePlay.moudle.Course;
import com.yidianling.course.widget.CourseItemNewView;
import com.yidianling.ydlcommon.adapter.CommonAdapter;
public class CourseNewListAdapter extends CommonAdapter<Course> {
......
......@@ -11,8 +11,11 @@ import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.ydlcommon.actions.share.ShareUtils
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.ImageUtil
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.view.dialog.YDLShareDialog
import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.bean.PostersShareBean
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
......@@ -20,6 +23,7 @@ import com.yidianling.course.widget.CoursePosterTemplate
import com.yidianling.course.widget.CustomPagerTransformer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_course_poster.*
/**
......
......@@ -7,6 +7,14 @@ import android.text.TextUtils
import com.alibaba.android.arouter.launcher.ARouter
import com.google.gson.Gson
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.actionutil.BIConstants
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.bean.CourseCouponBean
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
......@@ -14,14 +22,6 @@ import com.yidianling.course.flutterPlugin.CourseSendPlugin
import com.yidianling.course.widget.CourseCouponDialog
import com.yidianling.router.RouterManager
import com.yidianling.ydlcommon.flutter.base.BaseFlutterFragment
import com.yidianling.ydlcommon.http.BaseResponse
import com.yidianling.ydlcommon.http.RxUtils
import com.yidianling.ydlcommon.http.ThrowableConsumer
import com.yidianling.ydlcommon.remind.ToastHelper
import com.yidianling.ydlcommon.router.YdlCommonRouterManager
import com.yidianling.ydlcommon.utils.YDLCacheUtils
import com.yidianling.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.ydlcommon.utils.actionutil.BIConstants
import io.flutter.view.FlutterView
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
......
package com.yidianling.course.bean
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/27
*/
// noThing为无关参数
data class CouponHintParam(val noThing : Int)
\ No newline at end of file
package com.yidianling.course.bean
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:
* @Copyright Copyright (c) 2019
* @Company 壹点灵
* @date 2019/01/02
*/
class CouponHintResponseBean(val msg:String, val url:String)
\ No newline at end of file
package com.yidianling.course.bean
import com.ydl.ydlcommon.bean.ShareData
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/7/11
*/
data class CourseExtraBean(
/**
* 课程价格
*/
var applyFee: String,
/**
* 课程类型 1.音频课程 2.线下 3.app群直播 4.app音视频直播 5.站外课程 6.系列课程 7.视频课程 8.app视频直播 ,
*/
var courseType: Int,
/**
* 是否包含音视频 1:只有音频 2:只有视屏 3:音视频都有
*/
var mediaTypes: Int,
/**
* 咨询师头像
*/
var doctorHead: String,
/**
* 咨询师名字
*/
var doctorName: String,
/**
* 课程id
*/
var id: String,
/**
* 是否购买
*/
var isBuy: Boolean,
/**
* 课程原价
*/
var originalApplyFee: String,
/**
* 课程图
*/
var pic: String,
/**
* 子课程数量
*/
var serialsNumber: Int,
/**
* 分享数据
*/
var shareData: ShareData,
/**
* 课程标题
*/
var title: String,
/**
* 用户评论次数:等于大于1表示评论过
*/
var userCommentNum: Int
)
\ No newline at end of file
package com.yidianling.course.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/7/11
*/
data class CourseMediaBean(
/**
* 课程id ,
*/
var courseId: String,
/**
* 课程主讲人名字
*/
var doctorName: String,
/**
* 资料类型 1.音频 2.视频 ,
*/
var mediaType: Int,
/**
* 课程标题 ,
*/
var title: String,
/**
* 课程url ,
*/
var url: String,
/**
* 当前是否在播放
*/
var isPlaying: Boolean = false,
/**
* 是否是试听
*/
var isDemo: Boolean = false
)
\ No newline at end of file
package com.yidianling.course.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/7/11
*/
data class CourseMediaDetailBean(
/**
* 课程概括
*/
val courseExtra: CourseExtraBean,
/**
* 试听
*/
val voiceSample: CourseMediaGroupBean,
/**
* 系列音/视频
*/
val voiceWhole: CourseMediaGroupBean
)
\ No newline at end of file
package com.yidianling.course.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/7/11
*/
data class CourseMediaGroupBean(
/**
* 是否购买
*/
var isBuy: Boolean,
/**
* //是否是系列课
*/
var isSeries: Boolean,
/**
* 音频列表
*/
var courseMedia: List<CourseMediaBean>
)
\ No newline at end of file
package com.yidianling.course.coursePlay.http
package com.yidianling.course.bean
/**
* @author yuanWai
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/12
* @date 2018/11/27
*/
data class CourseListParams(val params : String)
\ No newline at end of file
data class RedListParam(val serviceType : Int)
\ No newline at end of file
package com.yidianling.course.courseNew;
/**
* Created by Jim on 2018/7/13 0013.
*/
public class BannerBean {
public String title;
public String image;
public String linkUrl;
}
package com.yidianling.course.courseNew
import android.content.Context
import android.view.LayoutInflater
import android.widget.FrameLayout
import android.widget.LinearLayout
import com.ydl.ydl_image.module.GlideApp
import com.yidianling.course.R
import kotlinx.android.synthetic.main.item_view_category.view.*
/**
* @author : Zhangwenchao
* @e-mail : zhangwch@yidianling.com
* @time : 2018/7/14
*/
class CategoryItemView(context: Context?) : FrameLayout(context) {
init {
LayoutInflater.from(context).inflate(R.layout.item_view_category, this, true)
}
fun setText(text: CharSequence?) {
tv_title.text = text
}
fun setImage(url: String?) {
url?.let { GlideApp.with(this).load(it).into(iv_icon) }
}
}
\ No newline at end of file
package com.yidianling.course.courseNew;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.ydl.ydl_image.module.GlideApp;
import com.yidianling.common.tools.RxImageTool;
import com.yidianling.course.R;
import com.yidianling.ydlcommon.utils.ScreenUtil;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import com.yidianling.ydlcommon.utils.actionutil.ActionCountUtils;
import com.yidianling.ydlcommon.utils.actionutil.BIConstants;
import java.util.List;
/**
* Created by softrice on 2015/11/13.
*/
public class CourseHeadPagerAdapter extends PagerAdapter {
/**
* 装ImageView数组
*/
private List<BannerBean> banners;
private ImageView[] mImageViews;
private Context mContext;
private int dp194, screenWidth;
public CourseHeadPagerAdapter(List<BannerBean> banners, Context context) {
this.banners = banners;
mContext = context;
dp194 = RxImageTool.dip2px(194f);
screenWidth = ScreenUtil.screenWidth;
initDatas();
}
public void setData(List<BannerBean> banners) {
this.banners = banners;
initDatas();
}
@Override
public int getCount() {
if (banners == null || banners.size() <= 0) {
return 1;
} else {
return banners.size();
}
}
private void initDatas() {
if (banners == null || banners.size() <= 0) {
mImageViews = new ImageView[1];
mImageViews[0] = new ImageView(mContext);
mImageViews[0].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp194));
mImageViews[0].setScaleType(ImageView.ScaleType.CENTER_CROP);
GlideApp.with(mContext)
.load(R.drawable.default_banner)
.override(screenWidth, dp194)
.into(mImageViews[0]);
} else {
mImageViews = new ImageView[banners.size()];
for (int i = 0; i < mImageViews.length; i++) {
mImageViews[i] = new ImageView(mContext);
mImageViews[i].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp194));
mImageViews[i].setScaleType(ImageView.ScaleType.CENTER_CROP);
GlideApp.with(mContext)
.load(banners.get(i).image)
.override(screenWidth, dp194)
.into(mImageViews[i]);
}
}
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
((ViewPager) container).removeView(mImageViews[position
% mImageViews.length]);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
try {
((ViewPager) container).addView(mImageViews[position
% mImageViews.length], 0);
} catch (Exception e) {
// handler something
}
mImageViews[position % mImageViews.length].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UMEventUtils.umEvent("banner点击", "banner链接", banners.get(position).linkUrl);
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_BANNER_CLICK, position + "");
LinkUrlRouterProtocol.jump(container.getContext(), banners.get(position).linkUrl);
}
});
return mImageViews[position % mImageViews.length];
}
}
package com.yidianling.course.courseNew
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.support.v4.widget.SwipeRefreshLayout
......@@ -12,16 +13,16 @@ import android.widget.LinearLayout
import android.widget.TextView
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.actions.share.ShareUtils
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.UMEventUtils
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxNetTool
import com.yidianling.course.R
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
import com.yidianling.course.coursePlay.moudle.Course
import com.yidianling.course.model.TopicCourseBean
import com.yidianling.ydlcommon.base.BaseActivity
import com.yidianling.ydlcommon.http.RxUtils
import com.yidianling.ydlcommon.share.ShareUtils
import com.yidianling.ydlcommon.utils.UMEventUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_course_topic.*
......@@ -64,11 +65,10 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa
specialId = intent.getStringExtra("special_id").toInt()
}
LogUtil.i("special id: $specialId")
swl.setColorSchemeResources(R.color.google_green)
swl.setColorSchemeResources(R.color.main_theme)
swl.setOnRefreshListener(this)
tv_left_menu.setOnClickListener {
UMEventUtils.umEvent("专题详情", "分享", "分享")
//分享
share()
}
......@@ -94,7 +94,7 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa
}
fun initFooterView() {
footerView = LayoutInflater.from(this).inflate(R.layout.item_text, course_topic_rcv, false)
footerView = LayoutInflater.from(this).inflate(R.layout.item_course_topic_text, course_topic_rcv, false)
adapter?.addFooterView(footerView)
}
......@@ -104,6 +104,7 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa
}
}
@SuppressLint("CheckResult")
private fun loadData() {
if (!RxNetTool.isConnected(CourseTopicActivity@ this)) {
swl.isRefreshing = false
......
......@@ -5,13 +5,13 @@ import android.support.v4.util.SparseArrayCompat
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.utils.UMEventUtils
import com.ydl.ydlcommon.view.BaseViewHolder
import com.yidianling.course.CourseConstants
import com.yidianling.course.coursePlay.moudle.Course
import com.yidianling.course.widget.CourseItemNewView
import com.yidianling.ydlcommon.h5.H5Params
import com.yidianling.ydlcommon.h5.NewH5Activity
import com.yidianling.ydlcommon.utils.UMEventUtils
import com.yidianling.ydlcommon.view.BaseViewHolder
/**
* Created by Jim on 2018/7/12 0012.
......
......@@ -5,8 +5,8 @@ import android.text.TextUtils;
import com.ydl.ydl_router.manager.YDLRouterManager;
import com.ydl.ydl_router.manager.YDLRouterParams;
import com.ydl.ydlcommon.router.IYDLRouterConstant;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.ydlcommon.router.IYDLRouterConstant;
/**
* Created by Jim on 2018/7/17 0017.
......
package com.yidianling.course.courseNew;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.AbsoluteSizeSpan;
import android.widget.TextView;
import com.yidianling.course.R;
import com.yidianling.ydlcommon.app.YdlCommonApp;
/**
* Created by Jim on 2018/7/17 0017.
*/
public class PriceUtil {
public static void formatPrice(String price, TextView textView) {
if (TextUtils.isEmpty(price) || "0.00".equals(price) || "null".equals(price)) {
textView.setTextSize(12);
textView.setTextColor(YdlCommonApp.INSTANCE.getApp().getResources().getColor(R.color.google_green));
String money = "0.00";
SpannableString sStr = new SpannableString("¥" + money);
int index = money.indexOf(".") + 1;
if (index != -1) {
sStr.setSpan(new AbsoluteSizeSpan(18, true), 1, index, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
textView.setText(sStr);
} else {
textView.setTextSize(12);
textView.setTextColor(YdlCommonApp.INSTANCE.getApp().getResources().getColor(R.color.cube_holo_orange_dark));
SpannableString sStr = new SpannableString("¥" + price);
int index = price.indexOf(".") + 1;
if (index != -1 && index > 1) {
sStr.setSpan(new AbsoluteSizeSpan(18, true), 1, index, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
textView.setText(sStr);
}
}
}
package com.yidianling.course.courseNew.courseList;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import butterknife.ButterKnife;
import butterknife.Unbinder;
public abstract class BaseLazyFragment extends Fragment {
protected boolean isVisible;
protected boolean isUseLazyMode=true;
private Unbinder mUnBinder;
protected View parentView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
parentView = inflater.inflate(getLayoutId(), container, false);
return parentView;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mUnBinder = ButterKnife.bind(this, view);
afterViewCreated(view,savedInstanceState);
}
public abstract void afterViewCreated(View view,Bundle savedInstanceState);
public abstract int getLayoutId();
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (!isUseLazyMode){
return;
}
if (getUserVisibleHint()) {
isVisible = true;
onVisible();
} else {
isVisible = false;
onInvisible();
}
}
public BaseLazyFragment setIsUseLazyMode(boolean isUseLazyMode){
this.isUseLazyMode=isUseLazyMode;
return this;
}
protected void onInvisible() {
}
protected void onVisible() {
lazyLoad();
};
public abstract void lazyLoad();
@Override
public void onDestroyView() {
super.onDestroyView();
mUnBinder.unbind();
}
public View getParentView(){
return parentView;
}
}
\ No newline at end of file
package com.yidianling.course.courseNew.courseList;
/**
* Created by Jim on 2018/7/16 0016.
*/
public class CouresListPresenter {
}
package com.yidianling.course.courseNew.courseList;//package com.yidianling.course.courseNew.courseList;
//
//import com.yidianling.common.tools.LogUtil;
//import com.yidianling.course.coursePlay.common.net.Command;
//import com.yidianling.course.coursePlay.common.net.RetrofitUtils;
//import com.yidianling.course.coursePlay.moudle.Course;
//import com.yidianling.ydlcommon.http.RxUtils;
//
//import java.util.List;
//
//import io.reactivex.android.schedulers.AndroidSchedulers;
//import io.reactivex.functions.Consumer;
//import io.reactivex.schedulers.Schedulers;
//
///**
// * Created by Jim on 2018/7/16 0016.
// */
//
//public class CourseListPresenter {
//
// private ICourseListView mView;
//
// public CourseListPresenter(ICourseListView view){
// mView=view;
// }
//
// public void fetchData(Command.GetCourse cmd) {
// RetrofitUtils.getCourseList(cmd)
// .subscribeOn(Schedulers.io())
// .compose(RxUtils.resultData())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(resp-> {
//
// },throwable -> {
// mView.showLoadErrorView();
// LogUtil.e("load error: "+throwable.toString());
// });
// }
//
//}
package com.yidianling.course.courseNew.courseList;
/**
* Created by Jim on 2018/7/16 0016.
*/
public interface ICourseListView {
void hideRefreshView();
void showLoadErrorView();
}
package com.yidianling.course.courseNew.courseList.widget
import android.content.Context
import android.graphics.Typeface
import android.graphics.drawable.BitmapDrawable
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.PopupWindow
import com.ydl.ydlcommon.view.SpaceItemDecorator
import com.yidianling.common.tools.RxImageTool
import com.yidianling.course.R
import com.yidianling.course.courseNew.courseList.widget.adapter.CourseGoodAdapter
import com.yidianling.course.model.CourseCategoryBean
import com.yidianling.ydlcommon.view.SpaceItemDecorator
import kotlinx.android.synthetic.main.course_good_popup_window.view.*
......
......@@ -13,7 +13,7 @@ import kotlinx.android.synthetic.main.item_course_good_item.view.*
/**
* @author yuanwai
* @描述:课程列表页--筛选模块--擅长方式popwindow适配器
* @描述:课程列表页--筛选模块--分类 popwindow适配器
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/9/22
......
package com.yidianling.course.courseNew.home
import android.annotation.SuppressLint
import android.content.Context
import android.os.Handler
import android.text.TextUtils
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.bean.CourseCouponBean
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
import com.yidianling.router.RouterManager
import com.yidianling.ydlcommon.http.RxUtils
import com.yidianling.ydlcommon.http.ThrowableConsumer
import com.yidianling.ydlcommon.router.YdlCommonRouterManager
import com.yidianling.ydlcommon.utils.AssetsUtils
import com.yidianling.ydlcommon.utils.YDLAsyncUtils
import com.yidianling.ydlcommon.utils.YDLCacheUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import java.text.SimpleDateFormat
import java.util.*
/**
* Created by Jim on 2018/7/11 0011.
*/
class CourseHomePresenter(var view: ICourseHomeView) {
private var hasRequestCoupon = false
private val compositeSubscription = CompositeDisposable()
/**
* 加载本地缓存
*/
fun localData(context: Context) {
YDLAsyncUtils.asyncAsResult(object : YDLAsyncUtils.AsyncObjecyerResult {
override fun doAsyncAction(): Any {
var cacheData = YDLCacheUtils.getCourseHomeData()
if (cacheData?.isEmpty()!!) {
cacheData = String(AssetsUtils.getAssertsFile(context, "course_home.json")!!)
}
return cacheData
}
override fun asyncResult(`object`: Any?) {
if (`object` is String) {
val gson = Gson()
if (!TextUtils.isEmpty(`object`)) {
val list = gson.fromJson<List<ResultBean>>(`object`, object : TypeToken<List<ResultBean>>() {}.type)
view.showBody(list)
}
}
}
})
}
/**
* 更新本地缓存
*/
private fun updateCache(list: List<ResultBean>) {
YDLAsyncUtils.async(object : YDLAsyncUtils.AsyncObjecyer {
override fun doAsyncAction() {
val gson = Gson()
val json = gson.toJson(list)
YDLCacheUtils.saveCourseHomeData(json)
}
})
}
fun fetchData() {
compositeSubscription.add(RetrofitUtils.getCoursesHomePage()
.subscribeOn(Schedulers.io())
.compose(RxUtils.resultJavaData())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ response ->
view.hideRefreshView()
view.showBody(response)
//更新本地缓存数据
updateCache(response)
}, { t: Throwable? ->
view.hideRefreshView()
view.showLoadErrorView(t)
LogUtil.e("CoursesHomePage data fetch error: " + t.toString())
}))
}
/**
* 获取优惠券信息
*/
fun prepareCoupon() {
//判断是否登录 以及本次app启动后是否已经请求过
if (RouterManager.getUserRouter()?.isLogin() == true && !hasRequestCoupon) {
Handler().postDelayed({
//优惠券逻辑
if (compareCouponTime()) {
getCouponData()
}
}, 2000)
}
}
/**
* 获取可以领取的课程优惠券
*
* @param uid uid
* @param services 适用服务 1预约咨询 2电话倾诉 3课程(用户课程 专家课程) 5测评
* @param receiveType 领取条件方式 1前台领取 2链接领取
* @param applyEnds 适用终端 1PC官网 2wap站点 3用户app 4好杮app 5专家app
* @return
*/
@SuppressLint("SimpleDateFormat")
private fun getCouponData() {
val (userId) = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo() ?: return
val disposable = RetrofitUtils.getCourseCoupons(userId, "3", "1", "3")
.compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
hasRequestCoupon = true
val simpleFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//如2016-08-10
val time = System.currentTimeMillis()
val date = Date()
date.time = time
val nowTime = simpleFormat.format(date)
if (it?.data != null && !it.data.isEmpty()) {
YDLCacheUtils.saveCouponTime(userId, nowTime)
view.couponDataResponse(it.data)
}
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
}
})
compositeSubscription.add(disposable)
}
/**
* 领取优惠券
*/
fun receiveCoupon(list: List<CourseCouponBean>) {
val (userId) = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo() ?: return
val couponIds = ArrayList<String>()
for (bean in list) {
couponIds.add(bean.id)
}
val bean = CouponReceiveBean()
bean.couponIds = couponIds
bean.uid = userId
val couponIdsStr = Gson().toJson(bean)
view.showRefreshView()
val disposable = RetrofitUtils.receiveCoupon(couponIdsStr)
.compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
view.hideRefreshView()
view.receiveCouponResponse(it)
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
view.hideRefreshView()
}
})
compositeSubscription.add(disposable)
}
/**
* 对比上次获取优惠券时间,若时间差超过一天,则再次请求,否则不获请求
*/
@SuppressLint("SimpleDateFormat")
private fun compareCouponTime(): Boolean {
val uid = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()?.userId
val simpleFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//如2016-08-10
val last = YDLCacheUtils.getCouponTime(uid)
return if (TextUtils.isEmpty(last)) {
//还没有获取过优惠券,直接请求数据
true
} else {
val time = System.currentTimeMillis()
val date = Date()
date.time = time
val nowTime = simpleFormat.format(date)
!TextUtils.equals(last.substring(0, 10), nowTime.substring(0, 10))
}
}
fun onDestroy() {
compositeSubscription.dispose()
}
inner class CouponReceiveBean {
var couponIds: List<String>? = null
var uid: String? = null
}
}
\ No newline at end of file
package com.yidianling.course.courseNew.home
import com.hannesdorfmann.mosby3.mvp.MvpView
import com.yidianling.course.bean.CourseCouponBean
import com.yidianling.ydlcommon.http.BaseResponse
/**
* Created by Jim on 2018/7/11 0011.
*/
interface ICourseHomeView : MvpView {
fun showBody(resultBeans: List<ResultBean>)
fun hideRefreshView()
fun showRefreshView()
fun showLoadErrorView(throwable: Throwable?)
fun couponDataResponse(data: List<CourseCouponBean>)
fun receiveCouponResponse(data: BaseResponse<List<String>>)
}
package com.yidianling.course.courseNew.home;
import com.google.gson.annotations.SerializedName;
import com.yidianling.course.bean.CourseHomeBodyBean;
import java.util.List;
/**
* Created by Jim on 2018/7/13 0013.
*/
public class ResultBean {
public Head head;
public List<CourseHomeBodyBean> body;
public Footer footer;
public int type;
public boolean diviLine;
public static class Head {
public String title;
public String subTitle;
public String subLinkUrl;
public String tab1Name;
public String tab2Name;
}
public static class Footer {
public String title;
@SerializedName(value = "linkUrl",alternate = "LinkUrl")
public String linkUrl;
}
}
......@@ -14,13 +14,13 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.ydl.base_module.ui.searchbarview.SearchBarView;
import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.utils.DisplayUtils;
import com.ydl.ydlcommon.utils.UMEventUtils;
import com.yidianling.course.CourseListFragment;
import com.yidianling.course.R;
import com.yidianling.ydlcommon.base.BaseActivity;
import com.yidianling.ydlcommon.ui.confideredpacket.ConfideRedPacketView;
import com.yidianling.ydlcommon.utils.DisplayUtils;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import com.yidianling.course.widget.CourseRedPacketView;
import com.yidianling.course.widget.SearchBarView;
import java.lang.reflect.Field;
......@@ -84,9 +84,9 @@ public class MyCourseActivity extends BaseActivity {
}
private void initConfideRedPacketView() {
ConfideRedPacketView confideRedPacketView = findViewById(R.id.confideRedPacketView);
confideRedPacketView.initData(View.VISIBLE);
confideRedPacketView.setConfide();
CourseRedPacketView courseRedPacketView = findViewById(R.id.courseRedPacketView);
courseRedPacketView.initData(View.VISIBLE);
courseRedPacketView.setConfide();
}
......
package com.yidianling.course.courseNew.sections;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.course.R;
import com.yidianling.course.courseNew.BannerBean;
import com.yidianling.course.courseNew.CourseHeadPagerAdapter;
import com.yidianling.ydlcommon.adapter.section.Section;
import com.yidianling.ydlcommon.view.LoopViewPager;
import java.util.List;
/**
* Created by Jim on 2018/6/22 0022.
* 轮播图模版
*/
public class BannerSection extends Section {
private List<BannerBean> mBanners;
private final int IDENTIFY_TYPE = BANNER_SECTION;
public BannerSection(List<BannerBean> banners) {
super(R.layout.item_course_banner);
this.mBanners=banners;
}
@Override
public void bindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof BannerViewHolder){
((BannerViewHolder) holder).notifyData(mBanners);
}
}
@Override
public int getTotalDataNum() {
return 1;
}
@Override
public int getItemViewType(int position) {
return combineType(IDENTIFY_TYPE, TYPE_BODY);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(itemResourceId,parent,false);
return new BannerViewHolder(view,mBanners);
}
@Override
public boolean isBelongTo(int viewType) {
return String.valueOf(viewType).startsWith(String.valueOf(IDENTIFY_TYPE));
}
@Override
public boolean isHeadType(int position) {
return false;
}
@Override
public boolean isFooterType(int position) {
return false;
}
@Override
public int getSectionId() {
return 0;
}
static class BannerViewHolder extends RecyclerView.ViewHolder {
private LoopViewPager mHeadViewPager;
private CourseHeadPagerAdapter mAdapter;
public BannerViewHolder(View itemView,List<BannerBean> banners) {
super(itemView);
mHeadViewPager=itemView.findViewById(R.id.vp_head_bar);
mAdapter=new CourseHeadPagerAdapter(banners,itemView.getContext());
mHeadViewPager.setAdapter(mAdapter);
}
public void notifyData(List<BannerBean> banners){
mAdapter=new CourseHeadPagerAdapter(banners,itemView.getContext());
mHeadViewPager.setAdapter(mAdapter);
}
}
}
package com.yidianling.course.courseNew.sections;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import com.yidianling.common.tools.RxDeviceTool;
import com.yidianling.course.R;
import com.yidianling.course.courseNew.CategoryItemView;
import com.yidianling.course.courseNew.LinkUrlRouterProtocol;
import com.yidianling.course.model.CatogoryBean;
import com.yidianling.ydlcommon.adapter.section.Section;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import com.yidianling.ydlcommon.utils.actionutil.ActionCountUtils;
import com.yidianling.ydlcommon.utils.actionutil.BIConstants;
import java.util.List;
import cn.lankton.flowlayout.FlowLayout;
/**
* Created by Jim on 2018/6/25 0025.
*/
public class CategorySection extends Section {
private final int IDENTIFY_TYPE = CATEGORY_SECTION;
public List<CatogoryBean> datas;
public CategorySection(List<CatogoryBean> datas) {
super(R.layout.item_category2);
this.datas = datas;
}
@Override
public void bindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof CategoryViewHolder) {
}
}
@Override
public int getTotalDataNum() {
return 1;
}
@Override
public int getItemViewType(int position) {
return combineType(IDENTIFY_TYPE, TYPE_BODY);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(itemResourceId, parent, false);
return new CategoryViewHolder(view, datas);
}
@Override
public boolean isBelongTo(int viewType) {
return String.valueOf(viewType).startsWith(String.valueOf(IDENTIFY_TYPE));
}
@Override
public boolean isHeadType(int position) {
return false;
}
@Override
public boolean isFooterType(int position) {
return false;
}
@Override
public int getSectionId() {
return 0;
}
static class CategoryViewHolder extends RecyclerView.ViewHolder {
public CategoryViewHolder(View itemView, List<CatogoryBean> datas) {
super(itemView);
int width = RxDeviceTool.getScreenWidth(itemView.getContext());
FlowLayout flowLayout = itemView.findViewById(R.id.flow_layout);
int itemWidth = width / 4;
for (int i = 0; i < datas.size(); i++) {
CatogoryBean category = datas.get(i);
CategoryItemView ciView = new CategoryItemView(itemView.getContext());
ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(itemWidth, WindowManager.LayoutParams.WRAP_CONTENT);
ciView.setLayoutParams(params);
ciView.setText(category.title);
ciView.setImage(category.image);
ciView.setOnClickListener(view -> {
UMEventUtils.umEvent("课程分类点击", "分类id", category.linkUrl);
UMEventUtils.umEvent("课程分类点击", "分类名称", category.title);
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_CLASSIFICATION_CLICK, category.title);
if (!TextUtils.isEmpty(category.linkUrl)) {
LinkUrlRouterProtocol.jump(itemView.getContext(), category.linkUrl);
}
});
flowLayout.addView(ciView);
}
}
}
}
package com.yidianling.course.courseNew.sections;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.yidianling.course.R;
import com.yidianling.course.bean.CourseHomeBodyBean;
import com.yidianling.course.courseNew.LinkUrlRouterProtocol;
import com.yidianling.course.courseNew.viewholder.FooterMoreViewHolder;
import com.yidianling.course.courseNew.viewholder.SingleTitleHeaderViewHolder;
import com.yidianling.course.coursePlay.moudle.Course;
import com.yidianling.course.model.NormalCourseBean;
import com.yidianling.course.widget.CourseItemNewView;
import com.yidianling.ydlcommon.adapter.section.Section;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import com.yidianling.ydlcommon.utils.actionutil.ActionCountUtils;
import com.yidianling.ydlcommon.utils.actionutil.BIConstants;
/**
* Created by Jim on 2018/6/25 0025.
* 分类课程模版
*/
public class ClassifiedCourseSection extends Section {
private final int IDENTIFY_TYPE = CLASSIFY_COURSE_SECTION;
private NormalCourseBean data;
private int totalNum;
private Context context;
public ClassifiedCourseSection(Context context, NormalCourseBean bean) {
super(R.layout.item_classified_title, R.layout.item_more, R.layout.item_course_list);
this.context = context;
this.data = bean;
initTotlaNum();
}
@Override
public void bindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof FooterMoreViewHolder) {
((FooterMoreViewHolder) holder).titleView.setText(data.footer.title);
((FooterMoreViewHolder) holder).linearLayout.setOnClickListener(view -> {
UMEventUtils.umEvent(data.head.title, "更多课程", "更多课程");
LinkUrlRouterProtocol.jump(context, data.footer.linkUrl);
if (!TextUtils.isEmpty(data.head.title)) {
if (data.head.title.contains("线下")) {
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_OFFLINE_CERTIFICATION_TRAINING_MORE_CLICK);
} else {
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_CONSULTANT_COURSE_MORE_CLICK);
}
}
});
} else if (holder instanceof SingleTitleHeaderViewHolder) {
((SingleTitleHeaderViewHolder) holder).titleView.setText(data.head.title);
} else if (holder instanceof CourseItemViewHolder) {
CourseItemViewHolder realHolder = (CourseItemViewHolder) holder;
// if ((data.head != null && position == 1) || (data.head == null && position == 0)) {
// realHolder.hideDividerLine();
// } else {
// realHolder.tv_line_bottom.setVisibility(View.VISIBLE);
// }
CourseHomeBodyBean course = data.body.get(position - 1);
Course courseBean = switchData(course);
realHolder.courseItemNewView.setData(courseBean);
holder.itemView.setOnClickListener(view -> {
UMEventUtils.umEvent(data.head.title, data.head.title + "链接", course.linkUrl);
LinkUrlRouterProtocol.jump(context, courseBean.linkUrl);
if (!TextUtils.isEmpty(data.head.title)) {
if (data.head.title.contains("线下")) {
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_OFFLINE_CERTIFICATION_TRAINING_XXX_CLICK + courseBean.id + "_click");
}
}
});
}
}
private Course switchData(CourseHomeBodyBean bean) {
Course course = new Course();
course.id = bean.id;
course.title = bean.title;
course.hostListPic = bean.hostListPic;
course.courseHostInfo = bean.courseHostInfo;
course.hostInfo = bean.hostInfo;
course.pic = bean.pic;
course.image = bean.image;
course.subCourseNum = bean.subCourseNum;
course.doctorName = bean.doctorName;
course.joinNum = bean.joinNum;
course.isInvite = bean.isInvite;
course.applyFee = bean.applyFee;
course.recommend = bean.recommend;
course.newCourse = bean.newCourse;
course.demoType = bean.demoType;
course.originalApplyFee = bean.originalApplyFee;
course.courseType = bean.courseType;
course.isBuy = bean.isBuy;
course.demoFile = bean.demoFile;
course.promotionApplyFee = bean.promotionApplyFee;
course.isPromotion = bean.isPromotion;
course.linkUrl = bean.linkUrl;
return course;
}
private void initTotlaNum() {
totalNum = 0;
if (data.head != null) {
totalNum++;
}
if (data.footer != null) {
totalNum++;
}
if (data.body != null) {
totalNum += data.body.size();
}
}
@Override
public int getTotalDataNum() {
return totalNum;
}
@Override
public int getItemViewType(int position) {
if (isHeadType(position)) {
return combineType(IDENTIFY_TYPE, TYPE_HEADER);
} else if (isFooterType(position)) {
return combineType(IDENTIFY_TYPE, TYPE_FOOTER);
} else {
return combineType(IDENTIFY_TYPE, TYPE_BODY);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
if (viewType == combineType(IDENTIFY_TYPE, TYPE_HEADER)) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_classified_title, parent, false);
return new SingleTitleHeaderViewHolder(view);
} else if (viewType == combineType(IDENTIFY_TYPE, TYPE_FOOTER)) {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_more, parent, false);
return new FooterMoreViewHolder(view);
} else {
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_course_list, parent, false);
return new CourseItemViewHolder(view);
}
}
@Override
public boolean isBelongTo(int viewType) {
return String.valueOf(viewType).startsWith(String.valueOf(IDENTIFY_TYPE));
}
@Override
public boolean isHeadType(int position) {
return data.head != null && position == 0;
}
@Override
public boolean isFooterType(int position) {
return data.footer != null && position == totalNum - 1;
}
@Override
public int getSectionId() {
return IDENTIFY_TYPE;
}
static class CourseItemViewHolder extends RecyclerView.ViewHolder {
public CourseItemNewView courseItemNewView;
public View tv_line_bottom;
public CourseItemViewHolder(View itemView) {
super(itemView);
courseItemNewView = itemView.findViewById(R.id.view_content);
tv_line_bottom = itemView.findViewById(R.id.tv_line_bottom);
}
public void hideDividerLine() {
tv_line_bottom.setVisibility(View.INVISIBLE);
}
}
}
package com.yidianling.course.courseNew.sections;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.yidianling.course.R;
import com.yidianling.ydlcommon.adapter.section.Section;
import com.yidianling.ydlcommon.view.BaseViewHolder;
/**
* Created by Jim on 2018/6/27 0027.
*/
public class ListEndSection extends Section {
private final int IDENTIFY_TYPE=LIST_END_SECTION;
public ListEndSection() {
super(R.layout.item_list_end);
}
private String title;
public ListEndSection(String title) {
super(R.layout.item_list_end);
this.title = title;
}
@Override
public void bindViewHolder(RecyclerView.ViewHolder holder, int position) {
}
@Override
public int getTotalDataNum() {
return 1;
}
@Override
public int getItemViewType(int position) {
return combineType(IDENTIFY_TYPE,TYPE_BODY);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(itemResourceId,parent,false);
BaseViewHolder viewHolder = new BaseViewHolder(view);
viewHolder.setText(R.id.tv_title, title);
return viewHolder;
}
@Override
public boolean isBelongTo(int viewType) {
return String.valueOf(viewType).startsWith(String.valueOf(IDENTIFY_TYPE));
}
@Override
public boolean isHeadType(int position) {
return false;
}
@Override
public boolean isFooterType(int position) {
return false;
}
@Override
public int getSectionId() {
return 0;
}
}
package com.yidianling.course.courseNew.sections;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.yidianling.course.R;
import com.yidianling.course.bean.CourseHomeBodyBean;
import com.yidianling.course.courseNew.LinkUrlRouterProtocol;
import com.yidianling.course.courseNew.viewholder.FooterMoreViewHolder;
import com.yidianling.course.coursePlay.moudle.Course;
import com.yidianling.course.model.QulityCourseBean;
import com.yidianling.ydlcommon.adapter.section.Section;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import com.yidianling.ydlcommon.utils.actionutil.ActionCountUtils;
import com.yidianling.ydlcommon.utils.actionutil.BIConstants;
/**
* Created by Jim on 2018/6/25 0025.
*/
public class QulityCourseSection extends Section {
private final int IDENTIFY_TYPE = QULITY_COURSE_SECTION;
private QulityCourseBean data;
private int totalNum = 0;
private static final int FREE = 0;
private static final int PAY = 1;
public static int type = PAY;
public void setType(int type) {
this.type = type;
initTotlaNum();
adapter.notifyDataSetChanged();
}
private RecyclerView.Adapter adapter;
private Context context;
public QulityCourseSection(Context context, QulityCourseBean data, RecyclerView.Adapter adapter) {
super(R.layout.item_head_quality_course, R.layout.item_more, R.layout.item_course_list);
this.context = context;
this.adapter = adapter;
this.data = data;
type = PAY;
initTotlaNum();
}
private void initTotlaNum() {
}
@Override
public void bindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof FooterMoreViewHolder) {
((FooterMoreViewHolder) holder).titleView.setText(data.footer.title);
((FooterMoreViewHolder) holder).linearLayout.setOnClickListener(v -> {
UMEventUtils.umEvent("更多课程", "更多课程", "更多课程");
LinkUrlRouterProtocol.jump(context, data.footer.linkUrl + "?childId=" + (type + 1));
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_EXCELLENT_COURSES_MORE_CLICK);
});
} else if (holder instanceof QulityCourseHeaderVH) {
((QulityCourseHeaderVH) holder).tv_title.setText(data.head.title);
((QulityCourseHeaderVH) holder).tv_tab1.setText(data.head.tab1Name);
((QulityCourseHeaderVH) holder).tv_tab2.setText(data.head.tab2Name);
if (type == PAY) {
((QulityCourseHeaderVH) holder).tv_tab2.setTextColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.green_34cd65));
((QulityCourseHeaderVH) holder).iv_tab2.setVisibility(View.VISIBLE);
((QulityCourseHeaderVH) holder).tv_tab1.setTextColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.grey_909599));
((QulityCourseHeaderVH) holder).iv_tab1.setVisibility(View.INVISIBLE);
} else {
((QulityCourseHeaderVH) holder).tv_tab1.setTextColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.green_34cd65));
((QulityCourseHeaderVH) holder).iv_tab1.setVisibility(View.VISIBLE);
((QulityCourseHeaderVH) holder).tv_tab2.setTextColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.grey_909599));
((QulityCourseHeaderVH) holder).iv_tab2.setVisibility(View.INVISIBLE);
}
} else if (holder instanceof ClassifiedCourseSection.CourseItemViewHolder) {
ClassifiedCourseSection.CourseItemViewHolder realHolder = (ClassifiedCourseSection.CourseItemViewHolder) holder;
// if ((data.head != null && position == 1) || (data.head == null && position == 0)) {
// realHolder.hideDividerLine();
// } else {
// realHolder.tv_line_bottom.setVisibility(View.VISIBLE);
// }
CourseHomeBodyBean course = data.body.get(type).get(position - 1);
Course courseBean = switchData(course);
realHolder.courseItemNewView.setData(courseBean);
holder.itemView.setOnClickListener(view -> {
UMEventUtils.umEvent("精品课程", "精品课程链接", courseBean.linkUrl);
LinkUrlRouterProtocol.jump(context, courseBean.linkUrl);
if (type == PAY) {
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_EXCELLENT_COURSES_PAY_XXX_CLICK + courseBean.id + "_click");
} else {
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_EXCELLENT_COURSES_FREE_XXX_CLICK + courseBean.id + "_click");
}
});
}
}
/**
* 这里是个坑
*
* @param bean
* @return
*/
private Course switchData(CourseHomeBodyBean bean) {
Course course = new Course();
course.id = bean.id;
course.title = bean.title;
course.hostListPic = bean.hostListPic;
course.courseHostInfo = bean.courseHostInfo;
course.pic = bean.pic;
course.image = bean.image;
course.hostInfo = bean.hostInfo;
course.subCourseNum = bean.subCourseNum;
course.doctorName = bean.doctorName;
course.joinNum = bean.joinNum;
course.isInvite = bean.isInvite;
course.applyFee = bean.applyFee;
course.recommend = bean.recommend;
course.newCourse = bean.newCourse;
course.demoType = bean.demoType;
course.originalApplyFee = bean.originalApplyFee;
course.isBuy = bean.isBuy;
course.demoFile = bean.demoFile;
course.promotionApplyFee = bean.promotionApplyFee;
course.courseType = bean.courseType;
course.isPromotion = bean.isPromotion;
course.linkUrl = bean.linkUrl;
return course;
}
@Override
public int getTotalDataNum() {
totalNum = 0;
if (data.head != null) {
totalNum++;
}
if (data.footer != null) {
totalNum++;
}
if (data.body != null) {
totalNum += data.body.get(type).size();
}
return totalNum;
}
@Override
public int getItemViewType(int position) {
if (isHeadType(position)) {
return combineType(IDENTIFY_TYPE, TYPE_HEADER);
} else if (isFooterType(position)) {
return combineType(IDENTIFY_TYPE, TYPE_FOOTER);
} else {
return combineType(IDENTIFY_TYPE, TYPE_BODY);
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == combineType(IDENTIFY_TYPE, TYPE_HEADER)) {
View view = LayoutInflater.from(parent.getContext()).inflate(headerResourceId, parent, false);
return new QulityCourseHeaderVH(this, view);
} else if (viewType == combineType(IDENTIFY_TYPE, TYPE_FOOTER)) {
View view = LayoutInflater.from(parent.getContext()).inflate(footerResourceId, parent, false);
return new FooterMoreViewHolder(view);
} else {
View view = LayoutInflater.from(parent.getContext()).inflate(itemResourceId, parent, false);
return new ClassifiedCourseSection.CourseItemViewHolder(view);
}
}
@Override
public boolean isBelongTo(int viewType) {
return String.valueOf(viewType).startsWith(String.valueOf(IDENTIFY_TYPE));
}
@Override
public boolean isHeadType(int position) {
return data.head != null && position == 0;
}
@Override
public boolean isFooterType(int position) {
return data.footer != null && position == totalNum - 1;
}
@Override
public int getSectionId() {
return IDENTIFY_TYPE;
}
static class QulityCourseHeaderVH extends RecyclerView.ViewHolder {
public TextView tv_title, tv_tab1, tv_tab2;
public ImageView iv_tab1, iv_tab2;
public QulityCourseHeaderVH(QulityCourseSection section, View itemView) {
super(itemView);
tv_title = itemView.findViewById(R.id.tv_title);
tv_tab1 = itemView.findViewById(R.id.tv_tab1);
iv_tab1 = itemView.findViewById(R.id.iv_tab1);
tv_tab2 = itemView.findViewById(R.id.tv_tab2);
iv_tab2 = itemView.findViewById(R.id.iv_tab2);
itemView.findViewById(R.id.ll_tab1).setOnClickListener(v -> {
UMEventUtils.umEvent("精品课程", "免费课程", "免费课程");
tv_tab1.setTextColor(ContextCompat.getColor(itemView.getContext(), R.color.green_34cd65));
iv_tab1.setVisibility(View.VISIBLE);
tv_tab2.setTextColor(ContextCompat.getColor(itemView.getContext(), R.color.grey_909599));
iv_tab2.setVisibility(View.INVISIBLE);
section.setType(FREE);
});
itemView.findViewById(R.id.ll_tab2).setOnClickListener(v -> {
UMEventUtils.umEvent("精品课程", "付费课程", "付费课程");
tv_tab2.setTextColor(ContextCompat.getColor(itemView.getContext(), R.color.green_34cd65));
iv_tab2.setVisibility(View.VISIBLE);
tv_tab1.setTextColor(ContextCompat.getColor(itemView.getContext(), R.color.grey_909599));
iv_tab1.setVisibility(View.INVISIBLE);
section.setType(PAY);
});
}
}
}
package com.yidianling.course.courseNew.sections;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.yidianling.course.R;
import com.yidianling.course.bean.CourseHomeBodyBean;
import com.yidianling.course.courseNew.LinkUrlRouterProtocol;
import com.yidianling.course.courseNew.viewholder.SingleTitleHeaderViewHolder;
import com.yidianling.course.link.CourseLinkUrl;
import com.yidianling.course.model.NormalCourseBean;
import com.yidianling.ydlcommon.adapter.section.Section;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import com.yidianling.ydlcommon.utils.actionutil.ActionCountUtils;
import com.yidianling.ydlcommon.utils.actionutil.BIConstants;
import com.yidianling.ydlcommon.view.BaseViewHolder;
import java.util.List;
/**
* Created by Jim on 2018/6/27 0027.
*/
public class TopicsCoursesSection extends Section {
private final int IDENTIFY_TYPE = TOPICS_COURSES_SECTION;
private Context mContext;
private NormalCourseBean data;
public TopicsCoursesSection(Context mContext, NormalCourseBean data) {
super(R.layout.item_classified_title, 0, R.layout.item_topics_courses);
this.mContext = mContext;
this.data = data;
}
@Override
public void bindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof SingleTitleHeaderViewHolder) {
if (data.head != null) {
if (!TextUtils.isEmpty(data.head.title)) {
((SingleTitleHeaderViewHolder) holder).titleView.setText(data.head.title);
}
if (!TextUtils.isEmpty(data.head.subTitle)) {
((SingleTitleHeaderViewHolder) holder).subTitleView.setVisibility(View.VISIBLE);
((SingleTitleHeaderViewHolder) holder).subTitleView.setText(data.head.subTitle);
((SingleTitleHeaderViewHolder) holder).subTitleView.setOnClickListener(v -> {
UMEventUtils.umEvent("专题课程", "更多点击", "更多点击");
if (null != mContext) {
CourseLinkUrl.Companion.jump(mContext, data.head.subLinkUrl);
}
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_THEMATIC_COURSES_MORE_CLICK);
});
} else {
((SingleTitleHeaderViewHolder) holder).subTitleView.setVisibility(View.GONE);
}
}
} else if (holder instanceof TopicsCoursesVH) {
((TopicsCoursesVH) holder).notifyData(data.body);
}
}
@Override
public int getTotalDataNum() {
return 2;
}
@Override
public int getItemViewType(int position) {
if (isHeadType(position)) {
return combineType(IDENTIFY_TYPE, TYPE_HEADER);
}
return combineType(IDENTIFY_TYPE, TYPE_BODY);
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = null;
if (viewType == combineType(IDENTIFY_TYPE, TYPE_HEADER)) {
view = LayoutInflater.from(parent.getContext()).inflate(headerResourceId, parent, false);
return new SingleTitleHeaderViewHolder(view);
}
view = LayoutInflater.from(parent.getContext()).inflate(itemResourceId, parent, false);
return new TopicsCoursesVH(view, data.body);
}
@Override
public boolean isBelongTo(int viewType) {
return String.valueOf(viewType).startsWith(String.valueOf(IDENTIFY_TYPE));
}
@Override
public boolean isHeadType(int position) {
return data.head != null && position == 0;
}
@Override
public boolean isFooterType(int position) {
return false;
}
@Override
public int getSectionId() {
return 0;
}
static class TopicsCoursesVH extends RecyclerView.ViewHolder {
private RecyclerView mRecyclerView;
private Adapter mAdapter;
public TopicsCoursesVH(View itemView, List<CourseHomeBodyBean> data) {
super(itemView);
mRecyclerView = itemView.findViewById(R.id.rcv_topics_courses);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(itemView.getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
mRecyclerView.setLayoutManager(linearLayoutManager);
mAdapter = new Adapter(data, itemView.getContext());
mRecyclerView.setAdapter(mAdapter);
}
public void notifyData(List<CourseHomeBodyBean> data) {
mAdapter.data = data;
mAdapter.notifyDataSetChanged();
}
}
static class Adapter extends RecyclerView.Adapter<BaseViewHolder> {
private List<CourseHomeBodyBean> data;
private Context mContext;
public Adapter(List<CourseHomeBodyBean> data, Context context) {
this.data = data;
mContext = context;
}
public void setData(List<CourseHomeBodyBean> data) {
this.data = data;
}
@Override
public BaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_imag, parent, false);
return new BaseViewHolder(view);
}
@Override
public void onBindViewHolder(BaseViewHolder holder, int position) {
holder.setImageWithUrl(R.id.img, data.get(position).image);
holder.setOnClickListener(R.id.img, view -> {
UMEventUtils.umEvent("专题课程", "专题链接", data.get(position).linkUrl);
LinkUrlRouterProtocol.jump(mContext, data.get(position).linkUrl);
ActionCountUtils.Companion.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_THEMATIC_COURSES_XXX_CLICK + data.get(position).id + "_click");
});
}
@Override
public int getItemCount() {
return data.size();
}
}
}
package com.yidianling.course.courseNew.viewholder;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.course.R;
import com.yidianling.course.courseNew.courseList.CourseListContainerActivity;
//更多课程
public class FooterMoreViewHolder extends RecyclerView.ViewHolder {
public TextView titleView;
public LinearLayout linearLayout;
public FooterMoreViewHolder(View itemView) {
super(itemView);
titleView = itemView.findViewById(R.id.tv_title);
linearLayout = itemView.findViewById(R.id.ll_more);
}
}
\ No newline at end of file
package com.yidianling.course.courseNew.viewholder;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.yidianling.course.R;
public class SingleTitleHeaderViewHolder extends RecyclerView.ViewHolder {
public TextView titleView;
public TextView subTitleView;
public SingleTitleHeaderViewHolder(View itemView) {
super(itemView);
titleView = itemView.findViewById(R.id.single_title);
subTitleView = itemView.findViewById(R.id.tv_more);
}
public SingleTitleHeaderViewHolder(Context context, ViewGroup parent) {
super(LayoutInflater.from(context).inflate(R.layout.item_classified_title, parent, false));
titleView = itemView.findViewById(R.id.single_title);
subTitleView = itemView.findViewById(R.id.tv_more);
}
}
\ No newline at end of file
package com.yidianling.course.coursePlay
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.CourseConstants
import com.yidianling.course.R
import com.yidianling.course.coursePlay.common.net.Command
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
import com.yidianling.ydlcommon.base.BaseActivity
import com.yidianling.ydlcommon.h5.H5Params
import com.yidianling.ydlcommon.h5.NewH5Activity
import com.yidianling.ydlcommon.log.LogHelper
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_course_commeny.*
......@@ -65,7 +66,7 @@ class CourseCommentActivity : BaseActivity() {
override fun afterTextChanged(s: Editable?) {
if (TextUtils.isEmpty(s)) {
tv_input_length.text = "0"
tv_input_length.setTextColor(resources.getColor(R.color.color_b3b3b3))
tv_input_length.setTextColor(resources.getColor(R.color.color_B3B3B3))
} else {
tv_input_length.text = s!!.length.toString()
tv_input_length.setTextColor(resources.getColor(R.color.color_242424))
......@@ -81,6 +82,7 @@ class CourseCommentActivity : BaseActivity() {
}
//提交评论
@SuppressLint("CheckResult")
private fun commitReply(content: String) {
showProgressDialog(null)
val cmd = Command.CourseCommitReply(courseId!!.toInt(), content)
......
......@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
import android.text.TextUtils
import android.view.View
import android.widget.LinearLayout
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.module.GlideApp
import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.CourseConstants
import com.yidianling.course.R
import com.yidianling.ydlcommon.bean.CourseExtraBean
import com.yidianling.ydlcommon.h5.H5Params
import com.yidianling.ydlcommon.h5.NewH5Activity
import com.yidianling.course.bean.CourseExtraBean
import kotlinx.android.synthetic.main.item_course_play_head.view.*
/**
......@@ -50,7 +50,7 @@ class CourseHeadView : LinearLayout {
@SuppressLint("SetTextI18n")
fun setData(bean: CourseExtraBean) {
courseId = bean.id
GlideApp.with(context).load(bean.doctorHead).error(R.drawable.head_place_hold_pic).into(img_head)
GlideApp.with(context).load(bean.doctorHead).error(R.drawable.course_head_place_hold_pic).into(img_head)
if (TextUtils.isEmpty(bean.doctorName)) {
ll_info.visibility= View.GONE
}else{
......
......@@ -6,6 +6,8 @@ import android.view.ViewGroup
import android.widget.RelativeLayout
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxNetTool
import com.yidianling.course.bean.CourseExtraBean
import com.yidianling.course.bean.CourseMediaBean
import com.yidianling.ydlcommon.bean.CourseExtraBean
import com.yidianling.ydlcommon.bean.CourseMediaBean
import com.yidianling.ydlcommon.dialog.CommonDialog
......
......@@ -9,12 +9,10 @@ import android.widget.RelativeLayout
import com.dou361.ijkplayer.widget.PlayStateParams
import com.dou361.ijkplayer.widget.PlayerView
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.course.R
import com.yidianling.ydlcommon.bean.CourseExtraBean
import com.yidianling.ydlcommon.bean.CourseMediaBean
import com.yidianling.ydlcommon.dialog.CommonDialog
import com.yidianling.ydlcommon.player.YDLMusicHelper
import com.yidianling.ydlcommon.player.util.UtilH
import com.yidianling.course.bean.CourseExtraBean
import com.yidianling.course.bean.CourseMediaBean
import tv.danmaku.ijk.media.player.IMediaPlayer
import java.text.SimpleDateFormat
import java.util.*
......
package com.yidianling.course.coursePlay
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import com.cxzapp.yidianling.common.view.FootViewLoadMore
import com.ydl.ydl_image.module.GlideApp
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.R
import com.yidianling.course.coursePlay.common.net.Command
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
import com.yidianling.course.coursePlay.moudle.CoursePlayBean
import com.yidianling.ydlcommon.adapter.CommonRecyclerAdapter
import com.yidianling.ydlcommon.base.BaseActivity
import com.yidianling.ydlcommon.view.BaseViewHolder
import com.yidianling.ydlcommon.view.CircleImageView
import com.yidianling.ydlcommon.view.TitleBar
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/**
* 课程课后笔记列表
*
*/
class CourseReplyListActivity : BaseActivity() {
override fun layoutResId(): Int {
return R.layout.activity_course_reply_list
}
override fun initDataAndEvent() {
course_id = intent.getIntExtra("course_id", 0)
initView()
getListData(false)
}
var title_bar: TitleBar? = null
var recycler_list: RecyclerView? = null
var footView: FootViewLoadMore? = null
var adapter: CommonRecyclerAdapter<CoursePlayBean.Comments>? = null
var page = 1 //分页
//课程id
var course_id = 0
fun initView() {
title_bar = findViewById<TitleBar>(R.id.title_bar)
recycler_list = findViewById<RecyclerView>(R.id.recycler_list)
recycler_list?.layoutManager = LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)
adapter = CommonRecyclerAdapter<CoursePlayBean.Comments>(recycler_list, R.layout.item_course_play_recylist)
.setBindDataCallback(object : CommonRecyclerAdapter.BindDataCallback<CoursePlayBean.Comments> {
override fun bindDatabindData(holder: BaseViewHolder, t: CoursePlayBean.Comments, position: Int) {
//绑定数据
var img: CircleImageView = holder.getView(R.id.img_head)
GlideApp.with(applicationContext).load(t.head).into(img)
holder.setText(R.id.text_name, t.name)
holder.setText(R.id.text_time, t.create_time)
holder.setText(R.id.text_des, t.content)
}
})
.setOnLoadMoreListener(object : CommonRecyclerAdapter.OnLoadMoreLIstener {
override fun onLoadMore() {
getListData(true)
LogUtil.e("---------------------------------------")
}
})
footView = FootViewLoadMore(mContext)
adapter?.addFootView(footView)
recycler_list?.adapter = adapter
}
//获取列表数据
fun getListData(isLoadMore: Boolean) {
if (isLoadMore) {
page++
} else {
page = 1
}
if (isLoadMore) {
footView?.onLoading()
} else {
showProgressDialog(null)
}
val cmd = Command.CourseReplyList(course_id, page)
RetrofitUtils.courseReplyList(cmd)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp ->
if (!isLoadMore) {
dismissProgressDialog()
}
if (resp.code == 0) {
//跟新view显示
updateView(isLoadMore, resp.data as List<CoursePlayBean.Comments>)
} else {
footView?.onError()
ToastUtil.toastShort(resp.msg)
}
}, {
throwable->
footView?.onError()
if (!isLoadMore) {
dismissProgressDialog()
}
RetrofitUtils.handleError(mContext, throwable)
})
}
//跟新视图
fun updateView(isLoadMore: Boolean, list: List<CoursePlayBean.Comments>) {
if (list == null) return
if (list.size == 0) {
footView?.onFinish()
return
}
if (isLoadMore) {
adapter?.addDatas(list)
} else {
adapter?.update(list)
}
}
}
package com.yidianling.course.coursePlay
import com.yidianling.ydlcommon.bean.CourseExtraBean
import com.yidianling.ydlcommon.bean.CourseMediaBean
import com.yidianling.course.bean.CourseExtraBean
import com.yidianling.course.bean.CourseMediaBean
import java.util.*
......
package com.yidianling.course.coursePlay.common.net;
import com.yidianling.course.CourseConstants;
import com.yidianling.ydlcommon.http.BaseCommand;
import com.yidianling.ydlcommon.router.YdlCommonOut;
import com.ydl.ydlcommon.data.http.BaseCommand;
import com.ydl.ydlcommon.router.YdlCommonOut;
/**
* Created by Jim on 2018/2/26 0026.
......@@ -81,14 +80,10 @@ public class Command {
this.type = type;
}
public GetCourse(int page, int type,int child_type) {
public GetCourse(int page, int type, int child_type) {
this.page = page;
this.type = type;
this.child_type=child_type;
}
public String getUrl() {
return CourseConstants.ALL_COURSE;
this.child_type = child_type;
}
}
......
package com.yidianling.course.coursePlay.common.net;
import com.ydl.ydlcommon.data.http.BaseAPIResponse;
import com.ydl.ydlcommon.data.http.BaseResponse;
import com.yidianling.course.bean.CouponHintResponseBean;
import com.yidianling.course.bean.CourseCouponBean;
import com.yidianling.course.bean.CourseMediaDetailBean;
import com.yidianling.course.bean.PostersShareBean;
import com.yidianling.course.courseNew.home.ResultBean;
import com.yidianling.course.coursePlay.moudle.Course;
import com.yidianling.course.coursePlay.moudle.CourseAddOrderBean;
import com.yidianling.course.coursePlay.moudle.CourseListDataBean;
import com.yidianling.course.coursePlay.moudle.CoursePlayBean;
import com.yidianling.course.model.CourseCategoryBean;
import com.yidianling.course.model.TopicCourseBean;
import com.yidianling.ydlcommon.http.BaseAPIResponse;
import com.yidianling.ydlcommon.http.BaseResponse;
import java.util.List;
import java.util.Map;
......@@ -42,12 +43,6 @@ public interface NetApiStore {
@POST("course/list")
Observable<BaseResponse<List<Course>>> getPhpCourseList(@FieldMap Map<String, String> params);
// //获取课程播放页 初始化数据
// @FormUrlEncoded
// @POST("course/play")
// Observable<BaseResponse<CoursePlayBean>> getCoursePlayData(@FieldMap Map<String, String> params);
//课程课后笔记列表
@FormUrlEncoded
@POST("course/comments")
......@@ -68,11 +63,6 @@ public interface NetApiStore {
@POST("course/add-order")
Observable<BaseResponse<CourseAddOrderBean>> addCourseOrder(@FieldMap Map<String, String> params);
//首页课程
@GET("auth/course/home")
Observable<BaseAPIResponse<List<ResultBean>>> getCourseHomePageDatas();
//获取课程海报分享数据
@GET("auth/course/posters/share")
Observable<BaseResponse<PostersShareBean>> getPosterData(@Query("id") String courseId);
......@@ -87,10 +77,6 @@ public interface NetApiStore {
@GET("auth/course/search/newsample")
Observable<BaseAPIResponse<CourseCategoryBean>> getCourseListCategory();
// //首页分类
// @FormUrlEncoded
// @POST("course/course-special")
// Observable<BaseResponse<TopicCourseBean>> getCourseTopic(@FieldMap Map<String, String> params);
//课程专题列表接口
......@@ -116,4 +102,18 @@ public interface NetApiStore {
//领取优惠券
@POST("marketing/coupon/new/receives")
Observable<BaseResponse<List<String>>> receiveCoupon(@Body RequestBody body);
@GET("auth/coupon/courseCoupon/warn")
Observable<BaseAPIResponse<CouponHintResponseBean>> getCouponHint();
//倾诉红包接口
@retrofit2.http.Headers("Content-Type:application/json")
@GET
Observable<BaseAPIResponse<String>> getCouponMax(@Url String url);
//获取课程播放页 java 接口
@GET("auth/course/get/all/audio-video")
Observable<BaseResponse<CourseMediaDetailBean>> getCoursePlayData(@Query("courseId") String courseId);
}
package com.yidianling.course.coursePlay.common.net;
import android.content.Context;
import com.yidianling.course.bean.CourseCouponBean;
import com.yidianling.course.bean.PostersShareBean;
import com.yidianling.course.courseNew.home.ResultBean;
import com.ydl.ydlcommon.data.http.BaseAPIResponse;
import com.ydl.ydlcommon.data.http.BaseResponse;
import com.ydl.ydlcommon.data.http.FormatText;
import com.ydl.ydlcommon.utils.NetworkParamsUtils;
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils;
import com.ydl.ydlnet.YDLHttpUtils;
import com.yidianling.course.bean.*;
import com.yidianling.course.coursePlay.moudle.Course;
import com.yidianling.course.coursePlay.moudle.CourseAddOrderBean;
import com.yidianling.course.coursePlay.moudle.CourseListDataBean;
import com.yidianling.course.coursePlay.moudle.CoursePlayBean;
import com.yidianling.course.model.CourseCategoryBean;
import com.yidianling.course.model.TopicCourseBean;
import com.yidianling.ydlcommon.http.BaseAPIResponse;
import com.yidianling.ydlcommon.http.BaseCommand;
import com.yidianling.ydlcommon.http.BaseResponse;
import com.yidianling.ydlcommon.http.FormatText;
import com.yidianling.ydlcommon.http.YdlRetrofitUtils;
import java.util.List;
import io.reactivex.Observable;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Retrofit;
import static com.yidianling.ydlcommon.http.YdlRetrofitUtils.getMaps;
import static com.yidianling.ydlcommon.http.YdlRetrofitUtils.getPostList;
import java.util.List;
/**
* Created by Jim on 2018/2/26 0026.
......@@ -33,62 +26,48 @@ import static com.yidianling.ydlcommon.http.YdlRetrofitUtils.getPostList;
public class RetrofitUtils {
public static void handleError(Context context, Throwable e) {
YdlRetrofitUtils.handleError(context, e);
}
public static Retrofit getRxRetrofit() {
return YdlRetrofitUtils.getRxRetrofit();
HttpErrorUtils.Companion.handleError(context, e);
}
//课程提交回复
public static Observable<BaseResponse<Object>> commitCourseReply(Command.CourseCommitReply cmd) {
List<FormatText> list = getPostList(cmd);
return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).commitCourseReply(getMaps(list));
List<FormatText> list = NetworkParamsUtils.getPostList(cmd);
// return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).commitCourseReply(getMaps(list));
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).commitCourseReply(NetworkParamsUtils.getMaps(list));
}
//获取课程海报分享数据
public static Observable<BaseResponse<PostersShareBean>> getPosterData(String courseId) {
return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getPosterData(courseId);
}
//课程播放页--点赞
public static Observable<BaseResponse<Object>> coursePlayZan(Command.CoursePlayZan cmd) {
List<FormatText> list = getPostList(cmd);
return getRxRetrofit().create(NetApiStore.class).coursePlayZan(getMaps(list));
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getPosterData(courseId);
// return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getPosterData(courseId);
}
//课程课后笔记列表
public static Observable<BaseResponse<List<CoursePlayBean.Comments>>> courseReplyList(Command.CourseReplyList cmd) {
List<FormatText> list = getPostList(cmd);
return getRxRetrofit().create(NetApiStore.class).courseReplyList(getMaps(list));
}
public static Observable<BaseAPIResponse<List<ResultBean>>> getCoursesHomePage() {
return getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getCourseHomePageDatas();
List<FormatText> list = NetworkParamsUtils.getPostList(cmd);
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).courseReplyList(NetworkParamsUtils.getMaps(list));
// return getRxRetrofit().create(NetApiStore.class).courseReplyList(getMaps(list));
}
//获取课程列表(php接口)
public static Observable<BaseResponse<List<Course>>> getCourseList(Command.GetCourse cmd) {
List<FormatText> list = getPostList(cmd);
return getRxRetrofit().create(NetApiStore.class).getPhpCourseList(getMaps(list));
}
List<FormatText> list = NetworkParamsUtils.getPostList(cmd);
//获取课程列表分类
public static Observable<BaseResponse<List<CourseCategoryBean>>> getCourseListCategory(BaseCommand cmd) {
List<FormatText> list = getPostList(cmd);
return getRxRetrofit().create(NetApiStore.class).getCourseCats(getMaps(list));
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getPhpCourseList(NetworkParamsUtils.getMaps(list));
// return getRxRetrofit().create(NetApiStore.class).getPhpCourseList(getMaps(list));
}
//获取课程列表分类
public static Observable<BaseAPIResponse<CourseCategoryBean>> getCourseListCategory() {
return getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getCourseListCategory();
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCourseListCategory();
// return getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getCourseListCategory();
}
//获取课程专题
public static Observable<BaseAPIResponse<TopicCourseBean>> getCourseTopic(String id) {
return getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getCourseSpecial(id);
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCourseSpecial(id);
// return getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getCourseSpecial(id);
}
......@@ -102,14 +81,39 @@ public class RetrofitUtils {
* @return
*/
public static Observable<BaseResponse<List<CourseCouponBean>>> getCourseCoupons(String uid, String services, String receiveType, String applyEnds) {
return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_COUPON_URL)
.build().create(NetApiStore.class).getCourseCoupons(uid, services, receiveType, applyEnds);
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCourseCoupons(uid, services, receiveType, applyEnds);
// return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_COUPON_URL)
// .build().create(NetApiStore.class).getCourseCoupons(uid, services, receiveType, applyEnds);
}
//领取优惠券
public static Observable<BaseResponse<List<String>>> receiveCoupon(String couponIds) {
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), couponIds);
return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_COUPON_URL).build().create(NetApiStore.class).receiveCoupon(body);
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).receiveCoupon(body);
}
public static Observable<BaseAPIResponse<CouponHintResponseBean>> getCouponHint(CouponHintParam param) {
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCouponHint();
}
public static Observable<BaseAPIResponse<String>> getCouponMax(RedListParam param) {
StringBuffer sb = new StringBuffer();
sb.append("serviceType").append("=").append(param.getServiceType()).append("&");
String confideParam = sb.toString() + NetworkParamsUtils.getCommonParam();
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCouponMax(confideParam);
}
public static Observable<BaseAPIResponse<CourseListDataBean>> getCourseList(String url) {
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCourseList(YdlRetrofitUtils.SERVER_API_JAVA_URL + "auth/course/getList?"+url);
}
/**
* 获取课程播放页 java 接口
*
*/
public static Observable<BaseResponse<CourseMediaDetailBean>> getCoursePlayData(String courseId) {
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCoursePlayData(courseId);
}
}
package com.yidianling.course.coursePlay.dialog
/**
* 课程播放列表dialog 实体类
* Created by harvie on 2017/6/29 0029.
*/
class CoursePlayListBean{
var isPlay = false //当前是否在播放
var title = "" //课程标题
var playUrl = "" //播放地址
var isTestPlay = false //是否试听音频
var playTime = "00:00" //音频时长
}
\ No newline at end of file
package com.yidianling.course.coursePlay.dialog
import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.Gravity
import android.view.View
import android.view.Window
import android.widget.ImageView
import android.widget.TextView
import com.ydl.ydl_image.module.GlideApp
import com.yidianling.course.R
import com.yidianling.ydlcommon.adapter.CommonRecyclerAdapter
import com.yidianling.ydlcommon.view.BaseViewHolder
/**
* 课程播放列表dialog
* Created by harvie on 2017/6/29 0029.
*/
class CoursePlayListDialog : Dialog {
var mContext: Context? = null
var recyList: RecyclerView? = null
var textClose: TextView? = null
var index = 0 //当前播放下标
var itemListener: ItemClickListener? = null
var adapter: CommonRecyclerAdapter<CoursePlayListBean>? = null
constructor(context: Context?) : super(context, R.style.commonDialog) {
mContext = context
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(R.layout.dialog_course_playlist)
val m = window.windowManager
val d = m.defaultDisplay
val p = window.attributes
p.width = d.width //设置dialog的宽度为当前手机屏幕的宽度
p.height = (d.height * 5 / 10)
window.attributes = p
window.setGravity(Gravity.BOTTOM)
initView()
}
//跟新当前播放下标
fun updateIndex(inde: Int) {
index = inde
adapter?.notifyDataSetChanged()
}
fun initView() {
recyList = findViewById<RecyclerView>(R.id.recy_list)
textClose = findViewById<TextView>(R.id.text_close)
textClose?.setOnClickListener {
dismiss()
}
recyList?.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
adapter = CommonRecyclerAdapter<CoursePlayListBean>(recyList, R.layout.dialog_course_playlist_item)
.setBindDataCallback(object : CommonRecyclerAdapter.BindDataCallback<CoursePlayListBean> {
override fun bindDatabindData(holder: BaseViewHolder, t: CoursePlayListBean, position: Int) {
var gifView: ImageView = holder.getView(R.id.gifView)
if (index == position) {
GlideApp.with(context).load(R.drawable.music).into(gifView)
gifView.visibility = View.VISIBLE
holder.setTextColor(R.id.text_title, context.resources.getColor(R.color.google_green))
} else {
gifView.visibility = View.GONE
holder.setTextColor(R.id.text_title, context.resources.getColor(R.color.black_deep))
}
var test: TextView = holder.getView(R.id.text_test)
if (t.isTestPlay) {
test.visibility = View.VISIBLE
} else {
test.visibility = View.GONE
}
holder.setText(R.id.text_title, t.title)
holder.setText(R.id.text_time, "" + t.playTime)
holder.setOnClickListener(R.id.lin_body) {
//item点击事件
var boo = itemListener?.itemClick(position) ?: false
if (boo) {
index = position
adapter?.notifyDataSetChanged()
}
}
}
})
recyList?.adapter = adapter
}
fun scrollToPosition(i: Int) {
recyList?.scrollToPosition(i)
}
//设置item点击事件
fun setItemClickListener(itemListener: ItemClickListener): CoursePlayListDialog {
this.itemListener = itemListener
return this
}
//设置列表数据
fun setList(playIndex: Int, list: List<CoursePlayListBean>?) {
this.index = playIndex
if (list != null) {
for (i in list.indices) {
list[i].isPlay = i == playIndex
}
adapter?.update(list)
}
}
//跟新列表状态
fun updateAdapter() {
adapter?.notifyDataSetChanged()
}
//列表点击事件
interface ItemClickListener {
fun itemClick(indec: Int): Boolean
}
override fun show() {
if (null == mContext) {
return
}
if (mContext is Activity) {
if ((mContext as Activity).isFinishing) {
return
}
}
super.show()
}
}
\ No newline at end of file
package com.yidianling.course.coursePlay.http
/**
* @author yuanwai
* @描述:课程列表页接口实现模型
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/11
*/
object CourseListDataManager{
fun getHttp(): ICourseListHttp = CourseListHttpImpl.getInstance()
}
\ No newline at end of file
package com.yidianling.course.coursePlay.http
import com.yidianling.course.coursePlay.common.net.NetApiStore
import com.yidianling.course.coursePlay.moudle.CourseListDataBean
import com.yidianling.ydlcommon.http.BaseAPIResponse
import com.yidianling.ydlcommon.http.RxUtils
import com.yidianling.ydlcommon.http.YdlRetrofitUtils
import io.reactivex.Observable
/**
* @author yuanWai
* @描述:课程列表页接口实现类
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/12
*/
class CourseListHttpImpl : ICourseListHttp{
companion object {
fun getInstance(): CourseListHttpImpl {
return Holder.INSTANCE
}
}
object Holder {
val INSTANCE = CourseListHttpImpl()
}
private val netApiStore: NetApiStore by lazy {
YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore::class.java)
}
override fun getCourseList(params: String): Observable<BaseAPIResponse<CourseListDataBean>> {
return RxUtils.mapObservable(CourseListParams(""))
.flatMap {netApiStore.getCourseList(YdlRetrofitUtils.SERVER_API_JAVA_URL + "auth/course/getList?" + params)
}
}
}
\ No newline at end of file
package com.yidianling.course.coursePlay.http
import com.yidianling.course.coursePlay.moudle.CourseListDataBean
import com.yidianling.ydlcommon.http.BaseAPIResponse
import io.reactivex.Observable
/**
* @author yuanwai
* @描述:课程列表页请求接口
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/11
*/
interface ICourseListHttp{
/**
* 专家搜索页请求
*/
fun getCourseList(params : String): Observable<BaseAPIResponse<CourseListDataBean>>
}
\ No newline at end of file
package com.yidianling.course.coursePlay.moudle;
import com.ydl.ydlcommon.bean.ShareData;
import com.yidianling.course.bean.CourseHostInfoBean;
import com.yidianling.ydlcommon.data.ShareData;
//课程列表
//课程
......
package com.yidianling.course.coursePlay.moudle
import com.yidianling.ydlcommon.bean.YDLBaseDataBean
import com.ydl.ydlcommon.bean.YDLBaseDataBean
/**
* @author yuanWai
......@@ -9,4 +9,4 @@ import com.yidianling.ydlcommon.bean.YDLBaseDataBean
* @Company 壹点灵
* @date 2018/12/12
*/
data class CourseListDataBean(val list : List<Course>) : YDLBaseDataBean()
\ No newline at end of file
data class CourseListDataBean(val list: List<Course>) : YDLBaseDataBean()
\ No newline at end of file
package com.yidianling.course.coursePlay.moudle
import com.yidianling.ydlcommon.data.ShareData
import com.ydl.ydlcommon.bean.ShareData
import java.util.*
/**
......
package com.yidianling.course.coursePlay.presenter
import android.annotation.SuppressLint
import com.yidianling.common.tools.ToastUtil
import com.yidianling.ydlcommon.bean.CourseMediaDetailBean
import com.yidianling.course.bean.CourseMediaDetailBean
import com.yidianling.course.coursePlay.CoursePlayActivity
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
import com.yidianling.ydlcommon.http.api.ApiRequestUtil
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......@@ -13,9 +13,10 @@ import io.reactivex.schedulers.Schedulers
* Created by harvie on 2017/6/28 0028.
*/
class CoursePlayPresenter(val view: CoursePlayActivity) {
@SuppressLint("CheckResult")
fun getInitData(course_id: Int) {
view.showLoadingDialog()
ApiRequestUtil.getCoursePlayData(course_id.toString())
RetrofitUtils.getCoursePlayData(course_id.toString())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp ->
......
......@@ -2,6 +2,7 @@ package com.yidianling.course.course_special_list.presenter
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.yidianling.common.tools.RxNetTool
import com.yidianling.course.course_special_list.bean.CourseSpecialItemBean
import com.yidianling.course.course_special_list.contract.ICourseSpecialListContract
......@@ -20,12 +21,18 @@ import io.reactivex.schedulers.Schedulers
* @Company 壹点灵
* @date 2018/9/18
*/
class CourseSpecialListPresenterImpl (view: ICourseSpecialListContract.View) :
RxPresenter<ICourseSpecialListContract.View, ICourseSpecialListContract.Model>(view), ICourseSpecialListContract.Presenter{
class CourseSpecialListPresenterImpl (var view: ICourseSpecialListContract.View) :
ICourseSpecialListContract.Presenter{
override fun attachView(view: ICourseSpecialListContract.View) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun detachView() {
TODO("not implemented") //To change body of crea ted functions use File | Settings | File Templates.
}
override fun createModel(): ICourseSpecialListContract.Model {
return CourseSpecialListModelImpl()
override fun destroy() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
/**
......@@ -90,6 +97,5 @@ class CourseSpecialListPresenterImpl (view: ICourseSpecialListContract.View) :
}
}
})
addDisposable(disposable)
}
}
\ No newline at end of file
import android.content.Intent
import android.net.Uri
import android.text.TextUtils
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.course.BuildConfig
......@@ -10,14 +14,7 @@ import com.yidianling.course.courseNew.mine.MyCourseActivity
import com.yidianling.course.course_special_list.activity.CourseSpecialListActivity
import com.yidianling.course.flutterPlugin.CourseSendPlugin
import com.yidianling.course.router.CourseIn
import com.yidianling.ydlcommon.app.YdlCommonApp
import com.yidianling.ydlcommon.flutter.base.BaseFlutterFragment
import com.yidianling.ydlcommon.h5.H5Params
import com.yidianling.ydlcommon.h5.NewH5Activity
import com.yidianling.ydlcommon.player.YDLMusicHelper
import com.yidianling.ydlcommon.router.YdlCommonRouterManager
import com.yidianling.ydlcommon.utils.PlayerFloatHelper
import com.yidianling.ydlcommon.view.PlayerFloatView
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.view.FlutterView
......@@ -57,8 +54,8 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
mMap["accessToken"] = YdlCommonRouterManager.getYdlCommonRoute().getAccessToken()
?: ""
mMap["isFromApp"] = "1"
mMap["version"] = RxDeviceTool.getAppVersionName(YdlCommonApp.getApp())
mMap["osBuild"] = RxDeviceTool.getBuildMANUFACTURER() + "," + RxDeviceTool.getBuildBrandModel() + "," + RxDeviceTool.getOsBuileVersion() + "," + RxDeviceTool.getAppVersionName(YdlCommonApp.getApp())
mMap["version"] = RxDeviceTool.getAppVersionName(BaseApp.getApp())
mMap["osBuild"] = RxDeviceTool.getBuildMANUFACTURER() + "," + RxDeviceTool.getBuildBrandModel() + "," + RxDeviceTool.getOsBuileVersion() + "," + RxDeviceTool.getAppVersionName(BaseApp.getApp())
result.success(mMap)
}
JUMPURL -> {
......
package com.yidianling.course.model;
/**
* Created by Jim on 2018/6/22 0022.
*/
public class Banner {
public String imagUrl;
}
package com.yidianling.course.model;
/**
* Created by Jim on 2018/7/14 0014.
*/
public class CatogoryBean {
public String title;
public String image;
public String linkUrl;
}
package com.yidianling.course.model;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Jim on 2018/7/14 0014.
*/
public class ClassifiedCoursesBean {
public Head head;
public Body body;
public Footer footer;
public static class Head {
/**
* title : 精品课程
* tab1Name : 免费课程
* tab2Name : 付费课程
*/
public String title;
public String tab1Name;
public String tab2Name;
}
public static class Body {
public List<TabListBean> oneTabList;
public List<TabListBean> twoTabList;
public static class TabListBean {
/**
* id : 6
* image : https://img.ydlcdn.com/file/2015/11/zawz18il050dybbm.jpg
* title : 阳光心灵分享会第一期:谈谈心中的那缕烦忧
* expert :
* price : 30.00
* popularity : 67
* linkUrl : https://testh2.yidianling.com/course/6
*/
public String id;
public String image;
public String title;
public String expert;
public String price;
public String popularity;
public String linkUrl;
}
}
public static class Footer {
public String title;
public String linkUrl;
}
}
package com.yidianling.course.model;
import com.google.gson.annotations.SerializedName;
public class CourseBean {
public String id;
public String image;
public String title;
public String leftBottom;
public String rightBottom;
public String linkUrl;
/**
* 是否显示返利标签
* 0不显示 1显示
*/
public int isInvite;
/**
* 促销标签:
* 1活动中 2结束or没开始 3倒计时
* <p>
* 1和3都显示促销标签
* <p>
* if(is_promotion == 1) 时 列表金额取 promotion_apply_fee字段
*/
@SerializedName("isPromotion")
//这么java接口和php接口字段名不同,兼容两个接口
public String is_promotion;
@SerializedName("promotionApplyFee")
public String promotion_apply_fee;
}
\ No newline at end of file
package com.yidianling.course.model;
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述: 用于存放私聊,倾诉,咨询三个按钮
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/26
*/
public class LocalButtonShownBean {
public int type; //0隐藏1显示
public String name; //按钮描述
public LocalButtonShownBean(int type, String name) {
this.type = type;
this.name = name;
}
}
package com.yidianling.course.model;
import com.yidianling.course.bean.CourseHomeBodyBean;
import com.yidianling.course.courseNew.home.ResultBean;
import java.util.List;
/**
* @author : Zhangwenchao
* @e-mail : zhangwch@yidianling.com
* @time : 2018/7/14
*/
public class NormalCourseBean {
public ResultBean.Head head;
public List<CourseHomeBodyBean> body;
public ResultBean.Footer footer;
public int type;
public boolean diviLine;
}
package com.yidianling.course.model;
import com.yidianling.course.bean.CourseHomeBodyBean;
import com.yidianling.course.courseNew.home.ResultBean;
import java.util.ArrayList;
import java.util.List;
/**
* @author : Zhangwenchao
* @e-mail : zhangwch@yidianling.com
* @time : 2018/7/14
*/
public class QulityCourseBean {
public ResultBean.Head head;
public List<ArrayList<CourseHomeBodyBean>> body;
public ResultBean.Footer footer;
public int type;
public boolean diviLine;
}
package com.yidianling.course.model
import com.ydl.ydlcommon.bean.ShareData
import com.yidianling.course.coursePlay.moudle.Course
import com.yidianling.ydlcommon.data.ShareData
/**
* Created by Jim on 2018/7/16 0016.
......
package com.yidianling.course.widget
import android.annotation.SuppressLint
import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
import android.util.Log
import android.view.View
import android.widget.RelativeLayout
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.course.R
import com.yidianling.course.bean.CouponHintParam
import com.yidianling.course.bean.CouponHintResponseBean
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import kotlinx.android.synthetic.main.coupon_hint_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:我的课程优惠码View
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/27
*/
class CouponHintView : RelativeLayout{
private var jumpType : Int = JUMP_TO_COUPON_LIST
private var mCouponHintCallBack : CouponHintCallBack? = null
//是否显示
private var couponHintVisible : Int = View.VISIBLE
private var couponUrl:String? = null
companion object {
/**
* 跳转类型
* 0.跳转红包
*/
const val JUMP_TO_COUPON_LIST = 0
}
constructor(context:Context):super(context){
initView()
}
constructor(context: Context,attributeSet: AttributeSet):super(context,attributeSet){
initView()
}
/**
* 界面初始化
*/
private fun initView(){
View.inflate(context, R.layout.coupon_hint_view,this)
setOnClickListener {
when(jumpType){
JUMP_TO_COUPON_LIST ->{//我的红包
if (TextUtils.isEmpty(couponUrl)) {
YDLRouterManager.router(IYDLRouterConstant.ROUTER_MINE_REDPACKET)
}else {
YDLRouterManager.router(couponUrl)
}
}
}
visibility = View.GONE
}
imgClose.setOnClickListener {
visibility = View.GONE
}
}
/**
* 请求红包列表数据
*/
@SuppressLint("CheckResult")
fun initData(visible : Int){
this.couponHintVisible = visible
RetrofitUtils.getCouponHint(CouponHintParam(0)).compose(RxUtils.resultJavaData())
.map { it }
.filter { it != null }
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
if (null != it) {
setData(it)
couponUrl = it.url
}
}, object: ThrowableConsumer() {
override fun accept(msg: String) {
visibility = View.GONE
}
})
}
//设置跳转到我的红包
fun setCouponList(){
jumpType = JUMP_TO_COUPON_LIST
}
/**
* 数据赋值
*/
private fun setData(couponData : CouponHintResponseBean){
if (TextUtils.isEmpty(couponData.msg)){
visibility = View.GONE
return
}
//因为数据请求是异步的 会出现 MainActivity设置了隐藏 但是到了这里 依然显示的现象
visibility = couponHintVisible
val sb = StringBuffer()
sb.append(couponData.msg)
tvMsg.text = sb.toString()
}
fun setCloseHide(){
imgClose.visibility = View.GONE
}
fun setRedPacketCallBack(mRedPacketCallBack : CouponHintCallBack){
this.mCouponHintCallBack = mRedPacketCallBack
}
interface CouponHintCallBack{
fun jumpInfo() //暂未设置跳转
}
}
\ No newline at end of file
......@@ -13,14 +13,6 @@ import com.yidianling.common.tools.RxImageTool
import com.yidianling.course.CourseConstants
import com.yidianling.course.R
import com.yidianling.course.coursePlay.moudle.Course
import com.yidianling.ydlcommon.h5.H5Params
import com.yidianling.ydlcommon.h5.NewH5Activity
import com.yidianling.ydlcommon.player.YDLMusicHelper
import com.yidianling.ydlcommon.utils.PlayerFloatHelper
import com.yidianling.ydlcommon.utils.actionutil.ActionCountUtils
import com.yidianling.ydlcommon.utils.actionutil.BIConstants
import com.yidianling.ydlcommon.view.PlayerFloatView
import kotlinx.android.synthetic.main.item_course_new_list_view.view.*
/**
* @author jiucheng
......
package com.yidianling.course.widget
import android.annotation.SuppressLint
import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.course.R
import com.yidianling.course.bean.RedListParam
import com.yidianling.course.coursePlay.common.net.RetrofitUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import kotlinx.android.synthetic.main.course_redpacket_view.view.*
/**
* @author yuanWai
* @描述:红包提示View
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/27
*/
class CourseRedPacketView : RelativeLayout {
private var jumpType: Int = JUMP_NOT
private var mRedPacketCallBack: RedPacketCallBack? = null
private var onDataRequestFinishedListener: OnDataRequestFinishedListener? = null
//是否显示
private var redPacketVisible: Int = View.VISIBLE
companion object {
/**
* 跳转类型
* 0.不跳转 1.跳转倾诉频道 2.跳转专家详情
*/
const val JUMP_NOT = 0
const val JUMP_CONFIDE_HOME = 1
const val JUMP_EXPERT_INFO = 2
}
constructor(context: Context) : super(context) {
initView()
}
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {
initView()
}
/**
* 界面初始化
*/
private fun initView() {
View.inflate(context, R.layout.course_redpacket_view, this)
setOnClickListener {
when (jumpType) {
JUMP_NOT -> {//不跳转
}
JUMP_CONFIDE_HOME -> {//跳转倾诉频道页
// ARouter.getInstance().build("/confide/home").navigation()
YDLRouterManager.router(IYDLRouterConstant.ROUTER_CONFIDE_HOME)
}
JUMP_EXPERT_INFO -> {//跳转专家详情页
if (null != mRedPacketCallBack) {
mRedPacketCallBack!!.jumpExpertInfo()
}
}
}
visibility = View.GONE
}
imgClose.setOnClickListener {
visibility = View.GONE
}
}
/**
* 请求红包列表数据
*/
@SuppressLint("CheckResult")
fun initData(visible: Int) {
this.redPacketVisible = visible
RetrofitUtils.getCouponMax(RedListParam(3)).compose(RxUtils.resultJavaData())
.map { it }
.filter { it != null }
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
setData(it)
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
visibility = View.GONE
}
})
}
//设置不跳转
fun setNot() {
jumpType = JUMP_NOT
}
//设置跳转倾诉列表首页
fun setConfide() {
jumpType = JUMP_CONFIDE_HOME
}
//设置跳转专家详情页
fun setExpertInfo() {
jumpType = JUMP_EXPERT_INFO
}
/**
* 数据赋值
*/
private fun setData(couponMax: String) {
if (TextUtils.isEmpty(couponMax)) {
visibility = View.GONE
return
}
var max = couponMax.toFloat().toInt()
visibility = if (max > 0) {
View.VISIBLE
} else {
View.GONE
}
//因为数据请求是异步的 会出现 MainActivity设置了隐藏 但是到了这里 依然显示的现象
visibility = redPacketVisible
if (max <= 0) {
visibility = View.GONE
}
val sb = StringBuffer()
sb.append("您有")
.append(max)
.append("元的倾诉红包,倾诉享")
tvMsg.text = sb.toString()
if (onDataRequestFinishedListener != null) {
onDataRequestFinishedListener!!.onDataRequestFinishedListener(max)
}
}
fun setCloseHide() {
imgClose.visibility = View.GONE
}
fun setRedPacketCallBack(mRedPacketCallBack: RedPacketCallBack) {
this.mRedPacketCallBack = mRedPacketCallBack
}
interface RedPacketCallBack {
fun jumpExpertInfo()
}
fun setOnDataRequestFinishedListener(onDataRequestFinishedListener: OnDataRequestFinishedListener) {
this.onDataRequestFinishedListener = onDataRequestFinishedListener
}
/**
* 数据请求完成回调
*/
interface OnDataRequestFinishedListener {
fun onDataRequestFinishedListener(max: Int)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<shape>
<corners android:radius="16dp"/>
<solid android:color="@color/color_FFDB26"/>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp"/>
<solid android:color="@color/color_FFDB26" />
<stroke android:width="1dp" android:color="@color/color_FFDB26"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<shape>
<gradient
android:angle="90"
android:endColor="#00000000"
android:startColor="#0A000000"
/>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true">
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/main_theme" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<shape>
<corners android:radius="4dp" />
<solid android:color="@color/color_30FFFFFF"/>
</shape>
</item>
<item android:state_checked="false">
<shape>
<corners android:radius="4dp" />
<stroke android:width="0.5dp" android:color="@color/white" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp"/>
<solid android:color="#f5f5f5" />
<stroke android:width="1dp" android:color="#f5f5f5"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp" />
<solid android:color="@color/main_theme" />
<stroke
android:width="1dp"
android:color="@color/main_theme" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="14dp" />
<solid android:color="@color/color_FFDB26" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="6dp" />
<solid android:color="@color/main_theme" />
<stroke
android:width="0.5px"
android:color="@color/main_theme" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="6dp" />
<solid android:color="@color/color_F7F7F7" />
<stroke
android:width="0.5px"
android:color="@color/main_theme" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />
<solid android:color="@color/color_F7F7F7" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />
<stroke android:color="@color/color_1DA1F2" android:width="1px" />
<solid android:color="@color/color_151DA1F2" />
</shape>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment