fmelib

Fragments Made Easy library for Android.

License

License

GroupId

GroupId

com.tananaev
ArtifactId

ArtifactId

fmelib
Last Version

Last Version

1.2
Release Date

Release Date

Type

Type

jar
Description

Description

fmelib
Fragments Made Easy library for Android.
Project URL

Project URL

https://github.com/tananaev/fmelib
Source Code Management

Source Code Management

https://github.com/tananaev/fmelib

Download fmelib

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » appcompat-v7 jar 25.3.1

Project Modules

There are no modules declared in this project.

Fragments Made Easy

Android library that makes Fragments easy to work with.

  • Easy asynchronous callbacks management

Main goal of the library is to allow developers focus more about business logic they are implementing and think less about proper handling of fragment lifecycle.

Current version of the library only provides classes based on Android Support Library Fragment, so you have to include Support Library dependency if you want to use EasyFragment.

Download

Just include Gradle dependency into your project:

compile "com.tananaev:fmelib:${version}"

Callbacks and listeners

It was always a pain to handle various asynchronous callbacks is fragments because fragments can be recreated by Android. With EasyFragment and magic runWhenStarted(Task) method you don't need to worry about it anymore.

public class LoginFragment extends EasyFragment {
    ...
    public void login() {
        sendLoginRequest(user -> runWhenStarted(fragmentDestroyed -> {
            Intent intent = new Intent(getActivity(), MainActivity.class);
            intent.putExtra(MainActivity.USER_KEY, user);
            startActivity(intent);
        }));
    }
    ...

Task will be executed immediately if fragment is in started state. If it's not currently visible, the task will be executed when fragment is started. If fragment is destroyed, task will be executed with fragmentDestroyed flag allowing you to handle this condition as well.

You can use anonymous clasess or lambda expressions for implementing Task interface. Nice benefit of this approach is that you can cache response using standard Java closure which makes code shorter and simpler. Library will automatically serialize your callback instance and associate it with a new fragment if your activity has been recreated.

Just make sure that all extra variables captured by your Task class or lambda are Serializable.

Team

License

Apache License, Version 2.0

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.

Versions

Version
1.2
1.1
1.0