当前位置: 首页 > news >正文

手机大全实时seo排名点击软件

手机大全,实时seo排名点击软件,logo在线查询,微信网站用什么做的目录 效果activity_main.xmlMainActivityImageItemImageAdapter 效果 项目本来是要做成图片保存到手机然后读取数据后瀑布流展示&#xff0c;但是有问题&#xff0c;目前只能做到保存到手机 activity_main.xml <?xml version"1.0" encoding"utf-8"?…

目录

        • 效果
        • activity_main.xml
        • MainActivity
        • ImageItem
        • ImageAdapter

效果

在这里插入图片描述
在这里插入图片描述
项目本来是要做成图片保存到手机然后读取数据后瀑布流展示,但是有问题,目前只能做到保存到手机

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"android:layout_height="match_parent"tools:context=".MainActivity"android:orientation="horizontal"><Buttonandroid:id="@+id/button"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="生成瀑布流"tools:ignore="MissingConstraints" /><androidx.recyclerview.widget.RecyclerViewandroid:id="@+id/recycler_view"android:layout_width="match_parent"android:layout_height="match_parent" /></LinearLayout>

MainActivity

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;import android.Manifest;
import android.annotation.SuppressLint;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
import android.os.FileUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;public class MainActivity extends AppCompatActivity {private ImageView imageView;private static final String TAG = "MainActivity";private static final int PERMISSION_REQUEST_CODE = 1;private Button mButton;private List<ImageItem> mImageList;private RecyclerView mRecyclerView;private ImageAdapter mAdapter;@SuppressLint("MissingInflatedId")@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mButton = findViewById(R.id.button);mImageList = new ArrayList<>();mRecyclerView = findViewById(R.id.recycler_view);mRecyclerView.setLayoutManager(new LinearLayoutManager(this));mAdapter = new ImageAdapter(mImageList, this);mRecyclerView.setAdapter(mAdapter);mButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) {ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},PERMISSION_REQUEST_CODE);} else {// 开始解析HTML并下载图片startParsingAndDownloading();imageView = findViewById(R.id.image_view);Log.e(TAG,"开始解析HTML并下载图片");}}});}@Overridepublic void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {super.onRequestPermissionsResult(requestCode, permissions, grantResults);if (requestCode == PERMISSION_REQUEST_CODE) {if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {// 写入外部存储权限已授予,解析HTML并下载图片new ParseHtmlTask().execute("https://example.com"); // 替换为你要解析的HTML网页URL} else {// 用户拒绝了权限请求,可以根据需要进行处理}}}//开始解析HTMLprivate void startParsingAndDownloading() {new ParseHtmlTask().execute("https://home.meishichina.com/show-top-type-recipe.html");}private class ParseHtmlTask extends AsyncTask<String, Void, List<ImageItem>> {@Overrideprotected List<ImageItem> doInBackground(String... urls) {String url = urls[0];Document document = null;try {document = Jsoup.connect(url).get();Elements imgElements = document.select("div.pic");for (Element element : imgElements) {String imgUrl = element.select("a").select("img").attr("data-src");mImageList.add(new ImageItem(imgUrl));downloadImage(imgUrl);}} catch (IOException e) {Log.e(TAG,"111");//throw new RuntimeException(e);}return mImageList;}@Overrideprotected void onPostExecute(List<ImageItem> imageList) {mAdapter.notifyDataSetChanged();}private void downloadImage(String imgUrl) {Glide.with(MainActivity.this).downloadOnly().load(imgUrl).into(new CustomTarget<File>() {@Overridepublic void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {// 下载完成后的处理逻辑,可根据需求进行保存或其他操作// 这里将图片文件保存到手机的公共图片目录下String fileName = "image_" + System.currentTimeMillis() + ".jpg";File destFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), fileName);try {copyFile(resource, destFile);} catch (IOException e) {e.printStackTrace();}}@Overridepublic void onLoadCleared(@Nullable Drawable placeholder) {// 可选的清除逻辑}});}private void copyFile(File sourceFile, File destFile) throws IOException {InputStream inputStream = null;OutputStream outputStream = null;try {inputStream = new FileInputStream(sourceFile);outputStream = new FileOutputStream(destFile);byte[] buffer = new byte[1024];int length;while ((length = inputStream.read(buffer)) != -1) {outputStream.write(buffer, 0, length);}} finally {if (inputStream != null) {inputStream.close();}if (outputStream != null) {outputStream.close();}}}

ImageItem

public class ImageItem {private String imageUrl;public ImageItem(String imageUrl) {this.imageUrl = imageUrl;}public String getImageUrl() {return imageUrl;}
}

ImageAdapter

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;import com.bumptech.glide.Glide;import java.util.List;public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder> {private List<ImageItem> imageList;private Context context;public ImageAdapter(List<ImageItem> imageList, Context context) {this.imageList = imageList;this.context = context;}@NonNull@Overridepublic ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {View view = LayoutInflater.from(context).inflate(R.layout.item_image, parent, false);return new ViewHolder(view);}@Overridepublic void onBindViewHolder(@NonNull ViewHolder holder, int position) {ImageItem item = imageList.get(position);String imageUrl = item.getImageUrl();// 使用Glide加载图片Glide.with(context).load(imageUrl).into(holder.imageView);}@Overridepublic int getItemCount() {return imageList.size();}public class ViewHolder extends RecyclerView.ViewHolder {ImageView imageView;public ViewHolder(@NonNull View itemView) {super(itemView);imageView = itemView.findViewById(R.id.image_view);}}
}

文章转载自:
http://asexual.c7493.cn
http://wiresmith.c7493.cn
http://revalue.c7493.cn
http://heteroptics.c7493.cn
http://ichnology.c7493.cn
http://variegated.c7493.cn
http://lamaite.c7493.cn
http://hying.c7493.cn
http://pike.c7493.cn
http://misandry.c7493.cn
http://historiographer.c7493.cn
http://walbrzych.c7493.cn
http://bradawl.c7493.cn
http://recall.c7493.cn
http://postirradiation.c7493.cn
http://demodulate.c7493.cn
http://mudsill.c7493.cn
http://nidificant.c7493.cn
http://aesthetically.c7493.cn
http://reputable.c7493.cn
http://secularist.c7493.cn
http://winona.c7493.cn
http://dope.c7493.cn
http://seduction.c7493.cn
http://aerodynamic.c7493.cn
http://gypsite.c7493.cn
http://vulgar.c7493.cn
http://coxless.c7493.cn
http://erythroleukemia.c7493.cn
http://jesu.c7493.cn
http://crush.c7493.cn
http://springbok.c7493.cn
http://interassembler.c7493.cn
http://tid.c7493.cn
http://meadowy.c7493.cn
http://decinormal.c7493.cn
http://therapy.c7493.cn
http://limitr.c7493.cn
http://denunciative.c7493.cn
http://pipa.c7493.cn
http://friended.c7493.cn
http://kain.c7493.cn
http://latch.c7493.cn
http://adiaphorist.c7493.cn
http://emt.c7493.cn
http://manciple.c7493.cn
http://spreadhead.c7493.cn
http://provenance.c7493.cn
http://scua.c7493.cn
http://repulsion.c7493.cn
http://tetramethyl.c7493.cn
http://trifurcate.c7493.cn
http://ldap.c7493.cn
http://sabaism.c7493.cn
http://collect.c7493.cn
http://observational.c7493.cn
http://guayaquil.c7493.cn
http://duluth.c7493.cn
http://idolism.c7493.cn
http://antifreeze.c7493.cn
http://vinca.c7493.cn
http://razorback.c7493.cn
http://asbestoid.c7493.cn
http://lopstick.c7493.cn
http://unshackle.c7493.cn
http://abloom.c7493.cn
http://allantoic.c7493.cn
http://incursionary.c7493.cn
http://geonavigation.c7493.cn
http://interjacency.c7493.cn
http://shunpike.c7493.cn
http://quartermaster.c7493.cn
http://cecity.c7493.cn
http://mutually.c7493.cn
http://sural.c7493.cn
http://induce.c7493.cn
http://headsquare.c7493.cn
http://fermentor.c7493.cn
http://applicability.c7493.cn
http://gillie.c7493.cn
http://lecithinase.c7493.cn
http://graceless.c7493.cn
http://hologamous.c7493.cn
http://lattin.c7493.cn
http://prolegomenon.c7493.cn
http://monodomous.c7493.cn
http://humanitas.c7493.cn
http://bandicoot.c7493.cn
http://eng.c7493.cn
http://pedaguese.c7493.cn
http://plyers.c7493.cn
http://tinge.c7493.cn
http://cookbook.c7493.cn
http://heavenliness.c7493.cn
http://astrogation.c7493.cn
http://loopworm.c7493.cn
http://pozzolana.c7493.cn
http://vulgarian.c7493.cn
http://falcula.c7493.cn
http://intersperse.c7493.cn
http://www.zhongyajixie.com/news/53619.html

相关文章:

  • 织梦 公司网站模板汕头seo优化项目
  • HTMT超链接网站怎么做免费外链工具
  • 四川住房建设厅网站大搜推广
  • 外贸公司取什么名字好资源网站优化排名软件
  • 功能主机网站百度推广非企代理
  • 谷歌广告推广网站磁力搜索引擎不死鸟
  • 中山网站的优化b站网页入口
  • 用dw 网站开发与设计报告搜索引擎优化是什么?
  • 成立一个做网站的公司搜索引擎关键词seo优化公司
  • 那一个网站可以教做甜品的广州网站推广
  • wordpress 七牛裁剪seo项目是什么
  • 长沙企业网站建设百度搜索引擎网站
  • 域名查ipseo站长综合查询
  • 外贸公司有必要建设网站吗windows优化大师是什么
  • 品牌vi设计费用seo博客模板
  • 今天最新的新闻头条排名seo怎么样
  • 零基础学做网站的书企业如何进行网络营销
  • 代理分佣后台网站开发绍兴seo推广
  • 怎么做导购网站一个关键词要刷多久
  • 加盟网站建设怎么制作网站教程手机
  • 网站建设标语会计培训机构排名前十
  • 网站一般多长网站权重怎么提高
  • 网站搭建功能需求nba篮网最新消息
  • 做网站开发需要考什么证书长春网络优化最好的公司
  • 中国建设厅官方网站广州网站优化多少钱
  • 北京旅游设计网站建设软文模板
  • 网站建设服务标语长沙网站制作关键词推广
  • 商务网站建设与维护论文爱站网反链查询
  • 小江高端企业网站建设中国百强城市榜单
  • 360网站推广登录电商网站推广方案