Commit a6273141 authored by wangfugui's avatar wangfugui

修改卡组tab中的显示

parent 961e0703
...@@ -17,8 +17,27 @@ import com.google.android.material.tabs.TabLayout; ...@@ -17,8 +17,27 @@ import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator; import com.google.android.material.tabs.TabLayoutMediator;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.utils.YGODeckDialogUtil;
public class DeckManageDialog extends DialogFragment { public class DeckManageDialog extends DialogFragment implements YGODeckDialogUtil.OnDeckDialogListener {
public void onDismiss() {
dismiss();
}
public void onShow() {
//todo
}
private YGODeckDialogUtil.OnDeckMenuListener mOnDeckMenuListener;
public DeckManageDialog(YGODeckDialogUtil.OnDeckMenuListener onDeckMenuListener) {
super();
mOnDeckMenuListener = onDeckMenuListener;
}
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
...@@ -27,6 +46,7 @@ public class DeckManageDialog extends DialogFragment { ...@@ -27,6 +46,7 @@ public class DeckManageDialog extends DialogFragment {
return inflater.inflate(R.layout.dialog_deck_manager, container, false); return inflater.inflate(R.layout.dialog_deck_manager, container, false);
} }
@Override @Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
...@@ -35,7 +55,7 @@ public class DeckManageDialog extends DialogFragment { ...@@ -35,7 +55,7 @@ public class DeckManageDialog extends DialogFragment {
TabLayout tabLayout = view.findViewById(R.id.deck_manager_tab_layout); TabLayout tabLayout = view.findViewById(R.id.deck_manager_tab_layout);
// Setup adapter // Setup adapter
ViewPagerAdapter adapter = new ViewPagerAdapter(this); ViewPagerAdapter adapter = new ViewPagerAdapter(this, mOnDeckMenuListener, this);
viewPager.setAdapter(adapter); viewPager.setAdapter(adapter);
// Connect TabLayout with ViewPager // Connect TabLayout with ViewPager
...@@ -63,8 +83,13 @@ public class DeckManageDialog extends DialogFragment { ...@@ -63,8 +83,13 @@ public class DeckManageDialog extends DialogFragment {
private static class ViewPagerAdapter extends FragmentStateAdapter { private static class ViewPagerAdapter extends FragmentStateAdapter {
public ViewPagerAdapter(@NonNull Fragment fragment) { private YGODeckDialogUtil.OnDeckMenuListener mOnDeckMenuListener;
private YGODeckDialogUtil.OnDeckDialogListener onDeckDialogListener;
public ViewPagerAdapter(@NonNull Fragment fragment, YGODeckDialogUtil.OnDeckMenuListener listener, YGODeckDialogUtil.OnDeckDialogListener dialogListener) {
super(fragment); super(fragment);
mOnDeckMenuListener = listener;
onDeckDialogListener = dialogListener;
} }
@NonNull @NonNull
...@@ -72,11 +97,13 @@ public class DeckManageDialog extends DialogFragment { ...@@ -72,11 +97,13 @@ public class DeckManageDialog extends DialogFragment {
public Fragment createFragment(int position) { public Fragment createFragment(int position) {
switch (position) { switch (position) {
case 0: case 0:
return new DeckSelectFragment(); return new DeckSelectFragment(mOnDeckMenuListener, onDeckDialogListener);
case 1: case 1:
return new DeckSquareFragment(); return new DeckSquareFragment();
case 2: case 2:
return new DeckSquareMyDeckFragment(); return new DeckSquareMyDeckFragment();
case 3:
return new MCOnlineManageFragment();
default: default:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
...@@ -84,7 +111,7 @@ public class DeckManageDialog extends DialogFragment { ...@@ -84,7 +111,7 @@ public class DeckManageDialog extends DialogFragment {
@Override @Override
public int getItemCount() { public int getItemCount() {
return 3; return 4;
} }
} }
......
...@@ -209,19 +209,19 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte ...@@ -209,19 +209,19 @@ public class DeckManagerFragment extends BaseFragemnt implements RecyclerViewIte
layoutView.findViewById(R.id.open_deck_square).setOnClickListener((v) -> doMenu(R.id.open_deck_square)); layoutView.findViewById(R.id.open_deck_square).setOnClickListener((v) -> doMenu(R.id.open_deck_square));
tv_deck.setOnClickListener(v -> tv_deck.setOnClickListener(v ->
{ {
new DeckManageDialog().show( new DeckManageDialog(this).show(
getActivity().getSupportFragmentManager(), getActivity().getSupportFragmentManager(),
"pagerDialog" "pagerDialog"
); );
} }
); );
// YGODeckDialogUtil.dialogDeckSelect(getActivity(), AppsSettings.get().getLastDeckPath(), this)); // YGODeckDialogUtil.dialogDeckSelect(getActivity(), AppsSettings.get().getLastDeckPath(), this));
mContext = (BaseActivity) getActivity(); mContext = (BaseActivity) getActivity();
} }
/** /**
*通过本文件,外部调用fragment时,如果通过setArguments(mBundle)方法设置了ydk文件路径,则直接打开它 * 通过本文件,外部调用fragment时,如果通过setArguments(mBundle)方法设置了ydk文件路径,则直接打开它
* 将mPreLoadFile设置为对应的File * 将mPreLoadFile设置为对应的File
*/ */
public void preLoadFile() { public void preLoadFile() {
......
...@@ -43,7 +43,6 @@ import cn.garymb.ygomobile.deck_square.api_response.MyDeckResponse; ...@@ -43,7 +43,6 @@ import cn.garymb.ygomobile.deck_square.api_response.MyDeckResponse;
import cn.garymb.ygomobile.deck_square.api_response.MyOnlineDeckDetail; import cn.garymb.ygomobile.deck_square.api_response.MyOnlineDeckDetail;
import cn.garymb.ygomobile.deck_square.api_response.OnlineDeckDetail; import cn.garymb.ygomobile.deck_square.api_response.OnlineDeckDetail;
import cn.garymb.ygomobile.deck_square.api_response.SquareDeckResponse; import cn.garymb.ygomobile.deck_square.api_response.SquareDeckResponse;
import cn.garymb.ygomobile.ex_card.ExPackageTabAdapter;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.adapters.DeckListAdapter; import cn.garymb.ygomobile.ui.adapters.DeckListAdapter;
import cn.garymb.ygomobile.ui.adapters.SimpleListAdapter; import cn.garymb.ygomobile.ui.adapters.SimpleListAdapter;
...@@ -100,8 +99,10 @@ public class YGODeckDialogUtil { ...@@ -100,8 +99,10 @@ public class YGODeckDialogUtil {
ViewHolder viewHolder = new ViewHolder(context, selectDeckPath, onDeckMenuListener); ViewHolder viewHolder = new ViewHolder(context, selectDeckPath, onDeckMenuListener);
viewHolder.show(); viewHolder.show();
} }
private DeckSquareTabAdapter adapter; private DeckSquareTabAdapter adapter;
//注册listener,发生点击卡组事件后,通知主界面进行对应的显示更新
//注册listener,发生点击卡组事件后,通知主界面进行对应的显示更新
public interface OnDeckMenuListener { public interface OnDeckMenuListener {
void onDeckSelect(DeckFile deckFile); void onDeckSelect(DeckFile deckFile);
...@@ -114,7 +115,12 @@ public class YGODeckDialogUtil { ...@@ -114,7 +115,12 @@ public class YGODeckDialogUtil {
void onDeckNew(DeckType currentDeckType); void onDeckNew(DeckType currentDeckType);
} }
public interface OnDeckDialogListener {
void onDismiss();
void onShow();
}
public interface OnDeckTypeListener { public interface OnDeckTypeListener {
void onDeckTypeListener(int position); void onDeckTypeListener(int position);
} }
...@@ -739,6 +745,7 @@ public class YGODeckDialogUtil { ...@@ -739,6 +745,7 @@ public class YGODeckDialogUtil {
ygoDialog.dismiss(); ygoDialog.dismiss();
} }
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout 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:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="16dp"> android:layout_weight="0.8">
<com.tubb.smrv.SwipeMenuRecyclerView <com.tubb.smrv.SwipeMenuRecyclerView
android:id="@+id/list_deck_info" android:id="@+id/list_deck_info"
...@@ -17,6 +18,33 @@ ...@@ -17,6 +18,33 @@
android:dividerHeight="4dp" android:dividerHeight="4dp"
android:padding="5dp" android:padding="5dp"
android:scrollbars="vertical" /> android:scrollbars="vertical" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> <LinearLayout
</androidx.coordinatorlayout.widget.CoordinatorLayout> android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="horizontal">
<Button
android:id="@+id/next_page_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="下一页"></Button>
<Button
android:id="@+id/former_page_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="上一页"></Button>
<Button
android:id="@+id/refresh_data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="刷新"></Button>
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:orientation="vertical">
<com.tubb.smrv.SwipeMenuRecyclerView <LinearLayout
android:id="@+id/list_my_deck_info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:divider="@android:color/transparent" android:layout_weight="0.8">
android:dividerHeight="4dp"
android:padding="5dp"
android:scrollbars="vertical"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="16dp" />
<FrameLayout <com.tubb.smrv.SwipeMenuRecyclerView
android:layout_width="match_parent" android:id="@+id/list_my_deck_info"
android:layout_height="70dp"
android:layout_gravity="bottom|right"
android:layout_marginLeft="10dp"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"> android:divider="@android:color/transparent"
android:dividerHeight="4dp"
android:padding="5dp"
android:scrollbars="vertical"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="16dp" />
</LinearLayout>
<Button <!-- <Button
android:id="@+id/refresh_data" android:id="@+id/upload_deck"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="right|bottom" android:layout_gravity="center|bottom"
android:text="刷新"></Button> android:text="上传卡组"></Button>-->
</LinearLayout>
<!-- <Button
android:id="@+id/upload_deck"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center|bottom"
android:text="上传卡组"></Button>-->
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="horizontal">
<Button
android:id="@+id/refresh_data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:text="刷新"></Button>
</LinearLayout>
<!--<com.google.android.material.floatingactionbutton.FloatingActionButton <!--<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -51,4 +50,4 @@ ...@@ -51,4 +50,4 @@
android:layout_marginEnd="@dimen/fab_margin" android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:tooltipText="刷新" />--> android:tooltipText="刷新" />-->
</androidx.coordinatorlayout.widget.CoordinatorLayout> </LinearLayout>
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