排卡最新升级

This commit is contained in:
2025-04-21 19:33:43 +08:00
parent 8a6e7d6dd9
commit 5f5dfeda2f
5 changed files with 115 additions and 30 deletions

View File

@@ -54,6 +54,17 @@ public class PixivAdapter extends RecyclerView.Adapter<PixivAdapter.ViewHolder>
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
IllustData data = dataList.get(position);
holder.backgroundLayout.setOnClickListener(v -> {
if (listener != null) {
listener.onItemClick(data);
}
});
holder.itemView.setOnClickListener(v -> {
if (listener != null) {
listener.onItemClick(data);
}
});
holder.title.setText(data.getTitle());
// 清除之前的图片和状态
@@ -73,12 +84,6 @@ public class PixivAdapter extends RecyclerView.Adapter<PixivAdapter.ViewHolder>
loadImage(holder.backgroundLayout, imageUrl);
}
}
holder.itemView.setOnClickListener(v -> {
if (listener != null) {
listener.onItemClick(data);
}
});
}
@Override

View File

@@ -14,10 +14,7 @@ import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.*;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
@@ -58,31 +55,82 @@ public class JMActivity extends AppCompatActivity {
initRecyclerView();
}
@SuppressLint({"ClickableViewAccessibility", "SetTextI18n", "ResourceType"})
private void initRecyclerView() {
Intent intent = getIntent();
String res = intent.getStringExtra("album");
Album a = new Gson().fromJson(res, Album.class);
album = a;
Toast.makeText(this,"加载中", Toast.LENGTH_SHORT).show();
Toast.makeText(this, "加载中", Toast.LENGTH_SHORT).show();
RecyclerView recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setVerticalScrollBarEnabled(true);
photoAdapter = new PhotoAdapter(this, a.getImage_urls(), a.getNums(), a);
photoAdapter.clearLoad();
recyclerView.setAdapter(photoAdapter);
MaterialButton downloadButton = findViewById(R.id.download);
downloadButton.setOnClickListener(v -> downloadAllImages());
recyclerView.setAdapter(photoAdapter);
bottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet));
bottomSheetBehavior.setPeekHeight(dpToPx(80));
TextView menu = findViewById(R.id.menu);
menu.setText(a.getName());
TextView dec = findViewById(R.id.dec);
dec.setText(a.getAuthors().toString().replaceAll( "\\[","").replaceAll( "]","")
+ " / " + a.getActors().toString().replaceAll( "\"","") .replaceAll( "\\[","").replaceAll( "]","")
+ " \n " + a.getTags().toString().replaceAll( "\"","") .replaceAll( "\\[","").replaceAll( "]","")
+ " \n " + a.getAlbum_id().replaceAll( "\"","").replaceAll( "\\[","").replaceAll( "]",""));
dec.setText(a.getAuthors().toString().replaceAll("\\[", "").replaceAll("]", "")
+ " / " + a.getActors().toString().replaceAll("\"", "").replaceAll("\\[", "").replaceAll("]", "")
+ " \n " + a.getTags().toString().replaceAll("\"", "").replaceAll("\\[", "").replaceAll("]", "")
+ " \n " + a.getAlbum_id().replaceAll("\"", "").replaceAll("\\[", "").replaceAll("]", ""));
// 初始化 SeekBar
SeekBar seekBar = findViewById(R.id.seekBar);
seekBar.setMax(100); // 最大值为 100表示百分比
// 设置 SeekBar 监听器
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
// 用户拖动 SeekBar 时,跳转到 RecyclerView 的指定位置
int totalItems = recyclerView.getAdapter().getItemCount();
int targetPosition = (int) (progress / 100.0 * totalItems);
recyclerView.scrollToPosition(targetPosition);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// 无需处理
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// 无需处理
}
});
// 设置 RecyclerView 滚动监听器,更新 SeekBar
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
if (layoutManager != null) {
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
int totalItems = recyclerView.getAdapter().getItemCount();
if (totalItems > 0) {
int progress = (int) (firstVisibleItemPosition / (float) totalItems * 100);
seekBar.setProgress(progress);
}
}
}
});
}
private void downloadAllImages() {
String folderName = album.getName();
File folder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + File.separator + "findmaimaiultra"), folderName);

View File

@@ -923,6 +923,11 @@ public class PageActivity extends AppCompatActivity {
tagplace = marketList.get(finalI).getMarketName().split(" ")[0];
//导航
Toast.makeText(PageActivity.context, "即将导航" + marketList.get(finalI).getMarketName(), Toast.LENGTH_SHORT).show();
//判断经纬度大小合不合法
if (tagXY[0] > 180 || tagXY[0] < -180 || tagXY[1] > 180 || tagXY[1] < -180) {
Toast.makeText(PageActivity.context, "经纬度不合法", Toast.LENGTH_SHORT).show();
return;
}
showNavigationOptions();
});
textViews.add(t);

View File

@@ -128,7 +128,7 @@ public class PixivFragment extends Fragment {
// 使用 savedData
}
adapter = new PixivAdapter(new ArrayList<>());
adapter.setOnItemClickListener(illustData -> openIllustData(illustData));
adapter.setOnItemClickListener(this::openIllustData);
recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
recyclerView.setAdapter(adapter);
// 设置搜索框的查询监听器
@@ -341,6 +341,11 @@ public class PixivFragment extends Fragment {
handler.post(() -> {
adapter.update(dataList);
adapter.notifyDataSetChanged();
//设置点击效果
adapter.setOnItemClickListener(illustData -> {
openIllustData(illustData);
});
// 隐藏 Snackbar
snackbar.dismiss();
});
@@ -380,6 +385,7 @@ public class PixivFragment extends Fragment {
@SuppressLint("MissingInflatedId")
private void openIllustData(IllustData illustData) {
Log.d("PixivFragment", "openIllustData: " + illustData.getTitle());
if (illustData.getUrl().startsWith("JM:")) {
Snackbar snackbar = Snackbar.make(binding.getRoot(), "正在获取数据", Snackbar.LENGTH_LONG);
snackbar.show();
@@ -521,9 +527,9 @@ public class PixivFragment extends Fragment {
//如果超过9点
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
if (Integer.parseInt(simpleDateFormat.format(date))>=21) {
snackbar = Snackbar.make(requireView(), "正在加载(夜晚时间段服务器压力较大)", Snackbar.LENGTH_INDEFINITE);
snackbar = Snackbar.make(requireView(), "正在加载(夜晚时间段服务器压力较大),注意:本程序原理是无视章节获取全部内容,如果内容过多很可能超时!", Snackbar.LENGTH_INDEFINITE);
} else {
snackbar = Snackbar.make(requireView(), "正在加载", Snackbar.LENGTH_INDEFINITE);
snackbar = Snackbar.make(requireView(), "正在加载,注意:本程序原理是无视章节获取全部内容,如果内容过多很可能超时!", Snackbar.LENGTH_INDEFINITE);
}
snackbar.show();
OkHttpClient httpClient = createOkHttpClient(); // 使用 createOkHttpClient 方法创建 OkHttpClient

View File

@@ -13,6 +13,10 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:scrollbars="vertical"
android:scrollbarSize="8dp"
android:scrollbarFadeDuration="300"
android:scrollbarTrackVertical="@color/primary"
app:layout_constraintEnd_toEndOf="parent"/>
@@ -38,17 +42,34 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="32sp"
android:textColor="@color/colorSecondaryVariant"
android:id="@+id/menu"/>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="18sp"
android:textColor="@color/colorSecondaryVariant"
android:id="@+id/dec"/>
<com.google.android.material.button.MaterialButton android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="下载全部本子"
android:id="@+id/download"/>
<TextView
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:textColor="@color/colorSecondaryVariant" />
<TextView
android:id="@+id/dec"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="@color/colorSecondaryVariant" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100" /> <!-- 最大值为 100表示百分比 -->
<com.google.android.material.button.MaterialButton
android:id="@+id/download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="下载全部本子" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>