/*
* Copyright 2015 jack wang
* Copyright 2021 Institute of Software Chinese Academy of Sciences, ISRC
* 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.
*/
package com.huawei.mytestproject.slice;
import com.wang.avi.AVLoadingIndicatorView;
import com.wang.avi.indicators.*;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.*;
import ohos.agp.components.DirectionalLayout.LayoutConfig;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.TextAlignment;
import ohos.bundle.AbilityInfo;
import java.util.ArrayList;
public class MainAbilitySlice extends AbilitySlice {
private DependentLayout myLayout = new DependentLayout(this);
private ArrayList<AVLoadingIndicatorView> animatorList=new ArrayList<>();
@Override
public void onStart(Intent intent) {
super.onStart(intent);
setDisplayOrientation(AbilityInfo.DisplayOrientation.PORTRAIT);
LayoutConfig config = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_PARENT);
myLayout.setLayoutConfig(config);
ShapeElement element = new ShapeElement();
element.setRgbColor(new RgbColor(231,87,100));
myLayout.setBackground(element);
ShapeElement commonElement = new ShapeElement();
commonElement.setRgbColor(new RgbColor(231,87,100));
//first row
LayoutConfig ballPulseIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
BallPulseIndicator ballPulseIndicator=new BallPulseIndicator(this);
ballPulseIndicator.setLayoutConfig(ballPulseIndicatorConfig);
ballPulseIndicator.setHeight(250);
ballPulseIndicator.setWidth(250);
ballPulseIndicator.setBackground(commonElement);
myLayout.addComponent(ballPulseIndicator);
animatorList.add(ballPulseIndicator);
LayoutConfig ballGridPulseIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
ballGridPulseIndicatorConfig.setMargins(250,0,0,0);
BallGridPulseIndicator ballGridPulseIndicator=new BallGridPulseIndicator(this);
ballGridPulseIndicator.setLayoutConfig(ballGridPulseIndicatorConfig);
ballGridPulseIndicator.setHeight(250);
ballGridPulseIndicator.setWidth(250);
ballGridPulseIndicator.setBackground(commonElement);
myLayout.addComponent(ballGridPulseIndicator);
animatorList.add(ballGridPulseIndicator);
LayoutConfig BallClipRotateIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
BallClipRotateIndicatorConfig.setMargins(500,0,0,0);
BallClipRotateIndicator ballClipRotateIndicator=new BallClipRotateIndicator(this);
ballClipRotateIndicator.setLayoutConfig(BallClipRotateIndicatorConfig);
ballClipRotateIndicator.setHeight(250);
ballClipRotateIndicator.setWidth(250);
ballClipRotateIndicator.setBackground(commonElement);
myLayout.addComponent(ballClipRotateIndicator);
animatorList.add(ballClipRotateIndicator);
LayoutConfig BallClipRotatePulseIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
BallClipRotatePulseIndicatorConfig.setMargins(750,0,0,0);
BallClipRotatePulseIndicator ballClipRotatePulseIndicator=new BallClipRotatePulseIndicator(this);
ballClipRotatePulseIndicator.setLayoutConfig(BallClipRotatePulseIndicatorConfig);
ballClipRotatePulseIndicator.setHeight(250);
ballClipRotatePulseIndicator.setWidth(250);
ballClipRotatePulseIndicator.setBackground(commonElement);
myLayout.addComponent(ballClipRotatePulseIndicator);
animatorList.add(ballClipRotatePulseIndicator);
//two row
LayoutConfig pacmanIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
pacmanIndicatorConfig.setMargins(0,250,0,0);
PacmanIndicator pacmanIndicator=new PacmanIndicator(this);
pacmanIndicator.setLayoutConfig(pacmanIndicatorConfig);
pacmanIndicator.setHeight(250);
pacmanIndicator.setWidth(250);
pacmanIndicator.setBackground(commonElement);
myLayout.addComponent(pacmanIndicator);
animatorList.add(pacmanIndicator);
LayoutConfig BallClipRotateMultipleIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
BallClipRotateMultipleIndicatorConfig.setMargins(250,250,0,0);
BallClipRotateMultipleIndicator ballClipRotateMultipleIndicator=new BallClipRotateMultipleIndicator(this);
ballClipRotateMultipleIndicator.setLayoutConfig(BallClipRotateMultipleIndicatorConfig);
ballClipRotateMultipleIndicator.setHeight(250);
ballClipRotateMultipleIndicator.setWidth(250);
ballClipRotateMultipleIndicator.setBackground(commonElement);
myLayout.addComponent(ballClipRotateMultipleIndicator);
animatorList.add(ballClipRotateMultipleIndicator);
LayoutConfig semiCircleSpinIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
semiCircleSpinIndicatorConfig.setMargins(500,250,0,0);
SemiCircleSpinIndicator semiCircleSpinIndicator=new SemiCircleSpinIndicator(this);
semiCircleSpinIndicator.setLayoutConfig(semiCircleSpinIndicatorConfig);
semiCircleSpinIndicator.setHeight(250);
semiCircleSpinIndicator.setWidth(250);
semiCircleSpinIndicator.setBackground(commonElement);
myLayout.addComponent(semiCircleSpinIndicator);
animatorList.add(semiCircleSpinIndicator);
LayoutConfig ballRotateIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
ballRotateIndicatorConfig.setMargins(750,250,0,0);
BallRotateIndicator ballRotateIndicator=new BallRotateIndicator(this);
ballRotateIndicator.setLayoutConfig(ballRotateIndicatorConfig);
ballRotateIndicator.setHeight(250);
ballRotateIndicator.setWidth(250);
ballRotateIndicator.setBackground(commonElement);
myLayout.addComponent(ballRotateIndicator);
animatorList.add(ballRotateIndicator);
//three row
LayoutConfig ballScaleIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
ballScaleIndicatorConfig.setMargins(0,500,0,0);
BallScaleIndicator ballScaleIndicator=new BallScaleIndicator(this);
ballScaleIndicator.setLayoutConfig(ballScaleIndicatorConfig);
ballScaleIndicator.setHeight(250);
ballScaleIndicator.setWidth(250);
ballScaleIndicator.setBackground(commonElement);
myLayout.addComponent(ballScaleIndicator);
animatorList.add(ballScaleIndicator);
LayoutConfig lineScaleIndicatorConfig = new LayoutConfig(LayoutConfig.MATCH_CONTENT, LayoutConfig.MATCH_CONTENT);
lineScaleIndicatorConfig.setMargins(250,500,0,0);
LineScaleIndicator lineScaleIndicator=new LineScaleIndicator(this);
lineScaleIndicator.setLayoutConfig(lineScaleIndicatorConfig);
lineScaleIndicator.setHeight(250);
lineScaleIndicator.setWidth(250);
lineScaleIndicator.setBackground(commonElement);
myLayout.addComponent(lineScaleIndicator);
animatorList.add(lineScaleIndicator);