Skip to content

Repository files navigation

PictureBrowser

一个基于support.v4.app.DialogFragment的图片浏览器

特点:

  • 图片浏览器,跟Dialog一样简单使用
  • 基于DialogFragment , 支持横竖屏切换不消失
  • 基于ViewPager+FragmentPagerAdapter,滑动流畅
  • 基于PhotoView,支持图片缩放
  • 可定制图片加载器
  • 提供一些定制接口

PictureBrowser.gif

文档

如何使用它?

gradle

1.先在 project的build.gradle 添加:

allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}

2.然后在module的build.gradle 添加:

dependencies {
compile 'com.github.LinweiJ:PictureBrowser:0.0.1'
}

java

1.简单使用例子

PictureLoaderpictureLoader = newPictureLoader() {
@OverridepublicvoidshowPicture(PictureFragmentfragment, PhotoViewphotoView, StringpictureUrl) {
//使用Glide加载图片,可自行根据需求选用其他图片加载库 Glide.with(fragment)
.load(pictureUrl)
.placeholder(newColorDrawable(Color.LTGRAY))
.into(photoView);
}
};
PictureBrowser.Builderbuilder = newPictureBrowser.Builder();
builder.setFragmentManager(getSupportFragmentManager())
.setUrlList(pictureUrl)
.setStartIndex(position)
.initPictureLoader(pictureLoader)
.setShowDeleteIcon(true)
.setShowIndexHint(true)
.setCancelOutside(true)
.create()
.show();

2.类/方法

  • PictureBrowser.Builder:
方法名描述备注(是否设置)
setFragmentManager请传入android.support.v4.app.FragmentManager必须
setUrlList请传入ArrayList ,暂时只支持String类型,一般表示为图片url必须
initPictureLoader初始化图片加载器PictureLoader,只能设置成功一次必须
setPictureLoader可重置图片加载器PictureLoader可选
setStartIndex首次显示图片页码,默认为0可选
setShowDeleteIcon是否显示左上角关闭按钮,默认为true可选
setShowIndexHint是否显示底部页码提示,默认为true可选
setCancelOutside是否开启点击关闭,默认为true可选
create以上设置完成后调用得到PictureBrowser的一个实例必须
  • PictureLoader
方法名描述备注
showPicture可用参数Fragment fragment, PhotoView pictureView, String pictureUrl,可自行根据需求选用合适图片加载库
  • PictureBrowser
方法名描述备注
show调用该方法,展示PictureBrowser必须

更多细节

可以参考 app/ 示例

Thanks

License

Copyright 2017 LinWeiJia
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

PictureBrowser - implementation of DialogFragment (基于DialogFragment的图片浏览器)

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages