Commit aafbf4f3 authored by fallenstardust's avatar fallenstardust

添加卡组分享者查询

parent 92b99ad2
package cn.garymb.ygomobile.deck_square;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -34,11 +36,7 @@ public class DeckSquareFragment extends Fragment {
}
@Override
public View onCreateView(
@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState
) {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentDeckSquareBinding.inflate(inflater, container, false);
deckSquareListAdapter = new DeckSquareListAdapter(R.layout.item_deck_info);
......@@ -47,6 +45,109 @@ public class DeckSquareFragment extends Fragment {
binding.listDeckInfo.setAdapter(deckSquareListAdapter);
deckSquareListAdapter.loadData();
binding.etGoToPage.setText("1");
binding.etDeckSquareInputDeckName.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Editable contributerName = binding.etInputContributerName.getText();
if (contributerName != null) contributerName.clear();
keyWord = v.getText().toString();
binding.etGoToPage.setText("1");
binding.etGoToPage.setEnabled(false);
// 底部按钮不可用状态
binding.formerPageBtn.setEnabled(false);
binding.formerPageBtn.setColorFilter(R.color.navigator_dir_text_color);
binding.nextPageBtn.setEnabled(false);
binding.nextPageBtn.setColorFilter(R.color.navigator_dir_text_color);
binding.refreshData.setEnabled(false);
binding.refreshData.setColorFilter(R.color.navigator_dir_text_color);
deckSquareListAdapter.loadData(1, 1000, keyWord, true, false, "");
binding.listDeckInfo.scrollToPosition(0);
return true;
}
return false;
});
// 添加文本变化监听器
binding.etDeckSquareInputDeckName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
binding.btnClearDeckName.setVisibility(View.VISIBLE);
}
@Override
public void afterTextChanged(Editable s) {
// 当输入框内容为空时
if (s.toString().isEmpty()) {
binding.btnClearDeckName.setVisibility(View.GONE);
// 恢复底部按钮可用状态
binding.formerPageBtn.setEnabled(true);
binding.formerPageBtn.setColorFilter(R.color.selector_text_color_white_gold);
binding.nextPageBtn.setEnabled(true);
binding.nextPageBtn.setColorFilter(R.color.selector_text_color_white_gold);
binding.refreshData.setEnabled(true);
binding.refreshData.setColorFilter(R.color.selector_text_color_white_gold);
// 重置页码为1
binding.etGoToPage.setText("1");
binding.etGoToPage.setEnabled(true);
deckSquareListAdapter.loadData();
binding.listDeckInfo.scrollToPosition(0);
}
}
});
binding.etInputContributerName.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Editable deckName = binding.etDeckSquareInputDeckName.getText();
if (deckName != null) deckName.clear();
contributer = v.getText().toString();
binding.etGoToPage.setText("1");
binding.etGoToPage.setEnabled(false);
// 底部按钮不可用状态
binding.formerPageBtn.setEnabled(false);
binding.formerPageBtn.setColorFilter(R.color.navigator_dir_text_color);
binding.nextPageBtn.setEnabled(false);
binding.nextPageBtn.setColorFilter(R.color.navigator_dir_text_color);
binding.refreshData.setEnabled(false);
binding.refreshData.setColorFilter(R.color.navigator_dir_text_color);
deckSquareListAdapter.loadData(1, 1000, null, true, false, contributer);
binding.listDeckInfo.scrollToPosition(0);
return true;
}
return false;
});
// 添加文本变化监听器
binding.etInputContributerName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
binding.btnClearContributerName.setVisibility(View.VISIBLE);
}
@Override
public void afterTextChanged(Editable s) {
// 当输入框内容为空时
if (s.toString().isEmpty()) {
binding.btnClearDeckName.setVisibility(View.GONE);
// 恢复底部按钮可用状态
binding.formerPageBtn.setEnabled(true);
binding.formerPageBtn.setColorFilter(R.color.selector_text_color_white_gold);
binding.nextPageBtn.setEnabled(true);
binding.nextPageBtn.setColorFilter(R.color.selector_text_color_white_gold);
binding.refreshData.setEnabled(true);
binding.refreshData.setColorFilter(R.color.selector_text_color_white_gold);
// 重置页码为1
binding.etGoToPage.setText("1");
binding.etGoToPage.setEnabled(true);
deckSquareListAdapter.loadData();
binding.listDeckInfo.scrollToPosition(0);
}
}
});
//设置清空按钮点击清除输入内容
binding.btnClearDeckName.setOnClickListener(view -> binding.etDeckSquareInputDeckName.getText().clear());
binding.btnClearContributerName.setOnClickListener(view -> binding.etInputContributerName.getText().clear());
// 设置页码跳转监听
binding.etGoToPage.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
......
......@@ -71,15 +71,6 @@ public class DeckSquareListAdapter extends BaseQuickAdapter<OnlineDeckDetail, Ba
}
private static Boolean isMonster(List<String> list) {
for (String data : list) {
if (data.equals("怪兽")) {
return true;
}
}
return false;
}
@Override
protected void convert(BaseViewHolder helper, OnlineDeckDetail item) {
helper.setText(R.id.deck_info_name, item.getDeckName());
......
......@@ -54,14 +54,16 @@
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_deck"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="2dp"
android:background="@drawable/button_radius_black_transparents"
android:ellipsize="end"
android:maxLines="1"
android:shadowColor="@color/black"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:gravity="center|left"
android:text="@string/select_deck"
android:textColor="@color/white"
android:textSize="18sp"
......@@ -92,7 +94,6 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="bottom|center_horizontal"
android:shadowColor="@color/black"
android:shadowDx="1"
......@@ -120,7 +121,6 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="bottom|center_horizontal"
android:shadowColor="@color/black"
android:shadowDx="1"
......@@ -163,7 +163,6 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="bottom|center_horizontal"
android:shadowColor="@color/black"
android:shadowDx="1"
......@@ -175,8 +174,6 @@
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
<LinearLayout
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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:weightSum="14"
android:orientation="vertical">
android:layout_height="match_parent">
<!-- 顶部输入框区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="12.5"
android:weightSum="10"
android:orientation="vertical">
android:id="@+id/top_input_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<!-- 第一个输入框及清空按钮 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/button_radius_black_transparents"
android:layout_marginEnd="2.5dp"
android:layout_weight="1">
<EditText
android:id="@+id/et_deck_square_input_deck_name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="@string/intpu_name"
android:imeOptions="actionSearch"
......@@ -26,35 +36,98 @@
android:singleLine="true"
android:textColor="@color/holo_blue_bright"
android:textColorHint="@color/gray"
android:textSize="15sp" />
android:textSize="15sp"
app:layout_constraintEnd_toStartOf="@id/btn_clear_deck_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/btn_clear_deck_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_close_black_24dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- 第二个输入框及清空按钮 -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="2.5dp"
android:background="@drawable/button_radius_black_transparents"
android:layout_weight="1">
<EditText
android:id="@+id/et_input_contributer_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="@string/input_contributor_name"
android:imeOptions="actionSearch"
android:inputType="textNoSuggestions"
android:singleLine="true"
android:textColor="@color/holo_blue_bright"
android:textColorHint="@color/gray"
android:textSize="15sp"
app:layout_constraintEnd_toStartOf="@id/btn_clear_contributer_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/btn_clear_contributer_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_close_black_24dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
<!-- 列表区域 - 设置底部边距为控制栏留出空间 -->
<com.tubb.smrv.SwipeMenuRecyclerView
android:id="@+id/list_deck_info"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="9"
android:layout_marginBottom="80dp"
android:divider="@android:color/transparent"
android:dividerHeight="4dp"
android:padding="5dp"
android:scrollbars="vertical" />
</LinearLayout>
android:scrollbars="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/top_input_container" />
<!-- 底部控制栏 - 固定在底部 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:id="@+id/ll_page_ctrl"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:elevation="8dp"
android:orientation="vertical"
android:weightSum="2">
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<!-- 页码输入区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:layout_height="wrap_content"
android:weightSum="3">
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@color/holo_blue_light" />
......@@ -62,34 +135,35 @@
android:id="@+id/et_go_to_page"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:background="@drawable/veil2"
android:gravity="center"
android:hint="@string/go_to"
android:inputType="number"
android:imeOptions="actionDone"
android:background="@drawable/veil2"
android:inputType="number"
android:singleLine="true"
android:textSize="14sp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@color/holo_blue_light" />
</LinearLayout>
<!-- 按钮控制区域 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="bottom"
android:layout_height="wrap_content"
android:layout_margin="5dp">
<ImageButton
android:id="@+id/former_page_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/ic_radius_bg"
android:src="@drawable/baseline_arrow_left_24" />
......@@ -97,8 +171,8 @@
android:id="@+id/next_page_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/ic_radius_bg"
android:src="@drawable/baseline_arrow_right_24" />
......@@ -106,10 +180,10 @@
android:id="@+id/refresh_data"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/ic_radius_bg"
android:src="@drawable/ic_refresh" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -381,5 +381,6 @@
<string name="input_pwd">Introduce la Contraseña</string>
<string name="deck_square">Plaza de Decks</string>
<string name="my_deck_online">Copia en la Nube</string>
<string name="input_contributor_name">Introduce el Nombre del Compartidor</string>
</resources>
......@@ -375,4 +375,5 @@
<string name="input_pwd">パスワードを入力してください</string>
<string name="deck_square">デッキ広場</string>
<string name="my_deck_online">クラウド バックアップ</string>
<string name="input_contributor_name">共有者の名前を入力してください</string>
</resources>
......@@ -376,4 +376,5 @@
<string name="input_pwd">비밀번호를 입력하세요</string>
<string name="deck_square">덱 공유 광장</string>
<string name="my_deck_online">클라우드 백업</string>
<string name="input_contributor_name">공유자의 이름을 입력하세요</string>
</resources>
......@@ -365,5 +365,6 @@
<string name="input_pwd">Insira a Senha</string>
<string name="deck_square">Praça de Decks</string>
<string name="my_deck_online">Backup na Nuvem</string>
<string name="input_contributor_name">Insira o Nome do Compartilhador</string>
</resources>
......@@ -136,7 +136,7 @@
<string name="last_path">上一级目录</string>
<string name="create_folder">新建文件夹</string>
<string name="intpu_name">输入卡组名</string>
<string name="intpu_name">输入卡组名</string>
<string name="the_name_is_folder">当前文件名是个文件夹</string>
<string name="tab_search">搜索</string>
<string name="tab_result">列表</string>
......@@ -380,4 +380,5 @@
<string name="sign_out">切换账号</string>
<string name="deck_square">卡组广场</string>
<string name="my_deck_online">云备份</string>
<string name="input_contributor_name">输入共享者名称</string>
</resources>
......@@ -445,4 +445,5 @@
<string name="input_pwd">Enter Password</string>
<string name="deck_square">Deck Plaza</string>
<string name="my_deck_online">Cloud Backup</string>
<string name="input_contributor_name">Enter the Sharer\'s Name</string>
</resources>
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