V1.0.0(3) ui优化,bug优化,增加删除功能
This commit is contained in:
parent
b58024ca73
commit
a2ee1ac4a3
@ -19,6 +19,7 @@
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:name=".MainApplication"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/logo"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
package com.lh.painting;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
@ -7,16 +8,15 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lh.painting.adapter.ImageAdapter;
|
||||
import com.lh.painting.databinding.ActivityImportBinding;
|
||||
import com.lh.painting.tool.MyItemSpace;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import com.lh.painting.tool.ItemDecoration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -26,9 +26,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportActivity extends AppCompatActivity {
|
||||
private ActivityImportBinding binding;
|
||||
RecyclerView recyclerView;
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 202; // 请求码,用于标识图片选择
|
||||
RecyclerView recyclerView;
|
||||
private ActivityImportBinding binding;
|
||||
private ImageAdapter adapter;
|
||||
private List<String> imagePaths = new ArrayList<>(); // 图片路径列表
|
||||
|
||||
@ -97,8 +97,8 @@ public class ImportActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
imagePaths.add(imagePath);
|
||||
Log.d("2332323", "run: "+imagePaths.size());
|
||||
if (!imagePaths.isEmpty()){
|
||||
Log.d("2332323", "run: " + imagePaths.size());
|
||||
if (!imagePaths.isEmpty()) {
|
||||
binding.importBackground.setVisibility(View.GONE);
|
||||
binding.importText.setVisibility(View.GONE);
|
||||
}
|
||||
@ -115,11 +115,11 @@ public class ImportActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void setRecyclerView() {
|
||||
MyItemSpace myItemSpace = new MyItemSpace(16, 20, 15);
|
||||
recyclerView.addItemDecoration(myItemSpace);
|
||||
ItemDecoration itemDecoration = new ItemDecoration(16, 19, 10);
|
||||
recyclerView.addItemDecoration(itemDecoration);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
Log.d("22222225555", "onCreate: " + imagePaths.size());
|
||||
adapter = new ImageAdapter(imagePaths, this,this);
|
||||
adapter = new ImageAdapter(imagePaths, this, this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@ -178,13 +178,23 @@ public class ImportActivity extends AppCompatActivity {
|
||||
if (!imagePaths.isEmpty()) {
|
||||
binding.importBackground.setVisibility(View.GONE);
|
||||
binding.importText.setVisibility(View.GONE);
|
||||
}else {
|
||||
} else {
|
||||
binding.importBackground.setVisibility(View.VISIBLE);
|
||||
binding.importText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteImage(String imagePath, ImageAdapter adapter) {
|
||||
File imageFile = new File(imagePath);
|
||||
if (imageFile.exists()) {
|
||||
imageFile.delete();// 删除文件
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ public class InitialPageActivity extends AppCompatActivity {
|
||||
}
|
||||
Intent intent = new Intent(InitialPageActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
33
app/src/main/java/com/lh/painting/MainApplication.java
Normal file
33
app/src/main/java/com/lh/painting/MainApplication.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.lh.painting;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
/**
|
||||
* 全局的上下文
|
||||
*/
|
||||
private static Context mContext;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
//获取应用的上下文并赋值给 mContext
|
||||
mContext = getApplicationContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取context
|
||||
* @return
|
||||
*/
|
||||
public static Context getContext(){
|
||||
return mContext;
|
||||
}
|
||||
|
||||
//重写 onLowMemory 方法,在系统内存不足时调用。这里只是调用了父类的 onLowMemory 方法,没有做其他处理
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,27 +1,20 @@
|
||||
package com.lh.painting;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.lh.painting.adapter.HomeAdapter;
|
||||
import com.lh.painting.adapter.LikeAdapter;
|
||||
import com.lh.painting.dao.TaskDao;
|
||||
import com.lh.painting.databinding.ActivityImportBinding;
|
||||
import com.lh.painting.databinding.ActivityMyFavotriteBinding;
|
||||
import com.lh.painting.db.AppDatabase;
|
||||
import com.lh.painting.entity.Favorite;
|
||||
import com.lh.painting.manager.Keys;
|
||||
import com.lh.painting.tool.MyItemSpace;
|
||||
import com.lh.painting.tool.ItemDecoration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -81,8 +74,8 @@ public class MyFavotrite extends AppCompatActivity {
|
||||
Log.d("3333333333", "setRecyclerview: "+favoriteList.size());
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(MyFavotrite.this, 2);
|
||||
binding.likeRecyclerview.setLayoutManager(gridLayoutManager);
|
||||
MyItemSpace myItemSpace = new MyItemSpace( 16,20, 15);
|
||||
binding.likeRecyclerview.addItemDecoration(myItemSpace);
|
||||
ItemDecoration itemDecoration = new ItemDecoration(16, 19, 10);
|
||||
binding.likeRecyclerview.addItemDecoration(itemDecoration);
|
||||
binding.likeRecyclerview.setAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
@ -1,30 +1,27 @@
|
||||
package com.lh.painting;
|
||||
|
||||
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.lh.painting.adapter.HomeAdapter;
|
||||
import com.lh.painting.databinding.FragmentPaintingBinding;
|
||||
|
||||
import com.lh.painting.manager.Keys;
|
||||
import com.lh.painting.tool.MyItemSpace;
|
||||
import com.lh.painting.tool.ItemDecoration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PaintingFragment extends Fragment {
|
||||
private FragmentPaintingBinding binding;
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
private FragmentPaintingBinding binding;
|
||||
private String dirStr;
|
||||
private int mParam1;
|
||||
|
||||
// private EndlessRecyclerViewScrollListener scrollListener;
|
||||
// private EndlessRecyclerViewScrollListener scrollListener;
|
||||
|
||||
|
||||
public static PaintingFragment newInstance(int i) {
|
||||
@ -49,20 +46,20 @@ public class PaintingFragment extends Fragment {
|
||||
View view = inflater.inflate(R.layout.fragment_painting, container, false);
|
||||
binding = FragmentPaintingBinding.bind(view);
|
||||
|
||||
setRecyclerView();
|
||||
|
||||
return view;
|
||||
}
|
||||
private void setRecyclerView() {
|
||||
//List<String> list = Utils.fileExistsInAssets(requireContext(), dirStr);
|
||||
MyItemSpace myItemSpace = new MyItemSpace( 16,20, 15);
|
||||
binding.recyclerview.addItemDecoration(myItemSpace);
|
||||
dirStr = Keys.getAllDir().get(mParam1);
|
||||
|
||||
HomeAdapter preViewAdapter = new HomeAdapter(requireContext(), dirStr);
|
||||
// binding.recyclerview.addOnScrollListener();
|
||||
// binding.recyclerview.addOnScrollListener();
|
||||
|
||||
binding.recyclerview.setLayoutManager(new GridLayoutManager(requireContext(), 2));
|
||||
|
||||
ItemDecoration itemDecoration = new ItemDecoration(16, 19, 10);
|
||||
binding.recyclerview.addItemDecoration(itemDecoration);
|
||||
|
||||
binding.recyclerview.setAdapter(preViewAdapter);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(requireContext(), 2);
|
||||
binding.recyclerview.setLayoutManager(gridLayoutManager);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
@ -57,74 +57,63 @@ public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.HomeVH> {
|
||||
public void onBindViewHolder(@NonNull HomeVH holder, @SuppressLint("RecyclerView") int position) {
|
||||
|
||||
String filePath = dir + "/" + (position + 1) + ".jpg";
|
||||
//Bitmap bitmap = Utils.loadImageFromAssets(mCon, filePath);
|
||||
|
||||
// 初始化数据库
|
||||
initDb();
|
||||
|
||||
// 重置收藏按钮的初始状态,避免复用问题
|
||||
holder.collect.setImageResource(R.drawable.collect); // 初始状态为未收藏
|
||||
|
||||
// 加载图片
|
||||
Glide.with(mCon)
|
||||
.asDrawable()
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.load("file:///android_asset/" + filePath)
|
||||
.into(holder.imPreview);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (dao.getTaskByUrl(filePath) != null) {
|
||||
Log.d("2323232", "run: " + dao.getTaskByUrl(filePath));
|
||||
((Activity) mCon).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder.collect.setBackgroundResource(R.drawable.like);
|
||||
}
|
||||
|
||||
// 查询数据库,更新收藏状态
|
||||
new Thread(() -> {
|
||||
Favorite favorite = dao.getTaskByUrl(filePath); // 查询数据库是否已收藏
|
||||
((Activity) mCon).runOnUiThread(() -> {
|
||||
if (favorite != null) {
|
||||
holder.collect.setImageResource(R.drawable.like); // 如果已收藏,设置为收藏状态
|
||||
} else {
|
||||
holder.collect.setImageResource(R.drawable.collect); // 未收藏,显示默认状态
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
|
||||
// 处理点击事件
|
||||
holder.collect.setOnClickListener(view -> {
|
||||
new Thread(() -> {
|
||||
Favorite favorite1 = dao.getTaskByUrl(filePath);
|
||||
if (favorite1 == null) {
|
||||
// 如果未收藏,添加到数据库
|
||||
favorite = new Favorite();
|
||||
favorite.setPicture(filePath);
|
||||
AppDatabase.getDatabase(mCon).taskDao().insertTask(favorite);
|
||||
((Activity) mCon).runOnUiThread(() -> {
|
||||
holder.collect.setImageResource(R.drawable.like); // 更新为已收藏状态
|
||||
});
|
||||
} else {
|
||||
// 如果已收藏,从数据库中移除
|
||||
AppDatabase.getDatabase(mCon).taskDao().deleteTaskByUrl(filePath);
|
||||
((Activity) mCon).runOnUiThread(() -> {
|
||||
holder.collect.setImageResource(R.drawable.collect); // 更新为未收藏状态
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(mCon, CameraActivity.class);
|
||||
intent.putExtra("filePath", filePath);
|
||||
mCon.startActivity(intent);
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
|
||||
|
||||
holder.collect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Favorite favorite1 = dao.getTaskByUrl(filePath);
|
||||
if (favorite1 == null) {
|
||||
favorite = new Favorite();
|
||||
favorite.setPicture(filePath);
|
||||
AppDatabase.getDatabase(mCon).taskDao().insertTask(favorite);
|
||||
Log.d("4444444", "run: " + position);
|
||||
Log.d("4444444", "run: " + filePath);
|
||||
((Activity) mCon).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder.collect.setBackgroundResource(R.drawable.like);
|
||||
Toast.makeText(mCon, "Successful collection", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AppDatabase.getDatabase(mCon).taskDao().deleteTaskByUrl(filePath);
|
||||
Log.d("4444444", "ru: " + filePath);
|
||||
((Activity) mCon).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder.collect.setBackgroundResource(R.drawable.collect);
|
||||
Toast.makeText(mCon, "cancel collection", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
// 处理点击查看大图的事件
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(mCon, CameraActivity.class);
|
||||
intent.putExtra("filePath", filePath);
|
||||
mCon.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void initDb() {
|
||||
//初始化db
|
||||
AppDatabase db = AppDatabase.getDatabase(mCon);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.lh.painting.adapter;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
@ -14,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.lh.painting.CameraActivity;
|
||||
import com.lh.painting.ImportActivity;
|
||||
import com.lh.painting.R;
|
||||
import com.lh.painting.dao.TaskDao;
|
||||
import com.lh.painting.db.AppDatabase;
|
||||
@ -26,8 +28,8 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHol
|
||||
private Context context;
|
||||
private Favorite favorite;
|
||||
private List<String> imagePaths = new ArrayList<>();
|
||||
private Activity activity;
|
||||
public ImageAdapter( List<String> imagePaths , Context context,Activity activity) {
|
||||
private ImportActivity activity;
|
||||
public ImageAdapter(List<String> imagePaths , Context context, ImportActivity activity) {
|
||||
this.imagePaths=imagePaths;
|
||||
this.context=context;
|
||||
this.activity=activity;
|
||||
@ -58,7 +60,7 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHol
|
||||
((Activity) context).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder.collect.setBackgroundResource(R.drawable.like);
|
||||
holder.collect.setImageResource(R.drawable.like);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -73,6 +75,40 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHol
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
holder.itemView.setOnLongClickListener(v -> {
|
||||
// 创建 AlertDialog.Builder
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Confirm deletion");
|
||||
builder.setMessage("Are you sure you want to delete this picture?");
|
||||
|
||||
// 设置删除按钮
|
||||
builder.setPositiveButton("delete", (dialog, which) -> {
|
||||
// 执行删除操作
|
||||
activity.deleteImage(imagePath, this); // 传递适配器实例,调用 ImportActivity 中的删除方法
|
||||
imagePaths.remove(position); // 从列表中移除
|
||||
notifyItemRemoved(position); // 通知适配器更新
|
||||
notifyItemRangeChanged(position, imagePaths.size()); // 更新剩余项的位置
|
||||
|
||||
activity.runOnUiThread(() -> {
|
||||
// 检查列表是否为空,更新 UI
|
||||
if (imagePaths.isEmpty()) {
|
||||
activity.findViewById(R.id.import_background).setVisibility(View.VISIBLE);
|
||||
activity.findViewById(R.id.import_text).setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 设置取消按钮
|
||||
builder.setNegativeButton("cancel", (dialog, which) -> dialog.dismiss());
|
||||
|
||||
// 显示对话框
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
return true; // 表示事件已处理
|
||||
});
|
||||
|
||||
holder.collect.setOnClickListener(new View.OnClickListener() {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
@ -90,8 +126,8 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHol
|
||||
((Activity) context).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder.collect.setBackgroundResource(R.drawable.like);
|
||||
Toast.makeText(context, "Successful collection", Toast.LENGTH_SHORT).show();
|
||||
holder.collect.setImageResource(R.drawable.like);
|
||||
// Toast.makeText(context, "Successful collection", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -100,8 +136,8 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHol
|
||||
((Activity) context).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder.collect.setBackgroundResource(R.drawable.collect);
|
||||
Toast.makeText(context, "cancel collection", Toast.LENGTH_SHORT).show();
|
||||
holder.collect.setImageResource(R.drawable.collect);
|
||||
// Toast.makeText(context, "cancel collection", Toast.LENGTH_SHORT).show();
|
||||
|
||||
}
|
||||
});
|
||||
@ -112,6 +148,7 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHol
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -126,14 +163,15 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHol
|
||||
dao = db.taskDao();
|
||||
}
|
||||
|
||||
|
||||
static class ImageViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView imageView;
|
||||
ImageView collect;
|
||||
ImageView delete;
|
||||
ImageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
imageView = itemView.findViewById(R.id.imPreview);
|
||||
collect = itemView.findViewById(R.id.collect);
|
||||
delete = itemView.findViewById(R.id.delete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ public class LikeAdapter extends RecyclerView.Adapter<LikeAdapter.HomeVH> {
|
||||
public void onBindViewHolder(@NonNull HomeVH holder, @SuppressLint("RecyclerView") int position) {
|
||||
|
||||
String filePath = infoList.get(position).getPicture();
|
||||
Bitmap bitmap;
|
||||
if (filePath.startsWith("/data/user/")) {
|
||||
bitmap = BitmapFactory.decodeFile(filePath);
|
||||
} else {
|
||||
@ -70,72 +71,46 @@ public class LikeAdapter extends RecyclerView.Adapter<LikeAdapter.HomeVH> {
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.load(bitmap)
|
||||
.into(holder.imPreview);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (dao.getTaskByUrl(filePath) != null) {
|
||||
Log.d("2323232", "run: " + dao.getTaskByUrl(filePath));
|
||||
((Activity) mCon).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder.collect.setBackgroundResource(R.drawable.like);
|
||||
}
|
||||
});
|
||||
}
|
||||
new Thread(() -> {
|
||||
if (dao.getTaskByUrl(filePath) != null) {
|
||||
Log.d("2323232", "run: " + dao.getTaskByUrl(filePath));
|
||||
((Activity) mCon).runOnUiThread(() -> holder.collect.setImageResource(R.drawable.like));
|
||||
}
|
||||
}).start();
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(mCon, CameraActivity.class);
|
||||
intent.putExtra("filePath", filePath);
|
||||
mCon.startActivity(intent);
|
||||
}
|
||||
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(mCon, CameraActivity.class);
|
||||
intent.putExtra("filePath", filePath);
|
||||
mCon.startActivity(intent);
|
||||
});
|
||||
|
||||
holder.collect.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Favorite favorite1 = dao.getTaskByUrl(filePath);
|
||||
if (favorite1 == null) {
|
||||
favorite = new Favorite();
|
||||
favorite.setPicture(filePath);
|
||||
AppDatabase.getDatabase(mCon).taskDao().insertTask(favorite);
|
||||
Log.d("4444444", "run: " + position);
|
||||
Log.d("4444444", "run: " + filePath);
|
||||
((Activity) mCon).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
holder.collect.setBackgroundResource(R.drawable.like);
|
||||
Toast.makeText(mCon, "Successful collection", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AppDatabase.getDatabase(mCon).taskDao().deleteTaskByUrl(filePath);
|
||||
holder.collect.setOnClickListener(view -> new Thread(() -> {
|
||||
Favorite favorite1 = dao.getTaskByUrl(filePath);
|
||||
if (favorite1 == null) {
|
||||
favorite = new Favorite();
|
||||
favorite.setPicture(filePath);
|
||||
AppDatabase.getDatabase(mCon).taskDao().insertTask(favorite);
|
||||
Log.d("4444444", "run: " + position);
|
||||
Log.d("4444444", "run: " + filePath);
|
||||
((Activity) mCon).runOnUiThread(() -> holder.collect.setImageResource(R.drawable.like));
|
||||
} else {
|
||||
AppDatabase.getDatabase(mCon).taskDao().deleteTaskByUrl(filePath);
|
||||
|
||||
infoList.remove(holder.getAdapterPosition());
|
||||
Log.d("4444444", "ru: " + filePath);
|
||||
((Activity) mCon).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (infoList.isEmpty()){
|
||||
activity.findViewById(R.id.like_background).setVisibility(View.VISIBLE);
|
||||
activity.findViewById(R.id.like_text).setVisibility(View.VISIBLE);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
|
||||
Toast.makeText(mCon, "cancel collection", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
int positionToRemove = holder.getAdapterPosition();
|
||||
infoList.remove(positionToRemove);
|
||||
Log.d("4444444", "ru: " + filePath);
|
||||
((Activity) mCon).runOnUiThread(() -> {
|
||||
if (infoList.isEmpty()) {
|
||||
activity.findViewById(R.id.like_background).setVisibility(View.VISIBLE);
|
||||
activity.findViewById(R.id.like_text).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}).start();
|
||||
notifyItemRemoved(positionToRemove);
|
||||
notifyItemRangeChanged(positionToRemove, infoList.size()); // Update the position of remaining items
|
||||
});
|
||||
}
|
||||
});
|
||||
}).start());
|
||||
}
|
||||
|
||||
/* private void updateFavoriteButton(ImageAdapter.ImageViewHolder holder, String imagePath) {
|
||||
LiveData<Favorite> favoriteImageLiveData = dao.getTaskByUrl(imagePath);
|
||||
favoriteImageLiveData.observe((LifecycleOwner) mCon, new Observer<Favorite>() {
|
||||
|
||||
96
app/src/main/java/com/lh/painting/tool/ItemDecoration.java
Normal file
96
app/src/main/java/com/lh/painting/tool/ItemDecoration.java
Normal file
@ -0,0 +1,96 @@
|
||||
package com.lh.painting.tool;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
import com.lh.painting.MainApplication;
|
||||
|
||||
// ItemDecoration 是一个自定义的 RecyclerView.ItemDecoration 类,用于在 RecyclerView 中为每个子项设置间距。
|
||||
public class ItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
// 垂直间距 (vertical spacing)、水平间距 (horizontal spacing) 和额外间距 (extra spacing):这里设置的是第一个的左边距,其它item根据剩余的距离均匀显示。
|
||||
private int v, h, ex;
|
||||
|
||||
// 构造函数,传入 dp 值的垂直、水平和额外间距,并将它们转换为像素值。
|
||||
public ItemDecoration(int v, int h, int ex) {
|
||||
// 将 dp 值转换为像素值并四舍五入
|
||||
this.v = Math.round(dpToPx(v));
|
||||
this.h = Math.round(dpToPx(h));
|
||||
this.ex = Math.round(dpToPx(ex));
|
||||
}
|
||||
|
||||
// 重写 getItemOffsets 方法,用于为每个子项设置偏移量(间距)。
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
|
||||
// 定义网格的列数(spanCount)、子项所占的列数(spanSize)以及子项在网格中的索引(spanIndex)
|
||||
int spanCount = 1; // 列数默认为 1
|
||||
int spanSize = 1; // 子项所占列数默认为 1
|
||||
int spanIndex = 0; // 子项在网格中的索引默认为 0
|
||||
|
||||
// 获取子项在 Adapter 中的位置
|
||||
int childAdapterPosition = parent.getChildAdapterPosition(view);
|
||||
// 获取 RecyclerView 的布局管理器
|
||||
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
|
||||
|
||||
// 如果布局管理器是 StaggeredGridLayoutManager(交错网格布局管理器)
|
||||
if (layoutManager instanceof StaggeredGridLayoutManager) {
|
||||
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
|
||||
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
|
||||
spanCount = staggeredGridLayoutManager.getSpanCount(); // 获取列数
|
||||
// 如果子项占据整行(isFullSpan),将 spanSize 设置为列数
|
||||
if (layoutParams.isFullSpan()) {
|
||||
spanSize = spanCount;
|
||||
}
|
||||
spanIndex = layoutParams.getSpanIndex(); // 获取子项的索引
|
||||
|
||||
// 如果布局管理器是 GridLayoutManager(网格布局管理器)
|
||||
} else if (layoutManager instanceof GridLayoutManager) {
|
||||
GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
|
||||
GridLayoutManager.LayoutParams layoutParams = (GridLayoutManager.LayoutParams) view.getLayoutParams();
|
||||
spanCount = gridLayoutManager.getSpanCount(); // 获取列数
|
||||
spanSize = gridLayoutManager.getSpanSizeLookup().getSpanSize(childAdapterPosition); // 获取子项占据的列数
|
||||
spanIndex = layoutParams.getSpanIndex(); // 获取子项的索引
|
||||
|
||||
// 如果布局管理器是 LinearLayoutManager(线性布局管理器)
|
||||
} else if (layoutManager instanceof LinearLayoutManager) {
|
||||
// 设置子项的左、右和底部的间距
|
||||
outRect.left = v;
|
||||
outRect.right = v;
|
||||
outRect.bottom = h;
|
||||
}
|
||||
|
||||
// 如果子项占据整行(spanSize == spanCount),设置左、右和底部的间距
|
||||
if (spanSize == spanCount) {
|
||||
outRect.left = v + ex;
|
||||
outRect.right = v + ex;
|
||||
outRect.bottom = h;
|
||||
|
||||
// 如果子项不占据整行,根据网格布局计算左右间距
|
||||
} else {
|
||||
// 计算每个子项的总间距(包括额外间距)
|
||||
int itemAllSpacing = (v * (spanCount + 1) + ex * 2) / spanCount;
|
||||
// 计算子项的左边距
|
||||
int left = v * (spanIndex + 1) - itemAllSpacing * spanIndex + ex;
|
||||
// 计算子项的右边距
|
||||
int right = itemAllSpacing - left;
|
||||
outRect.left = left;
|
||||
outRect.right = right;
|
||||
outRect.bottom = h;
|
||||
}
|
||||
}
|
||||
|
||||
// 将 dp 值转换为像素值的方法
|
||||
public static float dpToPx(float dpValue) {
|
||||
// 获取当前设备的屏幕密度(dpi)
|
||||
float density = MainApplication.getContext().getResources().getDisplayMetrics().density;
|
||||
// 通过公式 density * dp + 0.5f 将 dp 转换为像素,并返回结果
|
||||
return density * dpValue + 0.5f;
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
package com.lh.painting.tool;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class MyItemSpace extends RecyclerView.ItemDecoration {
|
||||
private int ex_space = 0;
|
||||
private int v_space = 0;
|
||||
private int h_space = 0;
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
|
||||
int position = parent.getChildAdapterPosition(view);
|
||||
int spanSize = 1;
|
||||
int spanIndex = 0;
|
||||
int spanCount = 1;
|
||||
|
||||
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
|
||||
|
||||
if (layoutManager instanceof GridLayoutManager) {
|
||||
GridLayoutManager layoutManager1 = (GridLayoutManager) layoutManager;
|
||||
GridLayoutManager.LayoutParams layoutParams = (GridLayoutManager.LayoutParams) view.getLayoutParams();
|
||||
spanCount = layoutManager1.getSpanCount();
|
||||
spanSize = layoutManager1.getSpanSizeLookup().getSpanSize(position);
|
||||
spanIndex = layoutParams.getSpanIndex();
|
||||
|
||||
}
|
||||
if (spanSize == spanCount) {
|
||||
outRect.left = v_space + ex_space;
|
||||
outRect.right = v_space + ex_space;
|
||||
outRect.bottom = h_space;
|
||||
} else {
|
||||
int itemAllSpacing = (v_space * (spanCount + 1) + ex_space * 2) / spanCount;
|
||||
int left = v_space * (spanIndex + 1) - itemAllSpacing * spanIndex + ex_space;
|
||||
int right = itemAllSpacing - left;
|
||||
outRect.left = left;
|
||||
outRect.right = right;
|
||||
outRect.bottom = h_space;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MyItemSpace(int v_space, int h_space, int ex_space) {
|
||||
this.ex_space = ex_space;
|
||||
this.h_space = h_space;
|
||||
this.v_space = v_space;
|
||||
|
||||
}
|
||||
}
|
||||
9
app/src/main/res/drawable/delete.xml
Normal file
9
app/src/main/res/drawable/delete.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:pathData="M8.699,15.061C9.066,15.061 9.365,14.764 9.365,14.394L8.699,7.746C8.699,7.379 8.402,7.08 8.033,7.08C7.664,7.08 7.367,7.377 7.367,7.746L8.033,14.394C8.035,14.762 8.332,15.061 8.699,15.061ZM16.678,3.756H12.025V3.424C12.025,2.689 11.43,2.094 10.695,2.094H9.365C8.631,2.094 8.035,2.689 8.035,3.424V3.756H3.381C3.014,3.756 2.715,4.053 2.715,4.422C2.715,4.789 3.012,5.088 3.381,5.088H16.68C17.047,5.088 17.346,4.791 17.346,4.422C17.346,4.053 17.047,3.756 16.678,3.756ZM10.695,3.756H9.365V3.424H10.695V3.756ZM15.418,5.762C15.031,5.762 14.715,6.066 14.697,6.449L13.223,16.391H6.842L5.361,6.418H5.354C5.318,6.051 5.01,5.762 4.637,5.762C4.26,5.762 3.951,6.049 3.92,6.418H3.895L5.258,16.783C5.264,16.729 5.26,16.668 5.248,16.602C5.348,17.236 5.898,17.721 6.561,17.721H13.518C14.184,17.721 14.734,17.232 14.83,16.598C14.822,16.641 14.82,16.68 14.82,16.721L16.172,6.416H16.137C16.1,6.049 15.793,5.762 15.418,5.762ZM12.025,14.394L12.691,7.746C12.691,7.379 12.394,7.08 12.025,7.08C11.656,7.08 11.359,7.377 11.359,7.746L10.693,14.394C10.693,14.762 10.99,15.061 11.359,15.061C11.727,15.061 12.025,14.762 12.025,14.394Z"
|
||||
android:fillColor="#FF6565"/>
|
||||
</vector>
|
||||
@ -54,7 +54,5 @@
|
||||
android:id="@+id/view_pager2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="20dp"/>
|
||||
android:layout_marginTop="20dp" />
|
||||
</LinearLayout>
|
||||
@ -1,61 +1,63 @@
|
||||
<RelativeLayout 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:id="@+id/details_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background"
|
||||
>
|
||||
android:background="@color/background">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginTop="40dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
tools:ignore="InvalidId">
|
||||
|
||||
<FrameLayout
|
||||
android:background="@drawable/rounded_corners_camera"
|
||||
android:id="@+id/imageview_back"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp">
|
||||
android:layout_height="44dp"
|
||||
android:background="@drawable/bg_circle">
|
||||
|
||||
<ImageView
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/imageview_back"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:src="@drawable/back_icon" />
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/left_back" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/details_text"
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="@string/import_photo"
|
||||
android:textColor="@color/text_color"
|
||||
android:textStyle="bold"
|
||||
android:textSize="24sp">
|
||||
</TextView>
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/import_background"
|
||||
android:layout_width="193dp"
|
||||
android:layout_height="193dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@+id/text"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="153dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@mipmap/painting"
|
||||
tools:ignore="ContentDescription">
|
||||
</ImageView>
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/import_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@+id/import_background"
|
||||
>
|
||||
android:layout_centerHorizontal="true">
|
||||
|
||||
<TextView
|
||||
android:layout_width="260dp"
|
||||
android:layout_height="wrap_content"
|
||||
@ -68,13 +70,14 @@
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_marginTop="10dp"
|
||||
android:id="@+id/import_recyclerview"
|
||||
android:layout_below="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</androidx.recyclerview.widget.RecyclerView>
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/text"
|
||||
android:layout_marginTop="10dp"></androidx.recyclerview.widget.RecyclerView>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/import_photo"
|
||||
android:layout_width="327dp"
|
||||
@ -82,17 +85,16 @@
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="70dp"
|
||||
android:background="@drawable/rounded_corners_import"
|
||||
>
|
||||
android:background="@drawable/rounded_corners_import">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/import_icon"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_toLeftOf="@+id/text2"
|
||||
>
|
||||
</ImageView>
|
||||
android:src="@drawable/import_icon"></ImageView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="109dp"
|
||||
@ -100,8 +102,7 @@
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/import_photo"
|
||||
android:textColor="@color/white">
|
||||
</TextView>
|
||||
android:textColor="@color/white"></TextView>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
@ -17,14 +17,14 @@
|
||||
tools:ignore="InvalidId">
|
||||
<FrameLayout
|
||||
android:id="@+id/imageview_back"
|
||||
android:background="@drawable/rounded_corners_camera"
|
||||
android:background="@drawable/bg_circle"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp">
|
||||
<ImageView
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:src="@drawable/back_icon" />
|
||||
android:src="@drawable/left_back" />
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/details_text"
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
android:layout_marginTop="40dp"
|
||||
>
|
||||
<FrameLayout
|
||||
android:background="@drawable/rounded_corners_camera"
|
||||
android:background="@drawable/bg_circle"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp">
|
||||
<ImageView
|
||||
@ -24,7 +24,7 @@
|
||||
android:id="@+id/imageview_back"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:src="@drawable/back_icon" />
|
||||
android:src="@drawable/left_back" />
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/details_text"
|
||||
|
||||
44
app/src/main/res/layout/adapter_home_new.xml
Normal file
44
app/src/main/res/layout/adapter_home_new.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView 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:id="@+id/card"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="146dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/imPreview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/collect"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:padding="10dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:src="@drawable/delete" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/collect"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:padding="10dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:src="@drawable/collect" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@ -3,36 +3,33 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="160dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="146dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="0dp">
|
||||
|
||||
<RelativeLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/imPreview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal">
|
||||
android:layout_below="@id/collect"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imPreview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
android:layout_below="@id/collect"
|
||||
android:layout_marginTop="-10dp"
|
||||
tools:ignore="ContentDescription" />
|
||||
<ImageView
|
||||
android:id="@+id/collect"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:padding="10dp"
|
||||
android:src="@drawable/collect" />
|
||||
|
||||
</RelativeLayout>
|
||||
<ImageView
|
||||
android:id="@+id/collect"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:padding="10dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:src="@drawable/collect" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -8,6 +8,7 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="30dp"/>
|
||||
|
||||
</FrameLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Loading…
Reference in New Issue
Block a user