1.6.4beta
This commit is contained in:
@@ -11,7 +11,7 @@ android {
|
||||
minSdk 29
|
||||
targetSdk 34
|
||||
versionCode 1
|
||||
versionName "1.6.3 beta"
|
||||
versionName "1.6.3"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ public class PhotoAdapter extends RecyclerView.Adapter<PhotoAdapter.PhotoViewHol
|
||||
this.nums = nums;
|
||||
this.album = a;
|
||||
}
|
||||
public void updateItem(int position) {
|
||||
notifyItemChanged(position);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
|
||||
@@ -136,17 +136,15 @@ public class JMActivity extends AppCompatActivity {
|
||||
private void getAll() {
|
||||
File file22 = FileUtils.getCacheDir(getBaseContext(), "lock");
|
||||
if (file22.getParentFile().exists()) {
|
||||
//删除文件夹
|
||||
if (file22.getParentFile().delete()) {
|
||||
// 删除成功
|
||||
} else {
|
||||
// 删除失败
|
||||
if (!file22.getParentFile().delete()) {
|
||||
Log.d("HHHHHHHHHH", "删除文件夹失败");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
file22.getParentFile().mkdirs();
|
||||
Log.d("HHHHHHHHHH", "创建文件夹失败");
|
||||
}
|
||||
ExecutorService executor = Executors.newFixedThreadPool(4); // 创建一个固定大小为4的线程池
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(4);
|
||||
|
||||
for (int i = 0; i < album.getImage_urls().size(); i++) {
|
||||
int finalI = i;
|
||||
@@ -155,7 +153,7 @@ public class JMActivity extends AppCompatActivity {
|
||||
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)
|
||||
@@ -164,6 +162,9 @@ public class JMActivity extends AppCompatActivity {
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
Bitmap decodedBitmap = decodeImage(resource, num);
|
||||
saveBitmapToFile(decodedBitmap, file);
|
||||
|
||||
// 主线程中刷新适配器
|
||||
runOnUiThread(() -> photoAdapter.updateItem(finalI));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,9 +179,10 @@ public class JMActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
executor.shutdown(); // 关闭线程池
|
||||
executor.shutdown();
|
||||
}
|
||||
|
||||
|
||||
private void downloadAllImages() {
|
||||
String folderName = album.getName();
|
||||
File folder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + File.separator + "findmaimaiultra"), folderName);
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.astral.findmaimaiultra.R;
|
||||
import org.astral.findmaimaiultra.been.Place;
|
||||
import org.astral.findmaimaiultra.databinding.ActivityMainBinding;
|
||||
import org.astral.findmaimaiultra.ui.home.HomeFragment;
|
||||
import org.astral.findmaimaiultra.utill.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -438,6 +439,12 @@ public class MainActivity extends AppCompatActivity implements ImagePickerListen
|
||||
editor.apply();
|
||||
show("成功");
|
||||
Log.d("SettingActivity", "图片已保存到: " + croppedFile.getAbsolutePath());
|
||||
|
||||
File backgroundFile =FileUtils.getBackground(this, "background.jpg");
|
||||
try (FileOutputStream out2 = new FileOutputStream(backgroundFile)) {
|
||||
photo.compress(Bitmap.CompressFormat.JPEG, 90, out2);
|
||||
Log.d("SettingActivity", "背景图片已保存到: " + backgroundFile.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
show("失败");
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.baidu.mapapi.map.*;
|
||||
import com.baidu.mapapi.model.LatLng;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import okhttp3.*;
|
||||
@@ -73,6 +74,11 @@ public class PageActivity extends AppCompatActivity {
|
||||
public static int id;
|
||||
private MapView mapView;
|
||||
private BaiduMap baiduMap;
|
||||
private MapView dialogMapView;
|
||||
private BaiduMap dialogBaiduMap;
|
||||
private LatLng selectedLatLng = null;
|
||||
private AlertDialog mapDialog;
|
||||
|
||||
@Override
|
||||
@SuppressLint({"MissingInflatedId", "Range", "SetTextI18n", "UnspecifiedRegisterReceiverFlag"})
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -392,7 +398,7 @@ public class PageActivity extends AppCompatActivity {
|
||||
baiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(latLng, 13)); // 缩放级别调整为
|
||||
// 添加独特样式的标记
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.logo); // 自定义图标资源
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, 200, 130, true); // 缩放到 100x100 像素
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, 300, 130, true); // 缩放到 100x100 像素
|
||||
BitmapDescriptor descriptor = BitmapDescriptorFactory.fromBitmap(scaledBitmap);
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(latLng)
|
||||
@@ -400,9 +406,156 @@ public class PageActivity extends AppCompatActivity {
|
||||
.icon(descriptor); // 使用自定义图标
|
||||
baiduMap.addOverlay(markerOptions);
|
||||
|
||||
|
||||
|
||||
MaterialButton moveButton = findViewById(R.id.move);
|
||||
moveButton.setOnClickListener(v -> showBaiduMapDialog());
|
||||
}
|
||||
private void showBaiduMapDialog() {
|
||||
// 加载弹窗布局
|
||||
View dialogView = getLayoutInflater().inflate(R.layout.dialog_baidu_map, null);
|
||||
|
||||
// 初始化 MapView 和 BaiduMap
|
||||
dialogMapView = dialogView.findViewById(R.id.dialogMapView);
|
||||
dialogMapView.onCreate(this, null);
|
||||
dialogBaiduMap = dialogMapView.getMap();
|
||||
|
||||
// 设置当前地点为中心点
|
||||
LatLng currentLatLng = new LatLng(place.getY(), place.getX()); // 注意:百度地图是 lat, lng
|
||||
dialogBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(currentLatLng, 15));
|
||||
|
||||
// 显示 Snackbar 提示用户点击地图
|
||||
TextView mapTip = dialogView.findViewById(R.id.mapTip);
|
||||
Snackbar.make(PageActivity.this.findViewById(android.R.id.content), "点击地图选择新的位置", Snackbar.LENGTH_LONG).show();
|
||||
|
||||
// 地图点击监听器
|
||||
dialogBaiduMap.setOnMapClickListener(new BaiduMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(LatLng latLng) {
|
||||
selectedLatLng = latLng;
|
||||
//选择位置添加一个标记
|
||||
dialogBaiduMap.clear();
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.logo);
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, 300, 130, true);
|
||||
BitmapDescriptor descriptor = BitmapDescriptorFactory.fromBitmap(scaledBitmap);
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(latLng)
|
||||
.title("新位置")
|
||||
.icon(descriptor);
|
||||
dialogBaiduMap.addOverlay(markerOptions);
|
||||
|
||||
Toast.makeText(PageActivity.this, "已选择新位置:" + latLng.latitude + ", " + latLng.longitude, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapPoiClick(MapPoi mapPoi) {}
|
||||
});
|
||||
|
||||
// 确定按钮点击事件
|
||||
MaterialButton confirmBtn = dialogView.findViewById(R.id.dialogConfirmBtn);
|
||||
confirmBtn.setOnClickListener(v -> {
|
||||
if (selectedLatLng != null) {
|
||||
// 更新 Place 的经纬度
|
||||
Log.d("TAG", "old: " + place.getY() + " " + place.getX());
|
||||
place.setX(selectedLatLng.longitude); // 注意:百度是 lat, lng,所以这里 longitude 是 X
|
||||
place.setY(selectedLatLng.latitude); // latitude 是 Y
|
||||
Log.d("TAG", "onClick: " + selectedLatLng.latitude + " " + selectedLatLng.longitude);
|
||||
// 关闭弹窗并刷新地图
|
||||
mapDialog.dismiss();
|
||||
updateMapLocation(); // 刷新主界面地图标记
|
||||
Toast.makeText(this, "经纬度已更新", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(this, "请先选择一个位置", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
// 取消按钮点击事件
|
||||
MaterialButton cancelBtn = dialogView.findViewById(R.id.dialogCancelBtn);
|
||||
cancelBtn.setOnClickListener(v -> mapDialog.dismiss());
|
||||
|
||||
// 构建并显示弹窗
|
||||
mapDialog = new AlertDialog.Builder(this)
|
||||
.setView(dialogView)
|
||||
.setTitle("选择新位置")
|
||||
.create();
|
||||
mapDialog.show();
|
||||
}
|
||||
private void updateMapLocation() {
|
||||
mapView.onDestroy();
|
||||
mapView = findViewById(R.id.bmapView);
|
||||
mapView.onCreate(this, null);
|
||||
baiduMap = mapView.getMap();
|
||||
|
||||
LatLng latLng = new LatLng(place.getY(), place.getX());
|
||||
baiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(latLng, 13));
|
||||
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.logo);
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, 300, 130, true);
|
||||
BitmapDescriptor descriptor = BitmapDescriptorFactory.fromBitmap(scaledBitmap);
|
||||
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(latLng)
|
||||
.title("机厅位置")
|
||||
.icon(descriptor);
|
||||
baiduMap.clear();
|
||||
baiduMap.addOverlay(markerOptions);
|
||||
|
||||
//构造json
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("https://mais.godserver.cn/api/mai/v1/place2")
|
||||
.put(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(place)))
|
||||
.build();
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
||||
runOnUiThread(() -> {
|
||||
Toast.makeText(PageActivity.this, "更新位置失败", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
runOnUiThread(() -> {
|
||||
try {
|
||||
Log.d("TAG", "onResponse: " + response.body().string());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Snackbar.make(PageActivity.this.findViewById(android.R.id.content), "位置上传成功", Snackbar.LENGTH_LONG).show();
|
||||
});
|
||||
} else {
|
||||
runOnUiThread(() -> {
|
||||
Toast.makeText(PageActivity.this, "更新位置失败", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (dialogMapView != null) {
|
||||
dialogMapView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (dialogMapView != null) {
|
||||
dialogMapView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (dialogMapView != null) {
|
||||
dialogMapView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
private void getContent() {
|
||||
MaterialButton button = findViewById(R.id.list);
|
||||
@@ -792,7 +945,7 @@ public class PageActivity extends AppCompatActivity {
|
||||
protected String doInBackground(Void... voids) {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
try {
|
||||
String web = "http://www.godserver.cn:11451/api/mai/v1/placePeo?";
|
||||
String web = "https://mais.godserver.cn/api/mai/v1/placePeo?";
|
||||
// 将JSON对象转换为RequestBody
|
||||
MediaType JSON = MediaType.get("application/json; charset=utf-8");
|
||||
@SuppressLint("StaticFieldLeak") Request request = new Request.Builder()
|
||||
|
||||
@@ -62,7 +62,7 @@ public class GalleryFragment extends Fragment {
|
||||
|
||||
// 添加独特样式的标记
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.logo); // 自定义图标资源
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, 200, 130, true); // 缩放到 100x100 像素
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, 300, 130, true); // 缩放到 100x100 像素
|
||||
BitmapDescriptor descriptor = BitmapDescriptorFactory.fromBitmap(scaledBitmap);
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.position(latLng)
|
||||
|
||||
@@ -53,8 +53,10 @@ import org.astral.findmaimaiultra.databinding.FragmentHomeBinding;
|
||||
import org.astral.findmaimaiultra.ui.MainActivity;
|
||||
import org.astral.findmaimaiultra.ui.PageActivity;
|
||||
import org.astral.findmaimaiultra.utill.AddressParser;
|
||||
import org.astral.findmaimaiultra.utill.FileUtils;
|
||||
import org.astral.findmaimaiultra.utill.SharedViewModel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -126,9 +128,16 @@ public class HomeFragment extends Fragment {
|
||||
}
|
||||
|
||||
if (settingProperties2.getString("image_uri", null) != null ) {
|
||||
Uri uri = Uri.parse(settingProperties2.getString("image_uri", null));
|
||||
try {
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(getContext().getContentResolver().openInputStream(uri));
|
||||
File backgroundFile =FileUtils.getBackground(requireContext(), "background.jpg");
|
||||
|
||||
if (!backgroundFile.exists()) {
|
||||
Toast.makeText(requireContext(), "文件不存在,请先设置背景图片", Toast.LENGTH_SHORT).show();
|
||||
return root;
|
||||
}
|
||||
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(backgroundFile.getAbsolutePath());
|
||||
|
||||
if (bitmap != null) {
|
||||
// 获取RecyclerView的尺寸
|
||||
int recyclerViewWidth = 0;
|
||||
@@ -240,6 +249,7 @@ public class HomeFragment extends Fragment {
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Toast.makeText(requireContext(), "图片加载失败,权限出错!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,13 @@ public class FileUtils {
|
||||
}
|
||||
return new File(cacheDir, fileName);
|
||||
}
|
||||
|
||||
public static File getBackground(Context context, String fileName) {
|
||||
File cacheDir = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), "background");
|
||||
if (!cacheDir.exists()) {
|
||||
cacheDir.mkdirs();
|
||||
}
|
||||
return new File(cacheDir, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 323 KiB After Width: | Height: | Size: 3.5 KiB |
@@ -152,7 +152,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="赞"
|
||||
android:paddingLeft="16sp"
|
||||
android:layout_marginLeft="2mm"
|
||||
android:layout_centerInParent="true"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/disButton"
|
||||
@@ -166,9 +165,17 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16sp"
|
||||
android:text="大众评价"
|
||||
android:text="评论"
|
||||
android:layout_marginLeft="2mm"
|
||||
android:layout_centerInParent="true"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/move"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16sp"
|
||||
android:text="移动"
|
||||
android:layout_marginLeft="2mm"
|
||||
android:layout_centerInParent="true"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:layout_width="match_parent" android:paddingLeft="16sp" android:layout_height="wrap_content" android:orientation="horizontal">
|
||||
<com.google.android.material.button.MaterialButton
|
||||
|
||||
42
app/src/main/res/layout/dialog_baidu_map.xml
Normal file
42
app/src/main/res/layout/dialog_baidu_map.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mapTip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="点击地图选择新的位置"
|
||||
android:textSize="16sp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<com.baidu.mapapi.map.MapView
|
||||
android:id="@+id/dialogMapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="300dp"
|
||||
android:clickable="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="end"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/dialogConfirmBtn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="确定" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/dialogCancelBtn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="取消"
|
||||
android:layout_marginLeft="8dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -67,6 +67,10 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="下载全部本子" />
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="收藏"
|
||||
android:id="@+id/shoucang"/>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
Reference in New Issue
Block a user