Commit ae6cc69a by konghaorui

删除无用资源

parent d1fcc291
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
......@@ -943,10 +943,6 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
ConsultantIn.startP2PXiaoYi(this)
}
R.id.ll_free -> {
val h5param = H5Params(HttpConfig.H5_URL + "ct/list", "免费咨询")
NewH5Activity.start(this, h5param)
}
R.id.rl_search -> {
ARouter.getInstance()
.build("/consult/hot_search")
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp" />
<solid android:color="@color/main_theme" />
<stroke
android:width="1dp"
android:color="@color/main_theme" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="20dp"></corners>
<solid android:color="@color/white" />
<stroke android:width="1dp" android:color="@color/color_grey_999999"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="5dp"/>
<solid android:color="@color/white" />
<stroke android:width="1dp" android:color="#ababab"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="6dp"/>
<solid android:color="@android:color/white" />
<stroke android:width="1px" android:color="#F0F0F0"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<size android:height="0.5dp" />
<stroke
android:dashGap="3dp"
android:dashWidth="8dp"
android:width="1dp"
android:color="#E0E0E0" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#3484da"
android:endColor="#05cbfc"
/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="#00000000"
android:startColor="#3f000000"
/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:paddingBottom="16dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="25dp">
<ImageView
android:id="@+id/ivHead"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:contentDescription="@null"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/avatar_def_circle" />
<TextView
android:id="@+id/tvService"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="8dp"
android:layout_marginStart="16dp"
android:ellipsize="end"
android:maxLines="2"
android:textColor="#1d1d1d"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@+id/btnChat"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toEndOf="@+id/ivHead"
app:layout_constraintTop_toTopOf="@+id/ivHead"
app:layout_goneMarginRight="16dp"
tools:text="婚恋家庭关系电话咨询套餐" />
<TextView
android:id="@+id/tvName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:textColor="#1d1d1d"
android:textStyle="bold"
app:layout_constraintLeft_toRightOf="@+id/ivHead"
app:layout_constraintTop_toBottomOf="@+id/tvService"
tools:text="夏一可" />
<TextView
android:id="@+id/tvArea"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:textColor="#1d1d1d"
app:layout_constraintLeft_toRightOf="@+id/tvName"
app:layout_constraintTop_toBottomOf="@+id/tvService"
tools:text="黑龙江省-齐齐哈尔" />
<TextView
android:id="@+id/tvDesc"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="12dp"
android:ellipsize="end"
android:maxLines="2"
android:textColor="#999999"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="@+id/ivHead"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvArea"
tools:text="恋爱心理、情感纠葛、失恋、网恋、分手挽留夫妻关系" />
<cn.lankton.flowlayout.FlowLayout
android:id="@+id/flTags"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="16dp"
android:layout_marginStart="0dp"
android:layout_marginTop="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/tvDesc"
app:layout_constraintTop_toBottomOf="@+id/tvDesc" />
<TextView
android:id="@+id/tvPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:textColor="@color/google_red"
app:layout_constraintLeft_toRightOf="@+id/ivHead"
app:layout_constraintTop_toBottomOf="@+id/flTags"
tools:text="25元起" />
<TextView
android:id="@+id/tvConsultTimes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:textColor="#1d1d1d"
app:layout_constraintLeft_toRightOf="@+id/tvPrice"
app:layout_constraintTop_toBottomOf="@+id/flTags"
tools:text="咨询次数 12" />
<TextView
android:id="@+id/tvRate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:textColor="#1d1d1d"
app:layout_constraintLeft_toRightOf="@+id/tvConsultTimes"
app:layout_constraintTop_toBottomOf="@+id/flTags"
tools:text="好评率 99%" />
<Button
android:id="@+id/btnChat"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="68dp"
android:layout_height="30dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:background="@drawable/bg_radius_line_green_5"
android:drawableLeft="@drawable/ic_chat_green"
android:drawablePadding="6dp"
android:drawableStart="@drawable/ic_chat_green"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="私聊"
android:textColor="@color/main_theme"
android:textSize="@dimen/sp_14"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ll_search"
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:tag="tag_search_input"
app:layout_anchor="@+id/middle_but_layout"
app:layout_anchorGravity="top"
android:focusable="true"
android:focusableInTouchMode="true"
>
<!--android:layout_marginTop="@dimen/search_input_margin"-->
<View
android:id="@+id/view_search_input_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_search_input"
android:tag="tag_search_input_bg"
/>
<ImageView
android:id="@+id/iv_search_icon"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:layout_width="14dp"
android:layout_height="14dp"
android:scaleType="centerCrop"
android:layout_centerVertical="true"
android:tag="tag_search_input_img"
android:src="@drawable/icon_input_search"/>
<EditText
android:id="@+id/etSearch"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="@dimen/dp_10"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/iv_search_icon"
android:background="@null"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="搜索心理问题或专家姓名"
android:imeOptions="actionSearch"
android:singleLine="true"
android:textColor="@color/color_444444"
android:textColorHint="#b3b3b3"
android:textSize="12sp"
android:textCursorDrawable="@color/main_theme"
android:tag="tag_search_input_edit"
/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.yidianling.consultant.ui.view.DisInterceptNestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/middle_but_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/head_bg_height"
android:background="@color/colorBg"
android:tag="middle_but_layout"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.434">
<LinearLayout
android:layout_marginBottom="@dimen/dp_5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@android:color/white"
android:orientation="horizontal"
android:paddingLeft="15dp"
android:paddingTop="40dp"
android:paddingRight="15dp"
android:paddingBottom="20dp">
<LinearLayout
android:id="@+id/ll_free"
android:layout_width="0dp"
android:layout_height="@dimen/dp_60"
android:layout_weight="1"
android:background="@drawable/bg_free_consult"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="免费咨询"
android:textStyle="bold"
android:textColor="@android:color/white"
android:layout_marginBottom="3.5dp"
android:textSize="17sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="权威大咖 邀你体验"
android:textColor="@android:color/white"
android:textSize="11sp"/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_guide"
android:layout_width="0dp"
android:layout_height="@dimen/dp_60"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:background="@drawable/bg_consult_guide"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="咨询指南"
android:textStyle="bold"
android:layout_marginBottom="3.5dp"
android:textColor="@android:color/white"
android:textSize="17sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="心理咨询是什么"
android:textColor="@android:color/white"
android:textSize="11sp"/>
</LinearLayout>
</LinearLayout>
</com.yidianling.consultant.ui.view.DisInterceptNestedScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--字体大小部分-->
<dimen name="default_text_size_little">10sp</dimen>
<dimen name="default_text_size_small">12sp</dimen>
<dimen name="default_text_size">14sp</dimen>
<dimen name="default_text_size_big">16sp</dimen>
<dimen name="default_text_size_large">18sp</dimen>
<!--距离部分-->
<dimen name="default_dis_size_nano">2dp</dimen>
<dimen name="default_dis_size_micro">4dp</dimen>
<dimen name="default_dis_size_small">6dp</dimen>
<dimen name="default_dis_size">8dp</dimen>
<dimen name="default_dis_size_big">10dp</dimen>
<dimen name="default_dis_size_large">12dp</dimen>
<dimen name="default_dis_size_huge">14dp</dimen>
<dimen name="default_dis_size_huge_more">16dp</dimen>
<!--分割线粗细-->
<dimen name="divide_line_stroke_width">1px</dimen>
......
......@@ -2,21 +2,17 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!--字体大小部分-->
<dimen name="text_size_14">14sp</dimen>
<dimen name="default_text_size_little">10sp</dimen>
<dimen name="default_text_size_small">12sp</dimen>
<dimen name="default_text_size">14sp</dimen>
<dimen name="default_text_size_big">16sp</dimen>
<dimen name="default_text_size_large">18sp</dimen>
<!--距离部分-->
<dimen name="default_dis_size_nano">2dp</dimen>
<dimen name="default_dis_size_micro">5dp</dimen>
<dimen name="default_dis_size_small">7.5dp</dimen>
<dimen name="default_dis_size">10dp</dimen>
<dimen name="default_dis_size_big">12.5dp</dimen>
<dimen name="default_dis_size_large">15dp</dimen>
<dimen name="default_dis_size_huge">17.5dp</dimen>
<dimen name="default_dis_size_huge_more">20dp</dimen>
<!--dialog部分-->
......@@ -35,5 +31,4 @@
<!--进度条-->
<!--照片选择器-->
<dimen name="head_size_big">72dp</dimen>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="msg_system_press">#fff7f7f7</color>
<color name="msg_bg_press">#eeeeeeee</color>
<color name="colorDivider">#ebebeb</color>
<!-- google color-->
<color name="google_red">#ed412c</color>
<color name="google_yellow">#fdbd00</color>
<color name="color_FF9500">#FF9500</color>
<color name="color_grey_d0d0d0">#d0d0d0</color>
<!--app主要颜色-->
<color name="white">#ffffff</color>
<color name="app_background">#fbf9fc</color>
<color name="theme_title_bar_color">#FFFFFF</color>
<color name="theme_bg">#FAFAFA</color>
<color name="default_text_color">#555555</color>
<color name="default_text_color_hint">#333333</color>
<color name="divide_color">#EDEDED</color>
<color name="new_divide_color">#f0f0f0</color>
<color name="new_background_color">#ececec</color>
<color name="place_holder_color">#DDDDDD</color>
<color name="transparent">#00FFFFFF</color>
<color name="price_color">#EC7100</color>
<color name="thx_red_color">#EB5835</color>
<color name="tag_text">#777777</color>
<color name="f5f5f5">#f5f5f5</color>
<color name="fffaec">#fffaec</color>
<color name="black_deep">#FF000000</color>
<color name="line">#e5e5e5</color>
......@@ -33,51 +22,26 @@
<color name="colorTextDefault">#555555</color>
<!-- main bg color -->
<color name="main_bg_color">#FFFFFF</color>
<!-- session -->
<color name="color_message_default_bg">#e9ecf0</color>
<color name="input_panel_text_color_757572">#757572</color>
<color name="color_gray_cbd0d8">#cbd0d8</color>
<!-- image picker -->
<color name="color_split_line_d9d9d9">#d9d9d9</color>
<color name="color_split_line_cccccc">#cccccc</color>
<!-- contact -->
<color name="contact_list_hover">#d9d9d9</color>
<color name="contact_letter_idx_bg">#33000000</color>
<color name="color_grey_ababab">#ababab</color>
<color name="color_yellow_796413">#796413</color>
<color name="color_red_f04c62">#f04c62</color>
<!-- setting -->
<color name="color_black_ff333333">#ff333333</color>
<color name="color_black_ff666666">#ff666666</color>
<color name="color_black_ff999999">#999999</color>
<!--云信 end-->
<color name="text_gray">#B6B6B6</color>
<color name="title_bottom_line_bg">#DDDDDD</color>
<color name="defult_bg">#f3f3f3</color>
<!--动态-->
<color name="text_trend_defult">#999999</color>
<color name="text_trend_black">#444444</color>
<color name="text_trend_title_black">#333333</color>
<!--动态顶部title背景变色-->
<color name="trend_transparent">#00ffffff</color>
<color name="trend_gray">#f3f3f3</color>
<color name="color_grey_555555">#555555</color>
<color name="color_background">#ECF1F5</color>
<color name="bg_top_msg">#f3f3f3</color>
<color name="color_grey_999999">#999999</color>
<color name="color_black_333333">#333333</color>
<color name="colorBg">#f5f5f5</color>
......
......@@ -5,23 +5,12 @@
<!--动态-->
<!--顶部title Size-->
<dimen name="title_height">45dp</dimen>
<dimen name="title_txt_sp">20sp</dimen>
<!-- map -->
<dimen name="text_size_9">9sp</dimen>
<dimen name="text_size_10">10sp</dimen>
<dimen name="text_size_12">12sp</dimen>
<dimen name="text_size_13">13sp</dimen>
<dimen name="text_size_14">14sp</dimen>
<dimen name="text_size_15">15sp</dimen>
<dimen name="text_size_16">16sp</dimen>
<dimen name="text_size_17">17sp</dimen>
<dimen name="text_size_18">18sp</dimen>
<dimen name="text_size_20">20sp</dimen>
<dimen name="title_bar_height">48dp</dimen>
<dimen name="head_bg_height">180dp</dimen>
</resources>
<resources>
<string name="app_name">consultant</string>
<string name="version_update">版本更新</string>
<string name="encourage_us">鼓励一下我们</string>
<string name="update_hint">已经是最新版本咯</string>
<string name="load_new_version">正在下载新版本</string>
<string name="cancel">取消</string>
<string name="service">客服小壹</string>
<string name="trends">动态</string>
<string name="course_recommend">课程推荐</string>
<string name="no_more_data_hint">到底了,陛下,就等你分享了呢</string>
<string name="loading_hint">正在加载中…</string>
<string name="popularity">人气:</string>
<string name="course_detail">课程详情</string>
<string name="attend_course_success">报名成功</string>
<string name="theme">主题</string>
<string name="area">地区</string>
<string name="sort">排序</string>
<string name="filter">筛选</string>
<string name="search">搜索</string>
<string name="show_type">显示方式</string>
<string name="enquiry_type">咨询方式</string>
<string name="age">年龄</string>
<string name="reset">重置</string>
<string name="confirm">确定</string>
<string name="no_more">没有更多了</string>
......@@ -28,36 +12,14 @@
<string name="search_by_category">按主题搜索看看</string>
<string name="search_hint">搜索话题、咨询师姓名</string>
<string name="need_storage_permission_hint">App正常工作需要内部存储使用权限,请开启</string>
<string name="register_by_phone">手机号注册</string>
<string name="login_by_phone">手机登录</string>
<string name="login_by_qq">QQ登录</string>
<string name="login_by_wechat">微信登录</string>
<string name="user_protocol">用户协议</string>
<string name="next_step">下一步</string>
<string name="walk_around">随便逛逛</string>
<string name="finish">完成</string>
<string name="nickname_hint">设置一个昵称,方便大家认识你哦(最多10个字)</string>
<string name="please_select_gender">请选择性别</string>
<string name="more">更多</string>
<string name="register_success">注册成功</string>
<string name="private_safe_hint">设置手势密码,保障安全隐私</string>
<string name="header">头像</string>
<string name="pause_play">暂停/播放</string>
<string name="start_test">立即测试</string>
<string name="test_result">测试结果</string>
<string name="test_again">重新测试</string>
<string name="send_to_expert">专家解读</string>
<string name="test_answer">测试回答</string>
<string name="introduction">说明</string>
<string name="last_question">上一题</string>
<string name="no_test_record_hint">还没有测试记录哦</string>
<string name="recommend_test">推荐测试</string>
<string name="test_count">%d人测过</string>
<string name="questions">%d个问题</string>
<string name="wrong_args">参数异常</string>
<string name="no_search_keyword_hint">请输入关键字</string>
<string name="gson_parse_error">解析错误</string>
<string name="test_either">我也要测试</string>
<!--网络提示模块-->
<string name="network_error">请检查网络连接!</string>
......@@ -67,10 +29,7 @@
<string name="loading">正在加载中...</string>
<!-- 个人名片 -->
<string name="other">其他</string>
<string name="set_head_image">设置头像</string>
<string name="appbar_scroll_behavior">com.yidianling.consultant.ui.behavior.SearchAppBarLayoutBehavior</string>
<string name="reload_hint">加载失败,换个网络环境试试吧</string>
</resources>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/main_theme</item>
<item name="colorPrimaryDark">@color/main_theme</item>
<item name="colorAccent">@color/main_theme</item>
</style>
<style name="FilterTextViewStyle">
<item name="android:layout_height">40dp</item>
<item name="android:textSize">14sp</item>
......
<?xml version="1.0" encoding="utf-8"?>
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="3" />
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="30" android:toXDelta="60"
android:duration="500"
android:interpolator="@anim/cycle"
/>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.ydl.ydlcommon.view.TitleBar
android:layout_width="match_parent"
android:layout_height="@dimen/title_bar_height"
app:left_start_icon="@drawable/toolbar_back"
app:title_text="更换手机" />
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:layout_marginTop="@dimen/default_dis_size_huge"
android:background="@color/divide_color" />
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:background="@color/divide_color" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal">
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:padding="@dimen/default_dis_size"
android:text="登录密码" />
<EditText
android:id="@+id/check_password"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:inputType="textPassword"
android:padding="@dimen/default_dis_size"
android:textColorHint="@color/default_text_color_hint" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:background="@color/divide_color" />
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:layout_marginTop="@dimen/default_dis_size_huge"
android:background="@color/divide_color" />
<com.ydl.ydlcommon.view.RoundCornerButton
android:id="@+id/change_next"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/default_dis_size"
android:layout_marginRight="@dimen/default_dis_size"
android:layout_marginTop="@dimen/default_dis_size_huge"
android:text="下一步"
android:textColor="@color/white"
android:textSize="@dimen/default_text_size_big"
app:round_btn_active_bg="@color/white"
app:round_btn_bg="@color/main_theme"
app:round_btn_radio_size="5dp" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical">
<TextView
android:id="@+id/tv_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:padding="10dp"
android:text="@string/cancel"
android:textColor="#ff3fcd4c"
android:textSize="17sp" />
<TextView
android:id="@+id/tv_walk_around"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="?android:attr/selectableItemBackground"
android:padding="10dp"
android:text="@string/walk_around"
android:textColor="#ff3fcd4c"
android:textSize="17sp"
tools:ignore="RelativeOverlap" />
<ImageView
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentBottom="true"
android:contentDescription="@null"
android:scaleType="centerCrop"
android:src="@drawable/login_img" />
<com.ydl.ydlcommon.view.RoundCornerButton
android:id="@+id/login_wechat"
android:layout_width="230dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:drawableLeft="@drawable/login_weixin"
android:drawablePadding="10dp"
android:drawableStart="@drawable/login_weixin"
android:paddingLeft="64dp"
android:paddingRight="64dp"
android:text="@string/login_by_wechat"
android:textColor="#ffffff"
android:textSize="17sp"
app:round_btn_bg="#ff3fcd4c"
app:round_btn_radio_size="50dp" />
<com.ydl.ydlcommon.view.RoundCornerButton
android:id="@+id/login_qq"
android:layout_width="230dp"
android:layout_height="50dp"
android:layout_below="@id/login_wechat"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:drawableLeft="@drawable/login_qq"
android:drawablePadding="10dp"
android:drawableStart="@drawable/login_qq"
android:paddingLeft="64dp"
android:paddingRight="64dp"
android:text="@string/login_by_qq"
android:textColor="#ffffff"
android:textSize="17sp"
app:round_btn_bg="#50befd"
app:round_btn_radio_size="50dp"
tools:visibility="visible" />
<com.ydl.ydlcommon.view.RoundCornerButton
android:id="@+id/login_phone"
android:layout_width="230dp"
android:layout_height="50dp"
android:layout_below="@id/login_qq"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:drawableLeft="@drawable/login_phone"
android:drawablePadding="10dp"
android:drawableStart="@drawable/login_phone"
android:paddingLeft="64dp"
android:paddingRight="64dp"
android:text="@string/login_by_phone"
android:textColor="#ffffff"
android:textSize="17sp"
app:round_btn_bg="#7e8dff"
app:round_btn_radio_size="50dp" />
<TextView
android:id="@+id/tv_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/login_phone"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="33dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center"
android:padding="5dp"
android:text="@string/register_by_phone"
android:textColor="#3fcd4c"
android:textSize="20sp" />
</RelativeLayout>
<resources xmlns:tools="http://schemas.android.com/tools">
<!--字体大小部分-->
<dimen name="default_text_size_little">10sp</dimen>
<dimen name="default_text_size_small">12sp</dimen>
<dimen name="default_text_size">14sp</dimen>
<dimen name="default_text_size_big">16sp</dimen>
<dimen name="default_text_size_large">18sp</dimen>
<!--距离部分-->
<dimen name="default_dis_size_nano">2dp</dimen>
<dimen name="default_dis_size_micro">4dp</dimen>
<dimen name="default_dis_size_small">6dp</dimen>
<dimen name="default_dis_size">8dp</dimen>
<dimen name="default_dis_size_big">10dp</dimen>
<dimen name="default_dis_size_large">12dp</dimen>
<dimen name="default_dis_size_huge">14dp</dimen>
<dimen name="default_dis_size_huge_more">16dp</dimen>
<!--分割线粗细-->
<dimen name="divide_line_stroke_width">1px</dimen>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer-array name="ydl_colors">
<item>@color/main_theme_blue</item>
</integer-array>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="msg_system_press">#fff7f7f7</color>
<color name="msg_bg_press">#eeeeeeee</color>
<color name="colorDivider">#ebebeb</color>
<!-- google color-->
<color name="google_red">#ed412c</color>
<color name="google_yellow">#fdbd00</color>
<color name="color_grey_d0d0d0">#d0d0d0</color>
<!--app主要颜色-->
<color name="white">#ffffff</color>
<color name="theme_title_bar_color">#FFFFFF</color>
<color name="theme_bg">#FAFAFA</color>
<color name="default_text_color">#555555</color>
<color name="default_text_color_hint">#333333</color>
......@@ -18,10 +12,8 @@
<color name="place_holder_color">#DDDDDD</color>
<color name="transparent">#00FFFFFF</color>
<color name="price_color">#EC7100</color>
<color name="thx_red_color">#EB5835</color>
<color name="tag_text">#777777</color>
<color name="f5f5f5">#f5f5f5</color>
<color name="fffaec">#fffaec</color>
<color name="black_deep">#FF000000</color>
......@@ -29,45 +21,23 @@
<color name="colorTextDefault">#555555</color>
<!-- main bg color -->
<color name="main_bg_color">#FFFFFF</color>
<!-- session -->
<color name="color_message_default_bg">#e9ecf0</color>
<color name="input_panel_text_color_757572">#757572</color>
<color name="color_gray_cbd0d8">#cbd0d8</color>
<!-- image picker -->
<color name="color_split_line_d9d9d9">#d9d9d9</color>
<color name="color_split_line_cccccc">#cccccc</color>
<!-- contact -->
<color name="contact_list_hover">#d9d9d9</color>
<color name="contact_letter_idx_bg">#33000000</color>
<color name="color_grey_ababab">#ababab</color>
<color name="color_yellow_796413">#796413</color>
<color name="color_red_f04c62">#f04c62</color>
<!-- setting -->
<color name="color_black_ff333333">#ff333333</color>
<color name="color_black_ff666666">#ff666666</color>
<color name="color_black_ff999999">#999999</color>
<!--云信 end-->
<color name="text_gray">#B6B6B6</color>
<color name="title_bottom_line_bg">#DDDDDD</color>
<color name="defult_bg">#f3f3f3</color>
<!--动态-->
<color name="text_trend_defult">#999999</color>
<color name="text_trend_black">#444444</color>
<color name="text_trend_title_black">#333333</color>
<!--动态顶部title背景变色-->
<color name="trend_transparent">#00ffffff</color>
<color name="trend_gray">#f3f3f3</color>
<color name="color_grey_555555">#555555</color>
<color name="color_background">#ECF1F5</color>
<color name="bg_top_msg">#f3f3f3</color>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_vertical_margin">16dp</dimen>
<!--动态-->
<!--顶部title Size-->
<dimen name="title_height">45dp</dimen>
<dimen name="title_txt_sp">20sp</dimen>
<!-- map -->
<dimen name="text_size_9">9sp</dimen>
<dimen name="text_size_10">10sp</dimen>
<dimen name="text_size_12">12sp</dimen>
<dimen name="text_size_13">13sp</dimen>
<dimen name="text_size_14">14sp</dimen>
<dimen name="text_size_15">15sp</dimen>
<dimen name="text_size_16">16sp</dimen>
<dimen name="text_size_17">17sp</dimen>
<dimen name="text_size_18">18sp</dimen>
<dimen name="text_size_20">20sp</dimen>
</resources>
<resources>
<string name="version_update">版本更新</string>
<string name="encourage_us">鼓励一下我们</string>
<string name="update_hint">已经是最新版本咯</string>
<string name="load_new_version">正在下载新版本</string>
<string name="cancel">取消</string>
<string name="service">客服小壹</string>
<string name="trends">动态</string>
<string name="course_recommend">课程推荐</string>
<string name="no_more_data_hint">到底了,陛下,就等你分享了呢</string>
<string name="loading_hint">正在加载中…</string>
<string name="popularity">人气:</string>
<string name="course_detail">课程详情</string>
<string name="attend_course_success">报名成功</string>
<string name="theme">主题</string>
<string name="area">地区</string>
<string name="sort">排序</string>
<string name="filter">筛选</string>
<string name="search">搜索</string>
<string name="show_type">显示方式</string>
<string name="enquiry_type">咨询方式</string>
<string name="age">年龄</string>
<string name="reset">重置</string>
<string name="confirm">确定</string>
<string name="no_more">没有更多了</string>
......@@ -27,36 +11,14 @@
<string name="search_by_category">按主题搜索看看</string>
<string name="search_hint">搜索话题、咨询师姓名</string>
<string name="need_storage_permission_hint">App正常工作需要内部存储使用权限,请开启</string>
<string name="register_by_phone">手机号注册</string>
<string name="login_by_phone">手机登录</string>
<string name="login_by_qq">QQ登录</string>
<string name="login_by_wechat">微信登录</string>
<string name="user_protocol">用户协议</string>
<string name="next_step">下一步</string>
<string name="walk_around">随便逛逛</string>
<string name="finish">完成</string>
<string name="nickname_hint">设置一个昵称,方便大家认识你哦(最多10个字)</string>
<string name="please_select_gender">请选择性别</string>
<string name="more">更多</string>
<string name="register_success">注册成功</string>
<string name="private_safe_hint">设置手势密码,保障安全隐私</string>
<string name="header">头像</string>
<string name="pause_play">暂停/播放</string>
<string name="start_test">立即测试</string>
<string name="test_result">测试结果</string>
<string name="test_again">重新测试</string>
<string name="send_to_expert">专家解读</string>
<string name="test_answer">测试回答</string>
<string name="introduction">说明</string>
<string name="last_question">上一题</string>
<string name="no_test_record_hint">还没有测试记录哦</string>
<string name="recommend_test">推荐测试</string>
<string name="test_count">%d人测过</string>
<string name="questions">%d个问题</string>
<string name="wrong_args">参数异常</string>
<string name="no_search_keyword_hint">请输入关键字</string>
<string name="gson_parse_error">解析错误</string>
<string name="test_either">我也要测试</string>
<!--网络提示模块-->
<string name="network_error">请检查网络连接!</string>
......@@ -64,8 +26,6 @@
<string name="httperror">请求失败</string>
<!--动态模块-->
<string name="trend_foucused">已关注</string>
<string name="trend_foucus">关注</string>
<string name="dialog_loading">加载中…</string>
<string name="edittext_hint"></string>
......
package com.ydl.ydlcommon.actions.player
/**
* 配置文件
* Created by hgw on 2018/3/31.
*/
object Config{
/**
* 进度保存文件名
*/
val HMusicProgress : String = "HMUSIC_PROGRESS"
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.player
/**
* 音乐详情
* Created by hgw on 2018/3/31.
*/
class MusicInfoBean{
constructor(url: String?, title: String?, pic: String?, desc: String?) {
this.url = url
this.title = title
this.pic = pic
this.desc = desc
}
constructor(url: String?) {
this.url = url
}
constructor()
var url : String? = null
var title : String? = null
var pic : String?= null
var desc : String? = null
//是否试听
var isTestPlay : Boolean = false
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.player
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.os.Bundle
import com.ydl.ydlcommon.actions.player.player.NotifyClickListener
import com.ydl.ydlcommon.actions.player.service.HMusicPlayService
/**
* 音频播放器辅助类
* Created by hgw on 2018/3/31.
*/
object MusicPlayerHelper {
var listener: NotifyClickListener? = null
fun bindService(context: Context, serviceConnection: ServiceConnection): Boolean {
var intent = Intent(context, HMusicPlayService::class.java)
return context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
}
fun unBinderService(activity: Context?, serviceConnection: ServiceConnection) {
activity?.unbindService(serviceConnection)
}
fun start(context: Context) {
var intent = Intent(context, HMusicPlayService::class.java)
var bundle = Bundle()
bundle.putString(HMusicPlayService.ACTION, HMusicPlayService.ONSTART)
intent.putExtra("bundle", bundle)
context.startService(intent)
}
fun start(context: Context, index: Int) {
var intent = Intent(context, HMusicPlayService::class.java)
var bundle = Bundle()
bundle.putString(HMusicPlayService.ACTION, HMusicPlayService.ONSTART_NEW)
bundle.putInt(HMusicPlayService.INDEX, index)
intent.putExtra("bundle", bundle)
context.startService(intent)
}
fun pause(context: Context) {
var intent = Intent(context, HMusicPlayService::class.java)
var bundle = Bundle()
bundle.putString(HMusicPlayService.ACTION, HMusicPlayService.ACTION_PAUSE)
intent.putExtra("bundle", bundle)
context.startService(intent)
}
fun pauseService(context: Context) {
//暂停播放
var intent = Intent(context, HMusicPlayService::class.java)
var bundle = Bundle()
bundle.putString(HMusicPlayService.ACTION, HMusicPlayService.ACTION_STOP)
intent.putExtra("bundle", bundle)
context.startService(intent)
}
fun stopService(context: Context) {
//停止服务
listener = null
var intent = Intent(context, HMusicPlayService::class.java)
context.stopService(intent)
}
/**
* 注册通知栏操作监听器监听器
*/
fun registerListener(listener: NotifyClickListener) {
MusicPlayerHelper.listener = listener
}
/**
* 播放通知栏详情点击
*/
fun notoifyDetailClick() {
listener?.notifyDetailClick()
}
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.player
import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.alibaba.android.arouter.launcher.ARouter
/**
* 音乐播放器辅助类
* 兼容原播放逻辑
*/
object YDLMusicHelper {
//公共参数
var title: String? = null
var cover: String? = null
var name: String? = null
//FM跳转参数
var fmId: Int = 0
//课程跳转参数
var course_id: Int = 0//课程id
//播放类型 1:视频 0:音频
var playType = 0
//课程播放地址
var courseVideoUlr: String? = null
//课程是否正在播放
var isVideoPlaying = false
//播放类型
val PLAY_TYPE_FM = "player_type_fm"
val PLAY_TYPE_COURSE = "play_type_course"
val PLAY_TYPE_CONFIDE = "play_type_confide"
val PLAY_TYPE_NONE = "play_type_none"
//当前播放类型 - <电台、倾诉、课程>
var playingType = PLAY_TYPE_NONE
var time: Int = 0
var allTime: Int = 0
//当前音频是否播放完成
var currentComplete: Boolean = false
private var playListener: YDLMusicPlayer.PlayStateChangeListener? = null
/**
* 打开播放中的页面详情
*/
fun startPlayingActivity(context: Context?, fullScreen: Int = 0) {
if (playingType == PLAY_TYPE_FM) {
//FM播放页
startFMPlayActivity(context)
} else if (playingType == PLAY_TYPE_COURSE) {
var url = if (playType == 0) {
getCurrentData()?.url
} else {
courseVideoUlr
}
//课程播放页
startCoursePlayActivity(
context,
1,
fullScreen,
url,
true
)
}
}
fun startCoursePlayActivity(context: Context?, from: Int, fullScreen: Int = 0, coursePlayUrl: String? = "", isFromFloatView: Boolean = false) {
ARouter.getInstance()
.build("/course/play")
.withInt("course_id", course_id)
.withInt("course_type", playType)
.withString("coursePlayUrl", coursePlayUrl)
.withInt("from", from)
.withBoolean("isFromFloatView", isFromFloatView)
.withInt("fullScreen", fullScreen)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.navigation()
}
fun startFMPlayActivity(context: Context?) {
val bundle = Bundle()
bundle.putInt("id", fmId)
ARouter.getInstance().build("/fm/detail")
.withBundle("bundle", bundle)
.navigation()
}
fun isCoursePlaying(): Boolean {
return YDLMusicPlayer.getInstance().isPlaying() && playingType == PLAY_TYPE_COURSE
}
fun isFMPlaying(): Boolean {
return YDLMusicPlayer.getInstance().isPlaying() && playingType == PLAY_TYPE_FM
}
fun isConfidePlaying(): Boolean {
return YDLMusicPlayer.getInstance().isPlaying() && playingType == PLAY_TYPE_CONFIDE
}
fun isPlaying(): Boolean {
return YDLMusicPlayer.getInstance().isPlaying()
}
fun fmPlay(url: String?) {
playingType =
PLAY_TYPE_FM
play(url)
}
fun confidePlay(url: String?) {
playingType =
PLAY_TYPE_CONFIDE
play(url)
}
fun coursePlay(url: String) {
playingType =
PLAY_TYPE_COURSE
play(url)
}
fun pause() {
YDLMusicPlayer.getInstance().pause()
}
fun seekTo(position: Int) {
YDLMusicPlayer.getInstance().seekTo(position)
}
fun play(url: String?, autoSaveProgress: Boolean = false) {
addHelperListener()
YDLMusicPlayer.getInstance().play(url, autoSaveProgress)
}
/**
* 直接播放
* 适用于已设置过播放参数的情景
*/
fun directPlay(index: Int = 0, autoSaveProgress: Boolean = false) {
addHelperListener()
YDLMusicPlayer.getInstance().play(autoSaveProgress, index)
}
private fun addHelperListener() {
if (playListener == null) {
playListener = object :
YDLMusicPlayer.PlayStateChangeListener {
override fun update(time: Int, allTime: Int) {
YDLMusicHelper.time = time
YDLMusicHelper.allTime = allTime
currentComplete = false
}
override fun reset() {
currentComplete = false
}
override fun completion() {
currentComplete = true
}
override fun prepared() {
currentComplete = false
}
}
YDLMusicPlayer.getInstance()
.addListener(playListener!!)
}
}
fun start() {
if (currentComplete) {
YDLMusicPlayer.getInstance().replay()
} else {
YDLMusicPlayer.getInstance().start()
}
}
fun stop() {
YDLMusicPlayer.getInstance().stop()
}
fun replay() {
YDLMusicPlayer.getInstance().replay()
}
fun release() {
YDLMusicPlayer.getInstance().release()
}
fun getCurrentData(): MusicInfoBean? {
return YDLMusicPlayer.getInstance().musicServiceControl?.getCurrentData()
}
/**
* 清除临时数据
*/
fun clearTempData() {
title = null
cover = null
name = null
courseVideoUlr = null
fmId = 0
isVideoPlaying = false
course_id = 0
playType = 0
}
}
package com.ydl.ydlcommon.actions.player
import android.content.ComponentName
import android.content.ServiceConnection
import android.os.IBinder
import android.text.TextUtils
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.actions.player.player.PlayStatusListener
import com.ydl.ydlcommon.actions.player.service.HMusicPlayService
import com.ydl.ydlcommon.utils.AppUtils
import java.util.concurrent.CopyOnWriteArraySet
class YDLMusicPlayer {
companion object {
fun getInstance(): YDLMusicPlayer {
return Holder.INSTANCE
}
}
private object Holder {
val INSTANCE = YDLMusicPlayer()
}
//记录服务是否bind成功,在unbind的时候进行判定,不然未bind成功却进行unbind操作会包错
private var isConnected = false
//常用自定义播放状态监听器
private var listeners: CopyOnWriteArraySet<PlayStateChangeListener> = CopyOnWriteArraySet()
//完整播放状态监听器
private var originalListeners: CopyOnWriteArraySet<PlayStatusListener> = CopyOnWriteArraySet()
//临时播放信息 - 服务未初始化时使用,初始化完成直接播放
var tempMusicInfoBean: MusicInfoBean? = null
var tempMusicList: ArrayList<MusicInfoBean>? = null
//当前播放音乐信息
var currentMusicInfoBean: MusicInfoBean? = null
//音乐列表
var musicList = ArrayList<MusicInfoBean>()
//播放控制器
var musicServiceControl: HMusicPlayService.MusicController? = null
//播放控制器获取回调
var controlTaker: MusicControlTaker? = null
//是否自动保存播放进度
var autoSaveProgress: Boolean = false
private var musicServiceConnection = object : ServiceConnection {
override fun onServiceConnected(componentName: ComponentName?, binder: IBinder?) {
musicServiceControl = binder as HMusicPlayService.MusicController
controlTaker?.onReceiveControl(musicServiceControl!!)
play(tempMusicInfoBean, autoSaveProgress)
play(tempMusicList, autoSaveProgress)
controlTaker = null
}
override fun onServiceDisconnected(p0: ComponentName?) {
}
}
fun addListener(listener: PlayStateChangeListener) {
listeners.add(listener)
}
fun removeListener(listener: PlayStateChangeListener) {
listeners.remove(listener)
}
fun addListener(listener: PlayStatusListener) {
originalListeners.add(listener)
}
fun removeListener(listener: PlayStatusListener) {
originalListeners.remove(listener)
}
fun isPlaying(): Boolean {
return musicServiceControl?.isPlaying() ?: false
}
fun pause() {
musicServiceControl?.pause();
}
fun play(url: String?, autoSaveProgress: Boolean = false) {
if (TextUtils.isEmpty(url)) {
return
}
play(MusicInfoBean(url), autoSaveProgress)
}
fun play(url: String, title: String, cover: String, desc: String, autoSaveProgress: Boolean = false) {
play(MusicInfoBean(url, title, cover, desc), autoSaveProgress)
}
fun play(musicInfoBean: MusicInfoBean?, autoSaveProgress: Boolean = false) {
if (musicInfoBean == null) {
return
}
if (isPrepareComplete(musicInfoBean, null, autoSaveProgress)) {
//如果单音频播放与上次播放内容不同则重新设置
// if (currentMusicInfoBean==null||
// musicInfoBean.url != currentMusicInfoBean?.url){
musicList.clear()
musicList.add(musicInfoBean)
currentMusicInfoBean = musicInfoBean
setData()
// }
play(autoSaveProgress)
}
}
fun play(musicInfoList: ArrayList<MusicInfoBean>?, autoSaveProgress: Boolean = false) {
if (musicInfoList == null || musicInfoList.isEmpty()) {
return
}
if (isPrepareComplete(null, musicInfoList, autoSaveProgress)) {
//如果不是完全相同则重新设置数据
// if (!(musicList.containsAll(musicInfoList) && musicInfoList.containsAll(musicList))){
musicList.clear()
musicList.addAll(musicInfoList)
setData()
// }
play(autoSaveProgress)
}
}
fun setData() {
musicServiceControl?.setData(musicList)
if (tempMusicInfoBean == null && tempMusicInfoBean == null) {
//非首次设置数据
for (listener in listeners) {
//数据重新设置回调
listener.reset()
}
}
tempMusicInfoBean = null
tempMusicList = null
autoSaveProgress = false
}
fun play(autoSaveProgress: Boolean = false, index: Int = 0) {
if (musicServiceControl?.playStatusListener != musicPlayListener) {
//设置播放监听
musicServiceControl?.playStatusListener = musicPlayListener
}
musicServiceControl?.play(index = index, autoSaveProgress = autoSaveProgress)
}
fun start() {
musicServiceControl?.start()
}
/**
* 播放服务是否初始化完毕
*/
private fun isPrepareComplete(musicInfoBean: MusicInfoBean?,
musicInfoList: ArrayList<MusicInfoBean>?,
autoSaveProgress: Boolean = false
): Boolean {
if (musicServiceControl == null
&& !AppUtils.isServiceRunning(BaseApp.getApp(), HMusicPlayService::class.java.name)) {
tempMusicInfoBean = musicInfoBean
tempMusicList = musicInfoList
this.autoSaveProgress = autoSaveProgress
if (!isConnected) {
isConnected = MusicPlayerHelper.bindService(
BaseApp.getApp(),
musicServiceConnection
)
}
return false
} else {
return true
}
}
/**
* 跳转至
*/
fun seekTo(position: Int) {
musicServiceControl?.seekTo(position)
}
/**
* 重新播放
*/
fun replay() {
musicServiceControl?.seekTo(0)
musicServiceControl?.play()
}
/**
* 停止播放
*/
fun stop() {
musicServiceControl?.stop()
}
/**
* 销毁服务、移除监听器并释放内存
*/
fun release() {
musicServiceControl?.stop()
listeners.clear()
originalListeners.clear()
//销毁后台服务
if (isConnected) {
MusicPlayerHelper.unBinderService(
BaseApp.getApp(),
musicServiceConnection
)
isConnected = false
}
MusicPlayerHelper.stopService(BaseApp.getApp())
}
private var musicPlayListener: PlayStatusListener = object :
PlayStatusListener {
override fun beforeStart(index: Int) {
for (listener in originalListeners) {
listener.beforeStart(index)
}
}
override fun onPrepared() {
for (listener in listeners) {
listener.prepared()
}
for (listener in originalListeners) {
listener.onPrepared()
}
}
override fun start() {
for (listener in originalListeners) {
listener.start()
}
}
override fun pause() {
for (listener in originalListeners) {
listener.pause()
}
}
override fun loading() {
for (listener in originalListeners) {
listener.loading()
}
}
override fun onProgressUpdate(progress: Int) {
for (listener in originalListeners) {
listener.onProgressUpdate(progress)
}
for (listener in listeners) {
listener.update(progress, musicServiceControl?.getDuration()!!)
}
}
override fun OnErrorListener(p1: Int, p2: String) {
for (listener in originalListeners) {
listener.OnErrorListener(p1, p2)
}
}
override fun OnBufferingUpdateListener(p1: Int) {
for (listener in originalListeners) {
listener.OnBufferingUpdateListener(p1)
}
}
override fun onCompletionListener() {
for (listener in originalListeners) {
listener.onCompletionListener()
}
for (listener in listeners) {
listener.completion()
}
}
}
/**
* 设置播放器控制器回调
* <课程播放 - HPlayView> 中使用
*/
fun setMusicControlTaker(taker: MusicControlTaker) {
if (isPrepareComplete(null, null)) {
taker.onReceiveControl(musicServiceControl!!)
} else {
this.controlTaker = taker;
}
}
interface MusicControlTaker {
fun onReceiveControl(control: HMusicPlayService.MusicController)
}
/**
* 自定义播放状态监听器
*/
interface PlayStateChangeListener {
fun update(time: Int, allTime: Int)
/**
* 重新设置数据回调
* 只有当和上次设置的数据源不同时才会调用
*
* 「场景:Page1点击音频播放,显示开始播放状态。
* 打开Page2开始播放新音频后,Page1应在会回调中重置播放状态」
*/
fun reset()
fun completion()
fun prepared()
}
}
package com.ydl.ydlcommon.actions.player.notifycation
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Build
import com.ydl.ydlcommon.actions.player.MusicPlayerHelper
import com.ydl.ydlcommon.actions.player.service.HMusicPlayService
import java.lang.reflect.Method
/**
* 播放通知栏状态变化接收器
*/
class MusicPlayerReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (intent.action) {
HMusicPlayService.ACTION_PLAY -> {
MusicPlayerHelper.start(context)
collapseStatusBar(context)
}
HMusicPlayService.ACTION_PAUSE -> {
MusicPlayerHelper.pause(context)
collapseStatusBar(context)
}
HMusicPlayService.ACTION_DETAIL -> {
MusicPlayerHelper.notoifyDetailClick()
collapseStatusBar(context)
}
HMusicPlayService.ACTION_STOP -> {
MusicPlayerHelper.pauseService(context)
collapseStatusBar(context)
}
}
}
fun collapseStatusBar(context: Context) {
try {
val statusBarManager = context.getSystemService("statusbar")
var collapse: Method
if (Build.VERSION.SDK_INT <= 16) {
collapse = statusBarManager!!.javaClass.getMethod("collapse")
} else {
collapse = statusBarManager!!.javaClass.getMethod("collapsePanels")
}
collapse.invoke(statusBarManager)
} catch (localException: Exception) {
localException.printStackTrace()
}
}
}
package com.ydl.ydlcommon.actions.player.notifycation
import android.annotation.SuppressLint
import android.app.Notification
import android.content.Context
import android.os.Build
import android.support.annotation.RequiresApi
import android.support.v7.app.AppCompatActivity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.RemoteViews
import android.widget.TextView
import java.util.*
/**
* 获取通知字体颜色
* Created by zqk on 17-11-15.
*/
object NotificationHelper {
private val NOTIFICATION_TITLE = "notification_title"
val INVALID_COLOR = -1 // 无效颜色
private var notificationTitleColor =
INVALID_COLOR // 获取到的颜色缓存
@SuppressLint("NewApi")
/**
* 获取系统通知栏主标题颜色,根据Activity继承自AppCompatActivity或FragmentActivity采取不同策略。
*
* @param context 上下文环境
* @return 系统主标题颜色
*/
fun getNotificationColor(context: Context): Int {
try {
if (notificationTitleColor == INVALID_COLOR) {
if (context is AppCompatActivity) {
notificationTitleColor =
getNotificationColorCompat(
context
)
} else {
notificationTitleColor =
getNotificationColorInternal(
context
)
}
}
} catch (ignored: Exception) {
}
return notificationTitleColor
}
/**
* 通过一个空的Notification拿到Notification.lceContentView,通过[RemoteViews.apply]方法返回通知栏消息根布局实例。
*
* @param context 上下文
* @return 系统主标题颜色
*/
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
private fun getNotificationColorInternal(context: Context): Int {
val builder = Notification.Builder(context)
builder.setContentTitle(NOTIFICATION_TITLE)
val notification = builder.build()
try {
val root = notification.contentView.apply(context, FrameLayout(context)) as ViewGroup
val titleView = root.findViewById<View>(android.R.id.title) as TextView
if (null == titleView) {
iteratorView(
root,
object : Filter {
override fun filter(view: View) {
if (view is TextView) {
val textView = view as TextView
if (NOTIFICATION_TITLE == textView.text.toString()) {
notificationTitleColor =
textView.currentTextColor
}
}
}
})
return notificationTitleColor
} else {
return titleView.currentTextColor
}
} catch (e: Exception) {
return getNotificationColorCompat(
context
)
}
}
/**
* 使用getNotificationColorInternal()方法,Activity不能继承自AppCompatActivity(实测5.0以下机型可以,5.0及以上机型不行),
* 大致的原因是默认通知布局文件中的ImageView(largeIcon和smallIcon)被替换成了AppCompatImageView,
* 而在5.0及以上系统中,AppCompatImageView的setBackgroundResource(int)未被标记为RemotableViewMethod,导致apply时抛异常。
*
* @param context 上下文
* @return 系统主标题颜色
*/
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
private fun getNotificationColorCompat(context: Context): Int {
try {
val builder = Notification.Builder(context)
val notification = builder.build()
val layoutId = notification.contentView.layoutId
val root = LayoutInflater.from(context).inflate(layoutId, null) as ViewGroup
val titleView = root.findViewById<View>(android.R.id.title) as TextView
return titleView?.currentTextColor ?: getTitleColorIteratorCompat(
root
)
} catch (e: Exception) {
}
return INVALID_COLOR
}
private fun iteratorView(view: View?, filter: Filter) {
if (view == null || filter == null) {
return
}
filter.filter(view)
if (view is ViewGroup) {
val viewGroup = view as ViewGroup?
for (i in 0 until viewGroup!!.childCount) {
val child = viewGroup.getChildAt(i)
iteratorView(child, filter)
}
}
}
private fun getTitleColorIteratorCompat(view: View?): Int {
if (view == null) {
return INVALID_COLOR
}
val textViews = getAllTextViews(view)
val maxTextSizeIndex =
findMaxTextSizeIndex(textViews)
return if (maxTextSizeIndex != Integer.MIN_VALUE) {
textViews[maxTextSizeIndex].currentTextColor
} else INVALID_COLOR
}
private fun findMaxTextSizeIndex(textViews: List<TextView>): Int {
var max = Integer.MIN_VALUE.toFloat()
var maxIndex = Integer.MIN_VALUE
var index = 0
for (textView in textViews) {
if (max < textView.textSize) {
// 找到字号最大的字体,默认把它设置为主标题字号大小
max = textView.textSize
maxIndex = index
}
index++
}
return maxIndex
}
/**
* 实现遍历View树中的TextView,返回包含TextView的集合。
*
* @param root 根节点
* @return 包含TextView的集合
*/
private fun getAllTextViews(root: View): List<TextView> {
val textViews = ArrayList<TextView>()
iteratorView(
root,
object : Filter {
override fun filter(view: View) {
if (view is TextView) {
textViews.add(view as TextView)
}
}
})
return textViews
}
private interface Filter {
fun filter(view: View)
}
}
package com.ydl.ydlcommon.actions.player.player
import com.ydl.ydlcommon.actions.player.MusicInfoBean
/**
* 播放状态监听起
* Created by hgw on 2018/4/28.
*/
interface HPlayStatusListener{
//判断是否可以播放
fun isCanPlay(data : MusicInfoBean?):Boolean
//音频初始化完成
fun onPrepared(data : MusicInfoBean?, index:Int=0)
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.player.player
/**
* 通知栏操作监听器
* Created by hgw on 2018/4/26.
*/
interface NotifyClickListener{
/**
* 播放通知栏详情点击
*/
fun notifyDetailClick()
}
package com.ydl.ydlcommon.actions.player.player
/**
* 播放状态回调
* Created by hgw on 2018/3/31.
*/
interface PlayStatusListener{
/**
* 开始播放之前
*/
fun beforeStart(index:Int)
fun onPrepared()
fun start()
fun pause()
fun loading()
fun onProgressUpdate(progress : Int)
fun OnErrorListener(p1: Int, p2: String)
fun OnBufferingUpdateListener(p1: Int)
fun onCompletionListener()
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.player.util
import android.util.Log
/**
* 日志打印
* Created by hgw on 2018/3/31.
*/
object LogH {
private val TAG : String = "harvieMusicPlayer"
fun d(str : String){
Log.d(TAG,str)
}
fun e(str : String){
Log.e(TAG,str)
}
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.player.util
import android.content.Context
import android.text.TextUtils
import com.ydl.ydlcommon.actions.player.Config
/**
* 工具类
* Created by hgw on 2018/3/31.
*/
object UtilH {
/**
* 保存播放进度
*/
fun saveProgress(context: Context?,url : String?,progress : Int){
if (TextUtils.isEmpty(url))return
var shared = context?.getSharedPreferences(Config.HMusicProgress,Context.MODE_PRIVATE)
var edit = shared?.edit()
edit?.putInt(url,progress)
edit?.commit()
}
/**
* 获取进度
*/
fun getProgress(context: Context?,url : String?):Int{
if (TextUtils.isEmpty(url))return 0
var shared = context?.getSharedPreferences(Config.HMusicProgress,Context.MODE_PRIVATE)
return shared?.getInt(url,0)?:0
}
}
\ No newline at end of file
package com.ydl.ydlcommon.actions.player.view
import android.app.Activity
import android.os.Handler
import android.view.View
import android.widget.RelativeLayout
import android.widget.SeekBar
import com.bumptech.glide.Glide
import com.ydl.ydlcommon.R
import com.ydl.ydlcommon.actions.player.MusicInfoBean
import com.ydl.ydlcommon.actions.player.YDLMusicHelper
import com.ydl.ydlcommon.actions.player.YDLMusicPlayer
import com.ydl.ydlcommon.actions.player.player.HPlayStatusListener
import com.ydl.ydlcommon.actions.player.player.PlayStatusListener
import com.ydl.ydlcommon.actions.player.service.HMusicPlayService
import kotlinx.android.synthetic.main.play_music_view.view.*
/**
* Created by hgw on 2018/4/28.
*/
class HPlayView : RelativeLayout, YDLMusicPlayer.MusicControlTaker {
var control: HMusicPlayService.MusicController? = null
var listener: HPlayStatusListener? = null
var mHandler: Handler? = null
//seekBar 按下标记
var seekBarIsDown = false
var progress = 0
var mContext: Activity? = null
constructor(context1: Activity?) : super(context1) {
this.mContext = context1
mHandler = Handler()
init()
}
fun init() {
if (mContext == null) return
YDLMusicPlayer.getInstance().setMusicControlTaker(this)
View.inflate(context, R.layout.play_music_view, this)
play_icon.setOnClickListener {
if (control?.isPlaying() == true) {
control?.pause()
} else {
control?.start()
}
}
img_gif.setOnClickListener {
if (control?.isPlaying() == false) {
control?.start()
}
}
pro_progress.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
if (p2) {
text_start_time.text = getStringTime(p1)
progress = p1
}
}
override fun onStartTrackingTouch(p0: SeekBar?) {
seekBarIsDown = true
}
override fun onStopTrackingTouch(p0: SeekBar?) {
seekBarIsDown = false
//拖动seekbar时不进行以下操作
if (!seekBarIsDown) {
control?.seekTo(progress)
}
}
})
}
fun showNetNotice(event: () -> Unit) {
ll_net_notice.visibility = View.VISIBLE
img_gif.visibility = View.GONE
iv_net_notice.setOnClickListener {
hideNetNotice()
event()
}
}
fun hideNetNotice() {
ll_net_notice.visibility = View.GONE
img_gif.visibility = View.VISIBLE
}
fun setData(urlLi: ArrayList<MusicInfoBean>): HPlayView {
control?.setData(urlLi)
return this
}
/**
* 后台进入前台view
*/
fun updateView(index: Int) {
if (control?.isPlaying()!!) {
mHandler?.postDelayed({
pro_progress.max = control?.getDuration() ?: 0
text_end_time.text = getStringTime(pro_progress.max)
listener?.onPrepared(control?.getCurrentData(), index)
}, 0)
updateButton()
}
}
/**
* 获取当前播放下标
*/
fun getCurrentIndex(): Int {
return control?.getCurrentIndex() ?: 0
}
/**
* 获取当前播放url
*/
fun getCurrentUrl(): String {
return control?.getCurrentUrl() ?: ""
}
fun play(index: Int) {
updateButton()
YDLMusicHelper.playingType = YDLMusicHelper.PLAY_TYPE_COURSE
YDLMusicHelper.directPlay(index, true)
}
fun setImageBackground(url: String?) {
Glide.with(mContext).load(url).into(img_bg)
}
/**
* 获取播放控制器
*/
fun getPlayControl(): HMusicPlayService.MusicController? {
return control
}
/**
* 设置自动播放下一曲
*/
fun setAutoNext(auto: Boolean) {
control?.setAutoPlayNext(auto)
}
override fun onReceiveControl(control: HMusicPlayService.MusicController) {
this.control = control
setControl1(control)
}
var playStatusListener: PlayStatusListener? = null
private fun setControl1(control: HMusicPlayService.MusicController?) {
control?.setOpenNotifyCation(true)
if (playStatusListener == null) {
playStatusListener = object : PlayStatusListener {
override fun beforeStart(index: Int) {
showBufferLoading(true)
}
override fun onCompletionListener() {
// LogH.d("onCompletionListener")
updateButton()
}
override fun loading() {
// LogH.d("loading")
showBufferLoading(true)
}
override fun onPrepared() {
// LogH.d("onPrepared")
mHandler?.postDelayed({
pro_progress.max = control?.getDuration() ?: 0
text_end_time.text = getStringTime(pro_progress.max)
listener?.onPrepared(control?.getCurrentData(), control?.getCurrentIndex()
?: 0)
}, 0)
}
override fun start() {
// LogH.d("start")
setGifVisibity(true)
}
override fun pause() {
// LogH.d("pause")
setGifVisibity(false)
}
override fun onProgressUpdate(progress: Int) {
mHandler?.postDelayed({
//拖动seekbar时不进行以下操作
if (!seekBarIsDown) {
pro_progress.progress = progress
text_start_time.text = getStringTime(progress)
}
}, 0)
}
override fun OnErrorListener(p1: Int, p2: String) {
// LogH.d("OnErrorListener:$p1 $p2")
setGifVisibity(false)
}
override fun OnBufferingUpdateListener(p1: Int) {
// LogH.d("OnBufferingUpdateListener:$p1")
mHandler?.postDelayed({
pro_progress.secondaryProgress = p1 * pro_progress.max / 100
}, 0)
}
}
YDLMusicPlayer.getInstance().addListener(playStatusListener!!)
}
}
fun showBufferLoading(show: Boolean) {
mHandler?.postDelayed({
if (show) {
if (mContext != null) {
Glide.with(mContext).asGif().load(R.mipmap.loading5).into(img_gif)
}
play_icon.setImageResource(R.drawable.ico_course_play)
} else {
if (mContext != null) {
Glide.with(mContext).asGif().load(R.mipmap.audio_play).into(img_gif)
}
play_icon.setImageResource(R.drawable.ico_course_pause)
}
}, 0)
}
//显示或隐藏播放动画
fun setGifVisibity(show: Boolean) {
if (context == null) return
mHandler?.postDelayed({
if (show) {
if (mContext != null) {
Glide.with(mContext).asGif().load(R.mipmap.audio_play).into(img_gif)
}
play_icon.setImageResource(R.drawable.ico_course_pause)
} else {
if (mContext != null) {
Glide.with(mContext).asBitmap().load(R.drawable.ico_course_bg_pause).into(img_gif)
}
play_icon.setImageResource(R.drawable.ico_course_play)
}
}, 0)
}
//跟新上下音频按钮状态
fun updateButton() {
mHandler?.postDelayed({
if (control?.isPlaying() == true) {
setGifVisibity(true)
}
}, 0)
}
fun getStringTime(time: Int): String {
if (time <= 0) return "00:00"
var min = time / 60000
var ss = (time - min * 60000) / 1000
var mm = "" + min
var SS = "" + ss
if (min < 10) {
mm = "0$mm"
}
if (ss < 10) {
SS = "0$ss"
}
return "$mm:$SS"
}
fun onDestroy() {
mContext = null
mHandler = null
playStatusListener?.let { YDLMusicPlayer.getInstance().removeListener(it) }
}
}
\ No newline at end of file
package com.ydl.ydlcommon.event
/**
* EventBus事件,通知更改FM或课程播放状态
* Created by zqk on 17-11-14.
*/
class UpdatePlayStatusEvent {
}
\ No newline at end of file
package com.ydl.ydlcommon.event;
/**
* Created by zqk on 17-11-15.
*/
public class UpdateSafeTipViewEvent {
}
package com.ydl.ydlcommon.ui.confideredpacket
import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.R
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.ui.confideredpacket.http.ConfideRedPacketHttpImpl
import com.ydl.ydlcommon.utils.RxLifecycleUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import kotlinx.android.synthetic.main.confide_redpacket_view.view.*
/**
* @author yuanWai
* @描述:倾诉红包提示View
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/27
*/
class ConfideRedPacketView : RelativeLayout {
private var jumpType: Int =
JUMP_NOT
private var mRedPacketCallBack: RedPacketCallBack? = null
private var onDataRequestFinishedListener: OnDataRequestFinishedListener? = null
//是否显示
private var redPacketVisible: Int = View.VISIBLE
companion object {
/**
* 跳转类型
* 0.不跳转 1.跳转倾诉频道 2.跳转专家详情
*/
const val JUMP_NOT = 0
const val JUMP_CONFIDE_HOME = 1
const val JUMP_EXPERT_INFO = 2
}
constructor(context: Context) : super(context) {
initView()
}
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {
initView()
}
/**
* 界面初始化
*/
private fun initView() {
View.inflate(context, R.layout.confide_redpacket_view, this)
setOnClickListener {
when (jumpType) {
JUMP_NOT -> {//不跳转
}
JUMP_CONFIDE_HOME -> {//跳转倾诉频道页
// ARouter.getInstance().build("/confide/home").navigation()
YDLRouterManager.router("ydl-user://confide/home")
}
JUMP_EXPERT_INFO -> {//跳转专家详情页
if (null != mRedPacketCallBack) {
mRedPacketCallBack!!.jumpExpertInfo()
}
}
}
visibility = View.GONE
}
imgClose.setOnClickListener {
visibility = View.GONE
}
}
/**
* 请求红包列表数据
*/
fun initData(visible: Int) {
this.redPacketVisible = visible
ConfideRedPacketHttpImpl.getInstance().getCouponMax(
RedListParam(
3
)
).compose(RxUtils.resultJavaData())
.map { it }
.filter { it != null }
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
setData(it)
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
visibility = View.GONE
}
})
}
//设置不跳转
fun setNot() {
jumpType = JUMP_NOT
}
//设置跳转倾诉列表首页
fun setConfide() {
jumpType = JUMP_CONFIDE_HOME
}
//设置跳转专家详情页
fun setExpertInfo() {
jumpType = JUMP_EXPERT_INFO
}
/**
* 数据赋值
*/
private fun setData(couponMax: String) {
if (TextUtils.isEmpty(couponMax)) {
visibility = View.GONE
return
}
var max = couponMax.toFloat().toInt()
visibility = if (max > 0) {
View.VISIBLE
} else {
View.GONE
}
//因为数据请求是异步的 会出现 MainActivity设置了隐藏 但是到了这里 依然显示的现象
visibility = redPacketVisible
if (max <= 0) {
visibility = View.GONE
}
val sb = StringBuffer()
sb.append("您有")
.append(max)
.append("元的倾诉红包,倾诉享")
tvMsg.text = sb.toString()
if (onDataRequestFinishedListener != null) {
onDataRequestFinishedListener!!.onDataRequestFinishedListener(max)
}
}
fun setCloseHide() {
imgClose.visibility = View.GONE
}
fun setRedPacketCallBack(mRedPacketCallBack: RedPacketCallBack) {
this.mRedPacketCallBack = mRedPacketCallBack
}
interface RedPacketCallBack {
fun jumpExpertInfo()
}
fun setOnDataRequestFinishedListener(onDataRequestFinishedListener: OnDataRequestFinishedListener) {
this.onDataRequestFinishedListener = onDataRequestFinishedListener
}
/**
* 数据请求完成回调
*/
interface OnDataRequestFinishedListener {
fun onDataRequestFinishedListener(max: Int)
}
}
\ No newline at end of file
package com.ydl.ydlcommon.ui.confideredpacket
/**
* @author yuanWai
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/27
*/
data class RedListParam(val serviceType : Int)
\ No newline at end of file
package com.ydl.ydlcommon.ui.confideredpacket.http
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import io.reactivex.Observable
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Query
/**
* @author yuanwai
* @描述:倾诉首页Api
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/8/10
*/
interface ConfideRedPacketApi{
//倾诉红包接口
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA,"Content-Type:application/json")
@GET("auth/coupon/max")
fun getCouponMax(@Query("serviceType") serviceType :String ): Observable<BaseAPIResponse<String>>
}
\ No newline at end of file
package com.ydl.ydlcommon.ui.confideredpacket.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.ui.confideredpacket.RedListParam
import com.ydl.ydlnet.YDLHttpUtils
import io.reactivex.Observable
/**
* @author yuanwai
* @描述:倾诉红包接口实现类
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/28
*/
class ConfideRedPacketHttpImpl private constructor() :
IConfideRedPacketHttp {
companion object {
fun getInstance(): ConfideRedPacketHttpImpl {
return Holder.INSTANCE
}
}
object Holder {
val INSTANCE = ConfideRedPacketHttpImpl()
}
private val confideHomeApi: ConfideRedPacketApi by lazy {
YDLHttpUtils.obtainApi(ConfideRedPacketApi::class.java)
}
override fun getCouponMax(param: RedListParam): Observable<BaseAPIResponse<String>> {
return RxUtils.mapObservable(param)
.flatMap {
confideHomeApi.getCouponMax(param.serviceType.toString())
}
}
}
\ No newline at end of file
package com.ydl.ydlcommon.ui.confideredpacket.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.ui.confideredpacket.RedListParam
import io.reactivex.Observable
/**
* @author yuanwai
* @描述:倾诉红包接口
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/11/28
*/
interface IConfideRedPacketHttp{
/**
* 倾诉首页请求
*/
fun getCouponMax(param: RedListParam): Observable<BaseAPIResponse<String>>
}
\ No newline at end of file
package com.ydl.ydlcommon.ui.couponhint
/**
* @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.ydl.ydlcommon.ui.couponhint
/**
* @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.ydl.ydlcommon.ui.couponhint
import android.content.Context
import android.text.TextUtils
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydlcommon.R
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.ui.couponhint.http.CouponHintHttpImpl
import com.ydl.ydlcommon.utils.RxLifecycleUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import kotlinx.android.synthetic.main.confide_redpacket_view.view.*
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:我的课程优惠码View
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/27
*/
class CouponHintView : RelativeLayout{
private var jumpType : Int =
JUMP_TO_COUPON_LIST
private var mCouponHintCallBack : CouponHintCallBack? = null
//是否显示
private var couponHintVisible : Int = View.VISIBLE
private var couponUrl:String? = null
companion object {
/**
* 跳转类型
* 0.跳转红包
*/
const val JUMP_TO_COUPON_LIST = 0
}
constructor(context:Context):super(context){
initView()
}
constructor(context: Context,attributeSet: AttributeSet):super(context,attributeSet){
initView()
}
/**
* 界面初始化
*/
private fun initView(){
View.inflate(context, R.layout.coupon_hint_view,this)
setOnClickListener {
when(jumpType){
JUMP_TO_COUPON_LIST ->{//我的红包
if (TextUtils.isEmpty(couponUrl)) {
YDLRouterManager.router("ydl-user://mine/redpacket")
}else {
YDLRouterManager.router(couponUrl)
}
}
}
visibility = View.GONE
}
imgClose.setOnClickListener {
visibility = View.GONE
}
}
/**
* 请求红包列表数据
*/
fun initData(visible : Int){
this.couponHintVisible = visible
CouponHintHttpImpl.getInstance().getCouponHint(
CouponHintParam(
0
)
).compose(RxUtils.resultJavaData())
.map { it }
.filter { it != null }
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
if (null != it) {
setData(it)
couponUrl = it.url
}
}, object: ThrowableConsumer() {
override fun accept(msg: String) {
visibility = View.GONE
}
})
}
//设置跳转到我的红包
fun setCouponList(){
jumpType = JUMP_TO_COUPON_LIST
}
/**
* 数据赋值
*/
private fun setData(couponData : CouponHintResponseBean){
if (TextUtils.isEmpty(couponData.msg)){
visibility = View.GONE
return
}
//因为数据请求是异步的 会出现 MainActivity设置了隐藏 但是到了这里 依然显示的现象
visibility = couponHintVisible
val sb = StringBuffer()
sb.append(couponData.msg)
tvMsg.text = sb.toString()
}
fun setCloseHide(){
imgClose.visibility = View.GONE
}
fun setRedPacketCallBack(mRedPacketCallBack : CouponHintCallBack){
this.mCouponHintCallBack = mRedPacketCallBack
}
interface CouponHintCallBack{
fun jumpInfo() //暂未设置跳转
}
}
\ No newline at end of file
package com.ydl.ydlcommon.ui.couponhint.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.ui.couponhint.CouponHintResponseBean
import retrofit2.http.GET
import io.reactivex.Observable
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/27
*/
interface CouponHintApi{
//倾诉红包接口
@GET("auth/coupon/courseCoupon/warn")
fun getCouponHint(): Observable<BaseAPIResponse<CouponHintResponseBean>>
}
\ No newline at end of file
package com.ydl.ydlcommon.ui.couponhint.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.ui.couponhint.CouponHintParam
import com.ydl.ydlcommon.ui.couponhint.CouponHintResponseBean
import com.ydl.ydlnet.YDLHttpUtils
import io.reactivex.Observable
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/27
*/
class CouponHintHttpImpl private constructor(): ICouponHintHttp {
companion object {
fun getInstance(): CouponHintHttpImpl {
return Holder.INSTANCE
}
}
object Holder {
val INSTANCE = CouponHintHttpImpl()
}
private val couponHintApi: CouponHintApi by lazy {
YDLHttpUtils.obtainApi(CouponHintApi::class.java)
}
override fun getCouponHint(param: CouponHintParam): Observable<BaseAPIResponse<CouponHintResponseBean>> {
return RxUtils.mapObservable(param)
.flatMap {
couponHintApi.getCouponHint()
}
}
}
\ No newline at end of file
package com.ydl.ydlcommon.ui.couponhint.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.ui.couponhint.CouponHintParam
import com.ydl.ydlcommon.ui.couponhint.CouponHintResponseBean
import io.reactivex.Observable
/**
* @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/27
*/
interface ICouponHintHttp{
/**
* 倾诉首页请求
*/
fun getCouponHint(param: CouponHintParam): Observable<BaseAPIResponse<CouponHintResponseBean>>
}
\ No newline at end of file
package com.ydl.ydlcommon.utils
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.PixelFormat
import android.graphics.Point
import android.text.TextUtils
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import com.yidianling.common.tools.RxImageTool
import com.ydl.ydlcommon.actions.player.YDLMusicHelper
import com.ydl.ydlcommon.view.PlayerFloatView
/**
* 音频播放悬浮窗 帮助类
*
* 需要在Activity onDestroy中调用removeView()方法移除
* 避免内存泄露
*/
class PlayerFloatHelper {
companion object {
@SuppressLint("StaticFieldLeak")
private var mPlayerFloatView: PlayerFloatView? = null
//已添加悬浮窗页面全路径名
private var showingPageName: String? = null
private var wm: WindowManager? = null
/**
* 如果有音频正在播放则显示
*/
fun showIfPlaying(context: Context) {
if (YDLMusicHelper.isFMPlaying()|| YDLMusicHelper.isConfidePlaying() || YDLMusicHelper.isCoursePlaying() || YDLMusicHelper.isVideoPlaying) {
show(context)
mPlayerFloatView?.updatePlayState()
} else {
hide()
}
}
/**
* 显示悬浮控件
*/
fun show(context: Context) {
if (mPlayerFloatView == null) {
mPlayerFloatView =
PlayerFloatView(context)
}
if (showingPageName != context::class.qualifiedName) {
mPlayerFloatView?.resetWm(context)
addFloatToWm(context)
}
mPlayerFloatView?.resetView()
mPlayerFloatView?.visibility = View.VISIBLE
mPlayerFloatView?.setPlayingState()
}
fun hide() {
mPlayerFloatView?.visibility = View.GONE
mPlayerFloatView?.stopVideo()
}
fun addClickListener(listener: PlayerFloatView.FloatViewPlayListener) {
mPlayerFloatView?.addFloatClickListener(listener)
}
fun removeClickListener(listener: PlayerFloatView.FloatViewPlayListener) {
mPlayerFloatView?.removeFloatClickListener(listener)
}
fun isShow(context: Context): Boolean {
return !TextUtils.isEmpty(showingPageName) && showingPageName == context::class.qualifiedName && mPlayerFloatView?.visibility == View.VISIBLE
}
fun removeView(context: Context) {
if (TextUtils.isEmpty(showingPageName) || showingPageName != context::class.qualifiedName) {
return
}
mPlayerFloatView?.stopVideo()
mPlayerFloatView?.visibility = View.GONE
wm?.removeViewImmediate(mPlayerFloatView)
showingPageName = ""
wm = null
}
fun onDestroy() {
if (mPlayerFloatView != null) {
if (!TextUtils.isEmpty(showingPageName)) {
wm?.removeViewImmediate(mPlayerFloatView)
showingPageName = ""
}
mPlayerFloatView?.onDestroy()
mPlayerFloatView?.removeAllViews()
}
}
fun setPlayingState(context: Context) {
if (YDLMusicHelper.playType == 1) {
hide()
YDLMusicHelper.playType = 0
show(context)
}
mPlayerFloatView?.setPlayingState()
}
fun updatePlayState() {
mPlayerFloatView?.updatePlayState()
}
private fun addFloatToWm(context: Context) {
if (wm != null && !TextUtils.isEmpty(showingPageName)) {
wm?.removeViewImmediate(mPlayerFloatView)
wm = null
}
//获取WindowManager
wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
//设置LayoutParams(全局变量)相关参数
val wmParams = mPlayerFloatView?.wmParams
wmParams?.type = WindowManager.LayoutParams.TYPE_APPLICATION //设置window type
wmParams?.format = PixelFormat.RGBA_8888 //设置图片格式,效果为背景透明
//设置Window flag
wmParams?.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
wmParams?.gravity = Gravity.LEFT or Gravity.TOP //调整悬浮窗口至左上角
//以屏幕左上角为原点,设置x、y初始值
val size = Point()
wm?.defaultDisplay?.getSize(size)
if (YDLMusicHelper.playType == 0) {//音频
wmParams?.x = 0
wmParams?.y = size.y * 5 / 6
//设置悬浮窗口长宽数据
wmParams?.width = WindowManager.LayoutParams.MATCH_PARENT
wmParams?.height = RxImageTool.dp2px(56f)
} else {
wmParams?.x = size.x - RxImageTool.dp2px(220f)
wmParams?.y = size.y * 3 / 4
//设置悬浮窗口长宽数据
wmParams?.width = RxImageTool.dp2px(220f)
wmParams?.height = RxImageTool.dp2px(124f)
}
//显示myFloatView图像
wm?.addView(mPlayerFloatView, wmParams)
showingPageName = context::class.qualifiedName!!
}
}
}
......@@ -20,7 +20,8 @@ import com.yidianling.common.tools.RxImageTool;
* 绘制波纹
* Created by Dog on 2015/7/22.
*/
public class DrawCircleShapeUtil{
public class
DrawCircleShapeUtil{
//点击drawable
ShapeDrawable mClickDrawable;
//消失动画
......
//package com.ydl.ydlcommon.view.widgets;
//
//import android.content.Context;
//import android.content.res.Resources;
//import android.graphics.Bitmap;
//import android.graphics.BitmapShader;
//import android.graphics.Canvas;
//import android.graphics.Paint;
//import android.graphics.RectF;
//import android.support.annotation.NonNull;
//
//import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
//import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
//
//import java.security.MessageDigest;
//
///**
// * @author jiucheng
// * @描述:glide加载图片:只有顶部圆角
// * @Copyright Copyright (c) 2018
// * @Company 壹点灵
// * @date 2018/7/30
// */
//
//public class GlideRoundTopTransform extends BitmapTransformation {
//
// private static float radius = 0f;
//
// public GlideRoundTopTransform(Context contex) {
// this(contex, 4);
// }
//
// public GlideRoundTopTransform(Context context, int dp) {
// super(context);
// this.radius = Resources.getSystem().getDisplayMetrics().density * dp;
//
// }
//
// @Override
// protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
// return roundCrop(pool, toTransform);
// }
//
//
// private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
// if (source == null) return null;
//
// Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
// if (result == null) {
// result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
// }
//
// Canvas canvas = new Canvas(result);
// Paint paint = new Paint();
// paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
// paint.setAntiAlias(true);
// RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
// canvas.drawRoundRect(rectF, radius, radius, paint);
// canvas.drawRect(new RectF(0, radius, source.getWidth(), source.getHeight()), paint);
// return result;
// }
//
// @Override
// public void updateDiskCacheKey(MessageDigest messageDigest) {
//
// }
//
// public String getId() {
// return getClass().getName() + Math.round(radius);
// }
//
//}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="0"
android:toYDelta="100%p"
android:duration="300"
/>
</set>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromXDelta="-100%p"
android:fromYDelta="0%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0%"
android:toYDelta="0%" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromXDelta="100%p"
android:fromYDelta="0%"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="0%"
android:toYDelta="0%" />
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromXDelta="0"
android:fromYDelta="0%"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="-100%p"
android:toYDelta="0%" />
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="100%p"
android:toYDelta="0%" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="#F0F3F7"/>
<item android:color="@android:color/white" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#000000" android:state_enabled="true" />
<item android:color="#66000000" android:state_enabled="false"/>
</selector>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment