8 Star 52 Fork 12

HarmonyOS-TPC / glide

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Glide

Introduction:

Glide is a fast and efficient image loading library for openharmony focused on smooth scrolling. Glide offers an easy to use API, a performant and extensible resource decoding pipeline and automatic resource pooling.# Glide

Glide hmos testapplication + ported code project Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible api that allows developers to plug in to almost any network stack. By default Glide uses a custom HttpUrlConnection based stack, but also includes utility libraries plug in to Google's Volley project or Square's OkHttp library instead.

Glide primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is also effective for almost any case where you need to fetch, resize, and display a remote image.

Usage Instructions:

API Glide uses a simple fluent API that allows users to make most requests in a single line:

1)Load Image from Internet
 //String can be like "https://picsum.photos/600"
 Glide.with(classcontext)
                    .load(String)  
                    .diskCacheStrategy(DiskCacheStrategy.NONE)
                    .skipMemoryCache(true)
                    .into(imageView);
                    
2)Load Image from Resource Folder
    //ResourceId can be esourceTable.Media_penguins
    Glide.with(classcontext)
            .load(ResourceId) 
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .into(imageView);
            
3) Uri uri =Uri.parse("https://picsum.photos/600");
   Glide.with(classcontext)
        .load(uri)
        .diskCacheStrategy(DiskCacheStrategy.NONE)
        .skipMemoryCache(true)
        .into(imageView);


4)Uri uri =Uri.parse("dataability:///" + "com.bumptech.glide"+ "/" + ResourceTable.Media_jellyfish);
  Glide.with(classcontext)
        .load(uri)
        .diskCacheStrategy(DiskCacheStrategy.NONE)
        .skipMemoryCache(true)
        .into(imageView);

GIF Introduction:

First, you need to use "DraweeView" as the carrier

Second, native "Image" do not support GIF

1.How to load a GIF by "Glide"

a. load gif from network

    DraweeView image = (DraweeView) findComponentById(ResourceTable.Id_image);
    Glide.with(this)
         .asGif()
         .load("https://img.blog.csdnimg.cn/2019120901303086.gif);
         .into(image);

b. load gif from native.

         DraweeView image = (DraweeView) findComponentById(ResourceTable.Id_drawview);
            Glide.with(this)
                 .asGif()
                 .load(ResourceTable.Media_happygirl);
                 .into(draweeView);  
  1. Lifecycle Management. When you don't need to show the gif, you need call draweeView.stopGif();
   DraweeView draweeView;
   @Override
   protected void onStart(Intent intent) {
       super.onStart(intent);
       super.setUIContent(ResourceTable.Layout_dodo1_slice_layout);
       draweeView = (DraweeView) findComponentById(ResourceTable.Id_draweeView);
       Glide.with(getApplicationContext())
          .asGif()
          .load(ResourceTable.Media_happygirl);
          .into(draweeView); 
       
   }     

   @Override
   protected void onBackground() {
       super.onBackground();
       draweeView.stopGif();
   }
  1. setScaleType Function

a. support Scale Mode

    public static enum ScaleMode {
        ZOOM_CENTER,
        ZOOM_START,
        ZOOM_END,
        STRECH,
        CENTER,
        INSIDE,
        CLIP_CENTER;
    }

b. how to use

    draweeView.setScaleType(mode);

c. how to set placeholder scale mode(only support CENTER, CLIP_CENTER, STRETCH, ZOOM_START, ZOOM_END, ZOOM_CENTER)

    Glide.with(classcontext)
        .load(uri)
        .placeholder(placeholderResourceId)
        .fallback(fallbackResourceId)
        .error(errorResourceId)
        .placeholderScaleMode(placeholderScaleMode)
        .into(imageView);
  1. Important Note:
    1. Currently the DraweeView must be used to use the GIF.
    2. If a context with a long lifecycle of a Glide is used, for example, applicationContext, call the stopGif method of the DraweeView when the GIF page ends to stop the Glide to reduceresource waste.
    3. If you want to use the GIF capability of Glide, the native image does not support this function beacuse Image and Element are independent and cannot be redrawn by using Element. To support GIF, you need to customize Image. For details, see the implementation of DraweeView

Installation instructions:

Method 1:
    Generate the .har package through the library and add the .har package to the libs folder.
    Add the following code to the entry gradle:
        implementation fileTree  (dir: 'libs', include: ['*.jar', '*.har'])

Method 2:
    allprojects{
        repositories{
            mavenCentral()
        }
    }
implementation 'io.openharmony.tpc.thirdlib:glide:1.1.5'
License for everything not in third_party and not otherwise marked: Copyright 2014 Google, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Google, Inc. --------------------------------------------------------------------------------------------- License for third_party/disklrucache: Copyright 2012 Jake Wharton Copyright 2011 The Android Open Source Project 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. --------------------------------------------------------------------------------------------- License for third_party/gif_decoder: Copyright (c) 2013 Xcellent Creations, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --------------------------------------------------------------------------------------------- License for third_party/gif_encoder/AnimatedGifEncoder.java and third_party/gif_encoder/LZWEncoder.java: No copyright asserted on the source code of this class. May be used for any purpose, however, refer to the Unisys LZW patent for restrictions on use of the associated LZWEncoder class. Please forward any corrections to kweiner@fmsware.com. ----------------------------------------------------------------------------- License for third_party/gif_encoder/NeuQuant.java Copyright (c) 1994 Anthony Dekker NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See "Kohonen neural networks for optimal colour quantization" in "Network: Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of the algorithm. Any party obtaining a copy of these files from the author, directly or indirectly, is granted, free of charge, a full and unrestricted irrevocable, world-wide, paid up, royalty-free, nonexclusive right and license to deal in this software and documentation files (the "Software"), including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons who receive copies from any such party to do so, with the only requirement being that this copyright notice remain intact.

简介

Glide is a fast and efficient image loading library for openharmony focused on smooth scrolling. 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/HarmonyOS-tpc/glide.git
git@gitee.com:HarmonyOS-tpc/glide.git
HarmonyOS-tpc
glide
glide
master

搜索帮助