鸿蒙开源组件——绑定ability和fraction页面切换的三方库

jacksky
发布于 2021-12-3 17:09
浏览
0收藏

Alligator

项目介绍

  • 项目名称:Alligator
  • 所属系列:openharmony的第三方组件适配移植
  • 功能:通过注解处理器实现一套绑定ability和fraction页面切换的三方库
  • 项目移植状态:主功能完成
  • 调用差异:无
  • 开发版本:sdk6,DevEco Studio2.2 beta1
  • 基线版本:Release 4.1.0

效果演示

鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区 鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区 鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区
鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区 鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区 鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区
鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区 鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区 鸿蒙开源组件——绑定ability和fraction页面切换的三方库-鸿蒙开发者社区

安装教程

1.在项目根目录下的build.gradle文件中,

allprojects {
    repositories {
        maven {
            url 'https://s01.oss.sonatype.org/content/repositories/releases/'
        }
    }
}

2.在entry模块的build.gradle文件中,

 dependencies {
    implementation('com.gitee.chinasoft_ohos:alligator:4.1.1')
    annotationProcessor('com.gitee.chinasoft_ohos:alligator:4.1.1')
    implementation('com.gitee.chinasoft_ohos:alligator-compiler:4.1.1')
    annotationProcessor('com.gitee.chinasoft_ohos:alligator-compiler:4.1.1')
    ......  
 }

在sdk6,DevEco Studio2.2 beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下

使用说明

一.将仓库导入到本地仓库中

  参照安装教程

二.使用方式

1.绑定Fraction切片

创建Fraction切片页面,并在getContainerId()

public class TabFraction extends MiFraction {
 
    @Override
    protected Component onComponentAttached(LayoutScatter scatter, ComponentContainer container, Intent intent) {
        return component;
    }
    @Override
    public void setInitialFragmentIfRequired() {
    }
}

创建切片页面绑定的的screen,继承自Screen类并实现序列化

public class TabScreen extends Screen implements Serializable {
    private String mName;

    public TabScreen(String name, int mContainerId, String group) {
        super(mContainerId, group);
        this.mName = name;
    }

    public String getmName() {
        return mName;
    }
}

使用注解将TabScreen与TabFraction进行绑定

@RegisterScreen(TabScreen.class)
public class TabFraction extends MiFraction {
    ......
}
2.绑定Ability功能页面

继承Screen类

public class MainScreen extends Screen {
    public MainScreen(int mContainerId, String group) {
        super(mContainerId, group);
    }
}
3.Fraction页面间的跳转

在AbilityPackage中初始化配置参数

public class SampleApplication extends AbilityPackage {
private static OhosNavigator sOhosNavigator;
     @Override
    public void onInitialize() {
        super.onInitialize();
        sOhosNavigator = new OhosNavigator(new GeneratedNavigationFactory());
    }
     public static Navigator getNavigator() {
        return sOhosNavigator;
    }
}

页面跳转方式:

 private Navigator mNavigator = SampleApplication.getNavigator();
 mNavigator.goForward();//跳转新页面
 mNavigator.replace();//替换当前页面
 mNavigator.reset();//重置当前栈
 mNavigator.goBack();//回退
 mNavigator.finishTopLevel();//关闭所有

测试信息

CodeCheck代码测试无异常

CloudTest代码测试无异常

病毒安全检测通过

当前版本demo功能与原组件基本无差异

版本迭代

  • 4.1.1
  • 0.0.1-SNAPSHOT

版权和许可信息

The MIT License (MIT)

Copyright (c) 2017 Artur Artikov

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.

Alligator-master.zip 4.64M 12次下载
已于2021-12-3 17:09:08修改
收藏
回复
举报
回复
    相关推荐