Description
DataFragment is a tiny tiny library that helps to prevent a little boilerplate code for retained data fragments in Android. This is really useful for holding data and longrunning tasks over activity lifecycle, namely orientation changes. If you want to read more about this topic or have no idea what i'm talking about, read this
DataFragment alternatives and similar packages
Based on the "App" category.
Alternatively, view DataFragment alternatives based on common mentions on social networks and blogs.
-
InstaMaterial
Implementation of Instagram with Material Design (originally based on Emmanuel Pacamalan's concept) -
Twidere-Android
Twidere is a powerful twitter client for Android 1.6+ 1 , which gives you a full Holo experience and nearly full Twitter's feature. -
Foodium 🍲
🍲Foodium is a sample food blog Android application 📱 built to demonstrate the use of Modern Android development tools - (Kotlin, Coroutines, Flow, Dagger 2/Hilt, Architecture Components, MVVM, Room, Retrofit, Moshi, Material Components). -
jianshi
A Full-Stack mobile app, including Android & Server, Simple-Poem 简诗. You can write poem in graceful & traditional Chinese style. -
Leisure
Leisure is an Android App containing Zhihu Daily,Guokr Scientific,XinhuaNet News and Douban Books -
WaniKani-for-Android
An Android client application for the awesome kanji learning website wanikani.com -
LeeCo
LeeCo is an awesome app for (including unlock) problems, solutions, discuss(from leetcode) and comments. -
FoldingNavigationDrawer-Android
This is a sample project present how to use Folding-Android to add Folding Efect to Navigation Drawer. -
GradientDrawableTuner
🕹️ See how the properties of Android's "shape" affect the Drawable's appearance, intuitively. -
MaterialDesignColorPalette
This is a dev tool to visualize the colours of Material design defined on -
freegemas-gdx
Freegemas libGDX is an Android and Java desktop port of Freegemas, which in turn is an open source version of the well known Bejeweled. -
vanilla
Vanilla Music Player for Android (abandoned). Visit https://github.com/vanilla-music/vanilla for an actively developed fork -
PopularMovies
:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.
InfluxDB - Power Real-Time Data Analytics at Scale
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of DataFragment or a related project?
README
DataFragment
DataFragment is a tiny tiny library that helps (me) to prevent a little boilerplate code for retained data fragments in Android. This is really useful for holding data and longrunning tasks over activity lifecycle, namely orientation changes. If you want to read more about this topic or have no idea what i'm talking about, read this
Usage
DataFragment only works with support library fragments !!!
Create your DataFragment
For that you have to inherit your class from DataFragmentBase
. That's all.
Now you can use it in your activity or where ever. You have to possibilities:
Activity (simpler, nicer)
You can inherit your Activity from the DataFragmentActivity
. This will do most of work for you.
All you have to do is three steps:
Extend from DataFragmentActivity with your DataFragment type ...
...
public class YourActivity extends DataFragmentActivity<YourDataFragment>
...
then put your DataFrament class in the constructor of the class
...
public YourActivity() {
super(YourDataFragment.class);
}
...
and last use your data with the following methods:
getDataFragment()
returns your dataFragment. If its not existent yet it will be created or retained. Now you can manipulate with you own methods.
Static methods (if you can't extends the Activity)
With this approach you have to keep the fragment yourself. You can get it with the following methods as static methods from your DataFragment:
YourDataFragment.createOrRetainDataFragment(FragmentManager, YourDataFragment.class)
YourDataFragment.createDataFragment(FragmentManager, YourDataFragment.class)
YourDataFragment.retainDataFragment(FragmentManager, YourDataFragment.class)
Important to know:
:heavy_exclamation_mark: DataFragment only works with support library fragments !!!
:heavy_exclamation_mark: DataFragment uses the (new) commitNow() to create your data frament, which means its synchronous, but you can use getContext() immediately in your data fragment methods.
Installation
DataFragment is published via Jitpack. Add this in your root build.gradle
file (not your module build.gradle
file):
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Add this to your module's build.gradle
file (make sure the version matches the JitPack badge above):
dependencies {
...
compile 'com.github.matecode:DataFragment:1.0.3'
}
Licence
Copyright 2017 Mate Siede
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 all licence references and agreements mentioned in the DataFragment README section above
are relevant to that project's source code only.