Efl is an Android Framework to simplify the android development process. It has many commonly used features like annotation binding, fast http connection wrappers, file utils, simple data caching, etc.
- Annotation Based Binding (View, Event Listener, Intent Extra, etc)
- Http Request (Simple, Lightweight, Support Multipart Request Body)
- Preferences Storage
- Simple Session Storage (Object Caching)
- Secure Session Storage (Encrypted)
- Extended Widget (TextView, EditText, Button, Checkbox, RadioButton)
- Form Validation
- Common Utils (MD5, File Utils, etc)
- Bitmap Cache
- Asychronous JSON and XML Request
You can import this library to your project by adding following dependency to your build.gradle
:
repositories {
jcenter()
}
dependencies {
compile 'com.fenlisproject.elf:core:0.2.5'
}
- Extends BaseApplication
First step to use this library is to Make your Application class extend BaseApplication.
public class SampleApplication extends BaseApplication {
@Override
public void onCreate() {
super.onCreate();
}
}
Don't forget change application name in your manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
...
<application
android:name="your.package.name.SampleApplication">
</application>
</manifest>
- Extends BaseActivity
In you want to utilize Binding feature, you must extends your Activity with BaseActivity.
BaseActivity itself extends from AppCompatActivity which use Android Support Fragment (appcompatv7).
Define content view by @ContentView
annotation. It will call setContentView
for you at Runtime.
Method onContentViewCreated
is called right before onCreate
finish. You you can treat this method same as onCreate
method. Do what you usually do in onCreate
in this method.
@ContentView(R.layout.activity_main)
public class MainActivity extends BaseActivity {
@ViewId(R.id.textview1)
private TextView textView1;
@Override
protected void onContentViewCreated() {
// Yo can safely access to textView1 in this method without call findViewById(). That's the magic
textView1.setText("Hello Elf");
}
}
- Extends BaseFragment
If you use Fragment, then you can extend your fragment with BaseFragment. And the other steps are same as when you use Activity.
@ContentView(R.layout.fragment_home)
public class HomeFragment extends BaseFragment {
@Override
protected void onContentViewCreated() {
// Treat this method as onCreateView() without inflate the layout
}
@OnClick(R.id.button1)
public void onButton1Clicked() {
// You can even bind button click listener without store it as variable.
}
}
For more detailed documentation, please visit Wiki Page.
Please refer to Release Notes to see what's recently changed.
Copyright 2015 Steven Lewi
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.