All Projects → jakubkinst → Android Statefullayout

jakubkinst / Android Statefullayout

A custom Android ViewGroup to display different states of screen (CONTENT, PROGRESS, OFFLINE, EMPTY, etc.)

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Statefullayout

Arclayout
With Arc Layout explore new styles and approaches on material design
Stars: ✭ 1,662 (+1087.14%)
Mutual labels:  view, layout
Mylinearlayout
MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITab…
Stars: ✭ 4,152 (+2865.71%)
Mutual labels:  view, layout
Stevia
🍃 Concise Autolayout code
Stars: ✭ 3,182 (+2172.86%)
Mutual labels:  view, layout
FastBanner
🔥快速轮播图,支持自定义布局和使用自有图片显示组件
Stars: ✭ 27 (-80.71%)
Mutual labels:  view, layout
Readablebottombar
Yet another material bottom bar library for Android
Stars: ✭ 977 (+597.86%)
Mutual labels:  view, layout
Shapeofview
Give a custom shape to any android view, Material Design 2 ready
Stars: ✭ 2,977 (+2026.43%)
Mutual labels:  view, layout
Bouncylayout
Make. It. Bounce.
Stars: ✭ 4,035 (+2782.14%)
Mutual labels:  view, layout
FillProgressLayout
A simple and flexible Fillable Progress Layout written in Kotlin
Stars: ✭ 77 (-45%)
Mutual labels:  view, layout
Androidlibs
🔥正在成为史上最全分类 Android 开源大全~~~~(长期更新 Star 一下吧)
Stars: ✭ 7,148 (+5005.71%)
Mutual labels:  view, layout
Physicslayout
Android layout that simulates physics using JBox2D
Stars: ✭ 658 (+370%)
Mutual labels:  view, layout
bubble-layout
An Android ViewGroup that displays avatar bubbles... similar to the chat bubbles on Facebook Messenger.
Stars: ✭ 46 (-67.14%)
Mutual labels:  view, layout
Kvconstraintkit
An Impressive Auto Layout DSL for iOS, tvOS & OSX. & It is written in pure swift.
Stars: ✭ 91 (-35%)
Mutual labels:  view, layout
PageStatusTransformer
A low invasive state management on Android
Stars: ✭ 12 (-91.43%)
Mutual labels:  layout, state
Stacks
⚡ Build React Native views blazingly fast.
Stars: ✭ 281 (+100.71%)
Mutual labels:  view, layout
table-layout
Styleable plain-text table generator. Useful for formatting console output.
Stars: ✭ 18 (-87.14%)
Mutual labels:  view, layout
Scalinglayout
With Scaling Layout scale your layout on user interaction.
Stars: ✭ 3,276 (+2240%)
Mutual labels:  view, layout
pulldownlayout
PullDownLayout is a small library that allows you to implement a view that can be dragged down your layout. PullDownLayout can also be used to implement Pull-To-Dismiss feature for your activities and fragments.
Stars: ✭ 16 (-88.57%)
Mutual labels:  view, layout
ShadowDrawable
为View 和 ViewGroup 添加阴影效果--Android,Add shadow for single view or viewgroup layout.
Stars: ✭ 22 (-84.29%)
Mutual labels:  view, layout
Longshadow
Add a long shadow on any Android View
Stars: ✭ 562 (+301.43%)
Mutual labels:  view, layout
Kotlinanim
Create fluent animations in a kotlin way
Stars: ✭ 72 (-48.57%)
Mutual labels:  view, layout

Android StatefulLayout 2

alt text

StatefulLayout

implementation 'cz.kinst.jakub:android-stateful-layout-base:2.0.7'

This is a base class you should use if you want to have completely custom set of states/views. You can either inherit and add custom states in constructor (see SimpleStatefulLayout as an example) or you can use directly StatefulLayout and add states dynamically in your code via setStateView(). Raw StatefulLayout contains only one state - StatefulLayout.State.CONTENT with whatever child is inside the XML content of the tag.

Example

<cz.kinst.jakub.view.StatefulLayout
	android:id="@+id/stateful_layout"
	android:layout_width="match_parent"
	android:layout_height="match_parent">
	
	<!--Your Content Here-->
		
</cz.kinst.jakub.view.StatefulLayout>
// in onCreate()
statefulLayout.setStateView(STATE_NO_PERSMISSION, LayoutInflater.from(this).inflate(R.layout.state_no_permission, null));
statefulLayout.setStateView(STATE_PROGRESS, LayoutInflater.from(this).inflate(R.layout.state_progress, null));

API

  • setStateView(String state, View view) Adds a new state and with a corresponding View
  • setState(String state) Changes current state
  • getState() Returns current view state (String ID)
  • setOnStateChangeListener(OnStateChangeListener listener) Sets a listener on state change event
  • setStateController(StateController stateController) Sets a state controller object. See below.

StateController

If you don't want to directly manipulate with the view (MVVM/MVP scenario) you can create an instance of StateController and bind it to StatefulLayout (e.g. using Data Binding). StateController allows you to setup different states as well as control current state itself. See example below or DataBindingControllerActivity in sample project.

<cz.kinst.jakub.view.StatefulLayout
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	app:stateController="@{viewModel.stateController}">
</cz.kinst.jakub.view.StatefulLayout>
stateController = StatefulLayout.StateController.create()
				.withState(STATE_NO_PERSMISSION, LayoutInflater.from(this).inflate(R.layout.state_no_permission, null))
				.withState(STATE_PROGRESS, LayoutInflater.from(this).inflate(R.layout.state_progress, null))
				.build();

//...

stateController.setState(STATE_PROGRESS);

SimpleStatefulLayout

implementation 'cz.kinst.jakub:android-stateful-layout-simple:2.0.7'

SimpleStatefulLayout extends StatefulLayout and adds couple of useful states for most apps - State.OFFLINE, State.PROGRESS, State.EMPTY. It provides customizable layout placeholder for these states as well as a way to provide completely custom layouts for the states.

You can also customize this by extending the class or adddd states by using setStateView().

Example

<cz.kinst.jakub.view.SimpleStatefulLayout
	android:id="@+id/stateful_view"
	android:layout_width="match_parent"
	android:layout_height="match_parent">
	
	<!--Your Content Here-->
		
</cz.kinst.jakub.view.SimpleStatefulLayout>
// in onCreate()
statefulLayout.showProgress();
// load data
statefulLayout.showContent();

Optional Attributes

  • app:offlineText Custom text to show when in OFFLINE state
  • app:offlineRetryText Text for a retry button in OFFLINE state
  • app:emptyText Custom text to show when in OFFLINE state
  • app:offlineImageDrawable Custom image to show above the offline state text (if not using custom layout)
  • app:emptyImageDrawable Custom image to show above the empty state text (if not using custom layout)
  • app:offlineLayout Custom layout to show when in OFFLINE state
  • app:emptyLayout Custom layout to show when in EMPTY state
  • app:progressLayout Custom layout to show when in PROGRESS state
  • app:state Initial state of the view (content, progress, offline, empty)
  • app:stateTextAppearance When not using custom layouts, this is the way to style the TextViews in OFFLINE and EMPTY states.

API

  • showContent()
  • showProgress()
  • showEmpty()
  • showOffline()
  • setEmptyText(String text) If using default layouts, this will set the text displayed in the EMPTY state
  • setOfflineText(String text) If using default layouts, this will set the text displayed in the OFFLINE state
  • setOfflineRetryText(String text) If using default layouts, this will set the text of a retry button displayed in the OFFLINE state
  • setOfflineRetryOnClickListener(OnClickListener listener) If using default layouts, this will set the click listener to a retry button displayed in the OFFLINE state
  • setEmptyImageDrawable(Drawable drawable) Sets custom image shown above empty text when not using custom layout
  • setEmptyImageResource(int resourceId) Sets custom image shown above empty text when not using custom layout
  • setOfflineImageDrawable(Drawable drawable) Sets custom image shown above offline text when not using custom layout
  • setOfflineImageResource(int resourceId) Sets custom image shown above offline text when not using custom layout
  • setTransitionsEnabled(boolean enabled) Enables/disables transitions between states

License

Copyright 2017 Jakub Kinst ([email protected])

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].