排卡最新升级
This commit is contained in:
@@ -54,6 +54,17 @@ public class PixivAdapter extends RecyclerView.Adapter<PixivAdapter.ViewHolder>
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
IllustData data = dataList.get(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());
|
holder.title.setText(data.getTitle());
|
||||||
|
|
||||||
// 清除之前的图片和状态
|
// 清除之前的图片和状态
|
||||||
@@ -73,12 +84,6 @@ public class PixivAdapter extends RecyclerView.Adapter<PixivAdapter.ViewHolder>
|
|||||||
loadImage(holder.backgroundLayout, imageUrl);
|
loadImage(holder.backgroundLayout, imageUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.itemView.setOnClickListener(v -> {
|
|
||||||
if (listener != null) {
|
|
||||||
listener.onItemClick(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ import android.util.Log;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.*;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@@ -58,31 +55,82 @@ public class JMActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
initRecyclerView();
|
initRecyclerView();
|
||||||
}
|
}
|
||||||
@SuppressLint({"ClickableViewAccessibility", "SetTextI18n", "ResourceType"})
|
|
||||||
private void initRecyclerView() {
|
private void initRecyclerView() {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String res = intent.getStringExtra("album");
|
String res = intent.getStringExtra("album");
|
||||||
Album a = new Gson().fromJson(res, Album.class);
|
Album a = new Gson().fromJson(res, Album.class);
|
||||||
album = a;
|
album = a;
|
||||||
Toast.makeText(this,"加载中", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "加载中", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
RecyclerView recyclerView = findViewById(R.id.recyclerView);
|
RecyclerView recyclerView = findViewById(R.id.recyclerView);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
recyclerView.setVerticalScrollBarEnabled(true);
|
||||||
|
|
||||||
photoAdapter = new PhotoAdapter(this, a.getImage_urls(), a.getNums(), a);
|
photoAdapter = new PhotoAdapter(this, a.getImage_urls(), a.getNums(), a);
|
||||||
photoAdapter.clearLoad();
|
photoAdapter.clearLoad();
|
||||||
|
recyclerView.setAdapter(photoAdapter);
|
||||||
|
|
||||||
MaterialButton downloadButton = findViewById(R.id.download);
|
MaterialButton downloadButton = findViewById(R.id.download);
|
||||||
downloadButton.setOnClickListener(v -> downloadAllImages());
|
downloadButton.setOnClickListener(v -> downloadAllImages());
|
||||||
recyclerView.setAdapter(photoAdapter);
|
|
||||||
bottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet));
|
bottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.bottom_sheet));
|
||||||
bottomSheetBehavior.setPeekHeight(dpToPx(80));
|
bottomSheetBehavior.setPeekHeight(dpToPx(80));
|
||||||
|
|
||||||
TextView menu = findViewById(R.id.menu);
|
TextView menu = findViewById(R.id.menu);
|
||||||
menu.setText(a.getName());
|
menu.setText(a.getName());
|
||||||
|
|
||||||
TextView dec = findViewById(R.id.dec);
|
TextView dec = findViewById(R.id.dec);
|
||||||
dec.setText(a.getAuthors().toString().replaceAll( "\\[","").replaceAll( "]","")
|
dec.setText(a.getAuthors().toString().replaceAll("\\[", "").replaceAll("]", "")
|
||||||
+ " / " + a.getActors().toString().replaceAll( "\"","") .replaceAll( "\\[","").replaceAll( "]","")
|
+ " / " + a.getActors().toString().replaceAll("\"", "").replaceAll("\\[", "").replaceAll("]", "")
|
||||||
+ " \n " + a.getTags().toString().replaceAll( "\"","") .replaceAll( "\\[","").replaceAll( "]","")
|
+ " \n " + a.getTags().toString().replaceAll("\"", "").replaceAll("\\[", "").replaceAll("]", "")
|
||||||
+ " \n " + a.getAlbum_id().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() {
|
private void downloadAllImages() {
|
||||||
String folderName = album.getName();
|
String folderName = album.getName();
|
||||||
File folder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + File.separator + "findmaimaiultra"), folderName);
|
File folder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + File.separator + "findmaimaiultra"), folderName);
|
||||||
|
|||||||
@@ -923,6 +923,11 @@ public class PageActivity extends AppCompatActivity {
|
|||||||
tagplace = marketList.get(finalI).getMarketName().split(" ")[0];
|
tagplace = marketList.get(finalI).getMarketName().split(" ")[0];
|
||||||
//导航
|
//导航
|
||||||
Toast.makeText(PageActivity.context, "即将导航" + marketList.get(finalI).getMarketName(), Toast.LENGTH_SHORT).show();
|
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();
|
showNavigationOptions();
|
||||||
});
|
});
|
||||||
textViews.add(t);
|
textViews.add(t);
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public class PixivFragment extends Fragment {
|
|||||||
// 使用 savedData
|
// 使用 savedData
|
||||||
}
|
}
|
||||||
adapter = new PixivAdapter(new ArrayList<>());
|
adapter = new PixivAdapter(new ArrayList<>());
|
||||||
adapter.setOnItemClickListener(illustData -> openIllustData(illustData));
|
adapter.setOnItemClickListener(this::openIllustData);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
// 设置搜索框的查询监听器
|
// 设置搜索框的查询监听器
|
||||||
@@ -341,6 +341,11 @@ public class PixivFragment extends Fragment {
|
|||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
adapter.update(dataList);
|
adapter.update(dataList);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
//设置点击效果
|
||||||
|
adapter.setOnItemClickListener(illustData -> {
|
||||||
|
openIllustData(illustData);
|
||||||
|
});
|
||||||
|
|
||||||
// 隐藏 Snackbar
|
// 隐藏 Snackbar
|
||||||
snackbar.dismiss();
|
snackbar.dismiss();
|
||||||
});
|
});
|
||||||
@@ -380,6 +385,7 @@ public class PixivFragment extends Fragment {
|
|||||||
|
|
||||||
@SuppressLint("MissingInflatedId")
|
@SuppressLint("MissingInflatedId")
|
||||||
private void openIllustData(IllustData illustData) {
|
private void openIllustData(IllustData illustData) {
|
||||||
|
Log.d("PixivFragment", "openIllustData: " + illustData.getTitle());
|
||||||
if (illustData.getUrl().startsWith("JM:")) {
|
if (illustData.getUrl().startsWith("JM:")) {
|
||||||
Snackbar snackbar = Snackbar.make(binding.getRoot(), "正在获取数据", Snackbar.LENGTH_LONG);
|
Snackbar snackbar = Snackbar.make(binding.getRoot(), "正在获取数据", Snackbar.LENGTH_LONG);
|
||||||
snackbar.show();
|
snackbar.show();
|
||||||
@@ -521,9 +527,9 @@ public class PixivFragment extends Fragment {
|
|||||||
//如果超过9点
|
//如果超过9点
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
|
||||||
if (Integer.parseInt(simpleDateFormat.format(date))>=21) {
|
if (Integer.parseInt(simpleDateFormat.format(date))>=21) {
|
||||||
snackbar = Snackbar.make(requireView(), "正在加载(夜晚时间段服务器压力较大)", Snackbar.LENGTH_INDEFINITE);
|
snackbar = Snackbar.make(requireView(), "正在加载(夜晚时间段服务器压力较大),注意:本程序原理是无视章节获取全部内容,如果内容过多很可能超时!", Snackbar.LENGTH_INDEFINITE);
|
||||||
} else {
|
} else {
|
||||||
snackbar = Snackbar.make(requireView(), "正在加载", Snackbar.LENGTH_INDEFINITE);
|
snackbar = Snackbar.make(requireView(), "正在加载,注意:本程序原理是无视章节获取全部内容,如果内容过多很可能超时!", Snackbar.LENGTH_INDEFINITE);
|
||||||
}
|
}
|
||||||
snackbar.show();
|
snackbar.show();
|
||||||
OkHttpClient httpClient = createOkHttpClient(); // 使用 createOkHttpClient 方法创建 OkHttpClient
|
OkHttpClient httpClient = createOkHttpClient(); // 使用 createOkHttpClient 方法创建 OkHttpClient
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:scrollbarSize="8dp"
|
||||||
|
android:scrollbarFadeDuration="300"
|
||||||
|
android:scrollbarTrackVertical="@color/primary"
|
||||||
app:layout_constraintEnd_toEndOf="parent"/>
|
app:layout_constraintEnd_toEndOf="parent"/>
|
||||||
|
|
||||||
|
|
||||||
@@ -38,17 +42,34 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="32sp"
|
|
||||||
android:textColor="@color/colorSecondaryVariant"
|
<TextView
|
||||||
android:id="@+id/menu"/>
|
android:id="@+id/menu"
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="18sp"
|
android:layout_width="wrap_content"
|
||||||
android:textColor="@color/colorSecondaryVariant"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/dec"/>
|
android:textSize="32sp"
|
||||||
<com.google.android.material.button.MaterialButton android:layout_width="match_parent"
|
android:textColor="@color/colorSecondaryVariant" />
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="下载全部本子"
|
<TextView
|
||||||
android:id="@+id/download"/>
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user