├── .gitignore ├── .idea ├── gradle.xml ├── misc.xml ├── previewer │ ├── phone │ │ └── phoneSettingConfig_106113203.json │ └── previewConfig.json └── vcs.xml ├── build.gradle ├── entry ├── .gitignore ├── build.gradle └── src │ └── main │ ├── config.json │ ├── java │ └── com │ │ └── istone │ │ └── myapplication │ │ ├── GifAbility.java │ │ ├── HarmonyOS.java │ │ ├── ListAbility.java │ │ ├── LocalAbility.java │ │ ├── MainAbility.java │ │ ├── ResourcesChangeAbility.java │ │ ├── ServerAbility.java │ │ ├── adapter │ │ └── TopicItemProvider.java │ │ ├── domain │ │ └── TopicDomain.java │ │ ├── slice │ │ ├── BAbilitySlice.java │ │ ├── GifAbilitySlice.java │ │ ├── ListAbilitySlice.java │ │ ├── LocalAbilitySlice.java │ │ ├── MainAbilitySlice.java │ │ ├── ResourcesChangeAbilitySlice.java │ │ └── ServerAbilitySlice.java │ │ └── utils │ │ └── LogUtils.java │ └── resources │ ├── base │ ├── element │ │ └── string.json │ ├── graphic │ │ ├── background_ability_gif.xml │ │ ├── background_ability_list.xml │ │ ├── background_ability_local.xml │ │ ├── background_ability_main.xml │ │ ├── background_ability_resources_change.xml │ │ ├── background_ability_second.xml │ │ └── background_ability_server.xml │ ├── layout │ │ ├── ability_gif.xml │ │ ├── ability_list.xml │ │ ├── ability_local.xml │ │ ├── ability_main.xml │ │ ├── ability_resources_change.xml │ │ ├── ability_second.xml │ │ ├── ability_server.xml │ │ ├── ability_two.xml │ │ └── list_item_layout.xml │ └── media │ │ ├── A.png │ │ ├── B.jpg │ │ └── icon.png │ └── rawfile │ ├── A.gif │ └── A.png ├── glidelibrary ├── .gitignore ├── build.gradle └── src │ └── main │ ├── config.json │ ├── java │ └── com │ │ └── isotne │ │ └── glidelibrary │ │ ├── FileType.java │ │ ├── cache │ │ ├── loader │ │ │ └── CacheLoader.java │ │ └── util │ │ │ ├── CacheUtils.java │ │ │ ├── DiskLruCache.java │ │ │ ├── DiskLruCacheImpl.java │ │ │ ├── DiskLruCacheUtil.java │ │ │ ├── ImageUtils.java │ │ │ ├── MemoryCacheUtil.java │ │ │ ├── StrictLineReader.java │ │ │ └── Utils.java │ │ ├── constant │ │ └── Constents.java │ │ ├── gif │ │ └── LoadGif.java │ │ ├── interceptor │ │ └── NetCacheInterceptor.java │ │ ├── okhttp │ │ └── OkHttpManager.java │ │ └── utils │ │ ├── LogUtils.java │ │ └── OhosGlide.java │ └── resources │ └── base │ ├── element │ └── string.json │ └── layout │ └── ability_main.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/previewer/phone/phoneSettingConfig_106113203.json: -------------------------------------------------------------------------------- 1 | { 2 | "setting": { 3 | "1.0.1": { 4 | "Language": { 5 | "args": { 6 | "Language": "zh-CN" 7 | } 8 | } 9 | } 10 | }, 11 | "frontend": { 12 | "1.0.0": { 13 | "Resolution": { 14 | "args": { 15 | "Resolution": "360*750" 16 | } 17 | }, 18 | "DeviceType": { 19 | "args": { 20 | "DeviceType": "phone" 21 | } 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /.idea/previewer/previewConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.0.0": { 3 | "LastPreviewDevice": { 4 | "E:\\MyApplication\\entry": [] 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | apply plugin: 'com.huawei.ohos.app' 3 | 4 | ohos { 5 | compileSdkVersion 4 6 | defaultConfig { 7 | compatibleSdkVersion 3 8 | } 9 | } 10 | 11 | buildscript { 12 | repositories { 13 | maven { 14 | url 'https://mirrors.huaweicloud.com/repository/maven/' 15 | } 16 | maven { 17 | url 'https://developer.huawei.com/repo/' 18 | } 19 | jcenter() 20 | } 21 | dependencies { 22 | classpath 'com.huawei.ohos:hap:2.4.1.4' 23 | } 24 | } 25 | 26 | allprojects { 27 | repositories { 28 | maven { 29 | url 'https://mirrors.huaweicloud.com/repository/maven/' 30 | } 31 | maven { 32 | url 'https://developer.huawei.com/repo/' 33 | } 34 | jcenter() 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /entry/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /entry/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.huawei.ohos.hap' 2 | ohos { 3 | signingConfigs { 4 | debug { 5 | storeFile file('D:/keystore.p12') 6 | storePassword '0000001C7688E2D7631C7D58FCC70E03015ECA5A955E6ADC78A7F0B119A36EEB6AAD3AD6C78D35BA70F7D2D1' 7 | keyAlias 'keystore' 8 | keyPassword '0000001C7E6B08B19B7DADEC085D2DA48449510520B84BD1DA40759BF553E0B74029FB8926E204A8619FE83D' 9 | signAlg 'SHA256withECDSA' 10 | profile file('D:/ohosGlideDebug.p7b') 11 | certpath file('D:/keystore.cer') 12 | } 13 | } 14 | compileSdkVersion 4 15 | defaultConfig { 16 | compatibleSdkVersion 3 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) 22 | testCompile'junit:junit:4.12' 23 | implementation project(path: ':glidelibrary') 24 | } 25 | -------------------------------------------------------------------------------- /entry/src/main/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "bundleName": "com.istone.myapplication", 4 | "vendor": "istone", 5 | "version": { 6 | "code": 1, 7 | "name": "1.0" 8 | }, 9 | "apiVersion": { 10 | "compatible": 3, 11 | "target": 4, 12 | "releaseType": "Beta1" 13 | } 14 | }, 15 | "deviceConfig": {}, 16 | "module": { 17 | "package": "com.istone.myapplication", 18 | "name": "com.istone.myapplication.HarmonyOS", 19 | "deviceType": [ 20 | "phone" 21 | ], 22 | "distro": { 23 | "deliveryWithInstall": true, 24 | "moduleName": "entry", 25 | "moduleType": "entry" 26 | }, 27 | "abilities": [ 28 | { 29 | "skills": [ 30 | { 31 | "entities": [ 32 | "entity.system.home" 33 | ], 34 | "actions": [ 35 | "action.system.home", 36 | "action.play", 37 | "action.goto.page" 38 | ] 39 | } 40 | ], 41 | "orientation": "unspecified", 42 | "name": "com.istone.myapplication.MainAbility", 43 | "icon": "$media:icon", 44 | "description": "$string:mainability_description", 45 | "label": "HarmonyOS", 46 | "type": "page", 47 | "launchType": "standard" 48 | }, 49 | { 50 | "orientation": "unspecified", 51 | "name": "com.istone.myapplication.ResourcesChangeAbility", 52 | "icon": "$media:icon", 53 | "description": "$string:resourceschangeability_description", 54 | "label": "entry", 55 | "type": "page", 56 | "launchType": "standard" 57 | }, 58 | { 59 | "orientation": "unspecified", 60 | "name": "com.istone.myapplication.ServerAbility", 61 | "icon": "$media:icon", 62 | "description": "$string:serverability_description", 63 | "label": "entry", 64 | "type": "page", 65 | "launchType": "standard" 66 | }, 67 | { 68 | "orientation": "unspecified", 69 | "name": "com.istone.myapplication.LocalAbility", 70 | "icon": "$media:icon", 71 | "description": "$string:localability_description", 72 | "label": "entry", 73 | "type": "page", 74 | "launchType": "standard" 75 | }, 76 | { 77 | "orientation": "unspecified", 78 | "name": "com.istone.myapplication.GifAbility", 79 | "icon": "$media:icon", 80 | "description": "$string:gifability_description", 81 | "label": "entry", 82 | "type": "page", 83 | "launchType": "standard" 84 | }, 85 | { 86 | "orientation": "unspecified", 87 | "name": "com.istone.myapplication.ListAbility", 88 | "icon": "$media:icon", 89 | "description": "$string:listability_description", 90 | "label": "entry", 91 | "type": "page", 92 | "launchType": "standard" 93 | } 94 | ], 95 | "reqPermissions": [ 96 | { 97 | "name": "ohos.permission.GET_NETWORK_INFO" 98 | }, 99 | { 100 | "name": "ohos.permission.GET_WIFI_INFO" 101 | }, 102 | { 103 | "name": "ohos.permission.INTERNET" 104 | }, 105 | { 106 | "name": "ohos.permission.READ_MEDIA" 107 | }, 108 | { 109 | "name": "ohos.permission.WRITE_MEDIA" 110 | }, 111 | { 112 | "name": "ohos.permission.READ_USER_STORAGE" 113 | }, 114 | { 115 | "name": "ohos.permission.WRITE_USER_STORAGE" 116 | }, 117 | { 118 | "name": "ohos.permission.LOCATION" 119 | } 120 | ] 121 | } 122 | } -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/GifAbility.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication; 2 | 3 | import com.istone.myapplication.slice.GifAbilitySlice; 4 | import ohos.aafwk.ability.Ability; 5 | import ohos.aafwk.content.Intent; 6 | 7 | /** 8 | * description gif 9 | * @author baihe 10 | * created 2021/2/8 14:51 11 | */ 12 | public class GifAbility extends Ability { 13 | @Override 14 | public void onStart(Intent intent) { 15 | super.onStart(intent); 16 | super.setMainRoute(GifAbilitySlice.class.getName()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/HarmonyOS.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication; 2 | 3 | import ohos.aafwk.ability.AbilityPackage; 4 | 5 | /** 6 | * description harmonyos 7 | * @author baihe 8 | * created 2021/2/8 14:51 9 | */ 10 | public class HarmonyOS extends AbilityPackage { 11 | @Override 12 | public void onInitialize() { 13 | 14 | super.onInitialize(); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/ListAbility.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication; 2 | 3 | import com.istone.myapplication.slice.ListAbilitySlice; 4 | import ohos.aafwk.ability.Ability; 5 | import ohos.aafwk.content.Intent; 6 | 7 | /** 8 | * description list 9 | * @author baihe 10 | * created 2021/2/8 14:50 11 | */ 12 | public class ListAbility extends Ability { 13 | @Override 14 | public void onStart(Intent intent) { 15 | super.onStart(intent); 16 | super.setMainRoute(ListAbilitySlice.class.getName()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/LocalAbility.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication; 2 | 3 | import com.istone.myapplication.slice.LocalAbilitySlice; 4 | import ohos.aafwk.ability.Ability; 5 | import ohos.aafwk.content.Intent; 6 | 7 | /** 8 | *description local 9 | *@author baihe 10 | *created 2021/2/8 14:52 11 | * 12 | */ 13 | public class LocalAbility extends Ability { 14 | @Override 15 | public void onStart(Intent intent) { 16 | super.onStart(intent); 17 | super.setMainRoute(LocalAbilitySlice.class.getName()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/MainAbility.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication; 2 | 3 | import com.istone.myapplication.slice.BAbilitySlice; 4 | import com.istone.myapplication.slice.MainAbilitySlice; 5 | import ohos.aafwk.ability.Ability; 6 | import ohos.aafwk.content.Intent; 7 | 8 | /** 9 | * description main 10 | * @author baihe 11 | * created 2021/2/8 14:50 12 | */ 13 | public class MainAbility extends Ability { 14 | @Override 15 | public void onStart(Intent intent) { 16 | super.onStart(intent); 17 | super.setMainRoute(MainAbilitySlice.class.getName()); 18 | addActionRoute("action.goto.page", BAbilitySlice.class.getName()); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/ResourcesChangeAbility.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication; 2 | 3 | import com.istone.myapplication.slice.ResourcesChangeAbilitySlice; 4 | import ohos.aafwk.ability.Ability; 5 | import ohos.aafwk.content.Intent; 6 | 7 | /** 8 | * description resources 9 | * @author baihe 10 | * created 2021/2/8 14:51 11 | */ 12 | public class ResourcesChangeAbility extends Ability { 13 | @Override 14 | public void onStart(Intent intent) { 15 | super.onStart(intent); 16 | super.setMainRoute(ResourcesChangeAbilitySlice.class.getName()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/ServerAbility.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication; 2 | 3 | import com.istone.myapplication.slice.ServerAbilitySlice; 4 | import ohos.aafwk.ability.Ability; 5 | import ohos.aafwk.content.Intent; 6 | 7 | /** 8 | * description server 9 | * @author baihe 10 | * created 2021/2/8 14:51 11 | */ 12 | public class ServerAbility extends Ability { 13 | @Override 14 | public void onStart(Intent intent) { 15 | super.onStart(intent); 16 | super.setMainRoute(ServerAbilitySlice.class.getName()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/adapter/TopicItemProvider.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.adapter; 2 | 3 | import com.isotne.glidelibrary.utils.LogUtils; 4 | import com.isotne.glidelibrary.utils.OhosGlide; 5 | import com.istone.myapplication.ResourceTable; 6 | import com.istone.myapplication.domain.TopicDomain; 7 | import ohos.aafwk.ability.AbilitySlice; 8 | import ohos.agp.components.Component; 9 | import ohos.agp.components.ComponentContainer; 10 | import ohos.agp.components.LayoutScatter; 11 | import ohos.agp.components.RecycleItemProvider; 12 | import ohos.agp.components.Text; 13 | import ohos.agp.components.Image; 14 | import java.io.IOException; 15 | import java.util.List; 16 | 17 | /** 18 | * description topicitem provider 19 | * 20 | * @author baihe 21 | * created 2021/2/8 14:53 22 | */ 23 | public class TopicItemProvider extends RecycleItemProvider { 24 | /** 25 | * list 26 | */ 27 | private List list; 28 | /** 29 | * slice 30 | */ 31 | private AbilitySlice slice; 32 | 33 | public TopicItemProvider(List list, AbilitySlice slice) { 34 | // subcribeNetwork(); 35 | this.list = list; 36 | this.slice = slice; 37 | } 38 | 39 | @Override 40 | public int getCount() { 41 | return list.size(); 42 | } 43 | 44 | @Override 45 | public Object getItem(int position) { 46 | if (list != null && position > 0 && position < list.size()) { 47 | return list.get(position); 48 | } 49 | return null; 50 | } 51 | 52 | @Override 53 | public long getItemId(int position) { 54 | return position; 55 | } 56 | 57 | @Override 58 | public Component getComponent(int position, Component convertComponent, ComponentContainer componentContainer) { 59 | Component cpt; 60 | ViewHolder viewHolder; 61 | LogUtils.log(LogUtils.ERROR,"abc=","===========33333"); 62 | if (convertComponent == null) { 63 | cpt = LayoutScatter.getInstance(slice).parse(ResourceTable.Layout_list_item_layout, null, false); 64 | viewHolder = new ViewHolder(); 65 | viewHolder.topic = (Text) cpt.findComponentById(ResourceTable.Id_topic); 66 | viewHolder.image = (Image) cpt.findComponentById(ResourceTable.Id_imageView); 67 | cpt.setTag(viewHolder); 68 | } else { 69 | cpt = convertComponent; 70 | viewHolder = (ViewHolder) cpt.getTag(); 71 | } 72 | 73 | TopicDomain topic = list.get(position); 74 | viewHolder.topic.setText(topic.getTopic()); 75 | try { 76 | OhosGlide.with(slice).load(topic.getUrl()).def(ResourceTable.Media_A).hasDiskCache(true).into(viewHolder.image); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | 81 | return cpt; 82 | } 83 | 84 | // private void subcribeNetwork(){ 85 | // LogUtils.log(LogUtils.ERROR,"abc=","========22222222"); 86 | // MatchingSkills matchingSkills = new MatchingSkills(); 87 | // matchingSkills.addEvent(CommonEventSupport.COMMON_EVENT_WIFI_CONN_STATE); // 网络链接状态监听事件 88 | // matchingSkills.addEvent(CommonEventSupport.COMMON_EVENT_WIFI_P2P_STATE_CHANGED); 89 | // CommonEventSubscribeInfo subscribeInfo = new CommonEventSubscribeInfo(matchingSkills); 90 | // WifiEventSubscriber subscriber = new WifiEventSubscriber(subscribeInfo); 91 | // try { 92 | // CommonEventManager.subscribeCommonEvent(subscriber); 93 | // publish(); 94 | // } catch (RemoteException e) { 95 | // } 96 | // } 97 | 98 | // private void publish(){ 99 | // try { 100 | // Intent intent = new Intent(); 101 | // Operation operation = new Intent.OperationBuilder() 102 | // .build(); 103 | // intent.setOperation(operation); 104 | // CommonEventData eventData = new CommonEventData(intent); 105 | // CommonEventManager.publishCommonEvent(eventData); 106 | // } catch (RemoteException e) { 107 | // } 108 | // } 109 | 110 | /** 111 | * viewholder 112 | */ 113 | class ViewHolder { 114 | /** 115 | * topic 116 | */ 117 | private Text topic; 118 | /** 119 | * image 120 | */ 121 | private Image image; 122 | 123 | /** 124 | * @return topic 125 | */ 126 | public Text getTopic() { 127 | return topic; 128 | } 129 | 130 | /** 131 | * @param topic topic text 132 | */ 133 | public void setTopic(Text topic) { 134 | this.topic = topic; 135 | } 136 | 137 | /** 138 | * @return iamge 139 | */ 140 | public Image getImage() { 141 | return image; 142 | } 143 | 144 | /** 145 | * @param image image 146 | */ 147 | public void setImage(Image image) { 148 | this.image = image; 149 | } 150 | } 151 | 152 | // class WifiEventSubscriber extends CommonEventSubscriber { 153 | // EventRunner runner = EventRunner.create(true); 154 | // 155 | // public WifiEventSubscriber(CommonEventSubscribeInfo subscribeInfo) { 156 | // super(subscribeInfo); 157 | // } 158 | // 159 | // @Override 160 | // public void onReceiveEvent(CommonEventData commonEventData) { 161 | // LogUtils.log(LogUtils.ERROR, "abc=", "======================"); 162 | // // 待执行的操作,由开发者定义 163 | // MyEventHandler myHandler = new MyEventHandler(runner); 164 | // InnerEvent innerEvent = InnerEvent.get(); 165 | // myHandler.sendEvent(innerEvent, 0, EventHandler.Priority.IMMEDIATE); 166 | // 167 | //// NetManager netManager = NetManager.getInstance(null); 168 | //// 169 | //// if (!netManager.hasDefaultNet()) { 170 | //// return; 171 | //// } else { 172 | ////// EventRunner runner = EventRunner.create(false); 173 | ////// MyEventHandler myHandler = new MyEventHandler(runner); 174 | ////// InnerEvent innerEvent = InnerEvent.get(); 175 | ////// myHandler.sendEvent(innerEvent); 176 | //// } 177 | // 178 | //// if (WifiEvents.EVENT_ACTIVE_STATE.equals(commonEventData.getIntent().getAction())) { 179 | //// // 获取附带参数 180 | //// IntentParams params = commonEventData.getIntent().getParams(); 181 | //// if (params == null) { 182 | //// return; 183 | //// } 184 | //// int wifiState = (int) params.getParam(WifiEvents.PARAM_ACTIVE_STATE); 185 | //// 186 | //// if (wifiState == WifiEvents.STATE_ACTIVE) { // 处理WLAN被打开消息 187 | //// } else if (wifiState == WifiEvents.STATE_INACTIVE) { // 处理WLAN被关闭消息 188 | //// } else { // 处理WLAN异常状态 189 | //// } 190 | //// } 191 | // } 192 | // } 193 | // 194 | // public class MyEventHandler extends EventHandler { 195 | // public MyEventHandler(EventRunner runner) { 196 | // super(runner); 197 | // } 198 | // // 重写实现processEvent方法 199 | // @Override 200 | // public void processEvent(InnerEvent event) { 201 | // super.processEvent(event); 202 | // 203 | // notifyDataChanged(); 204 | // 205 | // 206 | // } 207 | // } 208 | } 209 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/domain/TopicDomain.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.domain; 2 | 3 | 4 | /** 5 | * description list domain 6 | * 7 | * @author baihe 8 | * created 2021/2/8 14:37 9 | */ 10 | public class TopicDomain { 11 | /** 12 | * topic 13 | */ 14 | private String topic; 15 | /** 16 | * url 17 | */ 18 | private String url; 19 | 20 | public TopicDomain(String topic, String url) { 21 | this.topic = topic; 22 | this.url = url; 23 | 24 | } 25 | 26 | public String getTopic() { 27 | return topic; 28 | } 29 | 30 | public void setTopic(String topic) { 31 | this.topic = topic; 32 | } 33 | 34 | public String getUrl() { 35 | return url; 36 | } 37 | 38 | public void setUrl(String url) { 39 | this.url = url; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/slice/BAbilitySlice.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.slice; 2 | 3 | import com.istone.myapplication.ResourceTable; 4 | import ohos.aafwk.ability.AbilitySlice; 5 | import ohos.aafwk.content.Intent; 6 | 7 | /** 8 | * description resourcesslice 9 | * 10 | * @author baihe 11 | * created 2021/2/8 14:52 12 | */ 13 | public class BAbilitySlice extends AbilitySlice { 14 | 15 | @Override 16 | public void onStart(Intent intent) { 17 | super.onStart(intent); 18 | super.setUIContent(ResourceTable.Layout_ability_resources_change); 19 | 20 | } 21 | 22 | @Override 23 | public void onActive() { 24 | super.onActive(); 25 | } 26 | 27 | @Override 28 | public void onForeground(Intent intent) { 29 | super.onForeground(intent); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/slice/GifAbilitySlice.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.slice; 2 | 3 | import com.isotne.glidelibrary.utils.OhosGlide; 4 | import com.istone.myapplication.ResourceTable; 5 | import ohos.aafwk.ability.AbilitySlice; 6 | import ohos.aafwk.content.Intent; 7 | import ohos.agp.components.Image; 8 | 9 | import java.io.IOException; 10 | 11 | /** 12 | * description gifslice 13 | * @author baihe 14 | * created 2021/2/8 14:53 15 | */ 16 | public class GifAbilitySlice extends AbilitySlice { 17 | @Override 18 | public void onStart(Intent intent) { 19 | super.onStart(intent); 20 | super.setUIContent(ResourceTable.Layout_ability_gif); 21 | Image image = (Image) findComponentById(ResourceTable.Id_gif_image); 22 | try { 23 | OhosGlide.with(this).load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang" + 24 | ".com%2Fuploads%2Fitem%2F201611%2F04%2F20161104110413_XzVAk.thumb.700_0" + 25 | ".gif&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999," + 26 | "10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614137486&t=ad88afe8f35232022db6009e8a165889").def(ResourceTable.Media_A).into(image); 27 | } catch (IOException e) { 28 | e.printStackTrace(); 29 | } 30 | } 31 | 32 | @Override 33 | public void onActive() { 34 | super.onActive(); 35 | } 36 | 37 | @Override 38 | public void onForeground(Intent intent) { 39 | super.onForeground(intent); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/slice/ListAbilitySlice.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.slice; 2 | 3 | import com.istone.myapplication.ResourceTable; 4 | import com.istone.myapplication.adapter.TopicItemProvider; 5 | import com.istone.myapplication.domain.TopicDomain; 6 | import ohos.aafwk.ability.AbilitySlice; 7 | import ohos.aafwk.content.Intent; 8 | import ohos.agp.components.ListContainer; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * description listslice 14 | * 15 | * @author baihe 16 | * created 2021/2/8 14:53 17 | */ 18 | public class ListAbilitySlice extends AbilitySlice { 19 | @Override 20 | public void onStart(Intent intent) { 21 | super.onStart(intent); 22 | super.setUIContent(ResourceTable.Layout_ability_list); 23 | initListContainer(); 24 | } 25 | 26 | /** 27 | * initListContainer 28 | */ 29 | private void initListContainer() { 30 | ListContainer listContainer = (ListContainer) findComponentById(ResourceTable.Id_list_container); 31 | List list = getData(); 32 | TopicItemProvider sampleItemProvider = new TopicItemProvider(list, this); 33 | listContainer.setItemProvider(sampleItemProvider); 34 | } 35 | 36 | /** 37 | * 38 | * @return ArrayList 39 | */ 40 | private ArrayList getData() { 41 | ArrayList list = new ArrayList<>(); 42 | 43 | list.add(new TopicDomain("hello,1", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong" + 44 | ".com%2F86%2F10%2F01300000184180121920108394217.jpg&refer=http%3A%2F%2Fa2.att.hudong" + 45 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 46 | "=8bbec0d30e98bdd5d5fdea87628554da")); 47 | list.add(new TopicDomain("hello,2", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 48 | ".com%2F65%2F38%2F16300534049378135355388981738.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 49 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 50 | "=d27e0975ecff17c5ce14fa8494fb0733")); 51 | list.add(new TopicDomain("hello,3", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 52 | ".com%2F35%2F34%2F19300001295750130986345801104.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 53 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 54 | "=555f2ca5b1b68279c47be3efab31efdc")); 55 | list.add(new TopicDomain("hello,4", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fi2.w.yun.hjfile" + 56 | ".cn%2Fdoc%2F201303%2Fd5547c74-d9ad-4625-bd93-41c2817f1dff_03.jpg&refer=http%3A%2F%2Fi2.w.yun.hjfile" + 57 | ".cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 58 | "=b3454729f39611ac36cde849c02c2a7a")); 59 | list.add(new TopicDomain("hello,5", "https://ss0.baidu.com/7Po3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item" + 60 | "/9c16fdfaaf51f3de9ba8ee1194eef01f3a2979a8.jpg")); 61 | list.add(new TopicDomain("hello,6", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa1.att.hudong" + 62 | ".com%2F81%2F71%2F01300000164151121808718718556.jpg&refer=http%3A%2F%2Fa1.att.hudong" + 63 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 64 | "=de1cc282c8911a5c5fc2ffb9523bca16")); 65 | list.add(new TopicDomain("hello,7", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 66 | ".com%2F61%2F98%2F01300000248068123885985729957.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 67 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 68 | "=50a9dc20e962e5b8464c6cc3525e6e20")); 69 | list.add(new TopicDomain("hello,8", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.aiimg" + 70 | ".com%2Fuploads%2Fuserup%2F0909%2F2Z64022L38.jpg&refer=http%3A%2F%2Fimg.aiimg" + 71 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 72 | "=e56a3b4c167d619173aaa77a1b33cf48")); 73 | list.add(new TopicDomain("hello,9", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa4.att.hudong" + 74 | ".com%2F63%2F70%2F06300000046969120433706514748.jpg&refer=http%3A%2F%2Fa4.att.hudong" + 75 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 76 | "=4bdcf09101945fd4f78fdf943dc886dc")); 77 | list.add(new TopicDomain("hello,10", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 78 | ".com%2F02%2F38%2F01300000237560123245382609951.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 79 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 80 | "=13dec1ea4bae058c49ec0f28281445f9")); 81 | list.add(new TopicDomain("hello,11", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong" + 82 | ".com%2F42%2F31%2F01300001320894132989315766618.jpg&refer=http%3A%2F%2Fa2.att.hudong" + 83 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 84 | "=96a6896fae35450377ec81ea19a09a1f")); 85 | list.add(new TopicDomain("hello,12", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic25.nipic" + 86 | ".com%2F20121107%2F8847866_164210379199_2.jpg&refer=http%3A%2F%2Fpic25.nipic.com&app=2002&size=f9999," + 87 | "10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t=b535ad3cac3cfaf5ebcab0cb4c987dd7")); 88 | list.add(new TopicDomain("hello,13", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic16.nipic" + 89 | ".com%2F20110928%2F5200151_002314030000_2.jpg&refer=http%3A%2F%2Fpic16.nipic.com&app=2002&size=f9999," + 90 | "10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t=e37c1cca646f0ccc773ade0fbe007b29")); 91 | list.add(new TopicDomain("hello,14", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa4.att.hudong" + 92 | ".com%2F43%2F83%2F01300000241358124822839175242.jpg&refer=http%3A%2F%2Fa4.att.hudong" + 93 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 94 | "=18a0ca4b0c1efd6a1bd5cb9760128060")); 95 | list.add(new TopicDomain("hello,15", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa0.att.hudong" + 96 | ".com%2F65%2F07%2F01300000204202121839075492554.jpg&refer=http%3A%2F%2Fa0.att.hudong" + 97 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 98 | "=cd1f8cc3f7114cd2a5453a6d34cb83e5")); 99 | list.add(new TopicDomain("hello,16", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong" + 100 | ".com%2F14%2F68%2F19300001338674131496682910142.jpg&refer=http%3A%2F%2Fa2.att.hudong" + 101 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 102 | "=7d2fffd5d8565abd0ec6653681047631")); 103 | list.add(new TopicDomain("hello,17", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong" + 104 | ".com%2F06%2F02%2F19300534106437134465026151672.jpg&refer=http%3A%2F%2Fa2.att.hudong" + 105 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 106 | "=c44578bae5bc4cdb90453804ad07f25f")); 107 | list.add(new TopicDomain("hello,18", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong" + 108 | ".com%2F50%2F71%2F01300000240273131339713219664.jpg&refer=http%3A%2F%2Fa2.att.hudong" + 109 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 110 | "=5a3e158a0210c9eb5a47d0901b46bede")); 111 | list.add(new TopicDomain("hello,19", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 112 | ".com%2F45%2F36%2F14300000491308128107360639165.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 113 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 114 | "=628a23b650920999e2f4c5987d1362a9")); 115 | list.add(new TopicDomain("hello,20", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 116 | ".com%2F13%2F41%2F01300000201800122190411861466.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 117 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 118 | "=b90979078e62ebf9b549d19e726e18f0")); 119 | list.add(new TopicDomain("hello,21", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa4.att.hudong" + 120 | ".com%2F25%2F10%2F01300473586198134027108433788.jpg&refer=http%3A%2F%2Fa4.att.hudong" + 121 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 122 | "=42ba823236600a0f3b38fa049eb1048f")); 123 | list.add(new TopicDomain("hello,22", "https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item" + 124 | "/42166d224f4a20a4b44741a690529822720ed072.jpg")); 125 | list.add(new TopicDomain("hello,23", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbbs.jooyoo" + 126 | ".net%2Fattachment%2FMon_0910%2F24_293205_2d4adfacccd3031.jpg&refer=http%3A%2F%2Fbbs.jooyoo" + 127 | ".net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 128 | "=a9a3fd7321f526fce2efbc3f9ca12691")); 129 | list.add(new TopicDomain("hello,24", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa1.att.hudong" + 130 | ".com%2F57%2F92%2F01300542193590138063924441627.jpg&refer=http%3A%2F%2Fa1.att.hudong" + 131 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 132 | "=e70284b49966a7ed68dd66dc61f2265b")); 133 | list.add(new TopicDomain("hello,25", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa4.att.hudong" + 134 | ".com%2F20%2F39%2F01300542519189139990390839214.jpg&refer=http%3A%2F%2Fa4.att.hudong" + 135 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 136 | "=8872f9316d250b09c62bdaac4b0f39fd")); 137 | list.add(new TopicDomain("hello,26", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 138 | ".com%2F08%2F22%2F01300000013945118822221353308.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 139 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 140 | "=c342b96383bf760f3850c6aab89ae44c")); 141 | list.add(new TopicDomain("hello,27", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong" + 142 | ".com%2F12%2F87%2F01300001149956130041875096065.jpg&refer=http%3A%2F%2Fa2.att.hudong" + 143 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 144 | "=1c2d14c12c3fdbb784cfc4faedcbd21b")); 145 | list.add(new TopicDomain("hello,28", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 146 | ".com%2F92%2F04%2F01000000000000119090475560392.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 147 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 148 | "=de7a697e58b7d9973f53641042b24633")); 149 | list.add(new TopicDomain("hello,29", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa2.att.hudong" + 150 | ".com%2F11%2F48%2F01300000195282124296481807051.jpg&refer=http%3A%2F%2Fa2.att.hudong" + 151 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819582&t" + 152 | "=7cfffaaed1cb61482d00de24ac3caa41")); 153 | list.add(new TopicDomain("hello,30", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong" + 154 | ".com%2F03%2F88%2F01300000400534127693880874175.jpg&refer=http%3A%2F%2Fa3.att.hudong" + 155 | ".com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614819998&t" + 156 | "=697fb067f33484da214a584bf9d4cf48")); 157 | 158 | return list; 159 | } 160 | 161 | @Override 162 | public void onActive() { 163 | super.onActive(); 164 | } 165 | 166 | @Override 167 | public void onForeground(Intent intent) { 168 | super.onForeground(intent); 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/slice/LocalAbilitySlice.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.slice; 2 | 3 | import com.isotne.glidelibrary.utils.OhosGlide; 4 | import com.istone.myapplication.ResourceTable; 5 | import ohos.aafwk.ability.AbilitySlice; 6 | import ohos.aafwk.content.Intent; 7 | import ohos.agp.components.Image; 8 | import ohos.app.Environment; 9 | 10 | import java.io.File; 11 | import java.io.FileInputStream; 12 | import java.io.FileNotFoundException; 13 | import java.io.InputStream; 14 | import java.io.IOException; 15 | 16 | 17 | /** 18 | * description localslice 19 | * @author baihe 20 | * created 2021/2/8 14:52 21 | */ 22 | public class LocalAbilitySlice extends AbilitySlice { 23 | @Override 24 | public void onStart(Intent intent) { 25 | super.onStart(intent); 26 | super.setUIContent(ResourceTable.Layout_ability_local); 27 | Image image = (Image) findComponentById(ResourceTable.Id_local_image); 28 | File file = new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath(), "test.png"); 29 | InputStream inputStream = null; 30 | try { 31 | inputStream = new FileInputStream(file); 32 | } catch (FileNotFoundException e) { 33 | e.printStackTrace(); 34 | } 35 | try { 36 | OhosGlide.with(this).load(inputStream).def(ResourceTable.Media_B).into(image); 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | } 40 | } 41 | 42 | 43 | @Override 44 | public void onActive() { 45 | super.onActive(); 46 | } 47 | 48 | @Override 49 | public void onForeground(Intent intent) { 50 | super.onForeground(intent); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/slice/MainAbilitySlice.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.slice; 2 | 3 | import com.istone.myapplication.ResourceTable; 4 | import ohos.aafwk.ability.AbilitySlice; 5 | import ohos.aafwk.content.Intent; 6 | import ohos.agp.components.Button; 7 | 8 | 9 | /** 10 | * description mainslice 11 | * 12 | * @author baihe 13 | * created 2021/2/8 14:52 14 | */ 15 | public class MainAbilitySlice extends AbilitySlice { 16 | @Override 17 | public void onStart(Intent intent) { 18 | super.onStart(intent); 19 | super.setUIContent(ResourceTable.Layout_ability_main); 20 | requestPermissionsFromUser( 21 | new String[]{"ohos.permission.READ_MEDIA", "ohos.permission.WRITE_MEDIA", "ohos.permission" + 22 | ".READ_USER_STORAGE", "ohos.permission.WRITE_USER_STORAGE",}, 0); 23 | 24 | Button button1 = (Button) findComponentById(ResourceTable.Id_change_local_button); 25 | button1.setClickedListener(component -> { 26 | Intent intent2 = new Intent(); 27 | present(new ResourcesChangeAbilitySlice(), new Intent()); 28 | }); 29 | 30 | Button button2 = (Button) findComponentById(ResourceTable.Id_show_server_button); 31 | button2.setClickedListener(component -> { 32 | 33 | present(new ServerAbilitySlice(), new Intent()); 34 | }); 35 | 36 | Button button3 = (Button) findComponentById(ResourceTable.Id_show_local_button); 37 | button3.setClickedListener(component -> { 38 | present(new LocalAbilitySlice(), new Intent()); 39 | }); 40 | 41 | Button button4 = (Button) findComponentById(ResourceTable.Id_show_gif_button); 42 | button4.setClickedListener(component -> { 43 | present(new GifAbilitySlice(), new Intent()); 44 | }); 45 | 46 | Button button5 = (Button) findComponentById(ResourceTable.Id_disk_cache_button); 47 | button5.setClickedListener(component -> { 48 | present(new ListAbilitySlice(), new Intent()); 49 | }); 50 | } 51 | 52 | @Override 53 | public void onActive() { 54 | super.onActive(); 55 | } 56 | 57 | @Override 58 | public void onForeground(Intent intent) { 59 | super.onForeground(intent); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/slice/ResourcesChangeAbilitySlice.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.slice; 2 | 3 | import com.istone.myapplication.ResourceTable; 4 | import ohos.aafwk.ability.AbilitySlice; 5 | import ohos.aafwk.content.Intent; 6 | import ohos.agp.components.Button; 7 | import ohos.agp.components.Image; 8 | 9 | /** 10 | * description resourcesslice 11 | * @author baihe 12 | * created 2021/2/8 14:52 13 | */ 14 | public class ResourcesChangeAbilitySlice extends AbilitySlice { 15 | /** 16 | * istrue 17 | */ 18 | private boolean isTrue = true; 19 | 20 | @Override 21 | public void onStart(Intent intent) { 22 | super.onStart(intent); 23 | super.setUIContent(ResourceTable.Layout_ability_resources_change); 24 | Image image = (Image) findComponentById(ResourceTable.Id_resources_change_image); 25 | Button button = (Button) findComponentById(ResourceTable.Id_resources_change_button); 26 | button.setClickedListener(component -> { 27 | image.setPixelMap(isTrue ? ResourceTable.Media_A : ResourceTable.Media_B); 28 | isTrue = !isTrue; 29 | }); 30 | } 31 | 32 | @Override 33 | public void onActive() { 34 | super.onActive(); 35 | } 36 | 37 | @Override 38 | public void onForeground(Intent intent) { 39 | super.onForeground(intent); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/slice/ServerAbilitySlice.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.slice; 2 | 3 | import com.isotne.glidelibrary.utils.OhosGlide; 4 | import com.istone.myapplication.ResourceTable; 5 | import ohos.aafwk.ability.AbilitySlice; 6 | import ohos.aafwk.content.Intent; 7 | import ohos.agp.components.Image; 8 | 9 | import java.io.IOException; 10 | 11 | /** 12 | * description serverslice 13 | * @author baihe 14 | * created 2021/2/8 14:52 15 | */ 16 | public class ServerAbilitySlice extends AbilitySlice { 17 | @Override 18 | public void onStart(Intent intent) { 19 | super.onStart(intent); 20 | super.setUIContent(ResourceTable.Layout_ability_server); 21 | Image image = (Image) findComponentById(ResourceTable.Id_server_image); 22 | try { 23 | OhosGlide.with(this).load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.wallcoo" + 24 | ".com%2Fnature%2Fda_ps_landscape_01%2Fwallpapers%2F1280x1024%2F%5Bwallcoo_com%5D_1" + 25 | ".jpg&refer=http%3A%2F%2Fwww.wallcoo.com&app=2002&size=f9999," + 26 | "10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614218186&t=37efae92a69da2fe7685a2813ad36b50").def(ResourceTable.Media_A).into(image); 27 | } catch (IOException e) { 28 | e.printStackTrace(); 29 | } 30 | } 31 | 32 | @Override 33 | public void onActive() { 34 | super.onActive(); 35 | } 36 | 37 | @Override 38 | public void onForeground(Intent intent) { 39 | super.onForeground(intent); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /entry/src/main/java/com/istone/myapplication/utils/LogUtils.java: -------------------------------------------------------------------------------- 1 | package com.istone.myapplication.utils; 2 | 3 | import ohos.hiviewdfx.HiLog; 4 | import ohos.hiviewdfx.HiLogLabel; 5 | 6 | /** 7 | * description logutil 8 | * 9 | * @author baihe 10 | * created 2021/2/8 14:52 11 | */ 12 | public class LogUtils { 13 | /** 14 | * info 15 | */ 16 | public static final int INFO = 0; 17 | /** 18 | * error 19 | */ 20 | public static final int ERROR = 1; 21 | /** 22 | * debug 23 | */ 24 | public static final int DEBUG = 2; 25 | /** 26 | * warning 27 | */ 28 | public static final int WARN = 3; 29 | 30 | /** 31 | * @param logType LogUtils.INFO || LogUtils.ERROR || LogUtils.DEBUG|| LogUtils.WARN 32 | * @param tag 日志标识 根据喜好,自定义 33 | * @param message 需要打印的日志信息 34 | */ 35 | public static void log(int logType, String tag, String message) { 36 | HiLogLabel lable = new HiLogLabel(HiLog.LOG_APP, 0x0, tag); 37 | switch (logType) { 38 | case INFO: 39 | HiLog.info(lable, message); 40 | break; 41 | case ERROR: 42 | HiLog.error(lable, message); 43 | break; 44 | case DEBUG: 45 | HiLog.debug(lable, message); 46 | break; 47 | case WARN: 48 | HiLog.warn(lable, message); 49 | break; 50 | default: 51 | break; 52 | 53 | } 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "app_name", 5 | "value": "MyApplication" 6 | }, 7 | { 8 | "name": "mainability_description", 9 | "value": "Java_Phone_Empty Feature Ability" 10 | }, 11 | { 12 | "name": "otherability_descrition", 13 | "value": "otherability_descrition" 14 | }, 15 | { 16 | "name": "main_button_text", 17 | "value": "Switch Images" 18 | }, 19 | { 20 | "name": "main_button_text2", 21 | "value": "Show Server Image" 22 | }, 23 | { 24 | "name": "secondability_description", 25 | "value": "Java_Phone_Empty Feature Ability" 26 | }, 27 | { 28 | "name": "main_button_text3", 29 | "value": "Show Local Image" 30 | }, 31 | { 32 | "name": "resourceschangeability_description", 33 | "value": "hap sample empty provider" 34 | }, 35 | { 36 | "name": "resourceschangeability_description", 37 | "value": "Java_Phone_Empty Feature Ability" 38 | }, 39 | { 40 | "name": "serverability_description", 41 | "value": "Java_Phone_Empty Feature Ability" 42 | }, 43 | { 44 | "name": "localability_description", 45 | "value": "Java_Phone_Empty Feature Ability" 46 | }, 47 | { 48 | "name": "gifability_description", 49 | "value": "Java_Phone_Empty Feature Ability" 50 | }, 51 | { 52 | "name": "listability_description", 53 | "value": "Java_Phone_Empty Feature Ability" 54 | } 55 | ] 56 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/graphic/background_ability_gif.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/graphic/background_ability_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/graphic/background_ability_local.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/graphic/background_ability_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/graphic/background_ability_resources_change.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/graphic/background_ability_second.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/graphic/background_ability_server.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/layout/ability_gif.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/layout/ability_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/layout/ability_local.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/layout/ability_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |