/MultiStateView

Universal State Switch View (maintenance stopped).

Primary LanguageJavaApache License 2.0Apache-2.0

.github/workflows/main.yml Quality Gate Status

MultiStateView

A HMOS library which provide MultiStateView feature.

Source

Inspired by XuDaojie/MultiStateView

Feature

This library provides different switching states of View, included by default are Content, Empty, Fail, Loading states.

Dependency

  1. For using multistateview module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
	dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
        implementation project(path: ':multistateview')
        testImplementation 'junit:junit:4.13'
        ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
        }
  1. For using multistateview in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
	dependencies {
		implementation fileTree(dir: 'libs', include: ['*.har'])
		testImplementation 'junit:junit:4.13'
	}
  1. For using multistateview from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
    dependencies {
    implementation ('dev.applibgroup:multistateview:1.0.0')
    testCompile 'junit:junit:4.13'
}

Usage

Include following code in your layout

<?xml version="1.0" encoding="utf-8"?>
<me.xdj.view.SimpleMultiStateView
    xmlns:ohos="http://schemas.huawei.com/res/ohos"
    xmlns:app="http://schemas.huawei.com/apk/res-auto"
    ohos:id="$+id:multi_state_view"
    ohos:width="match_parent"
    ohos:height="match_parent"
    ohos:alignment="center"
    ohos:text_size="50vp"
    app:msv_emptyView="$layout:msv_view_state_empty"
    app:msv_failView="$layout:msv_view_state_fail"
    app:msv_loadingView="$layout:msv_view_state_loading">
    <DirectionalLayout
        ohos:height="match_parent"
        ohos:width="match_parent"
        ohos:alignment="vertical_center"
        ohos:orientation="vertical">
    </DirectionalLayout>
</me.xdj.view.SimpleMultiStateView>

Include following code in your activity

public void setViewState(int state); // Set the view state 
public int getViewState();           // Get the current state 
public View getView(int state);      // Get the view of the specified state 
public void addViewForStatus(int status, int resLayoutID); // Increase the state 
public void setOnInflaterListener(OnInflateListener onInflateListener); // Triggered when each state is Layout inflate (except CONTENT)

License

Copyright XuDaojie

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.