AutoBundler

Android AutoBundler library

License

License

Categories

Categories

Auto Application Layer Libs Code Generators
GroupId

GroupId

sk.teamsoft
ArtifactId

ArtifactId

autobundler
Last Version

Last Version

0.3.1
Release Date

Release Date

Type

Type

aar
Description

Description

AutoBundler
Android AutoBundler library
Project URL

Project URL

https://github.com/Team-SOFTsk/AutoBundler
Source Code Management

Source Code Management

https://github.com/Team-SOFTsk/AutoBundler

Download autobundler

How to add to project

<!-- https://jarcasting.com/artifacts/sk.teamsoft/autobundler/ -->
<dependency>
    <groupId>sk.teamsoft</groupId>
    <artifactId>autobundler</artifactId>
    <version>0.3.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/sk.teamsoft/autobundler/
implementation 'sk.teamsoft:autobundler:0.3.1'
// https://jarcasting.com/artifacts/sk.teamsoft/autobundler/
implementation ("sk.teamsoft:autobundler:0.3.1")
'sk.teamsoft:autobundler:aar:0.3.1'
<dependency org="sk.teamsoft" name="autobundler" rev="0.3.1">
  <artifact name="autobundler" type="aar" />
</dependency>
@Grapes(
@Grab(group='sk.teamsoft', module='autobundler', version='0.3.1')
)
libraryDependencies += "sk.teamsoft" % "autobundler" % "0.3.1"
[sk.teamsoft/autobundler "0.3.1"]

Dependencies

compile (2)

Group / Artifact Type Version
sk.teamsoft : autobundler-annotations jar 0.3.1
com.android.support » support-annotations jar 25.3.1

Project Modules

There are no modules declared in this project.

AutoBundler

Android AutoBundler library

Download Maven Central

Description

AutoBundler is a library for Android applications, which removes boilerplate code from your activities and fragments. The library handles typical actions with saving instance state. So implementing your own onSaveInstanceState and onRestoreInstanceState with hundreds of LOC is a history now.

Usage

All you need to do to make AutoBundler work, is to add annotations to specified fields. Then you can call store/restore actions with one line for all your properties. That's all.

public class MainActivity extends Activity {
    @KeepState int mId;
    @KeepState String mName;
    @KeepState double mValue;
    @KeepState(mode = AutoBundler.MODE_ONRESTORE) EditText mEditText;
    
    @Override protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_layout);
        AutoBundler.restore(this, savedInstanceState, AutoBundler.MODE_ONCREATE);
        ...
    }
    
    @Override protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        AutoBundler.restore(this, savedInstanceState, AutoBundler.MODE_ONRESTORE);
    }
    
    @Override protected void onSaveInstanceState(Bundle outState) {
        AutoBundler.save(this, outState);
        super.onSaveInstanceState(outState);
    }
}

AutoBundler supports basic classes, but you can also define your own class, which can either implement Parcelable or IFieldHandler interface. You can then specify the exact algorithm used to save and restore object values.

@KeepState DataObject mParcel;
@KeepState CustomObject mCustom;

...

class DataObject implements Parcelable {...}

class CustomObject implements IFieldHandler {
        ...
        
        @Override
        public void storeValue(Field field, Object object, Bundle bundle) throws IllegalAccessException {
            bundle.putString(field.getName(), data);
        }

        @Override
        public void readValue(Field field, Object object, Bundle bundle) throws IllegalAccessException {
            data = bundle.getString(field.getName());
        }
    }

License

Released under Apache v2 license

Contact

Team-SOFT s.r.o.

sk.teamsoft

Team-SOFT s.r.o.

Team-SOFT s.r.o. is a company, which focuses on complex enterprise solutions and ERP systems for small and medium-sized companies

Versions

Version
0.3.1
0.2.0
0.1.2
0.1.1