Commit 1591b992 by konghaorui
parents 6cae6ba3 1d3448bf
...@@ -183,6 +183,7 @@ dependencies { ...@@ -183,6 +183,7 @@ dependencies {
// api rootProject.ext.dependencies["ydl-m-fm-module-ydl"] // api rootProject.ext.dependencies["ydl-m-fm-module-ydl"]
// api rootProject.ext.dependencies["ydl-m-fm-api"] // api rootProject.ext.dependencies["ydl-m-fm-api"]
api project(':m-fm') api project(':m-fm')
api project(':m-course')
implementation modularPublication('com.ydl:m-fm-api') implementation modularPublication('com.ydl:m-fm-api')
} else { } else {
//发布模式 //发布模式
......
...@@ -120,6 +120,11 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -120,6 +120,11 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
startActivity(ModularServiceManager.provide(IFMService::class.java).fmListIntent(this)) startActivity(ModularServiceManager.provide(IFMService::class.java).fmListIntent(this))
// YDLRouterManager.router(IYDLRouterConstant.ROUTER_FM_LIST) // YDLRouterManager.router(IYDLRouterConstant.ROUTER_FM_LIST)
} }
bt_to_course.setOnClickListener{
ARouter.getInstance().build("/course/home")
.navigation()
}
} }
......
...@@ -164,6 +164,18 @@ ...@@ -164,6 +164,18 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/bt_to_course"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:text="Jump to Course" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<com.ydl.ydlcommon.mvp.lce.view.YDLStateView <com.ydl.ydlcommon.mvp.lce.view.YDLStateView
......
...@@ -38,6 +38,10 @@ android { ...@@ -38,6 +38,10 @@ android {
ydl {} ydl {}
xlzx {} xlzx {}
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets { sourceSets {
main { main {
...@@ -56,12 +60,22 @@ dependencies { ...@@ -56,12 +60,22 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
kapt 'com.alibaba:arouter-compiler:1.2.2' kapt 'com.alibaba:arouter-compiler:1.2.2'
implementation 'com.jakewharton:butterknife:8.8.1' implementation 'com.jakewharton:butterknife:8.8.1'
// api 'com.dou361.ijkplayer-armv5:jjdxm-ijkplayer-armv5:1.0.0'
// api 'com.dou361.ijkplayer-arm64:jjdxm-ijkplayer-arm64:1.0.0'
// api 'com.dou361.ijkplayer-x86:jjdxm-ijkplayer-x86:1.0.0'
// api 'com.dou361.ijkplayer-x86_64:jjdxm-ijkplayer-x86_64:1.0.0'
// api('com.dou361.ijkplayer:jjdxm-ijkplayer:1.0.6') {
// exclude group: 'com.android.support', module: 'appcompat-v7'
// }
api rootProject.ext.dependencies["ydl-user-router"] api rootProject.ext.dependencies["ydl-user-router"]
if (rootProject.ext.dev_mode){ if (rootProject.ext.dev_mode){
//开发时使用 //开发时使用
implementation modularPublication('com.ydl:m-user-api') implementation modularPublication('com.ydl:m-user-api')
api project(":ydl-webview") api project(":ydl-webview")
api project(":ydl-platform") api project(":ydl-platform")
api project(":ydl-media")
api project(":ydl-pay")
} else { } else {
//发布时使用 //发布时使用
compileOnly rootProject.ext.dependencies["ydl-m-user-api"] compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yidianling.course"/> package="com.yidianling.course">
<application>
<!--课程首页-->
<activity
android:name=".CourseActivity"
android:screenOrientation="portrait" />
<activity
android:name=".CoursePosterActivity"
android:hardwareAccelerated="false"
android:screenOrientation="portrait"
android:theme="@style/CoursePosterShowTheme" />
<activity
android:name=".coursePlay.CourseCommentActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".coursePlay.CoursePlayActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/CourseTheme" />
<!--课程课后笔记列表-->
<activity
android:name=".coursePlay.CourseReplyListActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
<!--课程分类列表-->
<activity
android:name=".courseNew.courseList.CourseListContainerActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<activity android:name=".courseNew.CourseTopicActivity" />
<activity android:name=".courseSearch.CourseSearchActivity"
android:screenOrientation="portrait"
/>
<activity
android:name=".courseNew.mine.MyCourseActivity"
android:screenOrientation="portrait" />
<activity
android:name=".course_special_list.activity.CourseSpecialListActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
package com.yidianling.course; package com.yidianling.course;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.android.arouter.facade.annotation.Route;
import com.ydl.ydlcommon.base.BaseActivity; import com.ydl.ydlcommon.base.BaseActivity;
import com.yidianling.course.courseNew.home.CourseHomeFragment;
import com.yidianling.course.courseNew.mine.MyCourseActivity;
import com.yidianling.course.router.CourseIn;
import com.yidianling.course.widget.SearchBarView;
/** /**
* 课程首页Activity(心理课程) * 课程首页Activity(心理课程)
...@@ -23,32 +11,6 @@ import com.yidianling.course.widget.SearchBarView; ...@@ -23,32 +11,6 @@ import com.yidianling.course.widget.SearchBarView;
@Route(path = "/course/home") @Route(path = "/course/home")
public class CourseActivity extends BaseActivity { public class CourseActivity extends BaseActivity {
@BindView(R2.id.content)
FrameLayout content;
@BindView(R2.id.img_music)
ImageView imgMusic;
@BindView(R2.id.iv_back)
ImageView ivBack;
@BindView(R2.id.tv_left_menu)
TextView leftMenu;
@BindView(R2.id.activity_course_search_bar)
SearchBarView activityCourseSearchBar;
private boolean isSplash;//是否从启动页进入
private final static String TAB = "tab";
public final static int TAB0 = 0;
private static final String IS_SPLASH = "isSplash";
public static void start(Context context, int tab) {
Intent intent = new Intent(context, CourseActivity.class);
Bundle bundle = new Bundle();
bundle.putInt(TAB, tab);
intent.putExtra("bundle", bundle);
context.startActivity(intent);
}
@Override @Override
protected int layoutResId() { protected int layoutResId() {
...@@ -58,81 +20,20 @@ public class CourseActivity extends BaseActivity { ...@@ -58,81 +20,20 @@ public class CourseActivity extends BaseActivity {
@Override @Override
protected void initDataAndEvent() { protected void initDataAndEvent() {
ButterKnife.bind(this);
Bundle bundle = getIntent().getBundleExtra("bundle");
if (bundle != null) {
isSplash = bundle.getBoolean("isSplash", false);
}
activityCourseSearchBar.initBarType(SearchBarView.JUMP_TO_SEARCH_COURSE, null);
init();
}
private void init() {
initTags(); initTags();
ivBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
imgMusic.setOnClickListener(v -> {
if (YDLMusicHelper.INSTANCE.isCoursePlaying()) {
//课程播放页
YDLMusicHelper.INSTANCE.startCoursePlayActivity(getMContext(), 1, 0, "", false);
} else {
imgMusic.setVisibility(View.GONE);
}
});
leftMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (CourseIn.INSTANCE.isLogin()) {
MyCourseActivity.start(CourseActivity.this);
} else {
startActivity(CourseIn.INSTANCE.loginWayIntent(CourseActivity.this));
}
}
});
} }
/** /**
* 初始化tab * 初始化tab
*/ */
private void initTags() { private void initTags() {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content); Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content);
if (fragment == null) { if (fragment == null) {
fragment = new CourseHomeFragment(); fragment = new FlutterCourseHomeFragment();
getSupportFragmentManager().beginTransaction() getSupportFragmentManager().beginTransaction()
.add(R.id.content, fragment) .add(R.id.content, fragment)
.commit(); .commit();
} }
} }
@Override
protected void onResume() {
super.onResume();
if (YDLMusicHelper.INSTANCE.isCoursePlaying()) {
imgMusic.setVisibility(View.VISIBLE);
} else {
imgMusic.setVisibility(View.GONE);
}
}
public void disPro() {
dismissProgressDialog();
}
@Override
public void onBackPressed() {
super.onBackPressed();
if (isSplash) {
startActivity(CourseIn.INSTANCE.mainIntent(this));
finish();
}
}
} }
package com.yidianling.course package com.yidianling.course
import com.yidianling.ydlcommon.http.YdlRetrofitUtils import com.ydl.ydlcommon.base.config.HttpConfig
import com.yidianling.ydlcommon.router.YdlCommonOut
class CourseConstants { class CourseConstants {
companion object { 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 const val COURSE_PAGE_SIZE = 20
//课程详情H5地址 //课程详情H5地址
var COURSE_DETAIL_H5 = YdlRetrofitUtils.MH5_URL + "course/Detail/v2/" var COURSE_DETAIL_H5 = HttpConfig.MH5_URL + "course/Detail/v2/"
//课程评价页面 //课程评价页面
var COURSE_COMMENT_H5 = YdlRetrofitUtils.MH5_URL + "course/all-comments/" var COURSE_COMMENT_H5 = HttpConfig.MH5_URL + "course/all-comments/"
} }
......
...@@ -4,8 +4,8 @@ import android.content.Context; ...@@ -4,8 +4,8 @@ import android.content.Context;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.yidianling.course.coursePlay.moudle.Course; import com.ydl.ydlcommon.adapter.CommonAdapter;
import com.yidianling.ydlcommon.adapter.CommonAdapter; import com.yidianling.course.bean.Course;
/** /**
* Created by zqk on 6/22/17. * Created by zqk on 6/22/17.
......
...@@ -9,13 +9,10 @@ import android.widget.LinearLayout; ...@@ -9,13 +9,10 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.ydl.ydl_router.manager.YDLRouterManager; import com.ydl.ydl_router.manager.YDLRouterManager;
import com.yidianling.course.bean.Course;
import com.yidianling.course.coursePlay.CourseCommentActivity; import com.yidianling.course.coursePlay.CourseCommentActivity;
import com.yidianling.course.coursePlay.moudle.Course;
import com.yidianling.course.widget.CourseItemNewView; import com.yidianling.course.widget.CourseItemNewView;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import butterknife.BindView;
import butterknife.ButterKnife;
/** /**
* Created by zqk on 6/22/17. * Created by zqk on 6/22/17.
...@@ -23,16 +20,11 @@ import butterknife.ButterKnife; ...@@ -23,16 +20,11 @@ import butterknife.ButterKnife;
public class CourseListItemView extends ConstraintLayout implements View.OnClickListener { public class CourseListItemView extends ConstraintLayout implements View.OnClickListener {
@BindView(R2.id.view_content)
CourseItemNewView courseItemNewView; CourseItemNewView courseItemNewView;
@BindView(R2.id.iv_export_btn_layout)
LinearLayout ivExportBtnLayout; LinearLayout ivExportBtnLayout;
@BindView(R2.id.tv_line_bottom)
View tvLineBottom; View tvLineBottom;
@BindView(R2.id.tv_course_item_first)
TextView tvCourseItemFirst; TextView tvCourseItemFirst;
@BindView(R2.id.tv_course_item_comment)
TextView tvCourseItemComment; TextView tvCourseItemComment;
private Course mCourse; private Course mCourse;
...@@ -42,7 +34,12 @@ public class CourseListItemView extends ConstraintLayout implements View.OnClick ...@@ -42,7 +34,12 @@ public class CourseListItemView extends ConstraintLayout implements View.OnClick
super(context); super(context);
this.context = context; this.context = context;
View view = inflate(context, R.layout.item_course_list, this); View view = inflate(context, R.layout.item_course_list, this);
ButterKnife.bind(this, view);
courseItemNewView = view.findViewById(R.id.view_content);
ivExportBtnLayout = view.findViewById(R.id.iv_export_btn_layout);
tvLineBottom = view.findViewById(R.id.tv_line_bottom);
tvCourseItemFirst = view.findViewById(R.id.tv_course_item_first);
tvCourseItemComment = view.findViewById(R.id.tv_course_item_comment);
} }
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
...@@ -81,12 +78,7 @@ public class CourseListItemView extends ConstraintLayout implements View.OnClick ...@@ -81,12 +78,7 @@ public class CourseListItemView extends ConstraintLayout implements View.OnClick
} }
tvCourseItemComment.setOnClickListener(v -> CourseCommentActivity.Companion.startActivity((Activity) context, mCourse.id + "")); tvCourseItemComment.setOnClickListener(v -> CourseCommentActivity.Companion.startActivity((Activity) context, mCourse.id + ""));
tvCourseItemFirst.setOnClickListener(new OnClickListener() { tvCourseItemFirst.setOnClickListener(v -> YDLRouterManager.Companion.router(mCourse.chatLinkUri));
@Override
public void onClick(View v) {
YDLRouterManager.Companion.router(mCourse.chatLinkUri);
}
});
} }
@Override @Override
......
...@@ -4,9 +4,9 @@ import android.content.Context; ...@@ -4,9 +4,9 @@ import android.content.Context;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.yidianling.course.coursePlay.moudle.Course; import com.ydl.ydlcommon.adapter.CommonAdapter;
import com.yidianling.course.bean.Course;
import com.yidianling.course.widget.CourseItemNewView; import com.yidianling.course.widget.CourseItemNewView;
import com.yidianling.ydlcommon.adapter.CommonAdapter;
public class CourseNewListAdapter extends CommonAdapter<Course> { public class CourseNewListAdapter extends CommonAdapter<Course> {
......
package com.yidianling.course package com.yidianling.course
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
...@@ -11,15 +12,19 @@ import android.view.View ...@@ -11,15 +12,19 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import com.alibaba.android.arouter.facade.annotation.Route 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.base.BaseActivity
import com.ydl.ydlcommon.utils.ImageUtil
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.view.dialog.YDLShareDialog
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.bean.PostersShareBean import com.yidianling.course.bean.PostersShareBean
import com.yidianling.course.coursePlay.common.net.RetrofitUtils import com.yidianling.course.net.CourseRetrofitUtils
import com.yidianling.course.widget.CoursePosterTemplate import com.yidianling.course.widget.CoursePosterTemplate
import com.yidianling.course.widget.CustomPagerTransformer import com.yidianling.course.widget.CustomPagerTransformer
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_course_poster.*
/** /**
...@@ -53,7 +58,7 @@ class CoursePosterActivity : BaseActivity() { ...@@ -53,7 +58,7 @@ class CoursePosterActivity : BaseActivity() {
override fun initDataAndEvent() { override fun initDataAndEvent() {
courseId = intent.getStringExtra(COURSE_ID) courseId = intent.getStringExtra(COURSE_ID)
StatusBarUtils.setWindowStatusBarColor(mContext, R.color.color_66000000) StatusBarUtils.setWindowStatusBarColor(mContext, R.color.course_color_66000000)
if (TextUtils.isEmpty(courseId)) { if (TextUtils.isEmpty(courseId)) {
ToastUtil.toastShort("参数错误") ToastUtil.toastShort("参数错误")
return return
...@@ -101,8 +106,9 @@ class CoursePosterActivity : BaseActivity() { ...@@ -101,8 +106,9 @@ class CoursePosterActivity : BaseActivity() {
} }
} }
@SuppressLint("CheckResult")
private fun getData() { private fun getData() {
RetrofitUtils.getPosterData(courseId) CourseRetrofitUtils.getPosterData(courseId)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp -> .subscribe({ resp ->
......
...@@ -7,21 +7,21 @@ import android.text.TextUtils ...@@ -7,21 +7,21 @@ import android.text.TextUtils
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.google.gson.Gson import com.google.gson.Gson
import com.ydl.ydl_router.manager.YDLRouterManager import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.base.flutter.base.BaseFlutterFragment
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.remind.ToastHelper
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.bean.CourseCouponBean import com.yidianling.course.bean.CourseCouponBean
import com.yidianling.course.coursePlay.common.net.RetrofitUtils import com.yidianling.course.constants.CourseBIConstants
import com.yidianling.course.flutterPlugin.CourseSendPlugin import com.yidianling.course.flutterPlugin.CourseSendPlugin
import com.yidianling.course.net.CourseRetrofitUtils
import com.yidianling.course.widget.CourseCouponDialog import com.yidianling.course.widget.CourseCouponDialog
import com.yidianling.router.RouterManager 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.flutter.view.FlutterView
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
...@@ -37,10 +37,11 @@ import java.util.* ...@@ -37,10 +37,11 @@ import java.util.*
* @date 2019/10/22 * @date 2019/10/22
*/ */
class FlutterCourseHomeFragment : BaseFlutterFragment() { class FlutterCourseHomeFragment : BaseFlutterFragment() {
private var hasRequestCoupon = false private var hasRequestCoupon = false
private var dialog: CourseCouponDialog? = null private var dialog: CourseCouponDialog? = null
override fun initChannelPlugin(flutterView: FlutterView) { override fun initChannelPlugin(flutterView: FlutterView) {
CoursePlugin.rigister(this, flutterView) CoursePlugin.register(this, flutterView)
CourseSendPlugin.initContext(this, flutterView) CourseSendPlugin.initContext(this, flutterView)
} }
...@@ -54,7 +55,7 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() { ...@@ -54,7 +55,7 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() {
if (isVisibleToUser) { if (isVisibleToUser) {
prepareCoupon() prepareCoupon()
ActionCountUtils.count(BIConstants.CourseHomeEvent.POSITION_COURSE_HOME_PAGE_VISIT) ActionCountUtils.count(CourseBIConstants.CourseHomeEvent.POSITION_COURSE_HOME_PAGE_VISIT)
} }
} }
...@@ -85,27 +86,27 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() { ...@@ -85,27 +86,27 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() {
@SuppressLint("SimpleDateFormat", "CheckResult") @SuppressLint("SimpleDateFormat", "CheckResult")
private fun getCouponData() { private fun getCouponData() {
val (userId) = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo() ?: return val (userId) = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo() ?: return
RetrofitUtils.getCourseCoupons(userId, "3", "1", "3") CourseRetrofitUtils.getCourseCoupons(userId, "3", "1", "3")
.compose(RxUtils.netCheck()) .compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer { .subscribe(Consumer {
hasRequestCoupon = true hasRequestCoupon = true
val simpleFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//如2016-08-10 val simpleFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//如2016-08-10
val time = System.currentTimeMillis() val time = System.currentTimeMillis()
val date = Date() val date = Date()
date.time = time date.time = time
val nowTime = simpleFormat.format(date) val nowTime = simpleFormat.format(date)
if (it?.data != null && it.data.isNotEmpty()) { if (it?.data != null && it.data.isNotEmpty()) {
YDLCacheUtils.saveCouponTime(userId, nowTime) YDLCacheUtils.saveCouponTime(userId, nowTime)
couponDataResponse(it.data) couponDataResponse(it.data)
} }
}, object : ThrowableConsumer() { }, object : ThrowableConsumer() {
override fun accept(msg: String) { override fun accept(msg: String) {
} }
}) })
} }
/** /**
...@@ -113,25 +114,28 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() { ...@@ -113,25 +114,28 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() {
*/ */
private fun couponDataResponse(data: List<CourseCouponBean>) { private fun couponDataResponse(data: List<CourseCouponBean>) {
if (dialog == null) { if (dialog == null) {
dialog = CourseCouponDialog(activity, data, object : CourseCouponDialog.OnClickEnsureListener { dialog = CourseCouponDialog(
override fun clickUse(toLink: String) { activity,
YDLRouterManager.router(toLink) data,
dialog!!.dismiss() object : CourseCouponDialog.OnClickEnsureListener {
} override fun clickUse(toLink: String) {
YDLRouterManager.router(toLink)
override fun clickEnsure(status: Int) {
if (status == CourseCouponDialog.STATUS_RECEIVER) {
receiveCoupon(data)
} else {
dialog!!.dismiss() dialog!!.dismiss()
}
override fun clickEnsure(status: Int) {
if (status == CourseCouponDialog.STATUS_RECEIVER) {
receiveCoupon(data)
} else {
dialog!!.dismiss()
//查看我的卡券 //查看我的卡券
ARouter.getInstance().build("/mine/redpacket") ARouter.getInstance().build("/mine/redpacket")
.withString("is_from_main", "1") .withString("is_from_main", "1")
.navigation() .navigation()
}
} }
} })
})
} }
dialog!!.show() dialog!!.show()
} }
...@@ -151,17 +155,17 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() { ...@@ -151,17 +155,17 @@ class FlutterCourseHomeFragment : BaseFlutterFragment() {
bean.couponIds = couponIds bean.couponIds = couponIds
bean.uid = userId bean.uid = userId
val couponIdsStr = Gson().toJson(bean) val couponIdsStr = Gson().toJson(bean)
RetrofitUtils.receiveCoupon(couponIdsStr) CourseRetrofitUtils.receiveCoupon(couponIdsStr)
.compose(RxUtils.netCheck()) .compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer { .subscribe(Consumer {
receiveCouponResponse(it) receiveCouponResponse(it)
}, object : ThrowableConsumer() { }, object : ThrowableConsumer() {
override fun accept(msg: String) { override fun accept(msg: String) {
ToastUtil.toastShort(msg) ToastUtil.toastShort(msg)
} }
}) })
} }
/** /**
......
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.coursePlay.moudle; package com.yidianling.course.bean;
import com.yidianling.course.bean.CourseHostInfoBean; import com.ydl.ydlcommon.bean.ShareData;
import com.yidianling.ydlcommon.data.ShareData;
//课程列表 //课程列表
//课程 //课程
......
package com.yidianling.course.coursePlay.moudle package com.yidianling.course.bean
/** /**
* 参加课程返回值 * 参加课程返回值
......
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; package com.yidianling.course.bean;
import com.yidianling.ydlcommon.data.ShareData;
import com.ydl.ydlcommon.bean.ShareData;
/** /**
* @author jiucheng * @author jiucheng
......
package com.yidianling.course.coursePlay.http package com.yidianling.course.bean
import com.ydl.ydlcommon.bean.YDLBaseDataBean
/** /**
* @author yuanWai * @author yuanWai
...@@ -7,4 +9,4 @@ package com.yidianling.course.coursePlay.http ...@@ -7,4 +9,4 @@ package com.yidianling.course.coursePlay.http
* @Company 壹点灵 * @Company 壹点灵
* @date 2018/12/12 * @date 2018/12/12
*/ */
data class CourseListParams(val params : String) data class CourseListDataBean(val list: List<Course>) : YDLBaseDataBean()
\ No newline at end of file \ 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.moudle package com.yidianling.course.bean
import com.yidianling.ydlcommon.data.ShareData import com.ydl.ydlcommon.bean.ShareData
import java.util.* import java.util.*
/** /**
......
package com.yidianling.course.bean package com.yidianling.course.bean
import com.yidianling.ydlcommon.data.ShareData import com.ydl.ydlcommon.bean.ShareData
/** /**
* @author jiucheng * @author jiucheng
......
package com.yidianling.course.coursePlay.moudle package com.yidianling.course.bean
import com.yidianling.ydlcommon.bean.YDLBaseDataBean
/** /**
* @author yuanWai * @author yuanWai
* @描述: * @描述:
* @Copyright Copyright (c) 2018 * @Copyright Copyright (c) 2018
* @Company 壹点灵 * @Company 壹点灵
* @date 2018/12/12 * @date 2018/11/27
*/ */
data class CourseListDataBean(val list : List<Course>) : YDLBaseDataBean() data class RedListParam(val serviceType : Int)
\ No newline at end of file \ No newline at end of file
package com.yidianling.course.constants
/**
* Created by xj on 2019/7/1.
*/
class CourseBIConstants {
companion object {
//消息端来源
const val APP_ID = "ydl-app-android-user" //这是用户端主包的
const val OS = "Android" //android系统
}
//====================课程列表页(course_list_page)====================
class CourseListEvent {
companion object {
private const val COURSE_LIST_PAGE: String = "course_list_page|"//课程列表页 partId
const val POSITION_COURSE_LIST_RETURN_CLICK = COURSE_LIST_PAGE + "course_list_return_click" //返回点击
const val POSITION_COURSE_LIST_SORT_CLICK = COURSE_LIST_PAGE + "course_list_sort_click" //综合排序点击
const val POSITION_COURSE_LIST_FILTER_CLICK = COURSE_LIST_PAGE + "course_list_filter_click" //筛选点击
const val POSITION_COURSE_LIST_CLASSIFICATION_CLICK = COURSE_LIST_PAGE + "course_list_classification_click" //分类点击
const val POSITION_COURSE_LIST_AUDITION_CLICK = COURSE_LIST_PAGE + "course_list_audition_click" //试听点击
const val POSITION_COURSE_LIST_PAGE_VISIT = COURSE_LIST_PAGE + "course_list_page_visit" //课程列表页浏览点击
const val POSITION_COURSE_LIST_XXX_CLICK = COURSE_LIST_PAGE + "course_list_" //课程点击
}
}
//====================课程频道页(course_home_page)====================
class CourseHomeEvent {
companion object {
private const val COURSE_HOME_PAGE: String = "course_home_page|"//课程频道页 partId
const val POSITION_COURSE_HOME_PAGE_VISIT = COURSE_HOME_PAGE + "course_home_page_visit" //列表页浏览点击
const val POSITION_COURSE_HOME_MY_COUSE_CLICK = COURSE_HOME_PAGE + "course_home_my_couse_click" //我的课程
const val POSITION_COURSE_HOME_SEACH_CLICK = COURSE_HOME_PAGE + "course_home_seach_click" //搜索
const val POSITION_COURSE_HOME_BANNER_CLICK = COURSE_HOME_PAGE + "course_home_banner_click" //banner-各位置
const val POSITION_COURSE_HOME_CLASSIFICATION_CLICK = COURSE_HOME_PAGE + "course_home_classification_click" //分类点击
const val POSITION_COURSE_HOME_EXCELLENT_COURSES_PAY_XXX_CLICK = COURSE_HOME_PAGE + "course_home_excellent_courses_pay_" //精品课程-付费课程-各课程页面点击
const val POSITION_COURSE_HOME_EXCELLENT_COURSES_FREE_XXX_CLICK = COURSE_HOME_PAGE + "course_home_excellent_courses_free_" //精品课程-免费课程-各课程页面点击
const val POSITION_COURSE_HOME_EXCELLENT_COURSES_MORE_CLICK = COURSE_HOME_PAGE + "course_home_excellent_courses_more_click" //精品课程-更多课程
const val POSITION_COURSE_HOME_CONSULTANT_COURSE_MORE_CLICK = COURSE_HOME_PAGE + "course_home_consultant_course_more_click" //咨询师课程-更多课程
const val POSITION_COURSE_HOME_OFFLINE_CERTIFICATION_TRAINING_XXX_CLICK = COURSE_HOME_PAGE + "course_home_offline_certification_training_" //线下考证培训-各课程页面点击
const val POSITION_COURSE_HOME_OFFLINE_CERTIFICATION_TRAINING_MORE_CLICK = COURSE_HOME_PAGE + "course_home_offline_certification_training_more_click" //线下考证培训-更多课程
const val POSITION_COURSE_HOME_THEMATIC_COURSES_XXX_CLICK = COURSE_HOME_PAGE + "course_home_thematic_courses_" //专题课程-各课程页面点击
const val POSITION_COURSE_HOME_THEMATIC_COURSES_MORE_CLICK = COURSE_HOME_PAGE + "course_home_thematic_courses_more_click" //专题课程-更多
}
}
}
\ 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) {
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 package com.yidianling.course.courseNew
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.support.v4.widget.SwipeRefreshLayout import android.support.v4.widget.SwipeRefreshLayout
...@@ -12,20 +13,19 @@ import android.widget.LinearLayout ...@@ -12,20 +13,19 @@ import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.ydl_image.module.GlideApp 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.yidianling.common.tools.LogUtil import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxNetTool import com.yidianling.common.tools.RxNetTool
import com.yidianling.course.R import com.yidianling.course.R
import com.yidianling.course.coursePlay.common.net.RetrofitUtils import com.yidianling.course.net.CourseRetrofitUtils
import com.yidianling.course.coursePlay.moudle.Course import com.yidianling.course.bean.Course
import com.yidianling.course.model.TopicCourseBean 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.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_course_topic.* import kotlinx.android.synthetic.main.activity_course_topic.*
import kotlinx.android.synthetic.main.layout_title_bar.* import kotlinx.android.synthetic.main.course_layout_title_bar.*
/** /**
* 课程专题页面 * 课程专题页面
...@@ -64,10 +64,9 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa ...@@ -64,10 +64,9 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa
specialId = intent.getStringExtra("special_id").toInt() specialId = intent.getStringExtra("special_id").toInt()
} }
LogUtil.i("special id: $specialId") LogUtil.i("special id: $specialId")
swl.setColorSchemeResources(R.color.google_green) swl.setColorSchemeResources(R.color.main_theme)
swl.setOnRefreshListener(this) swl.setOnRefreshListener(this)
tv_left_menu.setOnClickListener { tv_left_menu.setOnClickListener {
//分享 //分享
share() share()
} }
...@@ -93,7 +92,7 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa ...@@ -93,7 +92,7 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa
} }
fun initFooterView() { 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) adapter?.addFooterView(footerView)
} }
...@@ -103,6 +102,7 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa ...@@ -103,6 +102,7 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa
} }
} }
@SuppressLint("CheckResult")
private fun loadData() { private fun loadData() {
if (!RxNetTool.isConnected(CourseTopicActivity@ this)) { if (!RxNetTool.isConnected(CourseTopicActivity@ this)) {
swl.isRefreshing = false swl.isRefreshing = false
...@@ -112,7 +112,7 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa ...@@ -112,7 +112,7 @@ class CourseTopicActivity : BaseActivity(), View.OnClickListener, SwipeRefreshLa
} }
course_topic_rcv.visibility = View.VISIBLE course_topic_rcv.visibility = View.VISIBLE
v_no_network.visibility = View.GONE v_no_network.visibility = View.GONE
RetrofitUtils.getCourseTopic(specialId.toString()) CourseRetrofitUtils.getCourseTopic(specialId.toString())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.compose(RxUtils.resultJavaData()) .compose(RxUtils.resultJavaData())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
......
...@@ -5,13 +5,12 @@ import android.support.v4.util.SparseArrayCompat ...@@ -5,13 +5,12 @@ import android.support.v4.util.SparseArrayCompat
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.view.BaseViewHolder
import com.yidianling.course.CourseConstants import com.yidianling.course.CourseConstants
import com.yidianling.course.coursePlay.moudle.Course import com.yidianling.course.bean.Course
import com.yidianling.course.widget.CourseItemNewView 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. * Created by Jim on 2018/7/12 0012.
......
...@@ -5,8 +5,8 @@ import android.text.TextUtils; ...@@ -5,8 +5,8 @@ import android.text.TextUtils;
import com.ydl.ydl_router.manager.YDLRouterManager; import com.ydl.ydl_router.manager.YDLRouterManager;
import com.ydl.ydl_router.manager.YDLRouterParams; import com.ydl.ydl_router.manager.YDLRouterParams;
import com.ydl.ydlcommon.router.IYDLRouterConstant;
import com.yidianling.common.tools.LogUtil; import com.yidianling.common.tools.LogUtil;
import com.yidianling.ydlcommon.router.IYDLRouterConstant;
/** /**
* Created by Jim on 2018/7/17 0017. * 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 package com.yidianling.course.courseNew.courseList.widget
import android.content.Context import android.content.Context
import android.graphics.Typeface
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.support.v7.widget.GridLayoutManager import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.PopupWindow import android.widget.PopupWindow
import com.ydl.ydlcommon.view.SpaceItemDecorator
import com.yidianling.common.tools.RxImageTool import com.yidianling.common.tools.RxImageTool
import com.yidianling.course.R import com.yidianling.course.R
import com.yidianling.course.courseNew.courseList.widget.adapter.CourseGoodAdapter import com.yidianling.course.courseNew.courseList.widget.adapter.CourseGoodAdapter
import com.yidianling.course.model.CourseCategoryBean import com.yidianling.course.model.CourseCategoryBean
import com.yidianling.ydlcommon.view.SpaceItemDecorator
import kotlinx.android.synthetic.main.course_good_popup_window.view.* import kotlinx.android.synthetic.main.course_good_popup_window.view.*
......
...@@ -66,7 +66,7 @@ class CourseSortPopupWindow(val context: Context, var selectedSort: String, priv ...@@ -66,7 +66,7 @@ class CourseSortPopupWindow(val context: Context, var selectedSort: String, priv
} }
private fun setSelect(textView: TextView) { private fun setSelect(textView: TextView) {
textView.setTextColor(ContextCompat.getColor(context, R.color.color_1DA1F2)) textView.setTextColor(ContextCompat.getColor(context, R.color.course_color_1DA1F2))
textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD) textView.typeface = Typeface.defaultFromStyle(Typeface.BOLD)
} }
......
...@@ -13,7 +13,7 @@ import kotlinx.android.synthetic.main.item_course_good_item.view.* ...@@ -13,7 +13,7 @@ import kotlinx.android.synthetic.main.item_course_good_item.view.*
/** /**
* @author yuanwai * @author yuanwai
* @描述:课程列表页--筛选模块--擅长方式popwindow适配器 * @描述:课程列表页--筛选模块--分类 popwindow适配器
* @Copyright Copyright (c) 2018 * @Copyright Copyright (c) 2018
* @Company 壹点灵 * @Company 壹点灵
* @date 2018/9/22 * @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,12 @@ import android.widget.ImageView; ...@@ -14,13 +14,12 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; 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.yidianling.course.CourseListFragment; import com.yidianling.course.CourseListFragment;
import com.yidianling.course.R; import com.yidianling.course.R;
import com.yidianling.ydlcommon.base.BaseActivity; import com.yidianling.course.widget.CourseRedPacketView;
import com.yidianling.ydlcommon.ui.confideredpacket.ConfideRedPacketView; import com.yidianling.course.widget.SearchBarView;
import com.yidianling.ydlcommon.utils.DisplayUtils;
import com.yidianling.ydlcommon.utils.UMEventUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
...@@ -84,9 +83,9 @@ public class MyCourseActivity extends BaseActivity { ...@@ -84,9 +83,9 @@ public class MyCourseActivity extends BaseActivity {
} }
private void initConfideRedPacketView() { private void initConfideRedPacketView() {
ConfideRedPacketView confideRedPacketView = findViewById(R.id.confideRedPacketView); CourseRedPacketView courseRedPacketView = findViewById(R.id.courseRedPacketView);
confideRedPacketView.initData(View.VISIBLE); courseRedPacketView.initData(View.VISIBLE);
confideRedPacketView.setConfide(); 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 -> {
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 -> {
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 -> {
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 -> {
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 -> {
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 -> {
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 -> {
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 -> {
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 -> {
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 package com.yidianling.course.coursePlay
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.text.Editable import android.text.Editable
import android.text.TextUtils import android.text.TextUtils
import android.text.TextWatcher import android.text.TextWatcher
import com.alibaba.android.arouter.facade.annotation.Route 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.common.tools.ToastUtil
import com.yidianling.course.CourseConstants import com.yidianling.course.CourseConstants
import com.yidianling.course.R import com.yidianling.course.R
import com.yidianling.course.coursePlay.common.net.Command import com.yidianling.course.net.Command
import com.yidianling.course.coursePlay.common.net.RetrofitUtils import com.yidianling.course.net.CourseRetrofitUtils
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.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_course_commeny.* import kotlinx.android.synthetic.main.activity_course_commeny.*
...@@ -65,10 +66,10 @@ class CourseCommentActivity : BaseActivity() { ...@@ -65,10 +66,10 @@ class CourseCommentActivity : BaseActivity() {
override fun afterTextChanged(s: Editable?) { override fun afterTextChanged(s: Editable?) {
if (TextUtils.isEmpty(s)) { if (TextUtils.isEmpty(s)) {
tv_input_length.text = "0" tv_input_length.text = "0"
tv_input_length.setTextColor(resources.getColor(R.color.color_b3b3b3)) tv_input_length.setTextColor(resources.getColor(R.color.course_color_B3B3B3))
} else { } else {
tv_input_length.text = s!!.length.toString() tv_input_length.text = s!!.length.toString()
tv_input_length.setTextColor(resources.getColor(R.color.color_242424)) tv_input_length.setTextColor(resources.getColor(R.color.course_color_242424))
} }
} }
...@@ -81,10 +82,11 @@ class CourseCommentActivity : BaseActivity() { ...@@ -81,10 +82,11 @@ class CourseCommentActivity : BaseActivity() {
} }
//提交评论 //提交评论
@SuppressLint("CheckResult")
private fun commitReply(content: String) { private fun commitReply(content: String) {
showProgressDialog(null) showProgressDialog(null)
val cmd = Command.CourseCommitReply(courseId!!.toInt(), content) val cmd = Command.CourseCommitReply(courseId!!.toInt(), content)
RetrofitUtils.commitCourseReply(cmd) CourseRetrofitUtils.commitCourseReply(cmd)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp -> .subscribe({ resp ->
...@@ -102,7 +104,7 @@ class CourseCommentActivity : BaseActivity() { ...@@ -102,7 +104,7 @@ class CourseCommentActivity : BaseActivity() {
} }
}, { t -> }, { t ->
dismissProgressDialog() dismissProgressDialog()
RetrofitUtils.handleError(this, t) CourseRetrofitUtils.handleError(this, t)
LogHelper.getInstance().writeLogSync("提交评论失败:" + t.message) LogHelper.getInstance().writeLogSync("提交评论失败:" + t.message)
}) })
} }
......
...@@ -4,13 +4,13 @@ import android.annotation.SuppressLint ...@@ -4,13 +4,13 @@ import android.annotation.SuppressLint
import android.text.TextUtils import android.text.TextUtils
import android.view.View import android.view.View
import android.widget.LinearLayout import android.widget.LinearLayout
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.module.GlideApp import com.ydl.ydl_image.module.GlideApp
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.CourseConstants import com.yidianling.course.CourseConstants
import com.yidianling.course.R import com.yidianling.course.R
import com.yidianling.ydlcommon.bean.CourseExtraBean import com.yidianling.course.bean.CourseExtraBean
import com.yidianling.ydlcommon.h5.H5Params
import com.yidianling.ydlcommon.h5.NewH5Activity
import kotlinx.android.synthetic.main.item_course_play_head.view.* import kotlinx.android.synthetic.main.item_course_play_head.view.*
/** /**
...@@ -50,7 +50,7 @@ class CourseHeadView : LinearLayout { ...@@ -50,7 +50,7 @@ class CourseHeadView : LinearLayout {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
fun setData(bean: CourseExtraBean) { fun setData(bean: CourseExtraBean) {
courseId = bean.id 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)) { if (TextUtils.isEmpty(bean.doctorName)) {
ll_info.visibility= View.GONE ll_info.visibility= View.GONE
}else{ }else{
......
...@@ -4,15 +4,15 @@ import android.annotation.SuppressLint ...@@ -4,15 +4,15 @@ import android.annotation.SuppressLint
import android.text.TextUtils import android.text.TextUtils
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.RelativeLayout import android.widget.RelativeLayout
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.audio.model.Music
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.RxDeviceTool import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxNetTool import com.yidianling.common.tools.RxNetTool
import com.yidianling.ydlcommon.bean.CourseExtraBean import com.yidianling.course.bean.CourseExtraBean
import com.yidianling.ydlcommon.bean.CourseMediaBean import com.yidianling.course.bean.CourseMediaBean
import com.yidianling.ydlcommon.dialog.CommonDialog import com.yidianling.course.listener.HPlayStatusListener
import com.yidianling.ydlcommon.player.MusicInfoBean import com.yidianling.course.widget.HPlayView
import com.yidianling.ydlcommon.player.YDLMusicHelper
import com.yidianling.ydlcommon.player.player.HPlayStatusListener
import com.yidianling.ydlcommon.player.view.HPlayView
/** /**
...@@ -66,12 +66,8 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -66,12 +66,8 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
//设置监听事件 //设置监听事件
fun setListener() { fun setListener() {
playView?.listener = object : HPlayStatusListener { playView?.listener = object : HPlayStatusListener {
override fun isCanPlay(data: MusicInfoBean?): Boolean { override fun isCanPlay(data: Music?): Boolean {
var canPlay = false var canPlay = false
//判断当前课程是否试听
if (data?.isTestPlay == true) {
canPlay = true
} else {
//非试听 //非试听
if (courseExtra!!.isBuy) { if (courseExtra!!.isBuy) {
//已购买 //已购买
...@@ -92,11 +88,10 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -92,11 +88,10 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
.setCancelAble(false) .setCancelAble(false)
.show() .show()
} }
}
return canPlay return canPlay
} }
override fun onPrepared(data: MusicInfoBean?, index: Int) { override fun onPrepared(data: Music?, index: Int) {
//更新播放列表的状态 //更新播放列表的状态
activity!!.updatePlayingListStatus(index) activity!!.updatePlayingListStatus(index)
} }
...@@ -115,7 +110,7 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -115,7 +110,7 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
this.courseExtra = courseExtra this.courseExtra = courseExtra
currentIndex = index currentIndex = index
YDLMusicHelper.course_id = courseExtra.id.toInt() // YDLMusicHelper.course_id = courseExtra.id.toInt()
if (courseExtra.isBuy) { if (courseExtra.isBuy) {
playView?.setAutoNext(true) playView?.setAutoNext(true)
...@@ -128,12 +123,12 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -128,12 +123,12 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
playView!!.setData(stringToMusicPlayerList(playList)) playView!!.setData(stringToMusicPlayerList(playList))
if (playView?.control?.isPlaying() == true) { if (AudioPlayer.get().isPlaying) {
hasEnsureNetStatus = true hasEnsureNetStatus = true
} }
if (RxNetTool.isWifi(activity!!)) { if (RxNetTool.isWifi(activity!!)) {
if (playView?.control?.isPlaying() == true && (from == 1 || from == 2)) { if (AudioPlayer.get().isPlaying && (from == 1 || from == 2)) {
if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) { if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) {
playView?.updateView(currentIndex) playView?.updateView(currentIndex)
} else { } else {
...@@ -144,7 +139,7 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -144,7 +139,7 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
} }
} else { } else {
if (hasEnsureNetStatus) { if (hasEnsureNetStatus) {
if (playView?.control?.isPlaying() == true && (from == 1 || from == 2)) { if (AudioPlayer.get().isPlaying && (from == 1 || from == 2)) {
if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) { if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) {
playView?.updateView(currentIndex) playView?.updateView(currentIndex)
} else { } else {
...@@ -156,7 +151,7 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -156,7 +151,7 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
} else { } else {
playView?.showNetNotice { playView?.showNetNotice {
hasEnsureNetStatus = true hasEnsureNetStatus = true
if (playView?.control?.isPlaying() == true && (from == 1 || from == 2)) { if (AudioPlayer.get().isPlaying && (from == 1 || from == 2)) {
if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) { if (TextUtils.equals(playView?.getCurrentUrl(), list[currentIndex].url)) {
playView?.updateView(currentIndex) playView?.updateView(currentIndex)
} else { } else {
...@@ -171,15 +166,15 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -171,15 +166,15 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
} }
//将列表转为播放器可用列表 //将列表转为播放器可用列表
private fun stringToMusicPlayerList(list: List<CourseMediaBean>): ArrayList<MusicInfoBean> { private fun stringToMusicPlayerList(list: List<CourseMediaBean>): ArrayList<Music> {
var nlist = ArrayList<MusicInfoBean>() var nlist = ArrayList<Music>()
try { try {
for (i in list.indices) { for (i in list.indices) {
var be = MusicInfoBean() var be = Music()
be.url = list[i].url be.path = list[i].url
be.pic = courseExtra!!.pic be.coverPath = courseExtra!!.pic
be.isTestPlay = !courseExtra!!.isBuy
be.title = list[i].title be.title = list[i].title
be.artist = list[i].doctorName
nlist.add(be) nlist.add(be)
} }
} catch (e: Exception) { } catch (e: Exception) {
...@@ -190,10 +185,10 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface { ...@@ -190,10 +185,10 @@ class CoursePlayItemViewAudio : RelativeLayout, PlayViewInterface {
override fun onDestroy() { override fun onDestroy() {
//释放播放器 //释放播放器
if (playView?.control?.isPlaying() != true) { if (AudioPlayer.get().isPlaying) {
playView?.onDestroy() playView?.onDestroy()
playView = null playView = null
YDLMusicHelper.stop() AudioPlayer.get().stopPlayer()
} else { } else {
playView?.onDestroy() playView?.onDestroy()
playView = null playView = null
......
...@@ -8,13 +8,14 @@ import android.view.View ...@@ -8,13 +8,14 @@ import android.view.View
import android.widget.RelativeLayout import android.widget.RelativeLayout
import com.dou361.ijkplayer.widget.PlayStateParams import com.dou361.ijkplayer.widget.PlayStateParams
import com.dou361.ijkplayer.widget.PlayerView import com.dou361.ijkplayer.widget.PlayerView
import com.ydl.media.audio.utils.PlayProgressUtil
import com.ydl.media.view.PlayTypeEnum
import com.ydl.media.view.PlayerFloatHelper
import com.ydl.ydl_image.module.GlideApp import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.course.R import com.yidianling.course.R
import com.yidianling.ydlcommon.bean.CourseExtraBean import com.yidianling.course.bean.CourseExtraBean
import com.yidianling.ydlcommon.bean.CourseMediaBean import com.yidianling.course.bean.CourseMediaBean
import com.yidianling.ydlcommon.dialog.CommonDialog
import com.yidianling.ydlcommon.player.YDLMusicHelper
import com.yidianling.ydlcommon.player.util.UtilH
import tv.danmaku.ijk.media.player.IMediaPlayer import tv.danmaku.ijk.media.player.IMediaPlayer
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
...@@ -54,7 +55,7 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface { ...@@ -54,7 +55,7 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface {
@SuppressLint("InvalidWakeLockTag") @SuppressLint("InvalidWakeLockTag")
private constructor(context: CoursePlayActivity, playMoudle: Int) : super(context) { private constructor(context: CoursePlayActivity, playMoudle: Int) : super(context) {
this.playMoudle = playMoudle this.playMoudle = playMoudle
View.inflate(context, R.layout.view_course_play_item, this) View.inflate(context, R.layout.course_view_course_play_item, this)
activity = context activity = context
initView() initView()
...@@ -79,7 +80,7 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface { ...@@ -79,7 +80,7 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface {
if (isVideoPlaying) { if (isVideoPlaying) {
var time = activity?.videoView?.currentPosition ?: 0 var time = activity?.videoView?.currentPosition ?: 0
if (time < 3000) return if (time < 3000) return
UtilH.saveProgress(context, videoUrl, time) PlayProgressUtil.saveProgress(context, videoUrl, time)
} }
} }
}, 1000, 1000) }, 1000, 1000)
...@@ -106,7 +107,7 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface { ...@@ -106,7 +107,7 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface {
wakeLock!!.acquire() wakeLock!!.acquire()
} }
activity?.videoView?.onResume() activity?.videoView?.onResume()
var hisTime1 = UtilH.getProgress(context, videoUrl) var hisTime1 = PlayProgressUtil.getProgress(context, videoUrl)
activity?.videoView?.seekTo(hisTime1) activity?.videoView?.seekTo(hisTime1)
} }
...@@ -151,14 +152,15 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface { ...@@ -151,14 +152,15 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface {
} }
} }
if (canPlay) { if (canPlay) {
YDLMusicHelper.playingType = YDLMusicHelper.PLAY_TYPE_COURSE PlayerFloatHelper.playingType=PlayTypeEnum.PLAY_TYPE_COURSE
var url = playList[index].url var url = playList[index].url
url = url.replace("https", "http") url = url.replace("https", "http")
videoUrl = url videoUrl = url
var hisTime = UtilH.getProgress(context, url) var hisTime = PlayProgressUtil.getProgress(context, url)
try { try {
activity?.videoView = PlayerView(activity) activity?.videoView = PlayerView(activity)
.setScaleType(PlayStateParams.fitparent) .setScaleType(PlayStateParams.fitparent)
...@@ -196,7 +198,7 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface { ...@@ -196,7 +198,7 @@ class CoursePlayItemViewVideo : RelativeLayout, PlayViewInterface {
if (what == PlayStateParams.STATE_COMPLETED) { if (what == PlayStateParams.STATE_COMPLETED) {
isVideoPlaying = false isVideoPlaying = false
UtilH.saveProgress(this@CoursePlayItemViewVideo.activity, videoUrl, 0) PlayProgressUtil.saveProgress(this@CoursePlayItemViewVideo.activity, videoUrl, 0)
if (playList.size - 1 > this@CoursePlayItemViewVideo.index) { if (playList.size - 1 > this@CoursePlayItemViewVideo.index) {
//播放下一曲 //播放下一曲
play(this@CoursePlayItemViewVideo.index + 1) play(this@CoursePlayItemViewVideo.index + 1)
......
package com.yidianling.course.coursePlay package com.yidianling.course.coursePlay
import android.annotation.SuppressLint
import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
import com.cxzapp.yidianling.common.view.FootViewLoadMore
import com.ydl.ydl_image.module.GlideApp import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.adapter.CommonRecyclerAdapter
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.view.BaseViewHolder
import com.ydl.ydlcommon.view.CircleImageView
import com.ydl.ydlcommon.view.FootViewLoadMore
import com.ydl.ydlcommon.view.TitleBar
import com.yidianling.common.tools.LogUtil import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.R import com.yidianling.course.R
import com.yidianling.course.coursePlay.common.net.Command import com.yidianling.course.bean.CoursePlayBean
import com.yidianling.course.coursePlay.common.net.RetrofitUtils import com.yidianling.course.net.Command
import com.yidianling.course.coursePlay.moudle.CoursePlayBean import com.yidianling.course.net.CourseRetrofitUtils
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.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
...@@ -77,6 +78,7 @@ class CourseReplyListActivity : BaseActivity() { ...@@ -77,6 +78,7 @@ class CourseReplyListActivity : BaseActivity() {
} }
//获取列表数据 //获取列表数据
@SuppressLint("CheckResult")
fun getListData(isLoadMore: Boolean) { fun getListData(isLoadMore: Boolean) {
if (isLoadMore) { if (isLoadMore) {
page++ page++
...@@ -91,7 +93,7 @@ class CourseReplyListActivity : BaseActivity() { ...@@ -91,7 +93,7 @@ class CourseReplyListActivity : BaseActivity() {
val cmd = Command.CourseReplyList(course_id, page) val cmd = Command.CourseReplyList(course_id, page)
RetrofitUtils.courseReplyList(cmd) CourseRetrofitUtils.courseReplyList(cmd)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp -> .subscribe({ resp ->
...@@ -112,7 +114,7 @@ class CourseReplyListActivity : BaseActivity() { ...@@ -112,7 +114,7 @@ class CourseReplyListActivity : BaseActivity() {
if (!isLoadMore) { if (!isLoadMore) {
dismissProgressDialog() dismissProgressDialog()
} }
RetrofitUtils.handleError(mContext, throwable) CourseRetrofitUtils.handleError(mContext, throwable)
}) })
} }
......
package com.yidianling.course.coursePlay package com.yidianling.course.coursePlay
import com.yidianling.ydlcommon.bean.CourseExtraBean import com.yidianling.course.bean.CourseExtraBean
import com.yidianling.ydlcommon.bean.CourseMediaBean import com.yidianling.course.bean.CourseMediaBean
import java.util.* import java.util.*
......
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.presenter package com.yidianling.course.coursePlay.presenter
import android.annotation.SuppressLint
import com.yidianling.common.tools.ToastUtil 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.CoursePlayActivity
import com.yidianling.course.coursePlay.common.net.RetrofitUtils import com.yidianling.course.net.CourseRetrofitUtils
import com.yidianling.ydlcommon.http.api.ApiRequestUtil
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
...@@ -13,9 +13,10 @@ import io.reactivex.schedulers.Schedulers ...@@ -13,9 +13,10 @@ import io.reactivex.schedulers.Schedulers
* Created by harvie on 2017/6/28 0028. * Created by harvie on 2017/6/28 0028.
*/ */
class CoursePlayPresenter(val view: CoursePlayActivity) { class CoursePlayPresenter(val view: CoursePlayActivity) {
@SuppressLint("CheckResult")
fun getInitData(course_id: Int) { fun getInitData(course_id: Int) {
view.showLoadingDialog() view.showLoadingDialog()
ApiRequestUtil.getCoursePlayData(course_id.toString()) CourseRetrofitUtils.getCoursePlayData(course_id.toString())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp -> .subscribe({ resp ->
...@@ -32,7 +33,7 @@ class CoursePlayPresenter(val view: CoursePlayActivity) { ...@@ -32,7 +33,7 @@ class CoursePlayPresenter(val view: CoursePlayActivity) {
} }
}, { t -> }, { t ->
view.dismissLoadingDialog() view.dismissLoadingDialog()
RetrofitUtils.handleError(view, t) CourseRetrofitUtils.handleError(view, t)
}) })
} }
......
package com.yidianling.course.courseSearch package com.yidianling.course.courseSearch
import android.annotation.SuppressLint
import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.LinearLayoutManager
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
...@@ -7,22 +8,22 @@ import android.view.View ...@@ -7,22 +8,22 @@ import android.view.View
import android.view.WindowManager import android.view.WindowManager
import android.widget.ImageView import android.widget.ImageView
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.base_module.ui.searchbarview.SearchBarView import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.config.SimpleImageOpConfiger import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.listener.YDLImageRecyclerOnScrollListener import com.ydl.ydl_image.listener.YDLImageRecyclerOnScrollListener
import com.ydl.ydl_image.manager.YDLImageCacheManager import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.bean.ShareData
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.course.CourseConstants import com.yidianling.course.CourseConstants
import com.yidianling.course.R import com.yidianling.course.R
import com.yidianling.course.coursePlay.moudle.Course import com.yidianling.course.bean.Course
import com.yidianling.course.courseSearch.http.CourseSearchApiUtils import com.yidianling.course.courseSearch.http.CourseSearchApiUtils
import com.yidianling.course.courseSearch.view.ICourseSearchView import com.yidianling.course.courseSearch.view.ICourseSearchView
import com.yidianling.ydlcommon.base.BaseActivity import com.yidianling.course.widget.SearchBarView
import com.yidianling.ydlcommon.data.ShareData
import com.yidianling.ydlcommon.h5.H5Params
import com.yidianling.ydlcommon.h5.NewH5Activity
import com.yidianling.ydlcommon.http.ThrowableConsumer
import com.yidianling.ydlcommon.router.IYDLRouterConstant
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
...@@ -153,7 +154,7 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC ...@@ -153,7 +154,7 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC
override fun onItemClickEvent(position: Int) { override fun onItemClickEvent(position: Int) {
var courseItem = courseList[position] var courseItem = courseList[position]
if (null != courseItem) { if (null != courseItem) {
val h5Params = H5Params(CourseConstants.COURSE_DETAIL_H5 + courseItem.id, this.getString(R.string.course_detail)) val h5Params = H5Params(CourseConstants.COURSE_DETAIL_H5 + courseItem.id, "课程详情")
if (null != courseItem.share && !TextUtils.isEmpty(courseItem.share.share_url)) { if (null != courseItem.share && !TextUtils.isEmpty(courseItem.share.share_url)) {
val shareData = ShareData(courseItem.share.share_url, courseItem.share.title, courseItem.share.cover, courseItem.share.desc) val shareData = ShareData(courseItem.share.share_url, courseItem.share.title, courseItem.share.cover, courseItem.share.desc)
h5Params.shareData = shareData h5Params.shareData = shareData
...@@ -170,8 +171,8 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC ...@@ -170,8 +171,8 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC
val sp = SimpleImageOpConfiger() val sp = SimpleImageOpConfiger()
sp.heigt = height sp.heigt = height
sp.width = width sp.width = width
sp.errorPic = R.drawable.default_img sp.errorPic = R.drawable.course_default_img
sp.loadingPic = R.drawable.default_img sp.loadingPic = R.drawable.course_default_img
YDLImageCacheManager.showImage(CourseSearchActicity@ this, url, imageView, sp) YDLImageCacheManager.showImage(CourseSearchActicity@ this, url, imageView, sp)
} }
...@@ -179,6 +180,7 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC ...@@ -179,6 +180,7 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC
* 根据输入搜索专家课程 * 根据输入搜索专家课程
* type true代表首次加载,false代表加载下一页 * type true代表首次加载,false代表加载下一页
*/ */
@SuppressLint("CheckResult")
fun loadCourseList(type: Boolean) { fun loadCourseList(type: Boolean) {
if (TextUtils.isEmpty(inputString)) { if (TextUtils.isEmpty(inputString)) {
activity_course_search_swipe_refresh_layout.isRefreshing = false activity_course_search_swipe_refresh_layout.isRefreshing = false
...@@ -234,7 +236,7 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC ...@@ -234,7 +236,7 @@ class CourseSearchActivity : BaseActivity(), CourseSearchAdapter.OnItemClick, IC
if (!TextUtils.isEmpty(desc)) activity_course_search_unusual_layout_desc.text = desc if (!TextUtils.isEmpty(desc)) activity_course_search_unusual_layout_desc.text = desc
activity_course_search_unusual_layout.visibility = View.VISIBLE activity_course_search_unusual_layout.visibility = View.VISIBLE
activity_course_search_recycler.visibility = View.GONE activity_course_search_recycler.visibility = View.GONE
iv_empty.setImageResource(if (isEmpty) R.drawable.ico_img_zixun_empty else R.drawable.blank) iv_empty.setImageResource(if (isEmpty) R.drawable.course_ico_img_zixun_empty else R.drawable.course_blank)
} }
/** /**
......
...@@ -4,7 +4,7 @@ import android.content.Context ...@@ -4,7 +4,7 @@ import android.content.Context
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
import android.view.ViewGroup import android.view.ViewGroup
import com.yidianling.common.tools.RxImageTool import com.yidianling.common.tools.RxImageTool
import com.yidianling.course.coursePlay.moudle.Course import com.yidianling.course.bean.Course
import com.yidianling.course.courseSearch.view.ICourseSearchView import com.yidianling.course.courseSearch.view.ICourseSearchView
import com.yidianling.course.widget.CourseItemNewView import com.yidianling.course.widget.CourseItemNewView
......
...@@ -57,10 +57,10 @@ class CourseSearchAdapterWrapper( ...@@ -57,10 +57,10 @@ class CourseSearchAdapterWrapper(
var view:View? = null var view:View? = null
return when (viewType) { return when (viewType) {
TYPE_FOOTER_LOADING -> { TYPE_FOOTER_LOADING -> {
FooterHolder(mInflater!!.inflate(R.layout.footer, parent, false), TYPE_FOOTER_LOADING) FooterHolder(mInflater!!.inflate(R.layout.course_footer, parent, false), TYPE_FOOTER_LOADING)
} }
TYPE_FOOTER_NOMORE -> { TYPE_FOOTER_NOMORE -> {
FooterHolder(mInflater!!.inflate(R.layout.footer, parent, false), TYPE_FOOTER_NOMORE) FooterHolder(mInflater!!.inflate(R.layout.course_footer, parent, false), TYPE_FOOTER_NOMORE)
} }
else -> { else -> {
mAdapter.onCreateViewHolder(parent, viewType) mAdapter.onCreateViewHolder(parent, viewType)
......
package com.yidianling.course.courseSearch; package com.yidianling.course.courseSearch;
import com.yidianling.course.coursePlay.moudle.Course; import com.yidianling.course.bean.Course;
import java.util.List; import java.util.List;
......
package com.yidianling.course.courseSearch.http package com.yidianling.course.courseSearch.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.course.courseSearch.CourseSearchBean import com.yidianling.course.courseSearch.CourseSearchBean
import com.yidianling.ydlcommon.http.BaseAPIResponse
import com.yidianling.ydlcommon.http.BaseResponse
import com.yidianling.ydlcommon.http.YdlRetrofitUtils
import io.reactivex.Observable import io.reactivex.Observable
/** /**
...@@ -20,8 +19,7 @@ class CourseSearchApiUtils { ...@@ -20,8 +19,7 @@ class CourseSearchApiUtils {
* 专家课程搜索列表 * 专家课程搜索列表
*/ */
fun courseSearchList(page:Int, keyWord:String) : Observable<BaseAPIResponse<CourseSearchBean>> { fun courseSearchList(page:Int, keyWord:String) : Observable<BaseAPIResponse<CourseSearchBean>> {
return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build() return YDLHttpUtils.obtainApi(CourseSearchListApi::class.java).courseSearchList(page, keyWord)
.create(CourseSearchListApi::class.java).courseSearchList(page, keyWord)
} }
} }
......
package com.yidianling.course.courseSearch.http package com.yidianling.course.courseSearch.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.course.courseSearch.CourseSearchBean import com.yidianling.course.courseSearch.CourseSearchBean
import com.yidianling.ydlcommon.http.BaseAPIResponse
import io.reactivex.Observable import io.reactivex.Observable
import retrofit2.http.* import retrofit2.http.*
......
package com.yidianling.course.courseSearch.http package com.yidianling.course.courseSearch.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.course.courseSearch.CourseSearchBean import com.yidianling.course.courseSearch.CourseSearchBean
import com.yidianling.ydlcommon.http.BaseAPIResponse
import com.yidianling.ydlcommon.http.BaseResponse
import io.reactivex.Observable import io.reactivex.Observable
/** /**
......
...@@ -16,7 +16,7 @@ import com.yidianling.course.course_special_list.event.CourseSpecialListEventImp ...@@ -16,7 +16,7 @@ import com.yidianling.course.course_special_list.event.CourseSpecialListEventImp
import com.yidianling.course.course_special_list.event.ICourseSpecialListEvent import com.yidianling.course.course_special_list.event.ICourseSpecialListEvent
import com.yidianling.course.course_special_list.presenter.CourseSpecialListPresenterImpl import com.yidianling.course.course_special_list.presenter.CourseSpecialListPresenterImpl
import kotlinx.android.synthetic.main.course_special_list_activity.* import kotlinx.android.synthetic.main.course_special_list_activity.*
import kotlinx.android.synthetic.main.layout_title_bar.* import kotlinx.android.synthetic.main.course_layout_title_bar.*
/** /**
* @author yuanwai * @author yuanwai
......
package com.yidianling.course.course_special_list.http package com.yidianling.course.course_special_list.bean
import com.ydl.ydlcommon.data.http.BaseCommand import com.ydl.ydlcommon.data.http.BaseCommand
......
...@@ -6,7 +6,7 @@ import com.ydl.ydlcommon.mvp.base.IPresenter ...@@ -6,7 +6,7 @@ import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.course.course_special_list.bean.CourseSpecialItemBean import com.yidianling.course.course_special_list.bean.CourseSpecialItemBean
import com.yidianling.course.course_special_list.bean.CourseSpecialListBean import com.yidianling.course.course_special_list.bean.CourseSpecialListBean
import com.yidianling.course.course_special_list.http.CourseSpecialListParam import com.yidianling.course.course_special_list.bean.CourseSpecialListParam
import io.reactivex.Observable import io.reactivex.Observable
/** /**
......
package com.yidianling.course.course_special_list.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.course.course_special_list.bean.CourseSpecialListBean
import io.reactivex.Observable
import retrofit2.http.GET
import retrofit2.http.HEAD
import retrofit2.http.QueryMap
/**
* @author yuanwai
* @描述:课程专题列表Api
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/9/18
*/
interface CourseSpecialListApi {
//课程专题列表
//todo
@GET("auth/course/listCoursesBySpecialId")
fun courseSpecialList(@QueryMap params: Map<String, String>): Observable<BaseAPIResponse<CourseSpecialListBean>>
}
\ No newline at end of file
package com.yidianling.course.course_special_list.http
/**
* @author yuanwai
* @描述:课程专题列表接口实现模型
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/9/18
*/
object CourseSpecialListDataManager{
fun getHttp(): ICourseSpecialListHttp = CourseSpecialListHttpImpl.getInstance()
}
\ No newline at end of file
package com.yidianling.course.course_special_list.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseCommand
import com.ydl.ydlcommon.data.http.FormatText
import com.ydl.ydlcommon.utils.NetworkParamsUtils
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.course.course_special_list.bean.CourseSpecialListBean
import io.reactivex.Observable
/**
* @author yuanwai
* @描述:课程专题列表接口实现类
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/9/18
*/
class CourseSpecialListHttpImpl private constructor() : ICourseSpecialListHttp {
companion object {
fun getInstance(): CourseSpecialListHttpImpl {
return Holder.INSTANCE
}
fun clearCourseSpecialListApi() {
Holder.INSTANCE.courseSpecialListApi = null
}
}
object Holder {
val INSTANCE = CourseSpecialListHttpImpl()
}
fun getPostList(crq: BaseCommand): List<FormatText> {
return NetworkParamsUtils.getPostList(crq)
}
fun getMaps(list: List<FormatText>): Map<String, String> {
return NetworkParamsUtils.getMaps(list)
}
private var courseSpecialListApi: CourseSpecialListApi? = null
override fun courseSpecialList(param: CourseSpecialListParam): Observable<BaseAPIResponse<CourseSpecialListBean>> {
val list = getPostList(param)
return YDLHttpUtils.obtainApi(CourseSpecialListApi::class.java!!).courseSpecialList(getMaps(list))
}
}
\ No newline at end of file
package com.yidianling.course.course_special_list.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.course.course_special_list.bean.CourseSpecialListBean
import io.reactivex.Observable
/**
* @author yuanwai
* @描述:课程专题列表请求接口
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/9/18
*/
interface ICourseSpecialListHttp {
/**
* 课程专题列表
*
*
*/
fun courseSpecialList(param: CourseSpecialListParam):
Observable<BaseAPIResponse<CourseSpecialListBean>>
}
\ No newline at end of file
package com.yidianling.course.course_special_list.model package com.yidianling.course.course_special_list.model
import com.ydl.ydlcommon.data.http.RxUtils import com.ydl.ydlcommon.data.http.RxUtils
import com.yidianling.course.net.CourseRetrofitUtils
import com.yidianling.course.course_special_list.bean.CourseSpecialListBean import com.yidianling.course.course_special_list.bean.CourseSpecialListBean
import com.yidianling.course.course_special_list.contract.ICourseSpecialListContract import com.yidianling.course.course_special_list.contract.ICourseSpecialListContract
import com.yidianling.course.course_special_list.http.CourseSpecialListDataManager import com.yidianling.course.course_special_list.bean.CourseSpecialListParam
import com.yidianling.course.course_special_list.http.CourseSpecialListParam
import io.reactivex.Observable import io.reactivex.Observable
/** /**
...@@ -17,7 +17,7 @@ import io.reactivex.Observable ...@@ -17,7 +17,7 @@ import io.reactivex.Observable
class CourseSpecialListModelImpl : ICourseSpecialListContract.Model { class CourseSpecialListModelImpl : ICourseSpecialListContract.Model {
override fun specialListRequest(param: CourseSpecialListParam): Observable<CourseSpecialListBean> { override fun specialListRequest(param: CourseSpecialListParam): Observable<CourseSpecialListBean> {
return CourseSpecialListDataManager.getHttp().courseSpecialList(param) return CourseRetrofitUtils.specialListRequest(param)
.compose(RxUtils.resultJavaData()) .compose(RxUtils.resultJavaData())
} }
} }
\ No newline at end of file
...@@ -2,13 +2,13 @@ package com.yidianling.course.course_special_list.presenter ...@@ -2,13 +2,13 @@ package com.yidianling.course.course_special_list.presenter
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.yidianling.common.tools.RxNetTool import com.yidianling.common.tools.RxNetTool
import com.yidianling.course.course_special_list.bean.CourseSpecialItemBean import com.yidianling.course.course_special_list.bean.CourseSpecialItemBean
import com.yidianling.course.course_special_list.contract.ICourseSpecialListContract import com.yidianling.course.course_special_list.contract.ICourseSpecialListContract
import com.yidianling.course.course_special_list.http.CourseSpecialListParam import com.yidianling.course.course_special_list.bean.CourseSpecialListParam
import com.yidianling.course.course_special_list.model.CourseSpecialListModelImpl import com.yidianling.course.course_special_list.model.CourseSpecialListModelImpl
import com.yidianling.ydlcommon.http.ThrowableConsumer
import com.yidianling.ydlcommon.mvp.RxPresenter
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
...@@ -20,10 +20,8 @@ import io.reactivex.schedulers.Schedulers ...@@ -20,10 +20,8 @@ import io.reactivex.schedulers.Schedulers
* @Company 壹点灵 * @Company 壹点灵
* @date 2018/9/18 * @date 2018/9/18
*/ */
class CourseSpecialListPresenterImpl (view: ICourseSpecialListContract.View) : class CourseSpecialListPresenterImpl (var view: ICourseSpecialListContract.View) :
RxPresenter<ICourseSpecialListContract.View, ICourseSpecialListContract.Model>(view), ICourseSpecialListContract.Presenter{ BasePresenter<ICourseSpecialListContract.View, ICourseSpecialListContract.Model>(),ICourseSpecialListContract.Presenter{
override fun createModel(): ICourseSpecialListContract.Model { override fun createModel(): ICourseSpecialListContract.Model {
return CourseSpecialListModelImpl() return CourseSpecialListModelImpl()
} }
...@@ -70,7 +68,12 @@ class CourseSpecialListPresenterImpl (view: ICourseSpecialListContract.View) : ...@@ -70,7 +68,12 @@ class CourseSpecialListPresenterImpl (view: ICourseSpecialListContract.View) :
* @param loadMore 是否为上拉加载更多 * @param loadMore 是否为上拉加载更多
*/ */
private fun requestList(page: Int,loadMore : Boolean){ private fun requestList(page: Int,loadMore : Boolean){
val disposable = model.specialListRequest(CourseSpecialListParam(page,0)) val disposable = mModel.specialListRequest(
CourseSpecialListParam(
page,
0
)
)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.map { it } .map { it }
.filter { it != null } .filter { it != null }
...@@ -90,6 +93,5 @@ class CourseSpecialListPresenterImpl (view: ICourseSpecialListContract.View) : ...@@ -90,6 +93,5 @@ class CourseSpecialListPresenterImpl (view: ICourseSpecialListContract.View) :
} }
} }
}) })
addDisposable(disposable)
} }
} }
\ No newline at end of file
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Handler
import android.text.TextUtils import android.text.TextUtils
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.audio.model.Music
import com.ydl.media.view.PlayTypeEnum
import com.ydl.media.view.PlayerFloatHelper
import com.ydl.media.view.PlayerFloatView
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_router.manager.YDLRouterManager import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.flutter.base.BaseFlutterFragment
import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.common.tools.LogUtil import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxDeviceTool import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.course.BuildConfig import com.yidianling.course.BuildConfig
...@@ -10,17 +22,10 @@ import com.yidianling.course.courseNew.mine.MyCourseActivity ...@@ -10,17 +22,10 @@ import com.yidianling.course.courseNew.mine.MyCourseActivity
import com.yidianling.course.course_special_list.activity.CourseSpecialListActivity import com.yidianling.course.course_special_list.activity.CourseSpecialListActivity
import com.yidianling.course.flutterPlugin.CourseSendPlugin import com.yidianling.course.flutterPlugin.CourseSendPlugin
import com.yidianling.course.router.CourseIn 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.MethodCall
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
import io.flutter.view.FlutterView import io.flutter.view.FlutterView
import org.json.JSONObject
/** /**
* @author jiucheng * @author jiucheng
...@@ -43,7 +48,7 @@ class CoursePlugin : MethodChannel.MethodCallHandler { ...@@ -43,7 +48,7 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
const val PLAYCOURSEFILE: String = "playCourseFile" const val PLAYCOURSEFILE: String = "playCourseFile"
const val PAUSECOURSEPLAY: String = "pauseCoursePlay" const val PAUSECOURSEPLAY: String = "pauseCoursePlay"
fun rigister(fragment: BaseFlutterFragment, flutterView: FlutterView) { fun register(fragment: BaseFlutterFragment, flutterView: FlutterView) {
MethodChannel(flutterView, CHANNEL).setMethodCallHandler(CoursePlugin(fragment)) MethodChannel(flutterView, CHANNEL).setMethodCallHandler(CoursePlugin(fragment))
} }
} }
...@@ -51,28 +56,48 @@ class CoursePlugin : MethodChannel.MethodCallHandler { ...@@ -51,28 +56,48 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) { override fun onMethodCall(methodCall: MethodCall, result: MethodChannel.Result) {
when (methodCall.method) { when (methodCall.method) {
GETPUBLICPARAMAS -> { GETPUBLICPARAMAS -> {
val loginBean = ModularServiceManager.getPlatformUserService()?.getUser()
val mMap = mutableMapOf<String, Any>() val mMap = mutableMapOf<String, Any>()
mMap["isDevelopment"] = BuildConfig.DEBUG mMap["isDevelopment"] = BuildConfig.DEBUG
mMap["uid"] = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString() mMap["uid"] = loginBean?.userId ?: 0
mMap["accessToken"] = YdlCommonRouterManager.getYdlCommonRoute().getAccessToken() mMap["accessToken"] = loginBean?.token ?: ""
?: "" ?: ""
mMap["isFromApp"] = "1" mMap["isFromApp"] = "1"
mMap["version"] = RxDeviceTool.getAppVersionName(YdlCommonApp.getApp()) mMap["ffrom"] = PlatformDataManager.getRam().getChannelName()
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) result.success(mMap)
} }
JUMPURL -> { JUMPURL -> {
var jumpUrl: String? = methodCall.arguments.toString() var jumpUrl: String? = methodCall.arguments.toString()
if (!TextUtils.isEmpty(jumpUrl)) { if (!TextUtils.isEmpty(jumpUrl)) {
if (jumpUrl!!.startsWith("http")) {
val h5Params = H5Params(jumpUrl, "")
NewH5Activity.start(mFragment!!.activity, h5Params)
return
}
when { when {
jumpUrl!!.contains("user/login") -> mFragment!!.startActivity(CourseIn.loginWayIntent(mFragment!!.activity)) jumpUrl!!.contains("user/login") -> mFragment!!.startActivity(
CourseIn.loginWayIntent(
mFragment!!.activity!!
)
)
jumpUrl.contains("course/myCourse") -> MyCourseActivity.start(mFragment!!.activity) jumpUrl.contains("course/myCourse") -> MyCourseActivity.start(mFragment!!.activity)
jumpUrl.contains("course/specialList") -> //跳转专题列表页 jumpUrl.contains("course/specialList") -> //跳转专题列表页
mFragment!!.activity.startActivity(Intent(mFragment!!.activity, CourseSpecialListActivity::class.java)) mFragment!!.activity!!.startActivity(
Intent(
mFragment!!.activity,
CourseSpecialListActivity::class.java
)
)
jumpUrl.contains("course/detail") -> { jumpUrl.contains("course/detail") -> {
var uri = Uri.parse(jumpUrl) var uri = Uri.parse(jumpUrl)
var id = uri.getQueryParameter("id") var resultParams = uri.getQueryParameter("params")
val h5Params = H5Params(CourseConstants.COURSE_DETAIL_H5 + id, "课程详情") val jsonObject = JSONObject(resultParams)
val h5Params = H5Params(CourseConstants.COURSE_DETAIL_H5 + jsonObject.getString("id"), "课程详情")
NewH5Activity.start(mFragment!!.activity, h5Params) NewH5Activity.start(mFragment!!.activity, h5Params)
} }
else -> YDLRouterManager.router(jumpUrl) else -> YDLRouterManager.router(jumpUrl)
...@@ -85,8 +110,8 @@ class CoursePlugin : MethodChannel.MethodCallHandler { ...@@ -85,8 +110,8 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
playMedia(fileInfo) playMedia(fileInfo)
} }
PAUSECOURSEPLAY -> { PAUSECOURSEPLAY -> {
if (YDLMusicHelper.isPlaying()) { if (AudioPlayer.get().isPlaying) {
YDLMusicHelper.pause() AudioPlayer.get().playPause()
PlayerFloatHelper.updatePlayState() PlayerFloatHelper.updatePlayState()
} }
} }
...@@ -94,54 +119,54 @@ class CoursePlugin : MethodChannel.MethodCallHandler { ...@@ -94,54 +119,54 @@ class CoursePlugin : MethodChannel.MethodCallHandler {
} }
private fun playMedia(fileInfo: Map<*, *>) { private fun playMedia(fileInfo: Map<*, *>) {
if (PlayerFloatHelper.isShow(mFragment!!.activity)) { if (PlayerFloatHelper.isShow(mFragment!!.activity!!)) {
PlayerFloatHelper.hide() PlayerFloatHelper.hide()
PlayerFloatHelper.removeView(mFragment!!.activity) PlayerFloatHelper.removeView(mFragment!!.activity!!)
YDLMusicHelper.clearTempData() AudioPlayer.get().stopPlayer()
YDLMusicHelper.stop()
} else { } else {
PlayerFloatHelper.removeView(mFragment!!.activity) PlayerFloatHelper.removeView(mFragment!!.activity!!)
} }
YDLMusicHelper.title = fileInfo["title"].toString() val music = Music()
YDLMusicHelper.name = fileInfo["name"].toString() music.title = fileInfo["title"].toString()
YDLMusicHelper.cover = fileInfo["cover"].toString() music.artist = fileInfo["name"].toString()
YDLMusicHelper.course_id = fileInfo["courseId"] as Int music.coverPath = fileInfo["cover"].toString()
YDLMusicHelper.isCanClick = false PlayerFloatHelper.isCanClick = false
var demoType = fileInfo["demoType"] as Int var demoType = fileInfo["demoType"] as Int
var url = fileInfo["url"].toString() var url = fileInfo["url"].toString()
if (demoType == 1) { if (demoType == 1) {
YDLMusicHelper.playType = 0 music.path = url
PlayerFloatHelper.show(mFragment!!.activity)
YDLMusicHelper.coursePlay(url) PlayerFloatHelper.show(mFragment!!.activity,playTypeEnum=PlayTypeEnum.PLAY_TYPE_COURSE)
AudioPlayer.get().singlePlay(music)
} }
if (demoType == 2) { if (demoType == 2) {
YDLMusicHelper.playType = 1 //todo 视屏播放
YDLMusicHelper.courseVideoUlr = url // YDLMusicHelper.playType = 1
// YDLMusicHelper.courseVideoUlr = url
PlayerFloatHelper.show(mFragment!!.activity) //
// PlayerFloatHelper.show(mFragment!!.activity)
} }
Handler().postDelayed({ CourseSendPlugin.sendMsg(true) }, 300)
PlayerFloatHelper.addClickListener(object : PlayerFloatView.FloatViewPlayListener { PlayerFloatHelper.addClickListener(object : PlayerFloatView.FloatViewPlayListener {
override fun onStartClick() { override fun onStartClick() {
if (!YDLMusicHelper.isCanClick && YDLMusicHelper.course_id != 0) { if (!PlayerFloatHelper.isCanClick && PlayerFloatHelper.playingType == PlayTypeEnum.PLAY_TYPE_COURSE) {
CourseSendPlugin.sendMsg(true) CourseSendPlugin.sendMsg(true)
} }
} }
override fun onPlayFinish() { override fun onPlayFinish() {
PlayerFloatHelper.hide() PlayerFloatHelper.hide()
YDLMusicHelper.clearTempData() AudioPlayer.get().stopPlayer()
YDLMusicHelper.stop()
} }
override fun onPauseClick() { override fun onPauseClick() {
if (!YDLMusicHelper.isCanClick && YDLMusicHelper.course_id != 0) { if (!PlayerFloatHelper.isCanClick && PlayerFloatHelper.playingType == PlayTypeEnum.PLAY_TYPE_COURSE) {
CourseSendPlugin.sendMsg(false) CourseSendPlugin.sendMsg(false)
} }
} }
......
package com.yidianling.course.flutterPlugin package com.yidianling.course.flutterPlugin
import com.ydl.ydlcommon.flutter.io.flutter.facade.FlutterFragment import com.ydl.ydlcommon.base.flutter.io.flutter.facade.FlutterFragment
import io.flutter.plugin.common.EventChannel import io.flutter.plugin.common.EventChannel
import io.flutter.view.FlutterView import io.flutter.view.FlutterView
...@@ -36,4 +36,13 @@ object CourseSendPlugin { ...@@ -36,4 +36,13 @@ object CourseSendPlugin {
fun sendMsg(isPlaying: Boolean) { fun sendMsg(isPlaying: Boolean) {
eventSink!!.success(isPlaying) eventSink!!.success(isPlaying)
} }
fun sendRequestData(){
eventSink!!.success("requestData")
}
fun sendLoginSuccess(){
eventSink!!.success("loginSuccess")
}
} }
\ No newline at end of file
package com.yidianling.course.listener
import com.ydl.media.audio.model.Music
/**
* 播放状态监听起
* Created by hgw on 2018/4/28.
*/
interface HPlayStatusListener{
//判断是否可以播放
fun isCanPlay(data : Music?):Boolean
//音频初始化完成
fun onPrepared(data : Music?, index:Int=0)
}
\ No newline at end of file
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 package com.yidianling.course.model
import com.yidianling.course.coursePlay.moudle.Course import com.ydl.ydlcommon.bean.ShareData
import com.yidianling.ydlcommon.data.ShareData import com.yidianling.course.bean.Course
/** /**
* Created by Jim on 2018/7/16 0016. * Created by Jim on 2018/7/16 0016.
......
package com.yidianling.course.modular_service
import android.app.Activity
import android.content.Context
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayerFloatHelper
import com.yidianling.course.api.service.ICourseService
import com.yidianling.course.courseNew.CourseTopicActivity
import com.yidianling.course.flutterPlugin.CourseSendPlugin
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2019/11/12
*/
class CourseServiceImp :ICourseService {
override fun courseTopic(activity: Activity, id: String) {
CourseTopicActivity.start(activity, id)
}
override fun closePlayer() {
if (AudioPlayer.get().isPlaying){
AudioPlayer.get().stopPlayer()
}
}
override fun isPlaying(): Boolean {
return AudioPlayer.get().isPlaying
}
override fun startCoursePlayPage(activity: Activity, from: Int) {
PlayerFloatHelper.startCoursePlayActivity(activity,from)
}
override fun play() {
AudioPlayer.get().play()
}
override fun pause() {
AudioPlayer.get().playPause()
}
override fun sendLoginStatusToFlutter() {
CourseSendPlugin.sendLoginSuccess()
}
override fun init(context: Context?) {
}
}
\ No newline at end of file
package com.yidianling.course.coursePlay.common.net; package com.yidianling.course.net;
import com.yidianling.course.CourseConstants; import com.ydl.ydlcommon.data.http.BaseCommand;
import com.yidianling.ydlcommon.http.BaseCommand; import com.ydl.ydlcommon.router.YdlCommonOut;
import com.yidianling.ydlcommon.router.YdlCommonOut;
/** /**
* Created by Jim on 2018/2/26 0026. * Created by Jim on 2018/2/26 0026.
...@@ -81,14 +80,10 @@ public class Command { ...@@ -81,14 +80,10 @@ public class Command {
this.type = type; 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.page = page;
this.type = type; this.type = type;
this.child_type=child_type; this.child_type = child_type;
}
public String getUrl() {
return CourseConstants.ALL_COURSE;
} }
} }
......
package com.yidianling.course.coursePlay.common.net; package com.yidianling.course.net;
import android.content.Context; import android.content.Context;
import com.ydl.ydlcommon.base.config.HttpConfig;
import com.yidianling.course.bean.CourseCouponBean; import com.ydl.ydlcommon.data.http.BaseAPIResponse;
import com.yidianling.course.bean.PostersShareBean; import com.ydl.ydlcommon.data.http.BaseResponse;
import com.yidianling.course.courseNew.home.ResultBean; import com.ydl.ydlcommon.data.http.FormatText;
import com.yidianling.course.coursePlay.moudle.Course; import com.ydl.ydlcommon.utils.NetworkParamsUtils;
import com.yidianling.course.coursePlay.moudle.CourseAddOrderBean; import com.ydl.ydlcommon.utils.remind.HttpErrorUtils;
import com.yidianling.course.coursePlay.moudle.CoursePlayBean; import com.ydl.ydlnet.YDLHttpUtils;
import com.yidianling.course.bean.*;
import com.yidianling.course.course_special_list.bean.CourseSpecialListBean;
import com.yidianling.course.course_special_list.bean.CourseSpecialListParam;
import com.yidianling.course.model.CourseCategoryBean; import com.yidianling.course.model.CourseCategoryBean;
import com.yidianling.course.model.TopicCourseBean; 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 io.reactivex.Observable;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import retrofit2.Retrofit;
import static com.yidianling.ydlcommon.http.YdlRetrofitUtils.getMaps; import java.util.List;
import static com.yidianling.ydlcommon.http.YdlRetrofitUtils.getPostList;
/** /**
* Created by Jim on 2018/2/26 0026. * Created by Jim on 2018/2/26 0026.
*/ */
public class RetrofitUtils { public class CourseRetrofitUtils {
public static void handleError(Context context, Throwable e) { public static void handleError(Context context, Throwable e) {
YdlRetrofitUtils.handleError(context, e); HttpErrorUtils.Companion.handleError(context, e);
}
public static Retrofit getRxRetrofit() {
return YdlRetrofitUtils.getRxRetrofit();
} }
//课程提交回复 //课程提交回复
public static Observable<BaseResponse<Object>> commitCourseReply(Command.CourseCommitReply cmd) { public static Observable<BaseResponse<Object>> commitCourseReply(Command.CourseCommitReply cmd) {
List<FormatText> list = getPostList(cmd); 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) { public static Observable<BaseResponse<PostersShareBean>> getPosterData(String courseId) {
return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getPosterData(courseId); return YDLHttpUtils.Companion.obtainApi(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));
} }
//课程课后笔记列表 //课程课后笔记列表
public static Observable<BaseResponse<List<CoursePlayBean.Comments>>> courseReplyList(Command.CourseReplyList cmd) { public static Observable<BaseResponse<List<CoursePlayBean.Comments>>> courseReplyList(Command.CourseReplyList cmd) {
List<FormatText> list = getPostList(cmd); List<FormatText> list = NetworkParamsUtils.getPostList(cmd);
return getRxRetrofit().create(NetApiStore.class).courseReplyList(getMaps(list)); return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).courseReplyList(NetworkParamsUtils.getMaps(list));
}
public static Observable<BaseAPIResponse<List<ResultBean>>> getCoursesHomePage() {
return getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_API_JAVA_URL).build().create(NetApiStore.class).getCourseHomePageDatas();
}
//获取课程列表(php接口)
public static Observable<BaseResponse<List<Course>>> getCourseList(Command.GetCourse cmd) {
List<FormatText> list = getPostList(cmd);
return getRxRetrofit().create(NetApiStore.class).getPhpCourseList(getMaps(list));
}
//获取课程列表分类
public static Observable<BaseResponse<List<CourseCategoryBean>>> getCourseListCategory(BaseCommand cmd) {
List<FormatText> list = getPostList(cmd);
return getRxRetrofit().create(NetApiStore.class).getCourseCats(getMaps(list));
} }
//获取课程列表分类 //获取课程列表分类
public static Observable<BaseAPIResponse<CourseCategoryBean>> getCourseListCategory() { 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();
} }
//获取课程专题 //获取课程专题
public static Observable<BaseAPIResponse<TopicCourseBean>> getCourseTopic(String id) { 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);
} }
...@@ -102,14 +68,41 @@ public class RetrofitUtils { ...@@ -102,14 +68,41 @@ public class RetrofitUtils {
* @return * @return
*/ */
public static Observable<BaseResponse<List<CourseCouponBean>>> getCourseCoupons(String uid, String services, String receiveType, String applyEnds) { public static Observable<BaseResponse<List<CourseCouponBean>>> getCourseCoupons(String uid, String services, String receiveType, String applyEnds) {
return YdlRetrofitUtils.getRxRetrofit().newBuilder().baseUrl(YdlRetrofitUtils.SERVER_COUPON_URL) return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCourseCoupons(uid, services, receiveType, applyEnds);
.build().create(NetApiStore.class).getCourseCoupons(uid, services, receiveType, applyEnds);
} }
//领取优惠券 //领取优惠券
public static Observable<BaseResponse<List<String>>> receiveCoupon(String couponIds) { public static Observable<BaseResponse<List<String>>> receiveCoupon(String couponIds) {
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), 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(HttpConfig.Companion.getJAVA_BASE_URL() + "auth/coupon/max?" + confideParam);
}
public static Observable<BaseAPIResponse<CourseListDataBean>> getCourseList(String url) {
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCourseList(HttpConfig.Companion.getJAVA_BASE_URL() + "auth/course/getList?" + url);
}
/**
* 获取课程播放页 java 接口
*/
public static Observable<BaseResponse<CourseMediaDetailBean>> getCoursePlayData(String courseId) {
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).getCoursePlayData(courseId);
}
public static Observable<BaseAPIResponse<CourseSpecialListBean>> specialListRequest(CourseSpecialListParam param) {
List<FormatText> list = NetworkParamsUtils.getPostList(param);
return YDLHttpUtils.Companion.obtainApi(NetApiStore.class).courseSpecialList(NetworkParamsUtils.getMaps(list));
} }
} }
package com.yidianling.course.coursePlay.common.net; package com.yidianling.course.net;
import com.yidianling.course.bean.CourseCouponBean; import com.ydl.ydlcommon.data.http.BaseAPIResponse;
import com.yidianling.course.bean.PostersShareBean; import com.ydl.ydlcommon.data.http.BaseResponse;
import com.yidianling.course.courseNew.home.ResultBean; import com.yidianling.course.bean.*;
import com.yidianling.course.coursePlay.moudle.Course; import com.yidianling.course.course_special_list.bean.CourseSpecialListBean;
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.CourseCategoryBean;
import com.yidianling.course.model.TopicCourseBean; import com.yidianling.course.model.TopicCourseBean;
import com.yidianling.ydlcommon.http.BaseAPIResponse; import io.reactivex.Observable;
import com.yidianling.ydlcommon.http.BaseResponse; import okhttp3.RequestBody;
import retrofit2.http.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import io.reactivex.Observable; import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN;
import okhttp3.RequestBody; import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_COUPON_URL;
import retrofit2.http.Body; import static com.ydl.ydlcommon.base.config.AppConfigKt.YDL_DOMAIN_JAVA;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Url;
/** /**
* Created by Jim on 2018/2/26 0026. * Created by Jim on 2018/2/26 0026.
...@@ -42,12 +34,6 @@ public interface NetApiStore { ...@@ -42,12 +34,6 @@ public interface NetApiStore {
@POST("course/list") @POST("course/list")
Observable<BaseResponse<List<Course>>> getPhpCourseList(@FieldMap Map<String, String> params); Observable<BaseResponse<List<Course>>> getPhpCourseList(@FieldMap Map<String, String> params);
// //获取课程播放页 初始化数据
// @FormUrlEncoded
// @POST("course/play")
// Observable<BaseResponse<CoursePlayBean>> getCoursePlayData(@FieldMap Map<String, String> params);
//课程课后笔记列表 //课程课后笔记列表
@FormUrlEncoded @FormUrlEncoded
@POST("course/comments") @POST("course/comments")
...@@ -56,6 +42,7 @@ public interface NetApiStore { ...@@ -56,6 +42,7 @@ public interface NetApiStore {
//课程提交回复 //课程提交回复
@FormUrlEncoded @FormUrlEncoded
@POST("auth/course/comments/add") @POST("auth/course/comments/add")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
Observable<BaseResponse<Object>> commitCourseReply(@FieldMap Map<String, String> params); Observable<BaseResponse<Object>> commitCourseReply(@FieldMap Map<String, String> params);
//课程播放页--点赞 //课程播放页--点赞
...@@ -68,13 +55,9 @@ public interface NetApiStore { ...@@ -68,13 +55,9 @@ public interface NetApiStore {
@POST("course/add-order") @POST("course/add-order")
Observable<BaseResponse<CourseAddOrderBean>> addCourseOrder(@FieldMap Map<String, String> params); Observable<BaseResponse<CourseAddOrderBean>> addCourseOrder(@FieldMap Map<String, String> params);
//首页课程
@GET("auth/course/home")
Observable<BaseAPIResponse<List<ResultBean>>> getCourseHomePageDatas();
//获取课程海报分享数据 //获取课程海报分享数据
@GET("auth/course/posters/share") @GET("auth/course/posters/share")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
Observable<BaseResponse<PostersShareBean>> getPosterData(@Query("id") String courseId); Observable<BaseResponse<PostersShareBean>> getPosterData(@Query("id") String courseId);
...@@ -85,16 +68,13 @@ public interface NetApiStore { ...@@ -85,16 +68,13 @@ public interface NetApiStore {
//课程筛选分类 //课程筛选分类
@GET("auth/course/search/newsample") @GET("auth/course/search/newsample")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
Observable<BaseAPIResponse<CourseCategoryBean>> getCourseListCategory(); Observable<BaseAPIResponse<CourseCategoryBean>> getCourseListCategory();
// //首页分类
// @FormUrlEncoded
// @POST("course/course-special")
// Observable<BaseResponse<TopicCourseBean>> getCourseTopic(@FieldMap Map<String, String> params);
//课程专题列表接口 //课程专题列表接口
@GET("auth/course/new/listCoursesBySpecialId") @GET("auth/course/new/listCoursesBySpecialId")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
Observable<BaseAPIResponse<TopicCourseBean>> getCourseSpecial(@Query("specialId") String uid); Observable<BaseAPIResponse<TopicCourseBean>> getCourseSpecial(@Query("specialId") String uid);
...@@ -108,6 +88,7 @@ public interface NetApiStore { ...@@ -108,6 +88,7 @@ public interface NetApiStore {
* @return * @return
*/ */
@GET("marketing/coupon/new/available") @GET("marketing/coupon/new/available")
@Headers(YDL_DOMAIN + YDL_DOMAIN_COUPON_URL)
Observable<BaseResponse<List<CourseCouponBean>>> getCourseCoupons(@Query("uid") String uid, Observable<BaseResponse<List<CourseCouponBean>>> getCourseCoupons(@Query("uid") String uid,
@Query("services") String services, @Query("services") String services,
@Query("receiveType") String receiveType, @Query("receiveType") String receiveType,
...@@ -115,5 +96,28 @@ public interface NetApiStore { ...@@ -115,5 +96,28 @@ public interface NetApiStore {
//领取优惠券 //领取优惠券
@POST("marketing/coupon/new/receives") @POST("marketing/coupon/new/receives")
@Headers(YDL_DOMAIN + YDL_DOMAIN_COUPON_URL)
Observable<BaseResponse<List<String>>> receiveCoupon(@Body RequestBody body); Observable<BaseResponse<List<String>>> receiveCoupon(@Body RequestBody body);
@GET("auth/coupon/courseCoupon/warn")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
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")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
Observable<BaseResponse<CourseMediaDetailBean>> getCoursePlayData(@Query("courseId") String courseId);
//课程专题列表
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
@GET("auth/course/listCoursesBySpecialId")
Observable<BaseAPIResponse<CourseSpecialListBean>> courseSpecialList(@QueryMap Map<String, String> params);
} }
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