| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
ModChase
7年前发布

Android开源:Matisse-知乎出品的 Android 图片选择器

   <p style="text-align:center"><img src="https://simg.open-open.com/show/b7a2aafd0a27f99c3b26a3bb8187914c.png"></p>    <h2>Matisse</h2>    <p> </p>    <p>Matisse is a well-designed local image selector for Android. You can</p>    <ul>     <li>Use it in Activity or Fragment</li>     <li>Select JPEG, PNG and GIF</li>     <li>Apply different themes, including two built-in themes and custom themes</li>     <li>Different image loaders</li>     <li>Define custom filter rules</li>     <li>More to find out yourself</li>    </ul>    <table>     <thead>      <tr>       <th>Zhihu Style</th>       <th>Dracula Style</th>       <th>Preview</th>      </tr>     </thead>     <tbody>      <tr>       <td><img src="https://simg.open-open.com/show/8abde3665b45154ab52c17ad1e5bba43.png"></td>       <td><img src="https://simg.open-open.com/show/b70925171ae83bf09bf32022d6401bc0.png"></td>       <td><img src="https://simg.open-open.com/show/526c096a4c5dec4b086512d628209053.png"></td>      </tr>     </tbody>    </table>    <h2>Download</h2>    <p>Gradle:</p>    <pre>  <code class="language-java">repositories {      jcenter()  }    dependencies {      compile 'com.zhihu.android:matisse:0.4.3'  }</code></pre>    <h2>ProGuard</h2>    <p>If you use <a href="/misc/goto?guid=4958862736295244246" rel="nofollow,noindex">Glide</a> as your image engine, you may need the following rules:</p>    <pre>  <code class="language-java">-keep public class * implements com.bumptech.glide.module.GlideModule  -keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {    **[] $VALUES;    public *;  }    # for DexGuard only  -keepresourcexmlelements manifest/application/meta-data@value=GlideModule</code></pre>    <p>If you use <a href="/misc/goto?guid=4958972548258164558" rel="nofollow,noindex">Picasso</a> as your image engine, you may need the following rules:</p>    <pre>  <code class="language-java">-dontwarn com.squareup.okhttp.**</code></pre>    <h2>How do I use Matisse?</h2>    <p>Permission</p>    <p>The library requires two permissions:</p>    <ul>     <li>android.permission.READ_EXTERNAL_STORAGE</li>     <li>android.permission.WRITE_EXTERNAL_STORAGE</li>    </ul>    <p>So if you are targeting Android 6.0+, you need to handle runtime permission request before next step.</p>    <p>Simple usage snippet</p>    <p>Start MatisseActivity from current Activity or Fragment :</p>    <pre>  <code class="language-java">Matisse.from(MainActivity.this)          .choose(MimeType.of(MimeType.JPEG, MimeType.PNG, MimeType.GIF))          .countable(true)          .maxSelectable(9)          .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))          .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))          .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)          .thumbnailScale(0.85f)          .imageEngine(new GlideEngine())          .forResult(REQUEST_CODE_CHOOSE);</code></pre>    <p>Themes</p>    <p>There are two built-in themes you can use to start MatisseActivity :</p>    <ul>     <li>R.style.Matisse_Zhihu (light mode)</li>     <li>R.style.Matisse_Dracula (dark mode)</li>    </ul>    <p>And Also you can define your own theme as you wish.</p>    <p>Receive Result</p>    <p>In onActivityResult() callback of the starting Activity or Fragment :</p>    <pre>  <code class="language-java">List<Uri> mSelected;    @Override  protected void onActivityResult(int requestCode, int resultCode, Intent data) {      super.onActivityResult(requestCode, resultCode, data);      if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {          mSelected = Matisse.obtainResult(data);          Log.d("Matisse", "mSelected: " + mSelected);      }  }</code></pre>    <p>More</p>    <p>Find more details about Matisse in wiki.</p>    <h2>Contributing</h2>    <ul>     <li>To contribute with a small fix, simply create a pull request.</li>     <li>Better to open an issue to discuss with the team and the community if you're intended to work on something BIG.</li>     <li>Please follow <a href="/misc/goto?guid=4959747816280778149" rel="nofollow,noindex">Code Style for Contributors</a> of AOSP.</li>    </ul>    <h2>Thanks</h2>    <p>This library is inspired by <a href="/misc/goto?guid=4959747816375047133" rel="nofollow,noindex">Laevatein</a> and uses some of its source code.</p>    <h2>License</h2>    <pre>  <code class="language-java">Copyright 2017 Zhihu Inc.    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.</code></pre>    <p> </p>    <p>项目主页:<a href="http://www.open-open.com/lib/view/home/1492743484341">http://www.open-open.com/lib/view/home/1492743484341</a></p>    <p> </p>    
 本文由用户 ModChase 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1492743484341.html
安卓开发 Android开发 移动开发