1.6.3正式版
This commit is contained in:
@@ -55,8 +55,8 @@
|
||||
android:label="@string/app_name"
|
||||
android:persistent="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:roundIcon="@drawable/ic_launcher"
|
||||
android:icon="@drawable/icon"
|
||||
android:roundIcon="@drawable/icon"
|
||||
android:supportsRtl="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
@@ -105,45 +106,12 @@ public class PhotoAdapter extends RecyclerView.Adapter<PhotoAdapter.PhotoViewHol
|
||||
Log.e("PhotoAdapter", "Image load failed at position: " + position);
|
||||
}
|
||||
});
|
||||
} else if ((!loading.contains(position))) {
|
||||
// 从网络加载并处理图片
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
.load(imageUrl)
|
||||
.override(holder.itemView.getWidth(), holder.itemView.getHeight()) // 压缩图片到屏幕大小
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
Log.d("PhotoAdapter", "Image loaded successfully at position: " + position);
|
||||
if (!loading.contains(position)) {
|
||||
loading.add(position);
|
||||
}
|
||||
} else {
|
||||
ImageView imageView = holder.imageView;
|
||||
imageView = new ImageView(context);
|
||||
imageView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.loading));
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
|
||||
Bitmap decodedBitmap = decodeImage(resource, num);
|
||||
holder.imageView.setImageBitmap(decodedBitmap);
|
||||
holder.imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
|
||||
// 保存处理后的图片到缓存
|
||||
saveBitmapToCache(decodedBitmap, cacheFile);
|
||||
|
||||
// 设置长按监听器
|
||||
holder.imageView.setOnLongClickListener(v -> {
|
||||
saveImageToMediaStore(decodedBitmap, fileName);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(Drawable placeholder) {
|
||||
Log.d("PhotoAdapter", "Image load cleared at position: " + position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(Drawable errorDrawable) {
|
||||
super.onLoadFailed(errorDrawable);
|
||||
Log.e("PhotoAdapter", "Image load failed at position: " + position);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,15 @@ import com.google.gson.Gson;
|
||||
import org.astral.findmaimaiultra.R;
|
||||
import org.astral.findmaimaiultra.adapter.PhotoAdapter;
|
||||
import org.astral.findmaimaiultra.been.pixiv.jm.Album;
|
||||
import org.astral.findmaimaiultra.utill.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
|
||||
public class JMActivity extends AppCompatActivity {
|
||||
@@ -61,7 +65,7 @@ public class JMActivity extends AppCompatActivity {
|
||||
Album a = new Gson().fromJson(res, Album.class);
|
||||
album = a;
|
||||
Toast.makeText(this, "加载中", Toast.LENGTH_SHORT).show();
|
||||
|
||||
getAll();
|
||||
RecyclerView recyclerView = findViewById(R.id.recyclerView);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.setVerticalScrollBarEnabled(true);
|
||||
@@ -120,7 +124,7 @@ public class JMActivity extends AppCompatActivity {
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
if (layoutManager != null) {
|
||||
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
|
||||
int totalItems = recyclerView.getAdapter().getItemCount();
|
||||
int totalItems = Objects.requireNonNull(recyclerView.getAdapter()).getItemCount();
|
||||
if (totalItems > 0) {
|
||||
int progress = (int) (firstVisibleItemPosition / (float) totalItems * 100);
|
||||
seekBar.setProgress(progress);
|
||||
@@ -129,7 +133,53 @@ public class JMActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
private void getAll() {
|
||||
File file22 = FileUtils.getCacheDir(getBaseContext(), "lock");
|
||||
if (file22.getParentFile().exists()) {
|
||||
//删除文件夹
|
||||
if (file22.getParentFile().delete()) {
|
||||
// 删除成功
|
||||
} else {
|
||||
// 删除失败
|
||||
}
|
||||
}else {
|
||||
file22.getParentFile().mkdirs();
|
||||
Log.d("HHHHHHHHHH", "创建文件夹失败");
|
||||
}
|
||||
ExecutorService executor = Executors.newFixedThreadPool(4); // 创建一个固定大小为4的线程池
|
||||
|
||||
for (int i = 0; i < album.getImage_urls().size(); i++) {
|
||||
int finalI = i;
|
||||
executor.submit(() -> {
|
||||
String imageUrl = album.getImage_urls().get(finalI);
|
||||
int num = album.getNums().get(finalI);
|
||||
String FileName = "image_" + album.getAlbum_id() + "_" + finalI + ".jpg";
|
||||
File file = FileUtils.getCacheDir(getBaseContext(), FileName);
|
||||
Log.d("HHHHHHHHHH", "创建文件失败");
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(imageUrl)
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
Bitmap decodedBitmap = decodeImage(resource, num);
|
||||
saveBitmapToFile(decodedBitmap, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(Drawable placeholder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
super.onLoadFailed(errorDrawable);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
executor.shutdown(); // 关闭线程池
|
||||
}
|
||||
|
||||
private void downloadAllImages() {
|
||||
String folderName = album.getName();
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
@@ -22,6 +23,7 @@ import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.radiobutton.MaterialRadioButton;
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
@@ -32,6 +34,7 @@ import org.astral.findmaimaiultra.service.GitHubApiService;
|
||||
import org.astral.findmaimaiultra.ui.ImagePickerListener;
|
||||
import org.astral.findmaimaiultra.ui.LinkQQBot;
|
||||
import org.astral.findmaimaiultra.utill.GitHubApiClient;
|
||||
import org.w3c.dom.Text;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@@ -50,7 +53,8 @@ public class SlideshowFragment extends Fragment {
|
||||
private String y;
|
||||
private FragmentSlideshowBinding binding;
|
||||
private ImagePickerListener imagePickerListener;
|
||||
|
||||
private int iconId;
|
||||
private String username;
|
||||
private static final String[] REQUIRED_PERMISSIONS = {
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
@@ -70,7 +74,8 @@ public class SlideshowFragment extends Fragment {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
settingProperties = requireActivity().getSharedPreferences("setting", Context.MODE_PRIVATE);
|
||||
|
||||
username = settingProperties.getString("paikaname", "");
|
||||
iconId = settingProperties.getInt("iconId", 0);
|
||||
if (allPermissionsGranted()) {
|
||||
// 初始化代码
|
||||
} else {
|
||||
@@ -171,6 +176,13 @@ public class SlideshowFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
webView.loadUrl(url); // 加载网页
|
||||
|
||||
ImageView user_avatar = binding.useravatar ;
|
||||
Glide.with(this)
|
||||
.load("https://assets2.lxns.net/maimai/icon/" + iconId +".png")
|
||||
.into(user_avatar);
|
||||
TextView user_name = binding.username;
|
||||
user_name.setText(username);
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
BIN
app/src/main/res/drawable/icon.png
Normal file
BIN
app/src/main/res/drawable/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
BIN
app/src/main/res/drawable/loading.png
Normal file
BIN
app/src/main/res/drawable/loading.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
@@ -6,6 +6,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.slideshow.SlideshowFragment">
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
@@ -13,12 +14,46 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorOnPrimary"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
<!-- 开关按钮示例 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="16dp"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<!-- 用户头像 -->
|
||||
<ImageView
|
||||
android:id="@+id/useravatar"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginEnd="16dp" />
|
||||
|
||||
<!-- 用户名容器 -->
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/username"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="未绑定"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/textcolorPrimary"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center_vertical|start"/> <!-- 距离顶部4dp -->
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/switchBeta1"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
android:scrollbars="vertical"
|
||||
android:scrollbarSize="8dp"
|
||||
android:scrollbarFadeDuration="300"
|
||||
android:scrollbarTrackVertical="@color/primary"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark"
|
||||
android:orientation="vertical"
|
||||
android:gravity="bottom">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
<color name="primary_light">#D1C4E9</color>
|
||||
<color name="accent">#D5C4ED</color>
|
||||
<color name="primary_text">#8C8181</color>
|
||||
<color name="backg">#CCA4A4</color>
|
||||
|
||||
<color name="secondary_text">#727272</color>
|
||||
<color name="icons">#FFFFFF</color>
|
||||
<color name="divider">#B6B6B6</color>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="left">8dp</dimen>
|
||||
|
||||
<dimen name="activity_vertical_margin">32dp</dimen>
|
||||
<dimen name="nav_header_vertical_spacing">8dp</dimen>
|
||||
<dimen name="nav_header_height">176dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
|
||||
Reference in New Issue
Block a user