Skip to content

Commit

Permalink
base function and photo split
Browse files Browse the repository at this point in the history
  • Loading branch information
李松 committed Nov 19, 2016
1 parent 9f39734 commit 1293447
Show file tree
Hide file tree
Showing 45 changed files with 546 additions and 123 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "com.android.fresco.demo"
minSdkVersion 17
targetSdkVersion 24
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
Expand All @@ -26,6 +26,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':fresco-helper')
compile project(':fresco-photoview')

// compile 'com.facebook.fresco.helper:fresco-helper:1.0.2'
compile 'com.android.support:appcompat-v7:24.2.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.android.fresco.demo;

import android.view.View;

import java.util.ArrayList;

/**
Expand All @@ -8,6 +10,6 @@

public interface OnItemClickListener<T> {

void onItemClick(ArrayList<T> photos, int position);
void onItemClick(View view, ArrayList<T>photos, int position);

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;

import com.facebook.fresco.helper.photo.PictureBrowse;
import com.facebook.fresco.helper.photo.entity.PhotoInfo;
import com.facebook.fresco.helper.photoview.PictureBrowse;
import com.facebook.fresco.helper.photoview.entity.PhotoInfo;

import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -48,16 +49,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mPhotoWallAdapter = new PhotoWallAdapter(mImageList, new OnItemClickListener<PhotoInfo>() {

@Override
public void onItemClick(ArrayList<PhotoInfo> photos, int position) {
public void onItemClick(View view, ArrayList<PhotoInfo> photos, int position) {
// MLog.i("position = " + position);
// MLog.i("photos.get(position).thumbnailUrl = " + photos.get(position).thumbnailUrl);

PictureBrowse.newBuilder(PhotoAlbumActivity.this)
.setLayoutManager(mLayoutManager)
.setCurrentPosition(position)
.setPhotoList(photos)
.enabledAnimation(false) // 关闭动画效果
.build()
.setCurrentPosition(position)
.start();
}
});
Expand Down
36 changes: 31 additions & 5 deletions app/src/main/java/com/android/fresco/demo/PhotoWallActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.facebook.fresco.helper.photo.PictureBrowse;
import com.facebook.fresco.helper.photo.entity.PhotoInfo;
import com.facebook.fresco.helper.photoview.PictureBrowse;
import com.facebook.fresco.helper.photoview.entity.PhotoInfo;

import java.util.ArrayList;

Expand Down Expand Up @@ -91,17 +92,42 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mPhotoWallAdapter = new PhotoWallAdapter(data, new OnItemClickListener<PhotoInfo>() {

@Override
public void onItemClick(ArrayList<PhotoInfo> photos, int position) {
public void onItemClick(View view, ArrayList<PhotoInfo> photos, int position) {
// MLog.i("position = " + position);
// MLog.i("photos.get(position).thumbnailUrl = " + photos.get(position).thumbnailUrl);

PictureBrowse.newBuilder(PhotoWallActivity.this)
.setLayoutManager(mLayoutManager)
.setCurrentPosition(position)
.setPhotoList(photos)
.setCurrentPosition(position)
.enabledAnimation(true)
.build()
.start();

// PictureBrowse.newBuilder(PhotoWallActivity.this)
// .setPhotoList(photos)
// .setCurrentPosition(position)
// .start();

// String thumbnailUrl = photos.get(position).thumbnailUrl;
// PictureBrowse.newBuilder(PhotoWallActivity.this)
// .setThumbnailView(view)
// .setOriginalUrl(thumbnailUrl)
// .enabledAnimation(true)
// .start();

// PictureBrowse.newBuilder(PhotoWallActivity.this)
// .setThumbnailView(view)
// .setPhotoInfo(photos.get(position))
// .enabledAnimation(true)
// .start();

// String thumbnailUrl = photos.get(position).thumbnailUrl;
// PictureBrowse.newBuilder(PhotoWallActivity.this)
// .setThumbnailView(view)
// .setOriginalUrl(thumbnailUrl)
// .start();


}
});
mRecyclerView.setAdapter(mPhotoWallAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.fresco.helper.ImageLoader;
import com.facebook.fresco.helper.Phoenix;
import com.facebook.fresco.helper.photo.entity.PhotoInfo;
import com.facebook.fresco.helper.photoview.entity.PhotoInfo;
import com.facebook.fresco.helper.utils.DensityUtil;

import java.util.ArrayList;
Expand Down Expand Up @@ -41,7 +41,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(final ViewGroup parent, int vi
@Override
public void onClick(View v) {
if(mOnItemClickListener != null) {
mOnItemClickListener.onItemClick(mPhotos, photoViewHolder.getAdapterPosition());
mOnItemClickListener.onItemClick(v, mPhotos, photoViewHolder.getAdapterPosition());
}
}
});
Expand Down
11 changes: 4 additions & 7 deletions fresco-helper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {

defaultConfig {
minSdkVersion 17
targetSdkVersion 24
targetSdkVersion 22
versionCode 2
versionName "1.0.1"
}
Expand All @@ -29,23 +29,20 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'

compile 'com.facebook.fresco:fresco:0.14.1'
compile 'com.facebook.fresco:animated-base-support:0.14.1'
compile 'com.facebook.fresco:animated-gif:0.14.1'
compile 'com.facebook.fresco:webpsupport:0.14.1'
compile 'com.facebook.fresco:animated-webp:0.14.1'
compile 'com.facebook.fresco:imagepipeline-okhttp3:0.14.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
// compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
}

// Maven Group ID
group = "com.facebook.fresco.helper"
// library的版本号,后面每次更新都需要更改这个值
version = "1.0.3"
version = "1.0.4"

// 生成jar包的task
task sourcesJar(type: Jar) {
Expand Down Expand Up @@ -82,7 +79,7 @@ install {
packaging 'aar'
groupId 'com.facebook.fresco.helper'
artifactId 'fresco-helper'
version '1.0.3'
version '1.0.4'

licenses {
license {
Expand Down
19 changes: 1 addition & 18 deletions fresco-helper/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.fresco.helper">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:supportsRtl="true">

<activity android:name="com.facebook.fresco.helper.photo.PictureBrowseActivity"
android:screenOrientation="portrait"
android:theme="@style/picture_browse_activity_style"/>

</application>

</manifest>
<manifest package="com.facebook.fresco.helper"/>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Set;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;

/**
*
Expand Down Expand Up @@ -93,10 +92,10 @@ public void trim(MemoryTrimType trimType) {
}
});

HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
// HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
// loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
// .addInterceptor(loggingInterceptor)
// .retryOnConnectionFailure(false)
.build();

Expand Down
3 changes: 0 additions & 3 deletions fresco-helper/src/main/res/values/strings.xml

This file was deleted.

1 change: 1 addition & 0 deletions fresco-photoview/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
126 changes: 126 additions & 0 deletions fresco-photoview/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

android {
compileSdkVersion 24
buildToolsVersion "25.0.0"

defaultConfig {
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'

compile 'com.facebook.fresco:fresco:0.14.1'
compile 'com.facebook.fresco:animated-base-support:0.14.1'
compile 'com.facebook.fresco:animated-gif:0.14.1'
compile 'com.facebook.fresco:webpsupport:0.14.1'
compile 'com.facebook.fresco:animated-webp:0.14.1'
compile 'com.facebook.fresco:imagepipeline-okhttp3:0.14.1'
// compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'

}

// Maven Group ID
group = "com.facebook.fresco.helper"
// library的版本号,后面每次更新都需要更改这个值
version = "1.0.4"

// 生成jar包的task
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

// 生成jarDoc的task
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
failOnError false // 忽略注释语法错误,如果用jdk1.8你的注释写的不规范就编译不过。
}

// 生成javaDoc的jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives sourcesJar
}

install {
repositories.mavenInstaller {
pom.project {
name 'fresco-helper'
description 'Android上图片加载库Fresco的使用帮助类'
url 'https://github.com/hpdx/fresco-helper'
inceptionYear '2016'

packaging 'aar'
groupId 'com.facebook.fresco.helper'
artifactId 'photoview'
version '1.0.4'

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}

scm {
connection 'https://github.com/hpdx/fresco-helper.git' // Git仓库地址。
developerConnection 'https://github.com/hpdx/fresco-helper.git' // Git仓库地址。
url 'https://github.com/hpdx/fresco-helper' // 项目主页。
}

developers {
developer {
id 'android_ls'
name 'android_ls'
email 'android_ls@163.com'
}
}
}
}
}

Properties properties = new Properties()
// 读取properties的配置信息
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = 'maven'
name = 'fresco-helper'
userOrg = user
licenses = ['Apache-2.0']
websiteUrl = 'https://github.com/hpdx/fresco-helper'
vcsUrl = 'https://github.com/hpdx/fresco-helper.git'
publish = true
}
}



17 changes: 17 additions & 0 deletions fresco-photoview/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/android_ls/Documents/Tool/adt-bundle-mac-x86_64-20130917/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Loading

0 comments on commit 1293447

Please sign in to comment.