cc_美团 商品详情图片放大显示ViewPager

发布时间:2020-06-12 22:45:24 作者:愚人cc
来源:网络 阅读:413

cc_美团 商品详情图片放大显示ViewPager


package com.chencheng.meituan.view;


import java.util.ArrayList;

import java.util.List;

import com.xinbo.widget.HackyViewPager;

import android.app.Activity;

import android.graphics.Bitmap;

import android.graphics.drawable.Drawable;

import android.os.Bundle;

import android.support.v4.view.PagerAdapter;

import android.support.v4.view.ViewPager;

import android.util.Log;

import android.view.Menu;

import android.view.View;

import android.view.ViewGroup;

import android.view.ViewGroup.LayoutParams;

import uk.co.senab.photoview.PhotoView;

import com.nostra13.universalp_w_picpathloader.core.DisplayImageOptions;

import com.nostra13.universalp_w_picpathloader.core.ImageLoader;

import com.nostra13.universalp_w_picpathloader.core.assist.FailReason;

import com.nostra13.universalp_w_picpathloader.core.display.FadeInBitmapDisplayer;

import com.nostra13.universalp_w_picpathloader.core.listener.ImageLoadingListener;

import com.xinbo.utils.BitmapUtils;

import com.yuchen.meituan.R;


public class ShowImgActivity extends Activity {


private List<Drawable> mPics = new ArrayList<Drawable>();

private List<String> mImgURLs = new ArrayList<String>();

private ViewPager mViewPager;

private DisplayImageOptions options;

private Drawable mDrawable;

private String mImageUrl;

private MyPagerAdapter mPagerAdapter;


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_view_pager);

mImageUrl = getIntent().getStringExtra("p_w_picpathUrl");

initUIL();

initViewPager();

}


private void initViewPager() {

mViewPager = (HackyViewPager) findViewById(R.id.view_pager);

setContentView(mViewPager);

mPagerAdapter = new MyPagerAdapter();

loadPic();

// mViewPager.setAdapter(mPagerAdapter);

}


private void loadPic() {

Log.e("loadPic", "mImageUrl = " + mImageUrl);

ImageLoader.getInstance().loadImage(mImageUrl, options,

new ImageLoadingListener() {

@Override

public void onLoadingStarted(String arg0, View arg1) {

}


@Override

public void onLoadingFailed(String arg0, View arg1,

FailReason arg2) {

}


@Override

public void onLoadingComplete(String arg0, View arg1,

Bitmap arg2) {

mDrawable = BitmapUtils.bitmap2Drawable(arg2);

mViewPager.setAdapter(mPagerAdapter);

}


@Override

public void onLoadingCancelled(String arg0, View arg1) {

}

});

}


private void initUIL() {

options = new DisplayImageOptions.Builder()

.showImageOnLoading(R.drawable.ic_review_score_tip_excellent_off)

// 设置图片在下载期间显示的默认图片

.showImageForEmptyUri(R.drawable.ic_review_score_tip_excellent_off)

// 设置URI错误或者为空时显示的图片

.showImageOnFail(R.drawable.ic_review_score_tip_excellent_off)

// 设置图片加载或者解析出现错误时设置的图片

.cacheInMemory(true)

// 是否内存缓存

.cacheOnDisk(true)

// 是否外存缓存

.considerExifParams(true)

// .displayer(new RoundedBitmapDisplayer(100))// 是否设置图片圆角

.displayer(new FadeInBitmapDisplayer(200))// 图片加载好之后渐入的时间

.build();

}


class MyPagerAdapter extends PagerAdapter {

@Override

public int getCount() {

return 3;

}


@Override

public boolean isViewFromObject(View view, Object object) {

return view == object;

}


@Override

public Object instantiateItem(ViewGroup container, int position) {

PhotoView photoView = new PhotoView(container.getContext());

photoView.setImageDrawable(mDrawable);

// 在ViewPager中添加PhotoView,并返回

container.addView(photoView, LayoutParams.MATCH_PARENT,

LayoutParams.MATCH_PARENT);

return photoView;

}


@Override

public void destroyItem(ViewGroup container, int position, Object object) {

container.removeView((View) object);

}

}


@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return false;

}


}


推荐阅读:
  1. 项目拉手团购开发记录
  2. cc美团 滑动删除(SwipeListView)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

图片放大viewpager age pager

上一篇:java多媒体文件编码要怎么写,处理工具类代码实例详情介绍

下一篇:ActiveMQ(09):ActiveMQ消息存储持久化

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》