Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Android
TradeSteward
Commits
52a16288
Commit
52a16288
authored
6 months ago
by
linwei
Browse files
Options
Download
Email Patches
Plain Diff
重构学习中心、养生文库模块
parent
161b15ad
master
dev
dev-learning-center
dev-uniapp
v9.38.0_tag
v9.37.1_tag
v9.37.0_tag
No related merge requests found
Changes
37
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
AndroidManifest.xml
+5
-5
AndroidManifest.xml
base_lib/src/main/java/com/urovo/wugumofang/base/BaseActivity.java
+8
-0
...src/main/java/com/urovo/wugumofang/base/BaseActivity.java
base_lib/src/main/java/com/urovo/wugumofang/constants/ApiUrls.java
+24
-0
...src/main/java/com/urovo/wugumofang/constants/ApiUrls.java
base_lib/src/main/java/com/urovo/wugumofang/constants/AppConstants.java
+30
-2
...ain/java/com/urovo/wugumofang/constants/AppConstants.java
base_lib/src/main/java/com/urovo/wugumofang/utils/ExtensionFunction.kt
+12
-0
...main/java/com/urovo/wugumofang/utils/ExtensionFunction.kt
res/layout/activity_learning_center_detail.xml
+1
-1
res/layout/activity_learning_center_detail.xml
res/layout/activity_learning_center_menu_new.xml
+43
-0
res/layout/activity_learning_center_menu_new.xml
res/layout/activity_learning_center_search.xml
+10
-0
res/layout/activity_learning_center_search.xml
res/layout/learn_search_ll.xml
+0
-14
res/layout/learn_search_ll.xml
res/values/strings.xml
+10
-0
res/values/strings.xml
src/com/urovo/activity/MemberProfile/view/MemberProfileAct.java
+7
-6
...m/urovo/activity/MemberProfile/view/MemberProfileAct.java
src/com/urovo/activity/learning/ExamArchiveListActivity.kt
+3
-4
src/com/urovo/activity/learning/ExamArchiveListActivity.kt
src/com/urovo/activity/learning/LearningCenter2ndMenuAct.java
+203
-203
...com/urovo/activity/learning/LearningCenter2ndMenuAct.java
src/com/urovo/activity/learning/LearningCenterDetailActivity.java
+381
-380
...urovo/activity/learning/LearningCenterDetailActivity.java
src/com/urovo/activity/learning/LearningCenterDetailActivity.kt
+254
-0
...m/urovo/activity/learning/LearningCenterDetailActivity.kt
src/com/urovo/activity/learning/LearningCenterListActivity.java
+396
-396
...m/urovo/activity/learning/LearningCenterListActivity.java
src/com/urovo/activity/learning/LearningCenterListActivity.kt
+207
-0
...com/urovo/activity/learning/LearningCenterListActivity.kt
src/com/urovo/activity/learning/LearningCenterMenuActivity.java
+268
-266
...m/urovo/activity/learning/LearningCenterMenuActivity.java
src/com/urovo/activity/learning/LearningCenterMenuActivity.kt
+219
-0
...com/urovo/activity/learning/LearningCenterMenuActivity.kt
src/com/urovo/activity/learning/LearningCenterSearchActivity.kt
+229
-0
...m/urovo/activity/learning/LearningCenterSearchActivity.kt
with
2310 additions
and
1277 deletions
+2310
-1277
AndroidManifest.xml
+
5
-
5
View file @
52a16288
...
...
@@ -835,6 +835,11 @@
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"portrait"
tools:ignore=
"LockedOrientationActivity"
/>
<activity
android:name=
"com.urovo.activity.learning.LearningCenterSearchActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"portrait"
tools:ignore=
"LockedOrientationActivity"
/>
<activity
android:name=
"com.urovo.activity.xunjian.XunJianShangBaoActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
...
...
@@ -1033,11 +1038,6 @@
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"portrait"
tools:ignore=
"LockedOrientationActivity"
/>
<activity
android:name=
"com.urovo.activity.learning.LearningCenter2ndMenuAct"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"portrait"
tools:ignore=
"LockedOrientationActivity"
/>
<activity
android:name=
"com.urovo.wgmf.BaseFragmentActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
...
...
This diff is collapsed.
Click to expand it.
base_lib/src/main/java/com/urovo/wugumofang/base/BaseActivity.java
+
8
-
0
View file @
52a16288
...
...
@@ -569,6 +569,14 @@ public class BaseActivity extends AppCompatActivity implements AbsView, DialogRe
}
}
/**
* 显示无数据文案
*/
public
void
showNoData
(
int
message
)
{
mLoadWaitDominator
.
showNoData
(
message
);
}
/**
* 显示无数据文案
*/
...
...
This diff is collapsed.
Click to expand it.
base_lib/src/main/java/com/urovo/wugumofang/constants/ApiUrls.java
+
24
-
0
View file @
52a16288
...
...
@@ -1338,6 +1338,30 @@ public interface ApiUrls {
}
interface
SYGJApi
{
String
EnvPort
=
"sygj-api"
;
/**
* 分页查询学习文章分类列表
*/
String
QUERY_LEARN_ARTICLE_CATEGORY_PAGE_LIST
=
EnvPort
+
"/app/learn/article/category/page/list"
;
/**
* 分页查询学习文章列表
*/
String
QUERY_LEARN_ARTICLE_PAGE_LIST
=
EnvPort
+
"/app/learn/article/page/list"
;
/**
* 查询学习文章详情数据
*/
String
QUERY_LEARN_ARTICLE
=
EnvPort
+
"/app/user/learn/article/query"
;
/**
* 保存用户阅读学习文章记录
*/
String
SAVE_USER_READ_LEARN_ARTICLE
=
EnvPort
+
"/app/user/read/learn/article/save"
;
/**
* 收藏-取消收藏学习文章
*/
String
UPDATE_USER_STORE_LEARN_ARTICLE
=
EnvPort
+
"/app/user/store/learn/article/update"
;
}
/**
* 伪造数据接口测试,可以根据自己的地址更改ENV_PORT
*/
...
...
This diff is collapsed.
Click to expand it.
base_lib/src/main/java/com/urovo/wugumofang/constants/AppConstants.java
+
30
-
2
View file @
52a16288
...
...
@@ -434,9 +434,9 @@ public class AppConstants {
*/
public
static
final
String
DISPATCH_PRODUCT_DATA
=
"DISPATCH_PRODUCT_DATA"
;
/**
*非波次单货品产品数据
*
非波次单货品产品数据
*/
public
static
final
String
DISPATCH_NOT_PRODUCT_DATA
=
"DISPATCH_NOT_PRODUCT_DATA"
;
public
static
final
String
DISPATCH_NOT_PRODUCT_DATA
=
"DISPATCH_NOT_PRODUCT_DATA"
;
/**
* 配送单号角标
*/
...
...
@@ -455,6 +455,34 @@ public class AppConstants {
* 顾客标签
*/
public
static
final
String
CUSTOMER_LABEL
=
"CUSTOMER_LABEL"
;
/**
* 学习中心pid
*/
public
static
final
String
LEARNING_PID
=
"LEARNING_PID"
;
/**
* 文章、收藏列表
*/
public
static
final
String
LEARNING_COLLECT
=
"LEARNING_COLLECT"
;
/**
* URL地址
*/
public
static
final
String
LEARNING_URL
=
"LEARNING_URL"
;
/**
* 考试链接
*/
public
static
final
String
LEARNING_TEST_LINK
=
"LEARNING_TEST_LINK"
;
/**
* 是否需要考试
*/
public
static
final
String
LEARNING_IS_NEED_TEST
=
"LEARNING_IS_NEED_TEST"
;
/**
* 文章标题
*/
public
static
final
String
LEARNING_TITLE
=
"LEARNING_TITLE"
;
/**
* 文章业务ID
*/
public
static
final
String
LEARNING_ARTICLE_ID
=
"LEARNING_ARTICLE_ID"
;
public
static
final
String
STORE_ALLOT_ENTITY
=
"STORE_ALLOT_ENTITY"
;
...
...
This diff is collapsed.
Click to expand it.
base_lib/src/main/java/com/urovo/wugumofang/utils/ExtensionFunction.kt
+
12
-
0
View file @
52a16288
...
...
@@ -20,7 +20,19 @@ fun EditText.afterTextChanged(afterTextChanged: (String) -> Unit) {
}
})
}
fun
EditText
.
textChanged
(
onTextChanged
:
(
CharSequence
?)
->
Unit
)
{
this
.
addTextChangedListener
(
object
:
TextWatcher
{
override
fun
beforeTextChanged
(
p0
:
CharSequence
?,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
}
override
fun
onTextChanged
(
s
:
CharSequence
?,
p1
:
Int
,
p2
:
Int
,
p3
:
Int
)
{
onTextChanged
.
invoke
(
s
)
}
override
fun
afterTextChanged
(
editable
:
Editable
?)
{
}
})
}
fun
EditText
.
setOnEditorActionListener
(
editorActionListener
:
(
Int
,
String
)
->
Boolean
)
{
this
.
setOnEditorActionListener
{
view
,
actionId
,
_
->
val
content
=
view
.
text
.
toString
()
...
...
This diff is collapsed.
Click to expand it.
res/layout/activity_learning_detail.xml
→
res/layout/activity_learning_
center_
detail.xml
+
1
-
1
View file @
52a16288
...
...
@@ -95,7 +95,7 @@
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding
Top
=
"5dp"
android:padding=
"5dp"
android:text=
"分享到"
tools:ignore=
"HardcodedText"
/>
...
...
This diff is collapsed.
Click to expand it.
res/layout/activity_learning_center_menu_new.xml
0 → 100644
+
43
-
0
View file @
52a16288
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:fab=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
style=
"@style/match_match"
android:background=
"@color/wgmf_two_bg"
>
<LinearLayout
style=
"@style/match_match"
android:orientation=
"vertical"
>
<include
layout=
"@layout/title"
/>
<include
layout=
"@layout/public_page_list_content_view"
/>
</LinearLayout>
<com.melnykov.fab.FloatingActionButton
android:id=
"@+id/learning_center_menu_archive_fab"
style=
"@style/wrap_wrap"
android:layout_gravity=
"bottom|right"
android:layout_marginEnd=
"@dimen/space_16"
android:layout_marginRight=
"@dimen/space_16"
android:layout_marginBottom=
"@dimen/space_90"
android:src=
"@mipmap/icon_hover_test_file"
fab:elevation=
"5dp"
tools:ignore=
"RtlHardcoded"
/>
<com.melnykov.fab.FloatingActionButton
android:id=
"@+id/learning_center_menu_search_fab"
style=
"@style/wrap_wrap"
android:layout_gravity=
"bottom|right"
android:layout_marginEnd=
"@dimen/space_16"
android:layout_marginRight=
"@dimen/space_16"
android:layout_marginBottom=
"@dimen/space_20"
android:src=
"@drawable/wenti_sousuo"
fab:elevation=
"5dp"
fab:fab_colorNormal=
"@color/title_bg"
fab:fab_colorPressed=
"@color/color_common_theme_one"
fab:fab_colorRipple=
"@color/white"
tools:ignore=
"RtlHardcoded"
/>
</FrameLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
res/layout/activity_learning_center_search.xml
0 → 100644
+
10
-
0
View file @
52a16288
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
style=
"@style/match_match"
android:orientation=
"vertical"
>
<include
layout=
"@layout/search_title"
/>
<include
layout=
"@layout/public_page_list_content_view"
/>
</LinearLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
res/layout/learn_search_ll.xml
deleted
100644 → 0
+
0
-
14
View file @
161b15ad
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<include
layout=
"@layout/search_title"
></include>
<LinearLayout
android:id=
"@+id/result_container"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
></LinearLayout>
</LinearLayout>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
res/values/strings.xml
+
10
-
0
View file @
52a16288
...
...
@@ -409,6 +409,13 @@
<string
name=
"phone_member_phone_number"
>
手机号:%s
</string>
<!--学习中心-->
<string
name=
"learning_center_menu"
>
学习中心
</string>
<string
name=
"learning_center_collect_count"
>
我的收藏(%d)
</string>
<string
name=
"learning_center_my_collect"
>
我的收藏
</string>
<string
name=
"learning_center_read_num"
>
%d次
</string>
<string
name=
"learning_center_search_entry_tip"
>
搜索结果为空~
</string>
<string
name=
"learning_center_exam_archive"
>
考试档案
</string>
<string
name=
"learning_center_exam_archive_name_code"
>
%s,%s
</string>
<string
name=
"learning_center_exam_archive_entry_time"
>
入职时间:%s
</string>
...
...
@@ -419,6 +426,9 @@
<string
name=
"learning_center_exam_archive_cleared"
>
通关
</string>
<string
name=
"learning_center_exam_archive_not_cleared"
>
未通关
</string>
<!--养生文库-->
<string
name=
"health_library_menu"
>
养生文库
</string>
<!--会员录单-->
<string
name=
"member_detail_copy_mobile_list"
>
复制手机号去录单
</string>
...
...
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/MemberProfile/view/MemberProfileAct.java
+
7
-
6
View file @
52a16288
...
...
@@ -45,6 +45,7 @@ import com.urovo.wgmf.view.OnMeasuredListView;
import
com.urovo.wugumofang.R
;
import
com.urovo.wugumofang.base.BaseActivity
;
import
com.urovo.wugumofang.constants.AppConstants
;
import
com.urovo.wugumofang.constants.ConstantParams
;
import
com.urovo.wugumofang.constants.Files
;
import
com.urovo.wugumofang.constants.NetParam
;
import
com.urovo.wugumofang.data.DataMonthUtils
;
...
...
@@ -180,7 +181,7 @@ public class MemberProfileAct extends BaseActivity implements OnClickListener, M
mType
=
getIntent
().
getIntExtra
(
"mType"
,
1
),
false
);
careType
=
getIntent
().
getStringExtra
(
"careType"
);
taskId
=
getIntent
().
getStringExtra
(
"taskId"
);
isShowCareTools
=
getIntent
().
getBooleanExtra
(
"isShowCareTools"
,
true
);
//是否显示底栏关怀工具栏,默认显示
isShowCareTools
=
getIntent
().
getBooleanExtra
(
"isShowCareTools"
,
true
);
//是否显示底栏关怀工具栏,默认显示
mApi
=
WXAPIFactory
.
createWXAPI
(
this
,
NetParam
.
WXAPP_ID
,
false
);
}
...
...
@@ -200,7 +201,7 @@ public class MemberProfileAct extends BaseActivity implements OnClickListener, M
titleLayout
=
(
RelativeLayout
)
findViewById
(
R
.
id
.
layout_title
);
//底栏关怀工具栏
careToolBar
=
(
LinearLayout
)
findViewById
(
R
.
id
.
careToolBar
);
careToolBar
.
setVisibility
(
isShowCareTools
?
View
.
VISIBLE
:
View
.
GONE
);
careToolBar
.
setVisibility
(
isShowCareTools
?
View
.
VISIBLE
:
View
.
GONE
);
feedbackBottomBtn
=
(
ImageButton
)
findViewById
(
R
.
id
.
feedbackBottomBtn
);
feedbackBottomBtn
.
setOnClickListener
(
this
);
...
...
@@ -362,7 +363,7 @@ public class MemberProfileAct extends BaseActivity implements OnClickListener, M
case
R
.
id
.
share_layout
:
//转发文章
intent
.
setClass
(
MemberProfileAct
.
this
,
LearningCenterMenuActivity
.
class
);
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
,
"2"
);
//1是学习中心,2是养生文库
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
,
ConstantParams
.
CONSTANT_PARAMS_2
);
//1是学习中心,2是养生文库
startActivity
(
intent
);
break
;
case
R
.
id
.
btn_sure
:
//参考话术
...
...
@@ -425,7 +426,7 @@ public class MemberProfileAct extends BaseActivity implements OnClickListener, M
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
switch
(
resultCode
){
switch
(
resultCode
)
{
case
GuanhuaiFeedbackAct
.
FEEDBACK_SUCCESS
:
feedbackBottomBtn
.
setVisibility
(
View
.
GONE
);
break
;
...
...
@@ -634,7 +635,7 @@ public class MemberProfileAct extends BaseActivity implements OnClickListener, M
confirm_care_iv
.
setImageResource
(
R
.
drawable
.
sxp_care_available
);
}
//自定义关怀,点击关怀之后要返回上一页面;只有点的是“我已关怀”才关闭页面
if
(
careType
.
equals
(
"4"
)
&&
tag
.
endsWith
(
"confirmCare"
)){
if
(
careType
.
equals
(
"4"
)
&&
tag
.
endsWith
(
"confirmCare"
))
{
finish
();
}
}
else
{
...
...
@@ -724,7 +725,7 @@ public class MemberProfileAct extends BaseActivity implements OnClickListener, M
if
(!
TextUtils
.
isEmpty
(
tag
)
&&
"isShared"
.
equals
(
tag
))
{
//说明已转发成功
guanHuaiData
.
getCell
().
setShareCare
(
"1"
);
mShare
.
setImageResource
(
R
.
drawable
.
sxp_shared
);
mPresenter
.
upload
(
guanHuaiData
,
false
,
false
,
false
,
true
,
false
,
careType
,
mType
,
taskId
);
mPresenter
.
upload
(
guanHuaiData
,
false
,
false
,
false
,
true
,
false
,
careType
,
mType
,
taskId
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/ExamArchiveListActivity.kt
+
3
-
4
View file @
52a16288
...
...
@@ -5,7 +5,7 @@ import android.view.ViewGroup
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.urovo.activity.learning.model.ExamArchiveEntity
import
com.urovo.activity.learning.presenter.ArchiveDetailContract
import
com.urovo.activity.learning.presenter.
LearningCenter
Presenter
import
com.urovo.activity.learning.presenter.
ArchiveDetail
Presenter
import
com.urovo.activity.learning.view.adapter.ExamArchiveListAdapter
import
com.urovo.wugumofang.R
import
com.urovo.wugumofang.base.BaseActivity
...
...
@@ -22,7 +22,7 @@ import kotlinx.android.synthetic.main.activity_exam_archive_list.*
*/
class
ExamArchiveListActivity
:
BaseActivity
(),
ArchiveDetailContract
.
IView
{
private
var
mLearningCenterPresenter
:
LearningCenter
Presenter
?
=
null
private
var
mLearningCenterPresenter
:
ArchiveDetail
Presenter
?
=
null
private
var
mExamArchiveListAdapter
:
ExamArchiveListAdapter
?
=
null
...
...
@@ -48,12 +48,11 @@ class ExamArchiveListActivity : BaseActivity(), ArchiveDetailContract.IView {
}
override
fun
addPresenter
():
BasePresenter
{
mLearningCenterPresenter
=
LearningCenter
Presenter
(
this
)
mLearningCenterPresenter
=
ArchiveDetail
Presenter
(
this
)
return
mLearningCenterPresenter
!!
}
override
fun
examArchiveInfoData
(
data
:
ExamArchiveEntity
)
{
super
.
examArchiveInfoData
(
data
)
val
archiveDetailList
=
data
.
archiveDetailList
if
(
archiveDetailList
.
isNotNullOrSize
())
{
mExamArchiveListAdapter
?.
setNewData
(
archiveDetailList
)
...
...
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/LearningCenter2ndMenuAct.java
+
203
-
203
View file @
52a16288
package
com.urovo.activity.learning
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.AdapterView
;
import
android.widget.BaseAdapter
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
com.melnykov.fab.FloatingActionButton
;
import
com.urovo.activity.learningsearch.view.LearnSearchAct
;
import
com.urovo.wgmf.db.dao.entitys.LearningCenter2ndMenuRes
;
import
com.urovo.wgmf.db.dao.entitys.LearningCenterResultEntity
;
import
com.urovo.wugumofang.R
;
import
com.urovo.wugumofang.base.BaseActivity
;
import
com.urovo.wugumofang.constants.AppConstants
;
import
com.urovo.wugumofang.constants.NetParam
;
import
com.urovo.wugumofang.net.OkHttpDominator
;
import
com.urovo.wugumofang.ui.ViewUtil
;
import
org.greenrobot.eventbus.EventBus
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.greenrobot.eventbus.ThreadMode
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
butterknife.OnClick
;
import
butterknife.Unbinder
;
import
okhttp3.Request
;
/**
* Created by Sasuke on 2016/12/19.
*/
public
class
LearningCenter2ndMenuAct
extends
BaseActivity
implements
AdapterView
.
OnItemClickListener
{
@BindView
(
R
.
id
.
learning_center_list_menu_lv
)
ListView
lv
;
@BindView
(
R
.
id
.
learning_center_search_fab
)
FloatingActionButton
mLearningCenterSearchFab
;
LearningCenterResultEntity
.
LearningCenterEntityList
entityList
;
//从一级目录点进来的那一条。
List
<
LearningCenter2ndMenuRes
.
Item
>
dataList
=
new
ArrayList
<>();
int
flag
;
//1学习中心 非1养生文库
Unbinder
unbinder
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_learning_center_menu
);
unbinder
=
ButterKnife
.
bind
(
this
);
initUI
();
requestTask
();
EventBus
.
getDefault
().
register
(
this
);
}
protected
void
initUI
(){
initTitle
();
titleTextView
.
setText
(
getIntent
().
getStringExtra
(
"title"
));
entityList
=
(
LearningCenterResultEntity
.
LearningCenterEntityList
)
getIntent
().
getSerializableExtra
(
"learningCenterEntityList"
);
String
flagString
=
getIntent
().
getStringExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
);
flag
=
TextUtils
.
isEmpty
(
flagString
)?
1
:
Integer
.
parseInt
(
flagString
);
lv
.
setOnItemClickListener
(
this
);
mLearningCenterSearchFab
.
attachToListView
(
lv
);
}
protected
void
requestTask
(){
if
(
entityList
!=
null
){
HashMap
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"stype"
,
entityList
.
getSelectTypeId
());
param
.
put
(
"flag"
,
flag
==
1
?
"study"
:
"yangsheng"
);
ViewUtil
.
showProgress
(
this
,
""
,
"正在获取目录....."
);
OkHttpDominator
.
getAsyn
(
NetParam
.
LEARNINGCENTER_2ND_MENU
,
param
,
new
OkHttpDominator
.
ResultCallback
<
LearningCenter2ndMenuRes
>()
{
@Override
public
void
onError
(
Request
request
,
Exception
e
)
{
ViewUtil
.
dismissProgress
();
showMsg
(
getString
(
R
.
string
.
request_data_fail
));
}
@Override
public
void
onResponse
(
LearningCenter2ndMenuRes
res
)
{
ViewUtil
.
dismissProgress
();
dataList
.
clear
();
dataList
=
new
ArrayList
<>();
dataList
=
res
.
getResultInfo
();
EventBus
.
getDefault
().
post
(
dataList
);
}
});
// RequestParams params = new RequestParams();
// params.addQueryStringParameter("stype", entityList.getSelectTypeId());//一级类目的主键
// params.addQueryStringParameter("flag",flag == 1?"study" : "yangsheng");//study:为学习中心文章,yangsheng:为养生文库的文章
// // 默认查当月
// mHttpUtils.send(HttpRequest.HttpMethod.GET, NetParam.LEARNINGCENTER_2ND_MENU,
// params, mRequestCallBack);
}
}
// private RequestCallBack<String> mRequestCallBack = new RequestCallBack<String>(){
//package com.urovo.activity.learning;
//
//import android.content.Intent;
//import android.os.Bundle;
//import android.text.TextUtils;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.AdapterView;
//import android.widget.BaseAdapter;
//import android.widget.ListView;
//import android.widget.TextView;
//
//import com.melnykov.fab.FloatingActionButton;
//import com.urovo.activity.learningsearch.view.LearnSearchAct;
//import com.urovo.wgmf.db.dao.entitys.LearningCenter2ndMenuRes;
//import com.urovo.wgmf.db.dao.entitys.LearningCenterResultEntity;
//import com.urovo.wugumofang.R;
//import com.urovo.wugumofang.base.BaseActivity;
//import com.urovo.wugumofang.constants.AppConstants;
//import com.urovo.wugumofang.constants.NetParam;
//import com.urovo.wugumofang.net.OkHttpDominator;
//import com.urovo.wugumofang.ui.ViewUtil;
//
//import org.greenrobot.eventbus.EventBus;
//import org.greenrobot.eventbus.Subscribe;
//import org.greenrobot.eventbus.ThreadMode;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//
//import butterknife.BindView;
//import butterknife.ButterKnife;
//import butterknife.OnClick;
//import butterknife.Unbinder;
//import okhttp3.Request;
//
///**
// * Created by Sasuke on 2016/12/19.
// */
//
//public class LearningCenter2ndMenuAct extends BaseActivity implements AdapterView.OnItemClickListener{
// @BindView(R.id.learning_center_list_menu_lv) ListView lv;
// @BindView(R.id.learning_center_search_fab) FloatingActionButton mLearningCenterSearchFab;
// LearningCenterResultEntity.LearningCenterEntityList entityList ;//从一级目录点进来的那一条。
// List<LearningCenter2ndMenuRes.Item> dataList = new ArrayList<>();
// int flag;//1学习中心 非1养生文库
// Unbinder unbinder;
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_learning_center_menu);
// unbinder = ButterKnife.bind(this);
// initUI();
// requestTask();
// EventBus.getDefault().register(this);
// }
//
//
// protected void initUI(){
// initTitle();
// titleTextView.setText(getIntent().getStringExtra("title"));
// entityList = (LearningCenterResultEntity.LearningCenterEntityList)
// getIntent().getSerializableExtra("learningCenterEntityList");
// String flagString = getIntent().getStringExtra(AppConstants.ExtraKeys.ACTIVITY_TYPE);
// flag = TextUtils.isEmpty(flagString)? 1 : Integer.parseInt(flagString);
// lv.setOnItemClickListener(this);
// mLearningCenterSearchFab.attachToListView(lv);
// }
//
// protected void requestTask(){
// if(entityList != null){
// HashMap<String,String> param = new HashMap<>();
// param.put("stype",entityList.getSelectTypeId());
// param.put("flag",flag == 1?"study" : "yangsheng");
// ViewUtil.showProgress(this, "", "正在获取目录.....");
// OkHttpDominator.getAsyn(NetParam.LEARNINGCENTER_2ND_MENU,
// param,
// new OkHttpDominator.ResultCallback<LearningCenter2ndMenuRes>() {
// @Override
// public void onError(Request request, Exception e) {
// ViewUtil.dismissProgress();
// showMsg(getString(R.string.request_data_fail));
// }
//
// @Override
// public void onResponse(LearningCenter2ndMenuRes res) {
// ViewUtil.dismissProgress();
// dataList.clear();
// dataList = new ArrayList<>();
// dataList = res.getResultInfo();
// EventBus.getDefault().post(dataList);
// }
// });
//// RequestParams params = new RequestParams();
//// params.addQueryStringParameter("stype", entityList.getSelectTypeId());//一级类目的主键
//// params.addQueryStringParameter("flag",flag == 1?"study" : "yangsheng");//study:为学习中心文章,yangsheng:为养生文库的文章
//// // 默认查当月
//// mHttpUtils.send(HttpRequest.HttpMethod.GET, NetParam.LEARNINGCENTER_2ND_MENU,
//// params, mRequestCallBack);
// }
// }
//
//
//// private RequestCallBack<String> mRequestCallBack = new RequestCallBack<String>(){
//// @Override
//// public void onStart() {
//// super.onStart();
//// GlobalApp.loger.info("请求报文:" + this.getRequestUrl());
//// }
////
//// @Override
//// public void onFailure(HttpException e, String s) {
//// showMsg(getString(R.string.request_data_fail));
//// GlobalApp.loger.info("失败" + ":" + s);
//// }
////
//// @Override
//// public void onSuccess(ResponseInfo<String> responseInfo) {
//// String json = responseInfo.result;
//// GlobalApp.loger.info("响应报文:" + json);
//// LearningCenter2ndMenuRes res = new Gson().fromJson(json,LearningCenter2ndMenuRes.class);
//// dataList.clear();
//// dataList = new ArrayList<>();
//// dataList = res.getResultInfo();
//// EventBus.getDefault().post(dataList);
//// }
//// };
//
//
// @Subscribe(threadMode = ThreadMode.MAIN)
// public void onEventMainThread(List<LearningCenter2ndMenuRes.Item> dataList) {
// lv.setAdapter(new SecondMenuAdapter(dataList));
// ViewUtil.dismissProgress();
// }
//
// /**
// * 跳转到关键词搜索
// */
// @OnClick(R.id.learning_center_search_fab)
// public void onSearchClick(View v){
// Intent intent = new Intent(this,LearnSearchAct.class);
// intent.putExtra(AppConstants.ExtraKeys.ARTICLE_SEARCH_TYPE, flag);
// intent.putExtra(AppConstants.ExtraKeys.ARTICLE_SEARCH_ALREADY_STORES, getIntent().getSerializableExtra("alreadyStores"));
// intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
// startActivity(intent);
// }
//
// /**
// * 跳转到关键词搜索
// */
// @OnClick(R.id.learning_center_exam_archive_fab)
// public void onExamArchiveClick(View v){
// Intent intent = new Intent(this, ExamArchiveListActivity.class);
// startActivity(intent);
// }
//
// @Override
// public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
// Intent intent = new Intent(LearningCenter2ndMenuAct.this,LearningCenterListActivity.class);
// intent.putExtra("tag", "content");//标记跳到的界面不是收藏,而是文章列表。
// intent.putExtra(AppConstants.ExtraKeys.ACTIVITY_TYPE,flag + "");
// intent.putExtra("title", dataList.get(position).getName());
//
// //把收藏列表传过去,后面跳文件的时候,要对比收藏列表,并显示收藏标记。
// intent.putExtra("alreadyStores",getIntent().getSerializableExtra("alreadyStores"));
// intent.putExtra("secondTypeId",dataList.get(position).getSid());
// intent.putExtra("selectType",entityList.getSelectTypeId());
// startActivity(intent);
// }
//
// protected class SecondMenuAdapter extends BaseAdapter{
// List<LearningCenter2ndMenuRes.Item> dataList ;
// public SecondMenuAdapter(List<LearningCenter2ndMenuRes.Item> dataList){
// this.dataList = dataList;
// }
// @Override
// public int getCount() {
// return dataList.size();
// }
//
// @Override
// public void onStart() {
// super.onStart();
// GlobalApp.loger.info("请求报文:" + this.getRequestUrl());
// public Object getItem(int i) {
// return null;
// }
//
// @Override
// public void onFailure(HttpException e, String s) {
// showMsg(getString(R.string.request_data_fail));
// GlobalApp.loger.info("失败" + ":" + s);
// public long getItemId(int i) {
// return i;
// }
//
// @Override
// public void onSuccess(ResponseInfo<String> responseInfo) {
// String json = responseInfo.result;
// GlobalApp.loger.info("响应报文:" + json);
// LearningCenter2ndMenuRes res = new Gson().fromJson(json,LearningCenter2ndMenuRes.class);
// dataList.clear();
// dataList = new ArrayList<>();
// dataList = res.getResultInfo();
// EventBus.getDefault().post(dataList);
// public View getView(int position, View view, ViewGroup viewGroup) {
// view = LayoutInflater.from( LearningCenter2ndMenuAct.this).inflate(R.layout.learning_center_2nd_menu_item, null);
// TextView tv = (TextView) view.findViewById(R.id.learning_2nd_text);
// String name = dataList.get(position).getName();
// tv.setText(name);
// return view;
// }
// };
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
public
void
onEventMainThread
(
List
<
LearningCenter2ndMenuRes
.
Item
>
dataList
)
{
lv
.
setAdapter
(
new
SecondMenuAdapter
(
dataList
));
ViewUtil
.
dismissProgress
();
}
/**
* 跳转到关键词搜索
*/
@OnClick
(
R
.
id
.
learning_center_search_fab
)
public
void
onSearchClick
(
View
v
){
Intent
intent
=
new
Intent
(
this
,
LearnSearchAct
.
class
);
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ARTICLE_SEARCH_TYPE
,
flag
);
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ARTICLE_SEARCH_ALREADY_STORES
,
getIntent
().
getSerializableExtra
(
"alreadyStores"
));
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NO_ANIMATION
);
startActivity
(
intent
);
}
/**
* 跳转到关键词搜索
*/
@OnClick
(
R
.
id
.
learning_center_exam_archive_fab
)
public
void
onExamArchiveClick
(
View
v
){
Intent
intent
=
new
Intent
(
this
,
ExamArchiveListActivity
.
class
);
startActivity
(
intent
);
}
@Override
public
void
onItemClick
(
AdapterView
<?>
adapterView
,
View
view
,
int
position
,
long
l
)
{
Intent
intent
=
new
Intent
(
LearningCenter2ndMenuAct
.
this
,
LearningCenterListActivity
.
class
);
intent
.
putExtra
(
"tag"
,
"content"
);
//标记跳到的界面不是收藏,而是文章列表。
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
,
flag
+
""
);
intent
.
putExtra
(
"title"
,
dataList
.
get
(
position
).
getName
());
//把收藏列表传过去,后面跳文件的时候,要对比收藏列表,并显示收藏标记。
intent
.
putExtra
(
"alreadyStores"
,
getIntent
().
getSerializableExtra
(
"alreadyStores"
));
intent
.
putExtra
(
"secondTypeId"
,
dataList
.
get
(
position
).
getSid
());
intent
.
putExtra
(
"selectType"
,
entityList
.
getSelectTypeId
());
startActivity
(
intent
);
}
protected
class
SecondMenuAdapter
extends
BaseAdapter
{
List
<
LearningCenter2ndMenuRes
.
Item
>
dataList
;
public
SecondMenuAdapter
(
List
<
LearningCenter2ndMenuRes
.
Item
>
dataList
){
this
.
dataList
=
dataList
;
}
@Override
public
int
getCount
()
{
return
dataList
.
size
();
}
@Override
public
Object
getItem
(
int
i
)
{
return
null
;
}
@Override
public
long
getItemId
(
int
i
)
{
return
i
;
}
@Override
public
View
getView
(
int
position
,
View
view
,
ViewGroup
viewGroup
)
{
view
=
LayoutInflater
.
from
(
LearningCenter2ndMenuAct
.
this
).
inflate
(
R
.
layout
.
learning_center_2nd_menu_item
,
null
);
TextView
tv
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
learning_2nd_text
);
String
name
=
dataList
.
get
(
position
).
getName
();
tv
.
setText
(
name
);
return
view
;
}
}
@Override
protected
void
onDestroy
()
{
// ButterKnife.unbind(this);
unbinder
.
unbind
();
EventBus
.
getDefault
().
unregister
(
this
);
super
.
onDestroy
();
}
}
// }
//
//
// @Override
// protected void onDestroy() {
//// ButterKnife.unbind(this);
// unbinder.unbind();
// EventBus.getDefault().unregister(this);
// super.onDestroy();
// }
//}
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/LearningCenterDetailActivity.java
+
381
-
380
View file @
52a16288
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/LearningCenterDetailActivity.kt
0 → 100644
+
254
-
0
View file @
52a16288
package
com.urovo.activity.learning
import
android.graphics.BitmapFactory
import
android.graphics.drawable.Drawable
import
android.os.Bundle
import
android.view.KeyEvent
import
android.view.View
import
android.view.ViewGroup
import
com.umeng.socialize.media.UMImage
import
com.urovo.activity.learning.model.LearnArticleDetailEntity
import
com.urovo.activity.learning.presenter.LearningCenterContract
import
com.urovo.activity.learning.presenter.LearningCenterPresenter
import
com.urovo.wugumofang.R
import
com.urovo.wugumofang.base.BaseActivity
import
com.urovo.wugumofang.base.BasePresenter
import
com.urovo.wugumofang.basewebview.ui.HtmlActivity.Companion.start
import
com.urovo.wugumofang.basewebview.ui.HtmlFragment
import
com.urovo.wugumofang.basewebview.ui.HtmlFragment.OnChangeTitleListener
import
com.urovo.wugumofang.constants.ApiUrls
import
com.urovo.wugumofang.constants.AppConstants
import
com.urovo.wugumofang.constants.ConstantParams
import
com.urovo.wugumofang.constants.NetParam
import
com.urovo.wugumofang.net.OkHttpDominator
import
com.urovo.wugumofang.response.BaseSimpleResponse
import
com.urovo.wugumofang.system.SystemHelper
import
com.urovo.wugumofang.ui.DensityUtil
import
com.urovo.wugumofang.ui.ShareDominator.Companion.doCircleWxShare
import
com.urovo.wugumofang.ui.ShareDominator.Companion.doEnterpriseShare
import
com.urovo.wugumofang.ui.ShareDominator.Companion.doFriendsShare
import
com.urovo.wugumofang.utils.StringUtil
import
com.urovo.wugumofang.utils.notNullAndEmpty
import
kotlinx.android.synthetic.main.activity_learning_center_detail.*
import
okhttp3.Request
/**
* 文章详情页面
* @author LW
*/
class
LearningCenterDetailActivity
:
BaseActivity
(),
LearningCenterContract
.
IView
,
OnChangeTitleListener
{
private
var
mLearningCenterPresenter
:
LearningCenterPresenter
?
=
null
private
var
mLearnArticleDetailEntity
:
LearnArticleDetailEntity
?
=
null
private
val
mTitle
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_TITLE
)
}
private
val
mUrl
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_URL
)
}
private
val
mArticleId
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_ARTICLE_ID
)
}
private
val
mActivityType
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
)
?:
ConstantParams
.
CONSTANT_PARAMS_1
}
private
var
mIsFavoriteArticle
:
Boolean
=
false
override
fun
addRootLayoutId
():
Int
=
R
.
layout
.
activity_learning_center_detail
override
fun
rootViewGroup
():
ViewGroup
=
learning_detail_container_fl
override
fun
initTitle
()
{
super
.
initTitle
()
titleTextView
.
text
=
mTitle
}
override
fun
initViewNew
()
{
initTitle
()
val
image
=
UMImage
(
mContext
,
BitmapFactory
.
decodeResource
(
resources
,
R
.
drawable
.
wgmf_logo
)
)
share_enterprise_weixin_ll
.
setOnClickListener
{
//链接后面的type,1是会员商品转发,2是养生文库
doEnterpriseShare
(
mUrl
,
mTitle
,
mTitle
,
""
,
ConstantParams
.
CONSTANT_PARAMS_2
)
articleBuryPoint
(
ConstantParams
.
CONSTANT_STARTS_2
)
}
share_weixin_ll
.
setOnClickListener
{
doFriendsShare
(
this
,
mUrl
,
mTitle
,
mTitle
,
image
,
ConstantParams
.
CONSTANT_PARAMS_2
)
articleBuryPoint
(
ConstantParams
.
CONSTANT_STARTS_1
)
}
share_friends_ll
.
setOnClickListener
{
doCircleWxShare
(
this
,
mUrl
,
mTitle
,
mTitle
,
image
,
ConstantParams
.
CONSTANT_PARAMS_2
)
articleBuryPoint
(
ConstantParams
.
CONSTANT_STARTS_0
)
}
favorite_tv
.
setOnClickListener
{
updateUserStoreLearnArticle
()
}
share_collect_ll
.
setOnClickListener
{
updateUserStoreLearnArticle
()
}
exam_tv
.
setOnClickListener
{
mLearnArticleDetailEntity
?.
let
{
if
(
it
.
testLink
.
notNullAndEmpty
())
{
start
(
mContext
,
it
.
testLink
)
}
}
}
if
(
ConstantParams
.
CONSTANT_PARAMS_1
==
mActivityType
)
{
//学习中心
favorite_and_read_ll
.
visibility
=
View
.
VISIBLE
share_and_favorite_ll
.
visibility
=
View
.
GONE
}
else
{
//养生文库
favorite_and_read_ll
.
visibility
=
View
.
GONE
share_and_favorite_ll
.
visibility
=
View
.
VISIBLE
}
queryLearnArticle
()
saveUserReadLearnArticle
()
}
private
fun
showViewForIsFavorite
(
isFavorite
:
Boolean
)
{
val
drawable
:
Drawable
mIsFavoriteArticle
=
isFavorite
if
(
isFavorite
)
{
share_collect_img
.
setImageResource
(
R
.
drawable
.
collected
)
share_collect_tv
.
text
=
"取消收藏"
drawable
=
resources
.
getDrawable
(
R
.
drawable
.
collected
)
favorite_tv
.
text
=
"取消收藏"
}
else
{
share_collect_img
.
setImageResource
(
R
.
drawable
.
collect
)
share_collect_tv
.
text
=
"收藏"
drawable
=
resources
.
getDrawable
(
R
.
drawable
.
collect
)
favorite_tv
.
text
=
"收藏"
}
drawable
.
setBounds
(
0
,
0
,
drawable
.
minimumWidth
,
drawable
.
minimumHeight
)
favorite_tv
.
setCompoundDrawables
(
null
,
drawable
,
null
,
null
)
}
private
fun
queryLearnArticle
()
{
mLearningCenterPresenter
?.
requestQueryLearnArticle
(
mActivityType
.
toInt
(),
mArticleId
)
}
private
fun
saveUserReadLearnArticle
()
{
mLearningCenterPresenter
?.
requestSaveUserReadLearnArticle
(
mArticleId
,
mActivityType
.
toInt
())
}
/**
* 收藏-取消收藏学习文章
* 1-收藏,2-取消收藏
*/
private
fun
updateUserStoreLearnArticle
()
{
var
type
=
ConstantParams
.
CONSTANT_STARTS_1
if
(
mIsFavoriteArticle
)
{
type
=
ConstantParams
.
CONSTANT_STARTS_2
}
mLearningCenterPresenter
?.
requestUpdateUserStoreLearnArticle
(
mArticleId
,
mActivityType
.
toInt
(),
type
)
}
/**
* 分享成功 埋点
* type 0:分享到朋友圈,1:分享给朋友 2:企业微信
*/
private
fun
articleBuryPoint
(
type
:
Int
)
{
val
param
=
HashMap
<
String
,
String
>()
param
[
"staffId"
]
=
SystemHelper
.
LoginUserId
param
[
"shopId"
]
=
SystemHelper
.
LoginOrganId
param
[
"type"
]
=
type
.
toString
()
param
[
"articleId"
]
=
mArticleId
param
[
"articleTitle"
]
=
mTitle
OkHttpDominator
.
postAsyn
(
NetParam
.
YINXIAOBU_SERVER
+
ApiUrls
.
APPSALER
.
MESSAGE_ARTICLE_BURYPOINT
,
param
,
object
:
OkHttpDominator
.
ResultCallback
<
BaseSimpleResponse
?
>()
{
override
fun
onError
(
request
:
Request
,
e
:
Exception
)
{}
override
fun
onResponse
(
response
:
BaseSimpleResponse
?)
{}
})
}
override
fun
learnArticleDetailData
(
data
:
LearnArticleDetailEntity
?)
{
data
?.
let
{
if
(
ConstantParams
.
CONSTANT_PARAMS_1
==
mActivityType
)
{
//学习中心
read_num_tv
.
text
=
StringUtil
.
formatString
(
getString
(
R
.
string
.
learning_center_read_num
),
it
.
readTimesCount
+
1
)
}
showViewForIsFavorite
(
it
.
isStore
)
var
bottomHeight
=
-
1
if
(
it
.
isNeedTest
&&
it
.
testLink
.
notNullAndEmpty
())
{
exam_tv
.
visibility
=
View
.
VISIBLE
bottomHeight
=
DensityUtil
.
dip2px
(
mContext
,
60f
)
}
else
{
exam_tv
.
visibility
=
View
.
GONE
}
val
htmlFragment
=
HtmlFragment
()
val
htmlBundle
=
Bundle
()
htmlBundle
.
putString
(
"branchUrl"
,
mUrl
)
htmlBundle
.
putInt
(
"bottomHeight"
,
bottomHeight
)
htmlFragment
.
arguments
=
htmlBundle
supportFragmentManager
.
beginTransaction
()
.
add
(
R
.
id
.
learning_detail_container_fl
,
htmlFragment
).
commit
()
}
this
.
mLearnArticleDetailEntity
=
data
}
override
fun
saveUserReadLearnArticle
(
status
:
Boolean
)
{
}
override
fun
updateUserStoreLearnArticle
(
status
:
Boolean
)
{
if
(
status
)
{
showViewForIsFavorite
(!
mIsFavoriteArticle
)
}
}
override
fun
back
()
{
val
fragment
=
supportFragmentManager
.
findFragmentById
(
R
.
id
.
learning_detail_container_fl
)
as
HtmlFragment
?
fragment
?.
back
()
}
override
fun
close
()
{
finish
()
}
override
fun
addPresenter
():
BasePresenter
{
mLearningCenterPresenter
=
LearningCenterPresenter
(
this
)
return
mLearningCenterPresenter
!!
}
override
fun
onKeyDown
(
keyCode
:
Int
,
event
:
KeyEvent
):
Boolean
{
if
(
event
.
action
==
KeyEvent
.
ACTION_DOWN
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
back
()
return
true
}
}
return
super
.
onKeyDown
(
keyCode
,
event
)
}
override
fun
changeTitle
(
title
:
String
?)
{
if
(
title
.
notNullAndEmpty
())
{
titleTextView
.
text
=
title
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/LearningCenterListActivity.java
+
396
-
396
View file @
52a16288
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/LearningCenterListActivity.kt
0 → 100644
+
207
-
0
View file @
52a16288
package
com.urovo.activity.learning
import
android.content.Intent
import
android.graphics.Color
import
android.view.ViewGroup
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.urovo.activity.learning.model.LearnArticleEntity
import
com.urovo.activity.learning.model.LearnArticleRequest
import
com.urovo.activity.learning.presenter.LearningCenterContract
import
com.urovo.activity.learning.presenter.LearningCenterPresenter
import
com.urovo.activity.learning.view.adapter.LearningCenterListAdapter
import
com.urovo.wugumofang.R
import
com.urovo.wugumofang.base.BaseActivity
import
com.urovo.wugumofang.base.BasePresenter
import
com.urovo.wugumofang.constants.AppConstants
import
com.urovo.wugumofang.constants.ConstantParams
import
com.urovo.wugumofang.system.SystemHelper
import
com.urovo.wugumofang.utils.isNotNullOrSize
import
com.urovo.wugumofang.utils.isNullOrEmpty
import
com.urovo.wugumofang.view.DividerItemDecoration
import
com.urovo.wugumofang.view.LoadWaitDominator
import
kotlinx.android.synthetic.main.activity_learning_center_menu_new.*
import
kotlinx.android.synthetic.main.public_page_list_content_view.*
/**
* 文章列表、收藏列表
* @author LW
*/
class
LearningCenterListActivity
:
BaseActivity
(),
LearningCenterContract
.
IView
{
private
var
mLearningCenterPresenter
:
LearningCenterPresenter
?
=
null
private
var
mLearningCenterListAdapter
:
LearningCenterListAdapter
?
=
null
private
var
mLearnArticleList
:
MutableList
<
LearnArticleEntity
.
LearnArticleBean
>
=
mutableListOf
()
private
val
mPid
:
Int
by
lazy
{
intent
.
getIntExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_PID
,
-
1
)
}
private
val
mTitle
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_TITLE
)
}
private
val
mIsCollect
:
Boolean
by
lazy
{
intent
.
getBooleanExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_COLLECT
,
false
)
}
private
val
mActivityType
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
)
?:
ConstantParams
.
CONSTANT_PARAMS_1
}
private
var
mNextPage
:
Int
=
1
override
fun
addRootLayoutId
():
Int
=
R
.
layout
.
activity_learning_center_menu_new
override
fun
rootViewGroup
():
ViewGroup
=
public_container_fl
override
fun
initTitle
()
{
super
.
initTitle
()
titleTextView
.
text
=
if
(
mIsCollect
)
getString
(
R
.
string
.
learning_center_my_collect
)
else
mTitle
}
override
fun
initViewNew
()
{
initTitle
()
mLearningCenterListAdapter
=
LearningCenterListAdapter
(
mLearnArticleList
,
mIsCollect
)
public_list_view_rv
.
apply
{
layoutManager
=
LinearLayoutManager
(
mContext
)
addItemDecoration
(
DividerItemDecoration
(
this
@LearningCenterListActivity
,
DividerItemDecoration
.
HORIZONTAL_LIST
,
1
,
Color
.
parseColor
(
"#E3E7EE"
)
)
)
adapter
=
mLearningCenterListAdapter
}
mLearningCenterListAdapter
?.
setOnItemClickListener
{
adapter
,
view
,
position
->
val
item
=
adapter
.
getItem
(
position
)
as
LearnArticleEntity
.
LearnArticleBean
val
intent
=
Intent
(
mContext
,
LearningCenterDetailActivity
::
class
.
java
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_TITLE
,
item
.
title
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_URL
,
item
.
externalLink
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_IS_NEED_TEST
,
item
.
isNeedTest
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_TEST_LINK
,
item
.
testLink
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_ARTICLE_ID
,
item
.
articleId
)
if
(
mIsCollect
)
{
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
IS_FAVORITED_ARTICLE
,
true
)
}
else
{
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
IS_FAVORITED_ARTICLE
,
item
.
isStore
)
if
(
position
>=
0
&&
position
<
mLearnArticleList
.
size
)
{
mLearnArticleList
.
get
(
position
).
isRead
=
true
mLearningCenterListAdapter
?.
notifyItemChanged
(
position
)
}
}
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ARTICLE_READ_TIMES_COUNT
,
item
.
readTimesCount
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
,
mActivityType
)
startActivity
(
intent
)
}
public_refresh_view
.
apply
{
//刷新
setOnRefreshListener
{
queryLearnArticlePageList
(
1
)
}
//加载更多
setOnLoadMoreListener
{
queryLearnArticlePageList
(
mNextPage
)
}
}
learning_center_menu_archive_fab
.
setOnClickListener
{
startActivity
(
Intent
(
mContext
,
ExamArchiveListActivity
::
class
.
java
))
}
learning_center_menu_search_fab
.
setOnClickListener
{
startActivity
(
Intent
(
mContext
,
LearningCenterSearchActivity
::
class
.
java
).
apply
{
putExtra
(
AppConstants
.
ExtraKeys
.
ARTICLE_SEARCH_TYPE
,
mActivityType
)
flags
=
Intent
.
FLAG_ACTIVITY_NO_ANIMATION
})
}
learning_center_menu_search_fab
.
attachToRecyclerView
(
public_list_view_rv
)
public_refresh_view
.
autoRefresh
()
}
private
fun
queryLearnArticlePageList
(
page
:
Int
)
{
val
staffId
=
SystemHelper
.
LoginUserId
if
(
staffId
.
isNullOrEmpty
())
{
showError
(
R
.
string
.
common_load_error
)
return
}
val
request
=
if
(
mIsCollect
)
{
LearnArticleRequest
(
mActivityType
,
staffId
,
isUserStore
=
true
,
page
=
page
)
}
else
{
LearnArticleRequest
(
mActivityType
,
staffId
,
categoryIds
=
mPid
.
toString
(),
page
=
page
)
}
mLearningCenterPresenter
?.
requestQueryLearnArticlePageList
(
request
)
}
override
fun
addPresenter
():
BasePresenter
{
mLearningCenterPresenter
=
LearningCenterPresenter
(
this
)
return
mLearningCenterPresenter
!!
}
override
fun
learnArticlePageListData
(
pageData
:
LearnArticleEntity
?)
{
if
(
pageData
==
null
||
pageData
.
pages
==
ConstantParams
.
CONSTANT_STARTS_0
)
{
showState
(
LoadWaitDominator
.
NO_DATA
)
return
}
pageData
.
let
{
if
(
it
.
page
<=
it
.
pages
)
{
if
(
it
.
page
==
ConstantParams
.
CONSTANT_STARTS_1
)
{
refreshDataToView
(
it
.
data
)
}
else
{
loadMoreDateToView
(
it
.
data
)
}
this
.
mNextPage
=
it
.
page
+
1
}
else
{
public_refresh_view
.
resetNoMoreData
()
}
}
}
override
fun
learnArticleStatus
(
status
:
Boolean
)
{
public_refresh_view
?.
apply
{
finishRefresh
()
finishLoadMore
()
}
}
/**
* 刷新数据更新到View
*/
private
fun
refreshDataToView
(
list
:
List
<
LearnArticleEntity
.
LearnArticleBean
>?)
{
if
(
list
.
isNotNullOrSize
())
{
mLearnArticleList
.
clear
()
mLearnArticleList
.
addAll
(
list
!!
)
mLearningCenterListAdapter
?.
notifyDataSetChanged
()
}
else
{
showState
(
LoadWaitDominator
.
NO_DATA
)
}
}
/**
* 读取更多数据更新到View
*/
private
fun
loadMoreDateToView
(
list
:
List
<
LearnArticleEntity
.
LearnArticleBean
>?)
{
if
(
list
.
isNotNullOrSize
())
{
val
position
=
mLearnArticleList
.
size
mLearnArticleList
.
addAll
(
list
!!
)
mLearningCenterListAdapter
?.
notifyItemInserted
(
position
)
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/LearningCenterMenuActivity.java
+
268
-
266
View file @
52a16288
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/LearningCenterMenuActivity.kt
0 → 100644
+
219
-
0
View file @
52a16288
package
com.urovo.activity.learning
import
android.content.Intent
import
android.view.View
import
android.view.ViewGroup
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.urovo.activity.learning.model.LearnArticleCategoryEntity
import
com.urovo.activity.learning.model.LearnArticleCategoryRequest
import
com.urovo.activity.learning.model.LearnArticleEntity
import
com.urovo.activity.learning.model.LearnArticleRequest
import
com.urovo.activity.learning.presenter.LearningCenterContract
import
com.urovo.activity.learning.presenter.LearningCenterPresenter
import
com.urovo.activity.learning.view.adapter.LearningCenterMenuAdapter
import
com.urovo.wugumofang.R
import
com.urovo.wugumofang.base.BaseActivity
import
com.urovo.wugumofang.base.BasePresenter
import
com.urovo.wugumofang.constants.AppConstants
import
com.urovo.wugumofang.constants.ConstantParams
import
com.urovo.wugumofang.system.SystemHelper
import
com.urovo.wugumofang.ui.SpacesItemDecoration
import
com.urovo.wugumofang.utils.StringUtil
import
com.urovo.wugumofang.utils.isNotNullOrSize
import
com.urovo.wugumofang.utils.isNullOrEmpty
import
com.urovo.wugumofang.utils.notNullAndEmpty
import
com.urovo.wugumofang.view.LoadWaitDominator
import
kotlinx.android.synthetic.main.activity_learning_center_menu_new.*
import
kotlinx.android.synthetic.main.public_page_list_content_view.*
/**
* 学习中心、养生文库目录
* @author LW
*/
class
LearningCenterMenuActivity
:
BaseActivity
(),
LearningCenterContract
.
IView
{
private
var
mLearningCenterPresenter
:
LearningCenterPresenter
?
=
null
private
var
mLearningCenterMenuAdapter
:
LearningCenterMenuAdapter
?
=
null
private
var
mLearnArticleCategoryList
:
MutableList
<
LearnArticleCategoryEntity
.
LearnArticleCategoryBean
>
=
mutableListOf
()
private
val
mActivityType
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
)
?:
ConstantParams
.
CONSTANT_PARAMS_1
}
private
val
mPid
:
Int
by
lazy
{
intent
.
getIntExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_PID
,
-
1
)
}
private
val
mTitle
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_TITLE
)
}
private
var
mNextPage
:
Int
=
1
override
fun
addRootLayoutId
():
Int
=
R
.
layout
.
activity_learning_center_menu_new
override
fun
rootViewGroup
():
ViewGroup
=
public_container_fl
override
fun
initTitle
()
{
super
.
initTitle
()
if
(
mTitle
.
notNullAndEmpty
())
{
titleTextView
.
text
=
mTitle
}
else
{
titleTextView
.
text
=
if
(
ConstantParams
.
CONSTANT_PARAMS_1
.
equals
(
mActivityType
))
getString
(
R
.
string
.
learning_center_menu
)
else
getString
(
R
.
string
.
health_library_menu
)
}
submit
.
visibility
=
View
.
VISIBLE
submit
.
textSize
=
14f
submit
.
setOnClickListener
{
startActivity
(
Intent
(
mContext
,
LearningCenterListActivity
::
class
.
java
).
apply
{
putExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
,
mActivityType
)
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_COLLECT
,
true
)
})
}
}
override
fun
initViewNew
()
{
initTitle
()
mLearningCenterMenuAdapter
=
LearningCenterMenuAdapter
(
mLearnArticleCategoryList
)
public_list_view_rv
.
apply
{
layoutManager
=
LinearLayoutManager
(
mContext
)
adapter
=
mLearningCenterMenuAdapter
addItemDecoration
(
SpacesItemDecoration
(
20
,
adapter
!!
.
itemCount
,
false
))
}
mLearningCenterMenuAdapter
?.
setOnItemClickListener
{
adapter
,
view
,
position
->
val
item
=
adapter
.
getItem
(
position
)
as
LearnArticleCategoryEntity
.
LearnArticleCategoryBean
val
intent
=
Intent
()
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
,
mActivityType
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_TITLE
,
item
.
name
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_PID
,
item
.
id
)
if
(
item
.
isHaveChildren
)
{
//如果有二级目录
intent
.
setClass
(
mContext
,
LearningCenterMenuActivity
::
class
.
java
)
//二级目录专门界面
}
else
{
//如果没有二级目录
intent
.
setClass
(
mContext
,
LearningCenterListActivity
::
class
.
java
)
//普通文章列表
}
startActivity
(
intent
)
}
public_refresh_view
.
apply
{
//刷新
setOnRefreshListener
{
queryLearnArticleCategoryPageList
(
1
)
}
//加载更多
setOnLoadMoreListener
{
queryLearnArticleCategoryPageList
(
mNextPage
)
}
}
learning_center_menu_archive_fab
.
setOnClickListener
{
startActivity
(
Intent
(
mContext
,
ExamArchiveListActivity
::
class
.
java
))
}
learning_center_menu_search_fab
.
setOnClickListener
{
startActivity
(
Intent
(
mContext
,
LearningCenterSearchActivity
::
class
.
java
).
apply
{
putExtra
(
AppConstants
.
ExtraKeys
.
ARTICLE_SEARCH_TYPE
,
mActivityType
)
flags
=
Intent
.
FLAG_ACTIVITY_NO_ANIMATION
})
}
learning_center_menu_search_fab
.
attachToRecyclerView
(
public_list_view_rv
)
public_refresh_view
.
autoRefresh
()
queryLearnArticlePageList
()
}
private
fun
queryLearnArticleCategoryPageList
(
page
:
Int
)
{
val
pid
=
if
(
mPid
==
-
1
)
null
else
mPid
val
request
=
LearnArticleCategoryRequest
(
mActivityType
,
pid
,
page
=
page
)
mLearningCenterPresenter
?.
requestLearnArticleCategoryPageList
(
request
)
}
private
fun
queryLearnArticlePageList
()
{
val
staffId
=
SystemHelper
.
LoginUserId
if
(
staffId
.
isNullOrEmpty
())
{
showError
(
R
.
string
.
common_load_error
)
return
}
val
request
=
LearnArticleRequest
(
mActivityType
,
staffId
,
""
,
""
,
true
)
mLearningCenterPresenter
?.
requestQueryLearnArticlePageList
(
request
)
}
override
fun
addPresenter
():
BasePresenter
{
mLearningCenterPresenter
=
LearningCenterPresenter
(
this
)
return
mLearningCenterPresenter
!!
}
override
fun
learnArticleCategoryPageListData
(
pageData
:
LearnArticleCategoryEntity
?)
{
if
(
pageData
==
null
||
pageData
.
pages
==
ConstantParams
.
CONSTANT_STARTS_0
)
{
showState
(
LoadWaitDominator
.
NO_DATA
)
return
}
pageData
.
let
{
if
(
it
.
page
<=
it
.
pages
)
{
if
(
it
.
page
==
ConstantParams
.
CONSTANT_STARTS_1
)
{
refreshDataToView
(
it
.
data
)
}
else
{
loadMoreDateToView
(
it
.
data
)
}
this
.
mNextPage
=
it
.
page
+
1
}
else
{
public_refresh_view
.
resetNoMoreData
()
}
}
}
override
fun
learnArticleCategoryStatus
(
status
:
Boolean
)
{
public_refresh_view
?.
apply
{
finishRefresh
()
finishLoadMore
()
}
}
override
fun
learnArticlePageListData
(
pageData
:
LearnArticleEntity
?)
{
pageData
?.
let
{
val
total
=
it
.
total
submit
.
text
=
StringUtil
.
formatString
(
getString
(
R
.
string
.
learning_center_collect_count
),
total
)
}
}
override
fun
learnArticleStatus
(
status
:
Boolean
)
{
}
/**
* 刷新数据更新到View
*/
private
fun
refreshDataToView
(
list
:
List
<
LearnArticleCategoryEntity
.
LearnArticleCategoryBean
>?)
{
if
(
list
.
isNotNullOrSize
())
{
mLearnArticleCategoryList
.
clear
()
mLearnArticleCategoryList
.
addAll
(
list
!!
)
mLearningCenterMenuAdapter
?.
notifyDataSetChanged
()
}
else
{
showState
(
LoadWaitDominator
.
NO_DATA
)
}
}
/**
* 读取更多数据更新到View
*/
private
fun
loadMoreDateToView
(
list
:
List
<
LearnArticleCategoryEntity
.
LearnArticleCategoryBean
>?)
{
if
(
list
.
isNotNullOrSize
())
{
val
position
=
mLearnArticleCategoryList
.
size
mLearnArticleCategoryList
.
addAll
(
list
!!
)
mLearningCenterMenuAdapter
?.
notifyItemInserted
(
position
)
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/com/urovo/activity/learning/LearningCenterSearchActivity.kt
0 → 100644
+
229
-
0
View file @
52a16288
package
com.urovo.activity.learning
import
android.content.Intent
import
android.graphics.Color
import
android.view.KeyEvent
import
android.view.ViewGroup
import
android.view.animation.AnimationUtils
import
android.view.inputmethod.InputMethodManager
import
android.widget.EditText
import
android.widget.ImageButton
import
android.widget.RelativeLayout
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.urovo.activity.learning.model.LearnArticleEntity
import
com.urovo.activity.learning.model.LearnArticleRequest
import
com.urovo.activity.learning.presenter.LearningCenterContract
import
com.urovo.activity.learning.presenter.LearningCenterPresenter
import
com.urovo.activity.learning.view.adapter.LearningCenterSearchAdapter
import
com.urovo.wugumofang.R
import
com.urovo.wugumofang.base.BaseActivity
import
com.urovo.wugumofang.base.BasePresenter
import
com.urovo.wugumofang.constants.AppConstants
import
com.urovo.wugumofang.constants.ConstantParams
import
com.urovo.wugumofang.system.CountDownDominator
import
com.urovo.wugumofang.system.CountDownDominator.CountDownCallback
import
com.urovo.wugumofang.system.SystemHelper
import
com.urovo.wugumofang.utils.isNotNullOrSize
import
com.urovo.wugumofang.utils.isNullOrEmpty
import
com.urovo.wugumofang.utils.textChanged
import
com.urovo.wugumofang.view.DividerItemDecoration
import
kotlinx.android.synthetic.main.public_page_list_content_view.*
import
java.util.*
/**
* 文章、收藏搜索页面
* @author LW
*/
class
LearningCenterSearchActivity
:
BaseActivity
(),
LearningCenterContract
.
IView
{
private
var
mLearningCenterPresenter
:
LearningCenterPresenter
?
=
null
private
var
mLearningCenterSearchAdapter
:
LearningCenterSearchAdapter
?
=
null
private
var
mLearnArticleList
:
MutableList
<
LearnArticleEntity
.
LearnArticleBean
>
=
mutableListOf
()
private
val
mActivityType
:
String
by
lazy
{
intent
.
getStringExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
)
?:
ConstantParams
.
CONSTANT_PARAMS_1
}
private
var
mNextPage
:
Int
=
1
private
val
SEARCH_PERIOD
:
Long
=
(
1
*
1000
//输入完成后过多少秒自动执行搜索
).
toLong
()
private
var
mAutoTimer
//用来在输入框发生改变时,自动倒数进行刷新的装置。
:
Timer
?
=
null
private
var
mKeyWord
:
String
=
""
private
var
mSearchInputEt
:
EditText
?
=
null
private
var
mCountDownDominator
:
CountDownDominator
?
=
null
override
fun
addRootLayoutId
():
Int
=
R
.
layout
.
activity_learning_center_search
override
fun
rootViewGroup
():
ViewGroup
=
public_container_fl
override
fun
initViewNew
()
{
mLearningCenterSearchAdapter
=
LearningCenterSearchAdapter
(
mLearnArticleList
)
public_list_view_rv
.
apply
{
layoutManager
=
LinearLayoutManager
(
mContext
)
addItemDecoration
(
DividerItemDecoration
(
mContext
,
DividerItemDecoration
.
HORIZONTAL_LIST
,
1
,
Color
.
parseColor
(
"#E3E7EE"
)
)
)
adapter
=
mLearningCenterSearchAdapter
}
mLearningCenterSearchAdapter
?.
setOnItemClickListener
{
adapter
,
view
,
position
->
val
item
=
adapter
.
getItem
(
position
)
as
LearnArticleEntity
.
LearnArticleBean
val
intent
=
Intent
(
mContext
,
LearningCenterDetailActivity
::
class
.
java
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_TITLE
,
item
.
title
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_URL
,
item
.
externalLink
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_IS_NEED_TEST
,
item
.
isNeedTest
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_TEST_LINK
,
item
.
testLink
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
LEARNING_ARTICLE_ID
,
item
.
articleId
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ARTICLE_READ_TIMES_COUNT
,
item
.
readTimesCount
)
intent
.
putExtra
(
AppConstants
.
ExtraKeys
.
ACTIVITY_TYPE
,
mActivityType
)
startActivity
(
intent
)
}
public_refresh_view
.
apply
{
//刷新
setOnRefreshListener
{
queryLearnArticlePageList
(
1
)
}
//加载更多
setOnLoadMoreListener
{
queryLearnArticlePageList
(
mNextPage
)
}
}
//搜索框从右至左滑动的动画
findViewById
<
RelativeLayout
>(
R
.
id
.
search_anim_view
).
startAnimation
(
AnimationUtils
.
loadAnimation
(
this
,
R
.
anim
.
searchbar_right_in
)
)
//构造自动搜索
mAutoTimer
=
Timer
()
mCountDownDominator
=
CountDownDominator
(
this
,
object
:
CountDownCallback
{
override
fun
doWorkWhenTimeUp
(
tag
:
Int
)
{
queryLearnArticlePageList
(
1
)
}
})
mCountDownDominator
?.
build
(
mAutoTimer
)
//普通的左上角返回退出
findViewById
<
ImageButton
>(
R
.
id
.
search_back
).
setOnClickListener
{
finish
()
}
//输入框文字改变监听
mSearchInputEt
=
findViewById
(
R
.
id
.
search_input
)
mSearchInputEt
?.
textChanged
{
this
.
mKeyWord
=
it
?.
toString
()
?:
""
if
(
mAutoTimer
==
null
)
{
mAutoTimer
=
Timer
()
}
mCountDownDominator
?.
start
(
SEARCH_PERIOD
)
}
//键盘回车搜索
mSearchInputEt
?.
setOnKeyListener
{
v
,
keyCode
,
event
->
//因为DOWN和UP事件都是KEYCODE_ENTER事件,所以会触发两次,所以必须加一道判断ACTION_UP
if
(
keyCode
==
KeyEvent
.
KEYCODE_ENTER
&&
event
.
action
==
KeyEvent
.
ACTION_UP
)
{
hideKeyboard
()
this
.
mKeyWord
=
mSearchInputEt
?.
text
.
toString
()
queryLearnArticlePageList
(
1
)
mCountDownDominator
?.
cancel
()
//取消计时
}
false
}
}
private
fun
queryLearnArticlePageList
(
page
:
Int
)
{
val
staffId
=
SystemHelper
.
LoginUserId
if
(
staffId
.
isNullOrEmpty
())
{
showError
(
R
.
string
.
common_load_error
)
return
}
val
request
=
LearnArticleRequest
(
mActivityType
,
staffId
,
title
=
mKeyWord
,
page
=
page
)
mLearningCenterPresenter
?.
requestQueryLearnArticlePageList
(
request
)
}
/***
* 隐藏键盘
*/
private
fun
hideKeyboard
()
{
val
imm
=
getSystemService
(
INPUT_METHOD_SERVICE
)
as
InputMethodManager
imm
.
showSoftInput
(
mSearchInputEt
,
InputMethodManager
.
SHOW_FORCED
)
imm
.
hideSoftInputFromWindow
(
mSearchInputEt
?.
windowToken
,
0
)
//强制隐藏键盘
}
override
fun
addPresenter
():
BasePresenter
{
mLearningCenterPresenter
=
LearningCenterPresenter
(
this
)
return
mLearningCenterPresenter
!!
}
override
fun
learnArticlePageListData
(
pageData
:
LearnArticleEntity
?)
{
if
(
pageData
==
null
||
pageData
.
pages
==
ConstantParams
.
CONSTANT_STARTS_0
)
{
showNoData
(
R
.
string
.
learning_center_search_entry_tip
)
return
}
mLearningCenterSearchAdapter
?.
setSearchKeyWord
(
mKeyWord
)
pageData
.
let
{
if
(
it
.
page
<=
it
.
pages
)
{
if
(
it
.
page
==
ConstantParams
.
CONSTANT_STARTS_1
)
{
refreshDataToView
(
it
.
data
)
}
else
{
loadMoreDateToView
(
it
.
data
)
}
this
.
mNextPage
=
it
.
page
+
1
}
else
{
public_refresh_view
.
resetNoMoreData
()
}
}
}
override
fun
learnArticleStatus
(
status
:
Boolean
)
{
public_refresh_view
?.
apply
{
finishRefresh
()
finishLoadMore
()
}
}
/**
* 刷新数据更新到View
*/
private
fun
refreshDataToView
(
list
:
List
<
LearnArticleEntity
.
LearnArticleBean
>?)
{
if
(
list
.
isNotNullOrSize
())
{
mLearnArticleList
.
clear
()
mLearnArticleList
.
addAll
(
list
!!
)
mLearningCenterSearchAdapter
?.
notifyDataSetChanged
()
}
else
{
showNoData
(
R
.
string
.
learning_center_search_entry_tip
)
}
}
/**
* 读取更多数据更新到View
*/
private
fun
loadMoreDateToView
(
list
:
List
<
LearnArticleEntity
.
LearnArticleBean
>?)
{
if
(
list
.
isNotNullOrSize
())
{
val
position
=
mLearnArticleList
.
size
mLearnArticleList
.
addAll
(
list
!!
)
mLearningCenterSearchAdapter
?.
notifyItemInserted
(
position
)
}
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
if
(
mAutoTimer
!=
null
)
{
mAutoTimer
?.
cancel
()
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help