# picasso **Repository Path**: HarmonyOS-tpc/picasso ## Basic Information - **Project Name**: picasso - **Description**: A powerful image downloading and caching library for openharmony. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 8 - **Forks**: 0 - **Created**: 2021-04-01 - **Last Updated**: 2025-02-21 ## Categories & Tags **Categories**: harmonyos-image **Tags**: None ## README ## Picasso ## Introduction A powerful image downloading and caching library for openharmony. ## Usage Instructions Grid view - **Download image** from url Get access to the Picasso object & load the image from url ``` Picasso.get() .load(url) .placeholder(ResourceTable.Media_placeholder) .error(ResourceTable.Media_error) .fit() .tag(context) .into(view); ``` create grid view using the BaseItemProvider & Listcontainer Grid view - **Error image loading** Get access to the Picasso object & load the image from url ``` Picasso.get() .load(url) .placeholder(ResourceTable.Media_placeholder) .error(ResourceTable.Media_error) .fit() .tag(context) .into(view); ``` Validate with network disable to simulate image loading failure & check if error image is loaded Grid view - **Placeholder image loading** Get access to the Picasso object & load the image from url ``` Picasso.get() .load(url) .placeholder(ResourceTable.Media_placeholder) .error(ResourceTable.Media_error) .fit() .tag(context) .into(view); ``` Validate that before actual image loading the placeholder image gets shown in the grid Grid view - **Loading of image from cache/memory** Get access to the Picasso object & load the image from url ``` Picasso.get() .load(url) .placeholder(ResourceTable.Media_placeholder) .error(ResourceTable.Media_error) .fit() .tag(context) .into(view); ``` Validate loading of images from cache by disabling internet & navigating between screen. The images should be loaded from cache ***Notification*** Create notification using - NotificationRequest & NotificationPictureContent classes & then load the image from url using Picasso API call as below ``` Picasso.get() .load(Data.URLS[new SecureRandom().nextInt(Data.URLS.length)]) .resizeDimen(ResourceTable.Float_notification_icon_width_height,ResourceTable.Float_notification_icon_width_height ) .into(remoteview,ResourceTable.Id_photo, NOTIFICATION_ID, notification); ``` ***Gallery image loading*** ``` Picasso.get() .load(image) .fit() .centerInside() .into(imageView, new Callback.EmptyCallback() { @Override public void onSuccess() { } }); ``` *Note* : Currently launching of the Gallery is not supported in openharmony, hence we are checking the available images and launching the first image.If there is no Image available then we display a toast dialog. ***Listview*** - Get access to the Picasso object & load the image from url,Trigger the download of the URL asynchronously into the image view. ``` Picasso.get() .load(itemPosition) .placeholder(ResourceTable.Media_placeholder) .error(ResourceTable.Media_error) .resizeDimen(ResourceTable.Float_list_detail_image_size,ResourceTable.Float_list_detail_image_size) .centerInside() .tag(context) .into(image); ``` Validate loading of images from cache by disabling internet & navigating between screen. The images should be loaded from cache ***Loading of Image in a detail view*** - Get access to the Picasso object & load the image from url, Trigger the download of the URL asynchronously into the image view. ``` Picasso.get() .load(test.getParam("URL").toString()) .fit() .tag(getContext()) .into(image); ``` Validate loading of images from cache by disabling internet & navigating between screen. The images should be loaded from cache **Not supported-feature** 1. Transformation 2. Fading 3. Priority Requests 4. Support for Request cancellation and parallel downloading **Observations:** 1. Displaying the contact image in not implemented as not supported by OHOS. 2. *Notification:* Notification is shown in the Status bar and dismissed when clicking. But when clicking it is not launching the application. 3. *Orientation change:* Gridview: When orientation change the image size are not updated and while scrolling its fitting to the screen. Gallery: When orientation change the image size are not updated Detailed View: When orientation change the image size are not updated ## Installation Instructions ``` Method 1: Generate har package from library and add it to lib folder. add following code to gradle of entry implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) Method 2: allprojects{ repositories{ mavenCentral() } } implementation 'io.openharmony.tpc.thirdlib:picasso:1.0.4' ``` ## License Copyright 2013 Square, 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.