Commit 495261d1 authored by fallenstardust's avatar fallenstardust

添加新bottomnavigationbar样式

parent 20e0173e
...@@ -144,5 +144,5 @@ dependencies { ...@@ -144,5 +144,5 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.6'
implementation "androidx.palette:palette:1.0.0" implementation "androidx.palette:palette:1.0.0"
implementation 'com.github.xiaohaibin:XBanner:androidx_v1.2.0' implementation 'com.ashokvarma.android:bottom-navigation-bar:2.2.0'
} }
...@@ -107,15 +107,6 @@ import ocgcore.data.LimitList; ...@@ -107,15 +107,6 @@ import ocgcore.data.LimitList;
import ocgcore.enums.LimitType; import ocgcore.enums.LimitType;
public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewItemListener.OnItemListener, OnItemDragListener, YGODialogUtil.OnDeckMenuListener, CardLoader.CallBack, CardSearcher.CallBack { public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewItemListener.OnItemListener, OnItemDragListener, YGODialogUtil.OnDeckMenuListener, CardLoader.CallBack, CardSearcher.CallBack {
public static void start(Context context, String path) {
Intent starter = new Intent(context, DeckManagerFragment.class);
starter.putExtra(Intent.EXTRA_TEXT, path);
if (!(context instanceof Activity)) {
starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
context.startActivity(starter);
}
protected DrawerLayout mDrawerLayout; protected DrawerLayout mDrawerLayout;
protected RecyclerView mListView; protected RecyclerView mListView;
protected CardSearcher mCardSelector; protected CardSearcher mCardSelector;
...@@ -232,6 +223,15 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte ...@@ -232,6 +223,15 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
init(_file); init(_file);
} }
public static void start(Context context, String path) {
Intent starter = new Intent(context, DeckManagerFragment.class);
starter.putExtra(Intent.EXTRA_TEXT, path);
if (!(context instanceof Activity)) {
starter.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
context.startActivity(starter);
}
/*/https://www.jianshu.com/p/99649af3b191 /*/https://www.jianshu.com/p/99649af3b191
public void showNewbieGuide(String scene) { public void showNewbieGuide(String scene) {
HighlightOptions options = new HighlightOptions.Builder()//绘制一个高亮虚线圈 HighlightOptions options = new HighlightOptions.Builder()//绘制一个高亮虚线圈
......
...@@ -10,12 +10,10 @@ import android.view.MenuItem; ...@@ -10,12 +10,10 @@ import android.view.MenuItem;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.google.android.material.bottomnavigation.BottomNavigationView; import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.ourygo.assistant.base.listener.OnDuelAssistantListener; import com.ourygo.assistant.base.listener.OnDuelAssistantListener;
import com.ourygo.assistant.util.DuelAssistantManagement; import com.ourygo.assistant.util.DuelAssistantManagement;
import com.ourygo.assistant.util.Util; import com.ourygo.assistant.util.Util;
...@@ -34,7 +32,9 @@ import cn.garymb.ygomobile.ui.activities.BaseActivity; ...@@ -34,7 +32,9 @@ import cn.garymb.ygomobile.ui.activities.BaseActivity;
import cn.garymb.ygomobile.ui.cards.CardSearchFragment; import cn.garymb.ygomobile.ui.cards.CardSearchFragment;
import cn.garymb.ygomobile.ui.cards.DeckManagerFragment; import cn.garymb.ygomobile.ui.cards.DeckManagerFragment;
import cn.garymb.ygomobile.ui.cards.deck.DeckUtils; import cn.garymb.ygomobile.ui.cards.deck.DeckUtils;
import cn.garymb.ygomobile.ui.mycard.MycardFragment;
import cn.garymb.ygomobile.ui.plus.DialogPlus; import cn.garymb.ygomobile.ui.plus.DialogPlus;
import cn.garymb.ygomobile.ui.preference.fragments.SettingFragment;
import cn.garymb.ygomobile.utils.FileLogUtil; import cn.garymb.ygomobile.utils.FileLogUtil;
import cn.garymb.ygomobile.utils.ScreenUtil; import cn.garymb.ygomobile.utils.ScreenUtil;
import cn.garymb.ygomobile.utils.YGOUtil; import cn.garymb.ygomobile.utils.YGOUtil;
...@@ -45,6 +45,13 @@ public abstract class HomeActivity extends BaseActivity implements OnDuelAssista ...@@ -45,6 +45,13 @@ public abstract class HomeActivity extends BaseActivity implements OnDuelAssista
long exitLasttime = 0; long exitLasttime = 0;
private HomeFragment fragment_home;
private CardSearchFragment fragment_search;
private DeckManagerFragment fragment_deck_cards;
private MycardFragment fragment_mycard;
private SettingFragment fragment_settings;
private DuelAssistantManagement duelAssistantManagement; private DuelAssistantManagement duelAssistantManagement;
private AppBarConfiguration appBarConfiguration; private AppBarConfiguration appBarConfiguration;
...@@ -87,16 +94,44 @@ public abstract class HomeActivity extends BaseActivity implements OnDuelAssista ...@@ -87,16 +94,44 @@ public abstract class HomeActivity extends BaseActivity implements OnDuelAssista
private void initBottomNavigationBar() { private void initBottomNavigationBar() {
// 获取页面上的底部导航栏控件 // 获取页面上的底部导航栏控件
BottomNavigationView navView = findViewById(R.id.nav_view); BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
// 配置navigation与底部菜单之间的联系 bottomNavigationBar
// 底部菜单的样式里面的item里面的ID与navigation布局里面指定的ID必须相同,否则会出现绑定失败的情况 .addItem(new BottomNavigationItem(R.drawable.ic_home, R.string.mc_home))
appBarConfiguration = new AppBarConfiguration.Builder( .addItem(new BottomNavigationItem(R.drawable.ic_search, R.string.search))
R.id.home_fragment, R.id.cardSearcher_fragment, R.id.deckManager_fragment, R.id.mycard_fragment, R.id.setting_fragment).build(); .addItem(new BottomNavigationItem(R.drawable.ic_album, R.string.deck_manager))
// 建立fragment容器的控制器,这个容器就是页面的上的fragment容器 .addItem(new BottomNavigationItem(R.drawable.ic_add, R.string.mycard))
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); .addItem(new BottomNavigationItem(R.drawable.ic_settings, R.string.settings))
// 启动 .setActiveColor(R.color.holo_blue_bright)
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); .setBarBackgroundColor(R.color.transparent)
NavigationUI.setupWithNavController(navView, navController); .setMode(BottomNavigationBar.MODE_FIXED)
.initialise();//所有的设置需在调用该方法前完成
bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
@Override
public void onTabSelected(int position) {
//未选中->选中
}
@Override
public void onTabUnselected(int position) {
//选中->未选中
}
@Override
public void onTabReselected(int position) {
//选中->选中
}
});
fragment_home = new HomeFragment();
fragment_search = new CardSearchFragment();
fragment_deck_cards = new DeckManagerFragment();
fragment_mycard = new MycardFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_home, fragment_home)
.add(R.id.fragment_search, fragment_search)
.add(R.id.fragment_deck_cards, fragment_deck_cards)
.add(R.id.fragment_mycard, fragment_mycard)
//.add(R.id.fragment_settings,new Fragment())
.commit();
getSupportActionBar().hide(); getSupportActionBar().hide();
} }
......
...@@ -142,13 +142,14 @@ public class HomeFragment extends BaseFragemnt implements View.OnClickListener { ...@@ -142,13 +142,14 @@ public class HomeFragment extends BaseFragemnt implements View.OnClickListener {
cv_watch_replay.setOnClickListener(this); cv_watch_replay.setOnClickListener(this);
cv_download_ex = view.findViewById(R.id.action_download_ex); cv_download_ex = view.findViewById(R.id.action_download_ex);
cv_download_ex.setOnClickListener(this); cv_download_ex.setOnClickListener(this);
/*
cv_download_ex.setOnLongClickListener(new View.OnLongClickListener() { cv_download_ex.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
startActivity(new Intent(getActivity(), FileLogActivity.class)); startActivity(new Intent(getActivity(), FileLogActivity.class));
return true; return true;
} }
}); });*/
cv_reset_res = view.findViewById(R.id.action_reset_game_res); cv_reset_res = view.findViewById(R.id.action_reset_game_res);
cv_reset_res.setOnClickListener(this); cv_reset_res.setOnClickListener(this);
cv_join_QQ = view.findViewById(R.id.action_join_qq_group); cv_join_QQ = view.findViewById(R.id.action_join_qq_group);
......
...@@ -3,7 +3,6 @@ package cn.garymb.ygomobile.ui.preference; ...@@ -3,7 +3,6 @@ package cn.garymb.ygomobile.ui.preference;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.activities.BaseActivity; import cn.garymb.ygomobile.ui.activities.BaseActivity;
...@@ -13,7 +12,7 @@ public class SettingsActivity extends BaseActivity { ...@@ -13,7 +12,7 @@ public class SettingsActivity extends BaseActivity {
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings); setContentView(R.layout.fragment_settings);
getSupportActionBar().hide(); getSupportActionBar().hide();
enableBackHome(); enableBackHome();
getFragmentManager().beginTransaction().replace(R.id.fragment, new SettingFragment()).commit(); getFragmentManager().beginTransaction().replace(R.id.fragment, new SettingFragment()).commit();
......
...@@ -18,7 +18,7 @@ public class SettingsFragment extends BaseFragemnt implements View.OnClickListe ...@@ -18,7 +18,7 @@ public class SettingsFragment extends BaseFragemnt implements View.OnClickListe
super.onCreateView(inflater, container, savedInstanceState); super.onCreateView(inflater, container, savedInstanceState);
View layoutView; View layoutView;
layoutView = inflater.inflate(R.layout.activity_settings, container, false); layoutView = inflater.inflate(R.layout.fragment_settings, container, false);
//initView(layoutView, savedInstanceState); //initView(layoutView, savedInstanceState);
......
...@@ -7,34 +7,9 @@ ...@@ -7,34 +7,9 @@
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout <com.ashokvarma.bottomnavigation.BottomNavigationBar
android:id="@+id/container" android:id="@+id/bottom_navigation_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
<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> </FrameLayout>
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_deck_cards"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#80000000" android:id="@+id/fragment_home"
android:orientation="vertical"> android:orientation="vertical">
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mycard_fragment" android:id="@+id/fragment_mycard"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/fragment_search"
android:background="@drawable/bg3"> android:background="@drawable/bg3">
<androidx.drawerlayout.widget.DrawerLayout <androidx.drawerlayout.widget.DrawerLayout
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/fragment_settings"
android:background="@drawable/bg3"> android:background="@drawable/bg3">
<LinearLayout <LinearLayout
......
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
<fragment <fragment
android:id="@+id/setting_fragment" android:id="@+id/setting_fragment"
android:name="cn.garymb.ygomobile.ui.preference.fragments.SettingFragment" android:name="cn.garymb.ygomobile.ui.preference.fragments.SettingFragment"
tools:layout="@layout/activity_settings" /> tools:layout="@layout/fragment_settings" />
</navigation> </navigation>
\ 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