# Fragmentation **Repository Path**: HarmonyOS-tpc/Fragmentation ## Basic Information - **Project Name**: Fragmentation - **Description**: Fragmentation is a powerful library managing Fraction for openharmony. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 0 - **Created**: 2021-04-01 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: harmonyos-advanced **Tags**: None ## README ## Fragmentation ![](/gif/logo.png) ## Introduction Fragmentation is a powerful library managing Fraction for openharmony. It is designed for "Single Ability + Multi-Fractions" architecture to simplify development process. ### Feature **1. Develop Standard fraction app rapidly** **2. Use fraction's stack view dialog to debug easily** **3. Add launch mode, startForResult etc. to provide similar behavior of Ability** **4. Add onBackPressedSupport() method to support back button press monitoring in Fraction** **5. To simplify the communication between Fraction([EventBusActivityScope module]** ## Usage Instructions **1. Ability `extends` SupportAbility or `implements` ISupportAbility:(refer to [MySupportAbility](https://gitee.com/openharmony-tpc/Fragmentation/blob/master/entry/src/main/java/me/yokeyword/sample/demo_flow/base/MySupportAbility.java))** ````java // since v1.0.0, forced extends of SupportAbility is not required, you can use interface + delegate to implement your own SupportAbility public class MainAbility extends MySupportAbility { @Override protected void onStart(Intent intent) { super.onStart(intent); setUIContent(ResourceTable.Layout_ability_main); MySupportFraction fraction = findFraction(HomeFraction.class); if (fraction == null) { loadRootFraction(ResourceTable.Id_fl_container, HomeFraction.newInstance()); } EventBusAbilityScope.getDefault(this).register(this); (new DebugStackDelegate(this)).onPostCreate(this, ResourceTable.Id_fl_container2); } ```` **2. Fraction `extends` SupportFraction or `implements` ISupportFraction:(refer to [MySupportFraction](https://gitee.com/openharmony-tpc/Fragmentation/blob/master/entry/src/main/java/me/yokeyword/sample/demo_flow/base/MySupportFraction.java)):** ````java // since v1.0.0, forced extends of SupportFraction is not required, you can use interface + delegate to implement your own SupportFraction public class HomeFraction extends SupportFraction { private void xxx() { // launch a new Fraction, other methods: start(fraction,LAUNCH_SINGLETASK)、startForResult、startWithPop etc.         start(DetailFraction.newInstance());     } } ```` ## 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:eventbus_activity_scope:1.0.0" implementation "io.openharmony.tpc.thirdlib:fragmentation_core:1.0.0" implementation "io.openharmony.tpc.thirdlib:fragmentation:1.0.0" ``` ## LICENSE ```` 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. ````