Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
66b27522
Commit
66b27522
authored
Jun 05, 2022
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[working]navigation bar
parent
ccee9180
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
374 additions
and
1 deletion
+374
-1
mobile/build.gradle
mobile/build.gradle
+11
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+49
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
+63
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
...in/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
+70
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/SettingsFragment.java
...a/cn/garymb/ygomobile/ui/preference/SettingsFragment.java
+69
-0
mobile/src/main/res/layout/activity_home.xml
mobile/src/main/res/layout/activity_home.xml
+31
-0
mobile/src/main/res/layout/main_fragment.xml
mobile/src/main/res/layout/main_fragment.xml
+9
-0
mobile/src/main/res/layout/main_horizontal_fragment.xml
mobile/src/main/res/layout/main_horizontal_fragment.xml
+12
-0
mobile/src/main/res/layout/mycard_fragment.xml
mobile/src/main/res/layout/mycard_fragment.xml
+8
-0
mobile/src/main/res/layout/mycard_horizontal_fragment.xml
mobile/src/main/res/layout/mycard_horizontal_fragment.xml
+10
-0
mobile/src/main/res/menu/bottom_nav_menu.xml
mobile/src/main/res/menu/bottom_nav_menu.xml
+19
-0
mobile/src/main/res/menu/nav_main_menu.xml
mobile/src/main/res/menu/nav_main_menu.xml
+2
-1
mobile/src/main/res/navigation/mobile_navigation.xml
mobile/src/main/res/navigation/mobile_navigation.xml
+21
-0
No files found.
mobile/build.gradle
View file @
66b27522
...
...
@@ -99,6 +99,8 @@ dependencies {
implementation
'org.jdeferred:jdeferred-android-aar:1.2.4'
implementation
'com.github.bumptech.glide:glide:4.12.0'
implementation
'androidx.navigation:navigation-fragment:2.3.5'
implementation
'androidx.navigation:navigation-ui:2.3.5'
annotationProcessor
'com.github.bumptech.glide:compiler:4.12.0'
implementation
(
'com.github.chrisbanes.photoview:library:1.2.4'
)
{
implementation
'com.github.chrisbanes.photoview:library:1.2.4'
...
...
@@ -133,4 +135,13 @@ dependencies {
implementation
'com.bm.photoview:library:1.4.1'
//引导页库
implementation
'com.github.huburt-Hu:NewbieGuide:v2.4.4'
//androidX 版本使用下面的依赖
implementation
'com.github.xiaohaibin:XBanner:androidx_v1.2.0'
implementation
'com.android.support:multidex:1.0.3'
implementation
'com.flyco.tablayout:FlycoTabLayout_Lib:2.1.2@aar'
implementation
'com.github.jenly1314:circleprogressview:1.1.3'
implementation
'com.google.code.gson:gson:2.8.6'
implementation
"androidx.palette:palette:1.0.0"
}
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
66b27522
...
...
@@ -29,7 +29,14 @@ import android.widget.ListView;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.navigation.NavController
;
import
androidx.navigation.NavGraphNavigator
;
import
androidx.navigation.Navigation
;
import
androidx.navigation.ui.AppBarConfiguration
;
import
androidx.navigation.ui.NavigationUI
;
import
androidx.recyclerview.widget.DividerItemDecoration
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
...
...
@@ -40,6 +47,7 @@ import com.app.hubert.guide.listener.OnLayoutInflatedListener;
import
com.app.hubert.guide.model.GuidePage
;
import
com.app.hubert.guide.model.HighLight
;
import
com.app.hubert.guide.model.HighlightOptions
;
import
com.google.android.material.bottomnavigation.BottomNavigationView
;
import
com.nightonke.boommenu.BoomButtons.BoomButton
;
import
com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton
;
import
com.nightonke.boommenu.BoomMenuButton
;
...
...
@@ -107,6 +115,9 @@ public abstract class HomeActivity extends BaseActivity implements OnDuelAssista
private
CardManager
mCardManager
;
private
CardDetailRandom
mCardDetailRandom
;
private
ImageLoader
mImageLoader
;
private
NavigationUI
mNavigationUI
;
private
BottomNavigationView
.
OnNavigationItemSelectedListener
mOnItemSelectedListener
;
private
AppBarConfiguration
appBarConfiguration
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
...
@@ -152,6 +163,44 @@ public abstract class HomeActivity extends BaseActivity implements OnDuelAssista
StartMycard
();
checkNotch
();
showNewbieGuide
(
"homePage"
);
initBottomNavigationBar
();
onItemSelect
();
}
private
void
initBottomNavigationBar
()
{
Toolbar
toolbar
=
findViewById
(
R
.
id
.
toolbar
);
// 获取页面上的底部导航栏控件
BottomNavigationView
navView
=
findViewById
(
R
.
id
.
nav_view
);
// 配置navigation与底部菜单之间的联系
// 底部菜单的样式里面的item里面的ID与navigation布局里面指定的ID必须相同,否则会出现绑定失败的情况
appBarConfiguration
=
new
AppBarConfiguration
.
Builder
(
R
.
id
.
home_fragment
,
R
.
id
.
mycard_fragment
,
R
.
id
.
setting_fragment
).
build
();
// 建立fragment容器的控制器,这个容器就是页面的上的fragment容器
NavController
navController
=
Navigation
.
findNavController
(
this
,
R
.
id
.
nav_host_fragment
);
// 启动
NavigationUI
.
setupActionBarWithNavController
(
this
,
navController
,
appBarConfiguration
);
NavigationUI
.
setupWithNavController
(
navView
,
navController
);
}
//调用
private
void
onItemSelect
()
{
mOnItemSelectedListener
=
new
BottomNavigationView
.
OnNavigationItemSelectedListener
()
{
@Override
public
boolean
onNavigationItemSelected
(
@NonNull
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
case
R
.
id
.
home_fragment
:
return
true
;
case
R
.
id
.
mycard_fragment
:
return
true
;
case
R
.
id
.
setting_fragment
:
return
true
;
}
return
false
;
}
};
}
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
0 → 100644
View file @
66b27522
package
cn.garymb.ygomobile.ui.home
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
cn.garymb.ygomobile.base.BaseFragemnt
;
import
cn.garymb.ygomobile.lite.R
;
public
class
HomeFragment
extends
BaseFragemnt
{
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
View
layoutView
;
if
(
isHorizontal
)
layoutView
=
inflater
.
inflate
(
R
.
layout
.
main_horizontal_fragment
,
container
,
false
);
else
layoutView
=
inflater
.
inflate
(
R
.
layout
.
main_fragment
,
container
,
false
);
//initView(layoutView, savedInstanceState);
return
layoutView
;
}
@Override
public
void
onResume
()
{
super
.
onResume
();
}
@Override
public
void
onFirstUserVisible
()
{
}
@Override
public
void
onUserVisible
()
{
}
@Override
public
void
onFirstUserInvisible
()
{
}
@Override
public
void
onUserInvisible
()
{
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
0 → 100644
View file @
66b27522
package
cn.garymb.ygomobile.ui.mycard
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
cn.garymb.ygomobile.base.BaseFragemnt
;
import
cn.garymb.ygomobile.lite.R
;
public
class
MycardFragment
extends
BaseFragemnt
implements
View
.
OnClickListener
{
private
Bundle
currentBundle
;
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
View
view
;
if
(
isHorizontal
)
view
=
inflater
.
inflate
(
R
.
layout
.
mycard_horizontal_fragment
,
container
,
false
);
else
view
=
inflater
.
inflate
(
R
.
layout
.
mycard_fragment
,
container
,
false
);
this
.
currentBundle
=
savedInstanceState
;
//initView(view);
return
view
;
}
/**
* 第一次fragment可见(进行初始化工作)
*/
@Override
public
void
onFirstUserVisible
()
{
}
/**
* fragment可见(切换回来或者onResume)
*/
@Override
public
void
onUserVisible
()
{
}
/**
* 第一次fragment不可见(不建议在此处理事件)
*/
@Override
public
void
onFirstUserInvisible
()
{
}
/**
* fragment不可见(切换掉或者onPause)
*/
@Override
public
void
onUserInvisible
()
{
}
/**
* Called when a view has been clicked.
*
* @param v The view that was clicked.
*/
@Override
public
void
onClick
(
View
v
)
{
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/SettingsFragment.java
0 → 100644
View file @
66b27522
package
cn.garymb.ygomobile.ui.preference
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
cn.garymb.ygomobile.base.BaseFragemnt
;
import
cn.garymb.ygomobile.lite.R
;
public
class
SettingsFragment
extends
BaseFragemnt
implements
View
.
OnClickListener
{
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
View
layoutView
;
layoutView
=
inflater
.
inflate
(
R
.
layout
.
activity_settings
,
container
,
false
);
//initView(layoutView, savedInstanceState);
return
layoutView
;
}
/**
* 第一次fragment可见(进行初始化工作)
*/
@Override
public
void
onFirstUserVisible
()
{
}
/**
* fragment可见(切换回来或者onResume)
*/
@Override
public
void
onUserVisible
()
{
}
/**
* 第一次fragment不可见(不建议在此处理事件)
*/
@Override
public
void
onFirstUserInvisible
()
{
}
/**
* fragment不可见(切换掉或者onPause)
*/
@Override
public
void
onUserInvisible
()
{
}
/**
* Called when a view has been clicked.
*
* @param v The view that was clicked.
*/
@Override
public
void
onClick
(
View
v
)
{
}
}
mobile/src/main/res/layout/activity_home.xml
View file @
66b27522
...
...
@@ -107,4 +107,35 @@
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id=
"@+id/container"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id=
"@+id/nav_view"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"0dp"
android:layout_marginEnd=
"0dp"
android:background=
"@color/cardview_shadow_end_color"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:menu=
"@menu/bottom_nav_menu"
/>
<!-- 页面中显式fragment的容器-->
<fragment
android:id=
"@+id/nav_host_fragment"
android:name=
"androidx.navigation.fragment.NavHostFragment"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:defaultNavHost=
"true"
app:layout_constraintBottom_toTopOf=
"@id/nav_view"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:navGraph=
"@navigation/mobile_navigation"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
\ No newline at end of file
mobile/src/main/res/layout/main_fragment.xml
0 → 100644
View file @
66b27522
<?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:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/ic_home"
android:orientation=
"vertical"
>
</LinearLayout>
\ No newline at end of file
mobile/src/main/res/layout/main_horizontal_fragment.xml
0 → 100644
View file @
66b27522
<?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:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingLeft=
"10dp"
android:orientation=
"horizontal"
android:background=
"@drawable/bg"
>
</LinearLayout>
\ No newline at end of file
mobile/src/main/res/layout/mycard_fragment.xml
0 → 100644
View file @
66b27522
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
</LinearLayout>
\ No newline at end of file
mobile/src/main/res/layout/mycard_horizontal_fragment.xml
0 → 100644
View file @
66b27522
<?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:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@drawable/mycard"
android:orientation=
"horizontal"
>
</LinearLayout>
\ No newline at end of file
mobile/src/main/res/menu/bottom_nav_menu.xml
0 → 100644
View file @
66b27522
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/home_fragment"
android:icon=
"@drawable/start"
android:title=
"@string/mc_home"
app:showAsAction=
"always"
/>
<item
android:id=
"@+id/mycard_fragment"
android:icon=
"@drawable/mycard"
android:title=
"@string/mycard"
app:showAsAction=
"always"
/>
<item
android:id=
"@+id/setting_fragment"
android:icon=
"@drawable/setting"
android:title=
"@string/settings"
app:showAsAction=
"always"
/>
</menu>
\ No newline at end of file
mobile/src/main/res/menu/nav_main_menu.xml
View file @
66b27522
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/action_card_search"
android:icon=
"@drawable/ic_search"
...
...
mobile/src/main/res/navigation/mobile_navigation.xml
0 → 100644
View file @
66b27522
<?xml version="1.0" encoding="utf-8"?>
<navigation
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:id=
"@+id/mobile_navigation"
app:startDestination=
"@+id/home_fragment"
>
<fragment
android:id=
"@+id/home_fragment"
android:name=
"cn.garymb.ygomobile.ui.home.HomeFragment"
tools:layout=
"@layout/main_fragment"
/>
<fragment
android:id=
"@+id/mycard_fragment"
android:name=
"cn.garymb.ygomobile.ui.mycard.MyCardFragment"
tools:layout=
"@layout/mycard_fragment"
/>
<fragment
android:id=
"@+id/setting_fragment"
android:name=
"cn.garymb.ygomobile.ui.cn.garymb.ygomobile.ui.preference.fragments.SettingFragment"
tools:layout=
"@layout/activity_settings"
/>
</navigation>
\ No newline at end of file
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