Commit a6273141 authored by wangfugui's avatar wangfugui

修改卡组tab中的显示

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