Repository: liuguangqiang/IPicker Branch: master Commit: db643cff3b82 Files: 58 Total size: 131.0 KB Directory structure: gitextract_0zrh03zi/ ├── .gitignore ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── liuguangqiang/ │ │ └── ipicker/ │ │ └── sample/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── liuguangqiang/ │ │ │ └── ipicker/ │ │ │ └── sample/ │ │ │ ├── MainActivity.java │ │ │ └── SelectedAdapter.java │ │ └── res/ │ │ ├── layout/ │ │ │ ├── activity_main.xml │ │ │ └── item_selected.xml │ │ ├── values/ │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── values-w820dp/ │ │ └── dimens.xml │ └── test/ │ └── java/ │ └── com/ │ └── liuguangqiang/ │ └── ipicker/ │ └── sample/ │ └── ExampleUnitTest.java ├── build.gradle ├── gradle/ │ ├── gradle-mvn-push.gradle │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── library/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── liuguangqiang/ │ │ └── ipicker/ │ │ └── ExampleInstrumentedTest.java │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── java/ │ │ │ └── com/ │ │ │ └── liuguangqiang/ │ │ │ └── ipicker/ │ │ │ ├── CropImageActivity.java │ │ │ ├── IPicker.java │ │ │ ├── IPickerActivity.java │ │ │ ├── adapters/ │ │ │ │ ├── BaseAdapter.java │ │ │ │ └── PhotosAdapter.java │ │ │ ├── crop/ │ │ │ │ ├── Crop.java │ │ │ │ ├── CropImageView.java │ │ │ │ ├── CropUtil.java │ │ │ │ ├── HighlightView.java │ │ │ │ ├── ImageViewTouchBase.java │ │ │ │ ├── Log.java │ │ │ │ ├── MonitoredActivity.java │ │ │ │ └── RotateBitmap.java │ │ │ ├── entities/ │ │ │ │ └── Photo.java │ │ │ ├── internal/ │ │ │ │ ├── ImageMedia.java │ │ │ │ └── Logger.java │ │ │ └── widgets/ │ │ │ └── SquareRelativeLayout.java │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── crop_texture.xml │ │ │ └── round_white.xml │ │ ├── layout/ │ │ │ ├── activity_ipicker.xml │ │ │ ├── activity_ipicker_crop.xml │ │ │ └── item_photo.xml │ │ ├── values/ │ │ │ ├── attrs.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── strings.xml │ │ └── values-zh/ │ │ └── strings.xml │ └── test/ │ └── java/ │ └── com/ │ └── liuguangqiang/ │ └── ipicker/ │ └── ExampleUnitTest.java └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Built application files *.apk *.ap_ # Files for the Dalvik VM *.dex # Java class files *.class # Generated files bin/ gen/ # Gradle files .gradle/ build/ # Local configuration file (sdk path, etc) local.properties # Proguard folder generated by Eclipse proguard/ #Eclipse .project .classpath .settings #OSX .DS_Store #Android Studio build/ # Intellij project files *.iml *.ipr *.iws .idea/ #gradle .gradle/ ================================================ FILE: README.md ================================================ IPicker ====================================== A material design style pictures selector. ## Screenshot ## Usage ### Gradle ``` dependencies { implementation 'com.liuguangqiang.ipicker:IPicker:1.1.0' } ``` ### Maven ``` com.liuguangqiang.ipicker IPicker 1.1.0 pom ``` ### Manifest ``` ``` ### Theme ``` ``` ### Open the picker ```java IPicker.setLimit(1); IPicker.open(context); ``` Return the selected images by EventBus. ``` @Subscribe public void onEvent(IPickerEvent event) { } ``` Also support to get the selected images by a listener. ``` IPicker.setOnSelectedListener(new IPicker.OnSelectedListener() { @Override public void onSelected(List paths) {} }); ``` ## License Copyright 2016 Eric Liu 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. ================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle ================================================ apply plugin: 'com.android.application' android { compileSdkVersion 28 buildToolsVersion "28.0.0" defaultConfig { applicationId "com.liuguangqiang.ipicker.sample" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:design:28.0.0' implementation 'com.github.liuguangqiang.permissionhelper:permissionhelper:0.1.0' implementation 'com.github.bumptech.glide:glide:4.11.0' androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) testImplementation 'junit:junit:4.12' implementation project(':library') } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Users/Eric/Dev/android-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 *; #} ================================================ FILE: app/src/androidTest/java/com/liuguangqiang/ipicker/sample/ExampleInstrumentedTest.java ================================================ package com.liuguangqiang.ipicker.sample; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.*; /** * Instrumentation test, which will execute on an Android device. * * @see Testing documentation */ @RunWith(AndroidJUnit4.class) public class ExampleInstrumentedTest { @Test public void useAppContext() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); assertEquals("com.liuguangqiang.ipicker.sample", appContext.getPackageName()); } } ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/java/com/liuguangqiang/ipicker/sample/MainActivity.java ================================================ /* * Copyright 2016 Eric Liu * * 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. */ package com.liuguangqiang.ipicker.sample; import android.os.Bundle; import android.view.View; import android.widget.Button; import com.liuguangqiang.ipicker.IPicker; import java.util.ArrayList; import java.util.List; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; /** * A Sample */ public class MainActivity extends AppCompatActivity { private RecyclerView recyclerView; private SelectedAdapter adapter; private ArrayList selectPictures = new ArrayList<>(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initViews(); } private void initViews() { IPicker.setLimit(1); IPicker.setOnSelectedListener(new IPicker.OnSelectedListener() { @Override public void onSelected(List paths) { selectPictures.clear(); selectPictures.addAll(paths); adapter.notifyDataSetChanged(); } }); Button button = findViewById(R.id.open_picker); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { IPicker.open(getApplicationContext()); } }); adapter = new SelectedAdapter(getApplicationContext(), selectPictures); recyclerView = findViewById(R.id.rv_photos); recyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 4, GridLayoutManager.VERTICAL, false)); recyclerView.setAdapter(adapter); } } ================================================ FILE: app/src/main/java/com/liuguangqiang/ipicker/sample/SelectedAdapter.java ================================================ /* * Copyright 2016 Eric Liu * * 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. */ package com.liuguangqiang.ipicker.sample; import android.content.Context; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.liuguangqiang.ipicker.adapters.BaseAdapter; import java.util.List; import androidx.recyclerview.widget.RecyclerView; /** * Created by Eric on 16/9/12. */ public class SelectedAdapter extends BaseAdapter { public SelectedAdapter(Context context, List data) { super(context, data); } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ViewHolder(layoutInflater, parent, false); } @Override public void onBindViewHolder(ViewHolder holder, int position) { super.onBindViewHolder(holder, position); holder.bindData(data.get(position)); } public static class ViewHolder extends RecyclerView.ViewHolder { private ImageView ivPhoto; public ViewHolder(LayoutInflater layoutInflater, ViewGroup parent, boolean attachToRoot) { super(layoutInflater.inflate(R.layout.item_selected, parent, attachToRoot)); ivPhoto = (ImageView) itemView.findViewById(R.id.iv_photo); } public void bindData(String path) { Glide.with(itemView.getContext()).load(path).into(ivPhoto); } } } ================================================ FILE: app/src/main/res/layout/activity_main.xml ================================================