├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ └── universal-image-loader-1.9.5.jar
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── cydeep
│ │ └── imageedit
│ │ ├── Constants.java
│ │ ├── ImageEditApplication.java
│ │ ├── MainActivity.java
│ │ ├── activity
│ │ └── BaseActivity.java
│ │ ├── base
│ │ ├── EventMsg.java
│ │ ├── ListViewAdapter.java
│ │ ├── OnUpdateListUIListener.java
│ │ ├── RecyclerViewBaseAdapter.java
│ │ ├── RxBus.java
│ │ ├── SharedPreferenceHelper.java
│ │ ├── TitleViews.java
│ │ └── ViewHolder.java
│ │ ├── draglistview
│ │ ├── OnCustomTouchEventListener.java
│ │ ├── OnInterceptTouchEventListener.java
│ │ ├── OnMoveLongClickListener.java
│ │ ├── coreutil
│ │ │ ├── Insertable.java
│ │ │ ├── ListViewWrapper.java
│ │ │ ├── OnItemMovedListener.java
│ │ │ ├── Swappable.java
│ │ │ └── TouchEventHandler.java
│ │ ├── dragdrop
│ │ │ ├── BitmapUtils.java
│ │ │ ├── DragAndDropHandler.java
│ │ │ ├── DragAndDropListViewWrapper.java
│ │ │ ├── DraggableManager.java
│ │ │ └── HoverDrawable.java
│ │ └── view
│ │ │ ├── ArrayAdapter.java
│ │ │ ├── DynamicListView.java
│ │ │ └── DynamicListViewWrapper.java
│ │ ├── imageEdit
│ │ ├── ClipBoundsView.java
│ │ ├── GPUImageFilterTools.java
│ │ ├── ImageClipActivity.java
│ │ ├── ImageEditActivity.java
│ │ ├── ImageFilterHandler.java
│ │ ├── ImageFilterManagerActivity.java
│ │ ├── ImageSaturationActivity.java
│ │ ├── ImageSaturationSeekBar.java
│ │ ├── bean
│ │ │ └── PostEditImageInfo.java
│ │ ├── filter
│ │ │ ├── IF1977Filter.java
│ │ │ ├── IFAmaroFilter.java
│ │ │ ├── IFBrannanFilter.java
│ │ │ ├── IFEarlybirdFilter.java
│ │ │ ├── IFHefeFilter.java
│ │ │ ├── IFHudsonFilter.java
│ │ │ ├── IFImageFilter.java
│ │ │ ├── IFInkwellFilter.java
│ │ │ ├── IFLomoFilter.java
│ │ │ ├── IFLordKelvinFilter.java
│ │ │ ├── IFNashvilleFilter.java
│ │ │ ├── IFRiseFilter.java
│ │ │ ├── IFSierraFilter.java
│ │ │ ├── IFSutroFilter.java
│ │ │ ├── IFToasterFilter.java
│ │ │ ├── IFValenciaFilter.java
│ │ │ ├── IFWaldenFilter.java
│ │ │ └── IFXprollFilter.java
│ │ └── updateUiListener
│ │ │ ├── OnImageEditUpdateRecyclerListener.java
│ │ │ └── OnImageFilterSelectUpdateRecyclerListener.java
│ │ ├── photoview
│ │ ├── Compat.java
│ │ ├── DefaultOnDoubleTapListener.java
│ │ ├── IPhotoView.java
│ │ ├── PhotoView.java
│ │ ├── PhotoViewAttacher.java
│ │ ├── gestures
│ │ │ ├── CupcakeGestureDetector.java
│ │ │ ├── EclairGestureDetector.java
│ │ │ ├── FroyoGestureDetector.java
│ │ │ ├── GestureDetector.java
│ │ │ ├── OnGestureListener.java
│ │ │ └── VersionedGestureDetector.java
│ │ ├── log
│ │ │ ├── LogManager.java
│ │ │ ├── Logger.java
│ │ │ └── LoggerDefault.java
│ │ └── scrollerproxy
│ │ │ ├── GingerScroller.java
│ │ │ ├── IcsScroller.java
│ │ │ ├── PreGingerScroller.java
│ │ │ └── ScrollerProxy.java
│ │ ├── selectimage
│ │ ├── AlbumInfo.java
│ │ ├── OnUpdateImageListener.java
│ │ └── SelectImageActivity.java
│ │ └── util
│ │ ├── BitmapDecodeUtil.java
│ │ ├── Constant.java
│ │ ├── FileUtils.java
│ │ ├── ImageUtil.java
│ │ ├── LogUtils.java
│ │ └── ViewSizeUtil.java
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable-xhdpi
│ ├── asy.png
│ ├── icon_bar_dress.png
│ ├── icon_bar_dress_click.png
│ ├── icon_bar_editor.png
│ ├── icon_bar_editor_click.png
│ ├── icon_editer_crop.png
│ ├── icon_editer_saturation.png
│ ├── icon_image_filter.png
│ ├── icon_image_filter_select.png
│ ├── icon_image_filter_unselect.png
│ ├── icon_image_saturation_seek_bar.png
│ ├── icon_nav_cut.png
│ ├── icon_notice_mould_edit.png
│ ├── icon_photo_scale.png
│ ├── im_system_album_check_normal.png
│ ├── image_filter_48.png
│ ├── image_filter_49.png
│ ├── image_filter_50.png
│ ├── image_filter_51.png
│ ├── image_filter_52.png
│ ├── image_filter_53.png
│ ├── image_filter_54.png
│ ├── image_filter_55.png
│ ├── image_filter_56.png
│ ├── image_filter_57.png
│ ├── image_filter_58.png
│ ├── image_filter_59.png
│ ├── image_filter_60.png
│ ├── image_filter_61.png
│ ├── image_filter_62.png
│ ├── image_filter_63.png
│ ├── image_filter_64.png
│ ├── image_filter_65.png
│ ├── image_filter_amaro_map.png
│ ├── image_filter_blackboard.png
│ ├── image_filter_brannan_blowout.png
│ ├── image_filter_brannan_contrast.png
│ ├── image_filter_brannan_luma.png
│ ├── image_filter_brannan_process.png
│ ├── image_filter_brannan_screen.png
│ ├── image_filter_earlybird_blowout.png
│ ├── image_filter_earlybird_curves.png
│ ├── image_filter_earlybird_map.png
│ ├── image_filter_earlybird_overlay_map.png
│ ├── image_filter_edge_burn.png
│ ├── image_filter_hefe_gradient_map.png
│ ├── image_filter_hefe_map.png
│ ├── image_filter_hefe_metal.png
│ ├── image_filter_hefe_soft_light.png
│ ├── image_filter_hudson_background.png
│ ├── image_filter_hudson_map.png
│ ├── image_filter_inkwell_map.png
│ ├── image_filter_kelvin_map.png
│ ├── image_filter_lomo_map.png
│ ├── image_filter_lookup_amatorka.png
│ ├── image_filter_nashville_map.png
│ ├── image_filter_nblowout.png
│ ├── image_filter_nmap.png
│ ├── image_filter_overlay_map.png
│ ├── image_filter_rise_map.png
│ ├── image_filter_sierra_map.png
│ ├── image_filter_sierra_vignette.png
│ ├── image_filter_soft_light.png
│ ├── image_filter_sutro_curves.png
│ ├── image_filter_sutro_edge_burn.png
│ ├── image_filter_sutro_metal.png
│ ├── image_filter_toaster_color_shift.png
│ ├── image_filter_toaster_curves.png
│ ├── image_filter_toaster_metal.png
│ ├── image_filter_toaster_overlay_map_warm.png
│ ├── image_filter_toaster_soft_light.png
│ ├── image_filter_valencia_gradient_map.png
│ ├── image_filter_valencia_map.png
│ ├── image_filter_vignette_map.png
│ ├── image_filter_walden_map.png
│ ├── image_filter_xpro_map.png
│ ├── image_select.png
│ ├── left.png
│ ├── left_gray.png
│ ├── lookup_amatorka.png
│ └── pic_normal.png
│ ├── drawable
│ ├── ic_launcher_background.xml
│ ├── icon_bar_dress_selector.xml
│ ├── icon_bar_edit_selector.xml
│ ├── image_clip.gif
│ ├── image_filter.gif
│ ├── image_filter_manage_background.xml
│ ├── image_saturation.gif
│ ├── rectangle_image_filter_setting.xml
│ └── shape_root_status_bar_white.xml
│ ├── layout
│ ├── activity_base.xml
│ ├── activity_image_filter_clip.xml
│ ├── activity_image_filter_manage.xml
│ ├── activity_image_saturation.xml
│ ├── activity_main.xml
│ ├── activity_post_image_edite.xml
│ ├── activity_select_image.xml
│ ├── image_saturation_seek.xml
│ ├── item_edit_recycler_view.xml
│ ├── item_image_filter_manage.xml
│ ├── item_image_filter_recycler_view.xml
│ ├── item_select_image.xml
│ └── layout_toolbar.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── raw
│ ├── haarcascade_eye.xml
│ ├── haarcascade_frontalface_alt2.xml
│ ├── haarcascade_mcs_leftear.xml
│ ├── haarcascade_mcs_mouth.xml
│ ├── haarcascade_mcs_rightear.xml
│ └── tone_cuver_sample.acv
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── config.gradle
├── gradle.properties
├── gradle
└── wrapper
│ └── gradle-wrapper.properties
├── lib_gpuimage
├── AndroidManifest.xml
├── android-artifacts.gradle
├── build.gradle
├── central-publish.gradle
├── jni
│ └── yuv-decoder.c
├── proguard-project.txt
├── project.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── jp
│ │ └── co
│ │ └── cyberagent
│ │ └── android
│ │ └── gpuimage
│ │ ├── GPUImage.java
│ │ ├── GPUImage3x3ConvolutionFilter.java
│ │ ├── GPUImage3x3TextureSamplingFilter.java
│ │ ├── GPUImageAddBlendFilter.java
│ │ ├── GPUImageAlphaBlendFilter.java
│ │ ├── GPUImageBoxBlurFilter.java
│ │ ├── GPUImageBrightnessFilter.java
│ │ ├── GPUImageBulgeDistortionFilter.java
│ │ ├── GPUImageCGAColorspaceFilter.java
│ │ ├── GPUImageChromaKeyBlendFilter.java
│ │ ├── GPUImageColorBalanceFilter.java
│ │ ├── GPUImageColorBlendFilter.java
│ │ ├── GPUImageColorBurnBlendFilter.java
│ │ ├── GPUImageColorDodgeBlendFilter.java
│ │ ├── GPUImageColorInvertFilter.java
│ │ ├── GPUImageColorMatrixFilter.java
│ │ ├── GPUImageContrastFilter.java
│ │ ├── GPUImageCrosshatchFilter.java
│ │ ├── GPUImageDarkenBlendFilter.java
│ │ ├── GPUImageDifferenceBlendFilter.java
│ │ ├── GPUImageDilationFilter.java
│ │ ├── GPUImageDirectionalSobelEdgeDetectionFilter.java
│ │ ├── GPUImageDissolveBlendFilter.java
│ │ ├── GPUImageDivideBlendFilter.java
│ │ ├── GPUImageEmbossFilter.java
│ │ ├── GPUImageExclusionBlendFilter.java
│ │ ├── GPUImageExposureFilter.java
│ │ ├── GPUImageFalseColorFilter.java
│ │ ├── GPUImageFilter.java
│ │ ├── GPUImageFilterGroup.java
│ │ ├── GPUImageGammaFilter.java
│ │ ├── GPUImageGaussianBlurFilter.java
│ │ ├── GPUImageGlassSphereFilter.java
│ │ ├── GPUImageGrayscaleFilter.java
│ │ ├── GPUImageHardLightBlendFilter.java
│ │ ├── GPUImageHazeFilter.java
│ │ ├── GPUImageHighlightShadowFilter.java
│ │ ├── GPUImageHueBlendFilter.java
│ │ ├── GPUImageHueFilter.java
│ │ ├── GPUImageKuwaharaFilter.java
│ │ ├── GPUImageLaplacianFilter.java
│ │ ├── GPUImageLevelsFilter.java
│ │ ├── GPUImageLightenBlendFilter.java
│ │ ├── GPUImageLinearBurnBlendFilter.java
│ │ ├── GPUImageLookupFilter.java
│ │ ├── GPUImageLuminosityBlendFilter.java
│ │ ├── GPUImageMixBlendFilter.java
│ │ ├── GPUImageMonochromeFilter.java
│ │ ├── GPUImageMultiplyBlendFilter.java
│ │ ├── GPUImageNativeLibrary.java
│ │ ├── GPUImageNonMaximumSuppressionFilter.java
│ │ ├── GPUImageNormalBlendFilter.java
│ │ ├── GPUImageOpacityFilter.java
│ │ ├── GPUImageOverlayBlendFilter.java
│ │ ├── GPUImagePixelationFilter.java
│ │ ├── GPUImagePosterizeFilter.java
│ │ ├── GPUImageRGBDilationFilter.java
│ │ ├── GPUImageRGBFilter.java
│ │ ├── GPUImageRenderer.java
│ │ ├── GPUImageSaturationBlendFilter.java
│ │ ├── GPUImageSaturationFilter.java
│ │ ├── GPUImageScreenBlendFilter.java
│ │ ├── GPUImageSepiaFilter.java
│ │ ├── GPUImageSharpenFilter.java
│ │ ├── GPUImageSketchFilter.java
│ │ ├── GPUImageSmoothToonFilter.java
│ │ ├── GPUImageSobelEdgeDetection.java
│ │ ├── GPUImageSobelThresholdFilter.java
│ │ ├── GPUImageSoftLightBlendFilter.java
│ │ ├── GPUImageSourceOverBlendFilter.java
│ │ ├── GPUImageSphereRefractionFilter.java
│ │ ├── GPUImageSubtractBlendFilter.java
│ │ ├── GPUImageSwirlFilter.java
│ │ ├── GPUImageThresholdEdgeDetection.java
│ │ ├── GPUImageToneCurveFilter.java
│ │ ├── GPUImageToonFilter.java
│ │ ├── GPUImageTwoInputFilter.java
│ │ ├── GPUImageTwoPassFilter.java
│ │ ├── GPUImageTwoPassTextureSamplingFilter.java
│ │ ├── GPUImageView.java
│ │ ├── GPUImageVignetteFilter.java
│ │ ├── GPUImageWeakPixelInclusionFilter.java
│ │ ├── GPUImageWhiteBalanceFilter.java
│ │ ├── OpenGlUtils.java
│ │ ├── PixelBuffer.java
│ │ ├── Rotation.java
│ │ └── util
│ │ └── TextureRotationUtil.java
│ └── jniLibs
│ ├── arm64-v8a
│ └── libgpuimage-library.so
│ ├── armeabi-v7a
│ └── libgpuimage-library.so
│ ├── armeabi
│ └── libgpuimage-library.so
│ ├── mips
│ └── libgpuimage-library.so
│ ├── mips64
│ └── libgpuimage-library.so
│ ├── x86
│ └── libgpuimage-library.so
│ └── x86_64
│ └── libgpuimage-library.so
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches/build_file_checksums.ser
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 | lib_gpuimage/build/
13 | lib_gpuimage/.idea/
14 | lib_gpuimage/.settings/org.eclipse.jdt.core.prefs
15 | gradlew.bat
16 | gradlew
17 | gradle/wrapper/gradle-wrapper.jar
18 | lib_gpuimage/.classpath
19 | lib_gpuimage/.project
20 | .idea/codeStyles/Project.xml
21 | .idea/gradle.xml
22 | .idea/misc.xml
23 | .idea/
24 | lib_gpuimage/local.properties
25 | app/proguard-rules.pro
26 | lib_gpuimage/gen/jp/co/cyberagent/android/gpuimage/BuildConfig.java
27 | app/src/test/
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ImageEdit
2 | 基于gpuimage和photoview的图片编辑(滤镜,饱和度,裁剪)的demo
3 |
4 | 博客地址:https://blog.csdn.net/baifghy/article/details/84860873
5 |
6 | 裁剪效果图
7 |
8 | 
9 |
10 | 饱和度效果图
11 |
12 | 
13 |
14 | 滤镜效果图
15 |
16 | 
17 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId rootProject.ext.android.applicationId
7 | minSdkVersion rootProject.ext.android.minSdkVersion
8 | targetSdkVersion rootProject.ext.android.targetSdkVersion
9 | versionCode rootProject.ext.android.versionCode
10 | versionName rootProject.ext.android.versionName
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | compileOptions {
20 | sourceCompatibility = '1.8'
21 | targetCompatibility = '1.8'
22 | }
23 | allprojects {
24 | repositories {
25 | maven { url 'https://jitpack.io' }
26 | }
27 | }
28 | }
29 |
30 | dependencies {
31 | api fileTree(include: ['*.jar'], dir: 'libs')
32 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
33 | testImplementation 'junit:junit:4.12'
34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
35 | api rootProject.ext.support["support-v4"]
36 | api rootProject.ext.support["appcompat-v7"]
37 | api rootProject.ext.support["recyclerview-v7"]
38 | api rootProject.ext.support["constraint-layout"]
39 | api project(path: ':lib_gpuimage')
40 | implementation files('libs/universal-image-loader-1.9.5.jar')
41 | api 'com.github.tbruyelle:rxpermissions:0.10.2'
42 | api rootProject.ext.dependencies["rxandroid"]
43 | api rootProject.ext.dependencies["rxjava"]
44 | api rootProject.ext.dependencies["rxrelay"]
45 | }
46 |
--------------------------------------------------------------------------------
/app/libs/universal-image-loader-1.9.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cydeep/ImageEdit/d110dbdc1f6d7c4c71153020c597c0933cd099dd/app/libs/universal-image-loader-1.9.5.jar
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
26 |
30 |
34 |
35 |
39 |
40 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cydeep/imageedit/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010-2013 The SINA WEIBO Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.cydeep.imageedit;
18 |
19 | /**
20 | * 该类定义了授权时所需要的参数。
21 | */
22 | public interface Constants {
23 | int REQUEST_CODE_1001 = 1001;
24 | int REQUEST_CODE_1002 = 1002;
25 | int REQUEST_CODE_1003 = 1003;
26 | int REQUEST_CODE_1004 = 1004;
27 | int REQUEST_CODE_1005 = 1005;
28 | int REQUEST_CODE_1026 = 1026;
29 | int REQUEST_CODE_1027 = 1027;
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cydeep/imageedit/ImageEditApplication.java:
--------------------------------------------------------------------------------
1 | package com.cydeep.imageedit;
2 |
3 |
4 | import android.app.Application;
5 | import android.os.Environment;
6 | import android.os.Handler;
7 |
8 | import com.cydeep.imageedit.util.FileUtils;
9 | import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
10 | import com.nostra13.universalimageloader.cache.memory.impl.FIFOLimitedMemoryCache;
11 | import com.nostra13.universalimageloader.core.ImageLoader;
12 | import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
13 |
14 | import java.io.File;
15 |
16 |
17 | public class ImageEditApplication extends Application {
18 |
19 | public Handler handler = new Handler() {
20 | @Override
21 | public void handleMessage(android.os.Message msg) {
22 | super.handleMessage(msg);
23 |
24 | }
25 | };
26 |
27 | private static ImageEditApplication sInstance;
28 | @Override
29 | public void onCreate() {
30 | super.onCreate();
31 | sInstance = this;
32 | ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
33 | .diskCache(new UnlimitedDiskCache(new File(Environment.getExternalStorageDirectory(), FileUtils.APP_DIR + "/" + FileUtils.File_IMG_DIR))) // 自定义缓存路径,自定义图片路径,不能现在disk存储大小
34 | .diskCacheSize(50 * 1024 * 1024)
35 | // .threadPoolSize(2)
36 | .memoryCache(new FIFOLimitedMemoryCache(20 * 1024 * 1024))
37 | .memoryCacheSize(20 * 1024 * 1024)
38 | .build();
39 | ImageLoader.getInstance().init(config);
40 |
41 | }
42 | public static ImageEditApplication getInstance() {
43 | return sInstance;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cydeep/imageedit/base/EventMsg.java:
--------------------------------------------------------------------------------
1 | package com.cydeep.imageedit.base;
2 |
3 | public class EventMsg {
4 | public static final int CODE_RESULT_SELECT_IMAGE = 1001;
5 | public static final int CODE_RESULT_FILTE_IMAGE = 1002;
6 |
7 | public String msg;
8 | public int code;
9 |
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cydeep/imageedit/base/ListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.cydeep.imageedit.base;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.BaseAdapter;
7 |
8 | /**
9 | * Created by ChenYu on 5/8/15.
10 | */
11 | public class ListViewAdapter extends BaseAdapter {
12 |
13 |
14 | public void setOnUpdateUIListener(OnUpdateListUIListener onUpdateUIListener) {
15 | this.onUpdateUIListener = onUpdateUIListener;
16 | }
17 |
18 | public void setContext(Context context) {
19 | this.context = context;
20 | }
21 |
22 | public OnUpdateListUIListener getOnUpdateUIListener() {
23 | return onUpdateUIListener;
24 | }
25 |
26 | protected OnUpdateListUIListener onUpdateUIListener;
27 | protected Context context;
28 |
29 | @Override
30 | public View getView(int position, View convertView, ViewGroup parent) {
31 | ViewHolder viewHolder;
32 | if (convertView == null) {
33 | // convertView = View.inflate(context,layoutResourceId,null);
34 | convertView = onUpdateUIListener.initLayout(context,position);
35 | viewHolder = new ViewHolder(convertView,context);
36 | convertView.setTag(viewHolder);
37 | } else {
38 | viewHolder = (ViewHolder)convertView.getTag();
39 | }
40 | if (onUpdateUIListener != null) {
41 | viewHolder.position = position;
42 | onUpdateUIListener.onUpdateUI(context, viewHolder, position);
43 | }
44 | return convertView;
45 | }
46 |
47 |
48 | @Override
49 | public int getCount() {
50 | return onUpdateUIListener != null ?onUpdateUIListener.getCount() : 0;
51 | }
52 |
53 | @Override
54 | public Object getItem(int position) {
55 | return null;
56 | }
57 |
58 | @Override
59 | public long getItemId(int position) {
60 | return 0;
61 | }
62 |
63 |
64 | public ListViewAdapter(){
65 | super();
66 | }
67 |
68 | public ListViewAdapter(Context context, OnUpdateListUIListener onSetUIListener) {
69 | this.context = context;
70 | this.onUpdateUIListener = onSetUIListener;
71 | }
72 |
73 |
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cydeep/imageedit/base/OnUpdateListUIListener.java:
--------------------------------------------------------------------------------
1 | package com.cydeep.imageedit.base;
2 |
3 |
4 | import android.content.Context;
5 | import android.view.View;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by chenyu on 16/2/18.
11 | */
12 | public abstract class OnUpdateListUIListener {
13 | protected List mList;
14 |
15 | protected int mCount;
16 |
17 | public abstract void onUpdateUI(Context context, ViewHolder holder, int position);
18 |
19 | public abstract int getCount();
20 |
21 | public abstract void setData(List list);
22 |
23 | public abstract void setCount(int count);
24 |
25 | public abstract View initLayout(Context context, int position);
26 |
27 | public List getData(){
28 | return mList;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cydeep/imageedit/base/RecyclerViewBaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.cydeep.imageedit.base;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | /**
9 | * Created by ChenYu on 5/8/15.
10 | */
11 | public class RecyclerViewBaseAdapter extends RecyclerView.Adapter {
12 |
13 |
14 | private final Context context;
15 |
16 | public OnUpdateListUIListener getOnSetUIListener() {
17 | return onSetUIListener;
18 | }
19 |
20 | public void setOnSetUIListener(OnUpdateListUIListener onSetUIListener) {
21 | this.onSetUIListener = onSetUIListener;
22 | }
23 |
24 | private OnUpdateListUIListener onSetUIListener;
25 |
26 |
27 | @Override
28 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
29 | View view = onSetUIListener.initLayout(context,viewType);
30 | ViewHolder viewHolder = new ViewHolder(view,context);
31 | return viewHolder;
32 | }
33 |
34 | @Override
35 | public int getItemViewType(int position) {
36 | return position;
37 | }
38 |
39 | @Override
40 | public void onBindViewHolder(ViewHolder holder, int position) {
41 | if (onSetUIListener != null){
42 | holder.position = position;
43 | onSetUIListener.onUpdateUI(context,holder, position);
44 | }
45 | }
46 |
47 | @Override
48 | public int getItemCount() {
49 | return onSetUIListener.getCount();
50 | }
51 |
52 |
53 | public RecyclerViewBaseAdapter(Context context, OnUpdateListUIListener onSetUIListener) {
54 | this.context = context;
55 | this.onSetUIListener = onSetUIListener;
56 | }
57 |
58 |
59 | public boolean isBottomView(int position) {
60 | return false;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cydeep/imageedit/base/RxBus.java:
--------------------------------------------------------------------------------
1 | package com.cydeep.imageedit.base;
2 |
3 | import com.jakewharton.rxrelay2.PublishRelay;
4 | import com.jakewharton.rxrelay2.Relay;
5 |
6 | import io.reactivex.Observable;
7 |
8 | public class RxBus {
9 | private static volatile RxBus instance;
10 | private final Relay