package com.s3hengwu.smile;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import net.youmi.android.AdView;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
public class ImageActivity extends Activity{
private GridView mGrid;
private TextView title;
private Button back;
//private String url="http://www.laifu.org";
private String pageUrl_1;
private String name;
private int page=1;
private String flag;
private ImageAdapter mAdapter;
private ProgressDialog mDialog;
private ArrayList<String> mImageUrl=new ArrayList<String>();//缩略图
//private ArrayList<String> mImageUrl2=new ArrayList<String>();//全图
private ArrayList<String> mImageName=new ArrayList<String>();//缩略名
private ArrayList<String> mImageName2=new ArrayList<String>();//全名
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_iamge);
LinearLayout ll=(LinearLayout) findViewById(R.id.ll_title_bottom);
ll.addView(new AdView(this),new LayoutParams(LinearLayout.LayoutParams.FILL_PARENT
, LinearLayout.LayoutParams.WRAP_CONTENT));
mGrid=(GridView) findViewById(R.id.gridview);
title=(TextView) findViewById(R.id.title);
back=(Button) findViewById(R.id.btnback);
mGrid.setOnItemClickListener(listener);
mAdapter=new ImageAdapter();
mDialog=new ProgressDialog(this);
mDialog.setMessage("正在加载数据...");
Intent it=getIntent();
name=it.getStringExtra("title");
title.setText(name);
if(name.equals("动物漫画")){
pageUrl_1="http://www.laifu.org/tupian/dongwutupian.htm";
flag="dongwutupian";
}else{
pageUrl_1="http://www.laifu.org/tupian/ertongtupian.htm";
flag="ertongtupian";
}
mDialog.show();
new Thread(){
public void run() {
try {
Document doc=Jsoup.connect(pageUrl_1).get();
Elements es=doc.select(".picListTable img");
for(int i=0;i<es.size();i++){
String img_url=es.get(i).attr("src");
String name=es.get(i).attr("alt");
mImageName2.add(name);
if(name.length()>8){
name=name.subSequence(0, 8).toString();
}
mImageName.add(name);
mImageUrl.add(img_url);
Message m=new Message();
m.what=1;
myHandler.sendMessage(m);
}
} catch (IOException e) {
Message m=new Message();
m.what=2;
myHandler.sendMessage(m);
}
};
}.start();
back.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ImageActivity.this.finish();
}
});
}
private OnItemClickListener listener=new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
int count = mAdapter.getCount();
if (arg2 == count - 1) {
page++;
final String nextPage="http://www.laifu.org/tupian/"+flag+"_"+page+".htm";
mDialog.show();
new Thread(){
public void run() {
try {
Document doc=Jsoup.connect(nextPage).get();
Elements es=doc.select(".picListTable img");
for(int i=0;i<es.size();i++){
String img_url=es.get(i).attr("src");
String name=es.get(i).attr("alt");
mImageName2.add(name);
if(name.length()>8){
name=name.subSequence(0, 8).toString();
}
mImageName.add(name);
mImageUrl.add(img_url);
Message m=new Message();
m.what=3;
myHandler.sendMessage(m);
}
} catch (IOException e) {
Message m=new Message();
m.what=2;
myHandler.sendMessage(m);
}
};
}.start();
return;
}
Intent it=new Intent(ImageActivity.this, ImageReadActivity.class);
it.putExtra("name", name);
it.putExtra("aticle_name", mImageName2.get(arg2));
it.putExtra("aticle_url", mImageUrl.get(arg2));
startActivity(it);
}
};
private Handler myHandler=new Handler(){
public void handleMessage(android.os.Message msg) {
switch(msg.what){
case 1:
mDialog.cancel();
mGrid.setAdapter(mAdapter);
break;
case 2:
mDialog.cancel();
final AlertDialog.Builder builder=new AlertDialog.Builder(ImageActivity.this);
builder.setTitle("提示")
.setMessage("晚上8:30-10:00数据更新中")
.setPositiveButton("我知道了", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}});
builder.create().show();
break;
case 3:
mDialog.cancel();
mAdapter.notifyDataSetChanged();
break;
}
};
};
private class ImageAdapter extends BaseAdapter{
@Override
public int getCount() {
return mImageName.size()+1;
}
@Override
public Object getItem(int arg0) {
return arg0;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
//if(convertView==null){
convertView=View.inflate(getApplicationContext(),R.layout.item2, null);
holder=new ViewHolder();
holder.text=(TextView) convertView.findViewById(R.id.text);
holder.image=(ImageView) convertView.findViewById(R.id.image);
convertView.setTag(holder);
//}else{
// holder = (ViewHolder) convertView.getTag();
//}
if(position==mImageName.size()){
holder.text.setText("");
holder.image.setImageResource(R.drawable.add_section);
return convertView;
}
holder.text.setText(mImageName.get(position));
ImageAsyncTask task=new ImageAsyncTask(ImageActivity.this, holder.image);
task.execute(mImageUrl.get(position));
//holder.image.setImageResource(R.drawable.main_pic_0);
return convertView;
}
class ViewHolder {
TextView text;
ImageView image;
}
};
private class ImageAsyncTask extends AsyncTask<String,Integer,Bitmap>{
private ImageView iv=null;
public ImageAsyncTask(Context context,ImageView iv){
this.iv=iv;
}
@Override
protected Bitmap doInBackground(String... params) {
String s=params[0];
URL url=null;
HttpURLConnection conn=null;
InputStream is=null;
try {
url=new URL(s);
conn=(HttpURLConnection) url.openConnection();
is=conn.getInputStream();
return BitmapFactory.decodeStream(is);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if(is!=null){
is.close();
}
if(conn!=null){
conn.disconnect();
}
} catch (IOException e) {
// TODO Auto-gen
没有合适的资源?快使用搜索试试~ 我知道了~
小程序源码 笑话故事应用源码.rar
共132个文件
class:49个
png:44个
xml:18个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 59 浏览量
2023-03-28
06:39:19
上传
评论
收藏 10.94MB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序源码 笑话故事应用源码.rar (132个子文件)
resources.ap_ 777KB
Cartoon.apk 6.26MB
smile.apk 982KB
WelcomeActivity.apk 982KB
proguard.cfg 1KB
TextActivity.class 5KB
ImageActivity.class 5KB
SmileActivity.class 3KB
TextReadActivity.class 3KB
ImageReadActivity.class 3KB
ImageReadActivity$ImageAsyncTask.class 3KB
ImageActivity$1.class 3KB
TextActivity$3$1.class 3KB
ImageActivity$ImageAdapter.class 3KB
ImageActivity$ImageAsyncTask.class 3KB
SmileActivity$ImageAdapter.class 3KB
WelcomeActivity.class 2KB
ImageActivity$1$1.class 2KB
TextActivity$4.class 2KB
ImageActivity$3.class 2KB
TextReadActivity$2.class 2KB
TextActivity$MyAdapter.class 2KB
ImageActivity$2.class 2KB
TextActivity$1.class 2KB
SmileActivity$1.class 2KB
TextActivity$3.class 2KB
TextActivity$2.class 2KB
NetManager.class 1KB
TextReadActivity$1.class 1KB
R$id.class 1KB
R$drawable.class 1KB
SmileActivity$2.class 1KB
ImageActivity$2$1.class 1019B
TextActivity$1$1.class 1013B
WelcomeActivity$2.class 1007B
WelcomeActivity$1.class 983B
ImageReadActivity$1.class 962B
SmileActivity$3.class 900B
AboutActivity.class 877B
ImageReadActivity$3.class 829B
TextReadActivity$3.class 823B
AboutActivity$1.class 805B
ImageActivity$4.class 805B
TextActivity$5.class 799B
R$layout.class 742B
ImageActivity$ImageAdapter$ViewHolder.class 729B
SmileActivity$ImageAdapter$ViewHolder.class 729B
TextActivity$MyAdapter$ViewHolder.class 659B
ImageReadActivity$2.class 644B
R.class 625B
R$color.class 460B
R$string.class 427B
R$menu.class 381B
R$attr.class 340B
.classpath 484B
classes.dex 511KB
jsoup-1.6.1.jar 275KB
youmi-android.jar 182KB
ImageActivity.java 8KB
TextActivity.java 6KB
SmileActivity.java 5KB
R.java 4KB
ImageReadActivity.java 4KB
TextReadActivity.java 3KB
WelcomeActivity.java 2KB
NetManager.java 1KB
AboutActivity.java 511B
splash.jpg 75KB
bg.png 362KB
bg.png 261KB
main_footer.png 89KB
main_footer.png 89KB
main_header.png 56KB
main_header.png 56KB
main_pic_0.png 45KB
main_pic_0.png 45KB
main_pic_2.png 43KB
main_pic_2.png 43KB
main_pic_3.png 41KB
main_pic_3.png 41KB
main_pic_1.png 37KB
main_pic_1.png 37KB
bg_tab_at_bottom_of_flow.png 36KB
bg_tab_at_bottom_of_flow.png 36KB
bg_title_bar_without_shadow.png 35KB
bg_title_bar_without_shadow.png 35KB
icon.png 8KB
icon.png 8KB
add_section.png 5KB
icon.png 4KB
icon.png 4KB
ic_launcher.png 4KB
ic_launcher.png 4KB
btn_back_normal.png 3KB
btn_back_normal.png 3KB
btn_back_pressed.png 3KB
btn_back_pressed.png 3KB
list_selected_background.png 3KB
icon.png 3KB
icon.png 3KB
共 132 条
- 1
- 2
资源评论
金枝玉叶9
- 粉丝: 194
- 资源: 7637
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 微信小程序跃动小子保卫主公自动通关之执行计划
- 朋友圈防折叠系统源码,简单使用的小工具,众多营销老板都需要
- STM32L4R/S系列中文参考手册
- 一个由商业级项目升级优化而来的微服务架构,采用Spring Boot 3.2 、Spring Cloud 2023等核心技术构建
- GAIIC2024无人机视角下的双光目标检测(Rank6 解决方案)+文档说明(高分项目)
- Unity3D机械臂动画示例
- 非常好的语音识别源代码100%好用.zip
- 0积分【尊重互联网共享原则】tauri2.0所需插件nsis-tauri-utils.dll
- 基于CNN+LSTM实现的网络流量检测系统python源码(高分课设)+文档说明
- PHP中把动态页面生成静态页面的示例
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功