Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
e8cc0c4c
Commit
e8cc0c4c
authored
May 13, 2021
by
宋永孟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 更新首页
parent
2a81ff52
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
334 additions
and
28 deletions
+334
-28
XRouterPathConstants.kt
...n/src/main/java/com/yidian/common/XRouterPathConstants.kt
+1
-0
ScrollViewPager.kt
.../main/java/com/yidian/common/ui/widget/ScrollViewPager.kt
+39
-0
ToolsUtil.kt
...Common/src/main/java/com/yidian/common/utils/ToolsUtil.kt
+5
-0
AndroidManifest.xml
Components/newscontent/src/main/AndroidManifest.xml
+9
-5
ViewPagerAdapter.kt
...dian/shenghuoquan/newscontent/adapter/ViewPagerAdapter.kt
+13
-0
NewsContentApplication.kt
...an/shenghuoquan/newscontent/app/NewsContentApplication.kt
+39
-21
FlashActivity.kt
...a/com/yidian/shenghuoquan/newscontent/ui/FlashActivity.kt
+1
-1
HomeActivity.kt
...va/com/yidian/shenghuoquan/newscontent/ui/HomeActivity.kt
+149
-0
BadgeUtils.kt
...a/com/yidian/shenghuoquan/newscontent/utils/BadgeUtils.kt
+58
-0
activity_home_layout.xml
.../newscontent/src/main/res/layout/activity_home_layout.xml
+19
-0
styles.xml
app/src/main/res/values/styles.xml
+1
-1
No files found.
CommonLib/Common/src/main/java/com/yidian/common/XRouterPathConstants.kt
View file @
e8cc0c4c
...
...
@@ -10,6 +10,7 @@ class XRouterPathConstants {
const
val
LOGIN_NATIVE
=
"/loginNative"
const
val
USER_INFO
=
"/fragment/userInfo"
const
val
NEWS_MAIN
=
"/MainActivity"
const
val
HOME
=
"/Home"
const
val
NEWS_CONTENT
=
"/news"
const
val
GALLERY
=
"/imageGallery"
const
val
PROTOCOL
=
"/protocol"
...
...
CommonLib/Common/src/main/java/com/yidian/common/ui/widget/ScrollViewPager.kt
0 → 100644
View file @
e8cc0c4c
package
com.yidian.common.ui.widget
import
android.content.Context
import
android.util.AttributeSet
import
android.view.MotionEvent
import
androidx.viewpager.widget.ViewPager
/**
* @version : 1.0
* @date : 2019-11-19 19:20
* @depiction : 可设置是否滑动的ViewPager
*/
class
ScrollViewPager
:
ViewPager
{
constructor
(
context
:
Context
)
:
super
(
context
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
?)
:
super
(
context
,
attrs
)
private
var
scrollable
=
false
fun
setScrollable
(
isScrollable
:
Boolean
)
{
scrollable
=
isScrollable
}
override
fun
onInterceptTouchEvent
(
ev
:
MotionEvent
?):
Boolean
{
return
if
(
scrollable
)
{
super
.
onInterceptTouchEvent
(
ev
)
}
else
{
scrollable
}
}
override
fun
onTouchEvent
(
ev
:
MotionEvent
?):
Boolean
{
return
if
(
scrollable
)
{
super
.
onTouchEvent
(
ev
)
}
else
{
scrollable
}
}
}
\ No newline at end of file
CommonLib/Common/src/main/java/com/yidian/common/utils/ToolsUtil.kt
View file @
e8cc0c4c
...
...
@@ -2,6 +2,7 @@ package com.yidian.common.utils
import
android.content.Context
import
android.os.Build
import
android.util.DisplayMetrics
import
android.util.Log
import
android.util.TypedValue
import
com.google.gson.Gson
...
...
@@ -53,6 +54,10 @@ object ToolsUtil {
).
toInt
()
}
fun
dp2px
(
dpValue
:
Float
):
Int
{
return
TypedValue
.
applyDimension
(
1
,
dpValue
,
DisplayMetrics
()).
toInt
()
}
//格式化展示
fun
formatShowNum
(
count
:
Int
):
String
{
var
showCount
=
count
.
toString
()
...
...
Components/newscontent/src/main/AndroidManifest.xml
View file @
e8cc0c4c
...
...
@@ -3,7 +3,7 @@
package=
"com.yidian.shenghuoquan.newscontent"
>
<application>
<activity
android:name=
".ui.CommonDetailActivity"
/>
<activity
android:name=
".ui.CommonDetailActivity"
/>
<activity
android:name=
".ui.FlashActivity"
android:theme=
"@style/FlashTheme"
>
...
...
@@ -16,11 +16,14 @@
</activity>
<activity
android:name=
".ui.MainActivity"
android:launchMode=
"singleTask"
/>
android:launchMode=
"singleTask"
/>
<activity
android:name=
".ui.DeepLinkActivity"
>
android:name=
".ui.HomeActivity"
android:launchMode=
"singleTask"
/>
<activity
android:name=
".ui.DeepLinkActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<category
android:name=
"android.intent.category.BROWSABLE"
/>
...
...
@@ -29,8 +32,9 @@
android:scheme=
"ydsubway"
/>
</intent-filter>
</activity>
<activity
android:name=
".ui.NewsContentActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
/>
<activity
android:name=
".ui.NewsContentActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
/>
<activity
android:name=
".ui.author.AuthorHomePageActivity"
/>
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/adapter/ViewPagerAdapter.kt
0 → 100755
View file @
e8cc0c4c
package
com.yidian.shenghuoquan.newscontent.adapter
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.FragmentManager
import
androidx.fragment.app.FragmentPagerAdapter
class
ViewPagerAdapter
(
fragmentManager
:
FragmentManager
,
private
val
fragments
:
List
<
Fragment
>)
:
FragmentPagerAdapter
(
fragmentManager
,
BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
)
{
override
fun
getItem
(
index
:
Int
):
Fragment
=
fragments
[
index
]
override
fun
getCount
():
Int
=
fragments
.
size
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/app/NewsContentApplication.kt
View file @
e8cc0c4c
This diff is collapsed.
Click to expand it.
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/FlashActivity.kt
View file @
e8cc0c4c
...
...
@@ -57,7 +57,7 @@ class FlashActivity: BaseActivity<ActivityFlashBinding>() {
val
isAgree
=
Hawk
.
get
<
Boolean
>(
HawkConfig
.
ProtocolIsAgree
,
false
)
if
(
isAgree
){
viewBind
.
clRoot
.
postDelayed
(
{
XPageManager
.
push
(
XRouterPathConstants
.
NEWS_MAIN
,
paramsMap
)
XPageManager
.
push
(
XRouterPathConstants
.
HOME
,
paramsMap
)
finish
()
},
2000
)
}
else
{
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/HomeActivity.kt
0 → 100644
View file @
e8cc0c4c
package
com.yidian.shenghuoquan.newscontent.ui
import
android.os.Bundle
import
android.view.MenuItem
import
androidx.core.view.forEach
import
androidx.core.view.get
import
androidx.fragment.app.Fragment
import
androidx.viewpager.widget.ViewPager
import
com.google.android.material.bottomnavigation.LabelVisibilityMode
import
com.yidian.common.XRouterPathConstants
import
com.yidian.common.base.BaseActivity
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.adapter.ViewPagerAdapter
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityHomeLayoutBinding
import
com.yidian.shenghuoquan.newscontent.ui.search.SearchFragment
import
com.yidian.shenghuoquan.newscontent.utils.badgeStyle
/**
* Author: sym
* Date: 2021/5/11 10:35 AM
* Describe:生活圈B端首页
*/
class
HomeActivity
:
BaseActivity
<
ActivityHomeLayoutBinding
>()
{
private
var
fragmentList
=
mutableListOf
<
Fragment
>()
var
menus
=
arrayListOf
(
"广场"
,
"求职招聘"
,
"燕郊圈"
,
"中间出角标"
,
"2出数字"
)
var
menuIcons
=
arrayListOf
<
Int
>(
R
.
drawable
.
ic_launcher_foreground
,
R
.
mipmap
.
ic_launcher_round
,
R
.
mipmap
.
ic_launcher_round
,
R
.
mipmap
.
ic_launcher_round
,
R
.
mipmap
.
ic_launcher_round
)
override
fun
createViewBinding
():
ActivityHomeLayoutBinding
{
return
ActivityHomeLayoutBinding
.
inflate
(
layoutInflater
)
}
override
fun
getXPageName
():
String
{
return
XRouterPathConstants
.
NEWS_MAIN
}
override
fun
init
(
savedInstanceState
:
Bundle
?)
{
super
.
init
(
savedInstanceState
)
initFragment
()
initView
()
initListener
()
}
private
fun
initFragment
()
{
fragmentList
.
add
(
SearchFragment
())
fragmentList
.
add
(
SearchFragment
())
fragmentList
.
add
(
SearchFragment
())
fragmentList
.
add
(
SearchFragment
())
fragmentList
.
add
(
SearchFragment
())
}
private
fun
initView
()
{
viewBind
.
viewPager
.
offscreenPageLimit
=
fragmentList
.
size
viewBind
.
viewPager
.
adapter
=
ViewPagerAdapter
(
supportFragmentManager
,
fragmentList
)
viewBind
.
viewPager
.
setScrollable
(
true
)
viewBind
.
viewPager
.
addOnPageChangeListener
(
object
:
ViewPager
.
OnPageChangeListener
{
override
fun
onPageScrolled
(
position
:
Int
,
positionOffset
:
Float
,
positionOffsetPixels
:
Int
)
{
}
override
fun
onPageSelected
(
position
:
Int
)
{
viewBind
.
navView
.
menu
.
forEach
{
viewBind
.
navView
.
menu
[
position
].
isChecked
=
true
if
(
position
==
it
.
itemId
)
{
it
.
setIcon
(
R
.
drawable
.
ic_launcher_foreground
)
if
(
it
.
itemId
==
1
)
{
viewBind
.
navView
.
getOrCreateBadge
(
1
).
clearNumber
()
viewBind
.
navView
.
getOrCreateBadge
(
1
).
isVisible
=
false
}
if
(
it
.
itemId
==
2
)
{
viewBind
.
navView
.
getOrCreateBadge
(
2
).
isVisible
=
false
}
if
(
it
.
itemId
==
3
)
{
viewBind
.
navView
.
getOrCreateBadge
(
2
).
isVisible
=
true
}
if
(
it
.
itemId
==
4
)
{
viewBind
.
navView
.
getOrCreateBadge
(
1
).
number
=
998
viewBind
.
navView
.
getOrCreateBadge
(
1
).
isVisible
=
true
}
}
else
{
it
.
setIcon
(
R
.
mipmap
.
ic_launcher_round
)
}
}
}
override
fun
onPageScrollStateChanged
(
state
:
Int
)
{
}
})
viewBind
.
navView
.
itemIconTintList
=
null
viewBind
.
navView
.
labelVisibilityMode
=
LabelVisibilityMode
.
LABEL_VISIBILITY_LABELED
;
//1 不开动画 0 动画
menus
.
forEachIndexed
{
index
,
title
->
viewBind
.
navView
.
menu
.
add
(
0
,
index
,
0
,
title
)
.
setShowAsAction
(
MenuItem
.
SHOW_AS_ACTION_IF_ROOM
)
viewBind
.
navView
.
menu
.
getItem
(
index
).
setIcon
(
menuIcons
[
index
])
}
//设置默认选中
viewBind
.
navView
.
menu
[
0
].
isChecked
=
true
addBadgeView
()
}
private
fun
initListener
()
{
viewBind
.
navView
.
setOnNavigationItemSelectedListener
{
menuItem
->
viewBind
.
navView
.
menu
.
forEach
{
if
(
it
.
itemId
==
menuItem
.
itemId
)
{
viewBind
.
viewPager
.
setCurrentItem
(
menuItem
.
itemId
,
false
)
it
.
setIcon
(
R
.
drawable
.
ic_launcher_foreground
)
if
(
it
.
itemId
==
1
)
{
viewBind
.
navView
.
getOrCreateBadge
(
1
).
clearNumber
()
viewBind
.
navView
.
getOrCreateBadge
(
1
).
isVisible
=
false
}
if
(
it
.
itemId
==
2
)
{
viewBind
.
navView
.
getOrCreateBadge
(
2
).
isVisible
=
false
}
if
(
it
.
itemId
==
3
)
{
viewBind
.
navView
.
getOrCreateBadge
(
2
).
isVisible
=
true
}
if
(
it
.
itemId
==
4
)
{
viewBind
.
navView
.
getOrCreateBadge
(
1
).
number
=
998
viewBind
.
navView
.
getOrCreateBadge
(
1
).
isVisible
=
true
}
}
else
{
it
.
setIcon
(
R
.
mipmap
.
ic_launcher_round
)
}
}
true
}
}
private
fun
addBadgeView
()
{
viewBind
.
navView
.
badgeStyle
(
1
,
null
,
android
.
R
.
color
.
holo_red_dark
)
viewBind
.
navView
.
getOrCreateBadge
(
1
).
maxCharacterCount
=
3
viewBind
.
navView
.
getOrCreateBadge
(
1
).
number
=
99
viewBind
.
navView
.
getOrCreateBadge
(
2
).
isVisible
=
true
}
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/utils/BadgeUtils.kt
0 → 100644
View file @
e8cc0c4c
package
com.yidian.shenghuoquan.newscontent.utils
import
com.google.android.material.badge.BadgeDrawable
import
com.google.android.material.bottomnavigation.BottomNavigationView
import
com.yidian.common.utils.ToolsUtil
/**
* @description: 小红点操作工具类 结合BottomNavigationView使用
* @author: huyajun
* @date: 2021/4/28
**/
class
BadgeUtils
{
// companion object {
/**
* 设置badge样式
*/
}
fun
BottomNavigationView
.
badgeStyle
(
index
:
Int
,
textColor
:
Int
?,
backgroundColor
:
Int
?)
{
getOrCreateBadge
(
index
).
horizontalOffset
=
ToolsUtil
.
dp2px
(-
10f
)
getOrCreateBadge
(
index
).
verticalOffset
=
ToolsUtil
.
dp2px
(
5f
)
textColor
?.
let
{
getOrCreateBadge
(
index
).
badgeTextColor
=
resources
.
getColor
(
it
)
}
backgroundColor
?.
let
{
getOrCreateBadge
(
index
).
backgroundColor
=
resources
.
getColor
(
it
)
}
}
/**
* 设置数字
*/
fun
setBadgeNumber
(
view
:
BottomNavigationView
,
index
:
Int
,
number
:
Int
)
{
if
(
number
==
0
)
{
removeBadge
(
view
,
index
)
}
else
{
view
.
getOrCreateBadge
(
index
).
number
=
number
}
}
/**
* 移除badge
*/
fun
removeBadge
(
view
:
BottomNavigationView
,
index
:
Int
)
{
view
.
removeBadge
(
index
)
}
fun
BottomNavigationView
.
item
(
index
:
Int
):
BadgeDrawable
{
return
getOrCreateBadge
(
index
)
}
\ No newline at end of file
Components/newscontent/src/main/res/layout/activity_home_layout.xml
0 → 100644
View file @
e8cc0c4c
<?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"
>
<com.yidian.common.ui.widget.ScrollViewPager
android:id=
"@+id/view_pager"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"10"
/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id=
"@+id/nav_view"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_weight=
"1"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
e8cc0c4c
<resources>
<!-- Base application theme. -->
<style
name=
"AppTheme"
parent=
"Theme.
AppCompat
.Light.NoActionBar"
>
<style
name=
"AppTheme"
parent=
"Theme.
MaterialComponents
.Light.NoActionBar"
>
<!-- Customize your theme here. -->
<item
name=
"colorPrimary"
>
@color/transparent
</item>
<item
name=
"colorPrimaryDark"
>
@color/transparent
</item>
...
...
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