All Projects → dilpreet2028 → fragmenter

dilpreet2028 / fragmenter

Licence: other
[Android Library] Remove Boilerplate code for initializing fragments

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to fragmenter

pixie
Tiny template functions.
Stars: ✭ 14 (-77.42%)
Mutual labels:  fragments
vue-piece-slider
animated slides in a fragmented look 🐞🌳✡️📐
Stars: ✭ 95 (+53.23%)
Mutual labels:  fragments
jeta
brooth.github.io/jeta
Stars: ✭ 21 (-66.13%)
Mutual labels:  annotation-processing
react-apollo-fragments
True Fragment component for react-apollo
Stars: ✭ 13 (-79.03%)
Mutual labels:  fragments
activity-based-security-framework
Exadel Activity-based Security Framework
Stars: ✭ 17 (-72.58%)
Mutual labels:  annotation-processing
AnnotationProcessing
✔️ㅤ[ARTICLE] Writing your own Annotation Processors in Android
Stars: ✭ 47 (-24.19%)
Mutual labels:  annotation-processing
MethodScope
Reduce repetitive inheritance works in OOP world using @MethodScope.
Stars: ✭ 33 (-46.77%)
Mutual labels:  annotation-processing
generate-kotlin-multiple-rounds
Android sample project demonstrating how to generate Kotlin code through annotation processing, and then feeding it into a second round of annotation processing.
Stars: ✭ 25 (-59.68%)
Mutual labels:  annotation-processing
shade
Automatic code generation for the SharedPreferences operation.
Stars: ✭ 26 (-58.06%)
Mutual labels:  annotation-processing
piri
Piri is a lightweight annotation processing library that generates static factory methods for your Activities and Fragments.
Stars: ✭ 53 (-14.52%)
Mutual labels:  annotation-processing
circular-reveal-fragment
Push/pop fragment in style
Stars: ✭ 34 (-45.16%)
Mutual labels:  fragments
Assume
Easy Response Mocking for Retrofit using annotations
Stars: ✭ 25 (-59.68%)
Mutual labels:  annotation-processing
Spork
Annotation processing and dependency injection for Java/Android
Stars: ✭ 77 (+24.19%)
Mutual labels:  annotation-processing
news-fragments
An easy way to create your changelog file
Stars: ✭ 31 (-50%)
Mutual labels:  fragments
Prevailer-orientation-support-library-for-Android
Prevailer is a simple android library that helps in preserving object instances across orientation change in android and is JAVA 8 and MVP ready.
Stars: ✭ 17 (-72.58%)
Mutual labels:  fragments
navigator
Annotation processor that eliminates navigation and Bundle boilerplate
Stars: ✭ 13 (-79.03%)
Mutual labels:  fragments
Spring-Boot-Application-Template
Spring Boot Web App, Flyway, MySQL, H2DB, Bootstrap, Thymeleaf, JWT, Swagger, API Rate Limiting, Docker, RBAC, i18n
Stars: ✭ 90 (+45.16%)
Mutual labels:  fragments
HighLite
An SQLite ORM for Android with automatic database migrations built with annotation processing
Stars: ✭ 77 (+24.19%)
Mutual labels:  annotation-processing
CrowdTruth-core
CrowdTruth framework for crowdsourcing ground truth for training & evaluation of AI systems
Stars: ✭ 45 (-27.42%)
Mutual labels:  annotation-processing
AnnotationProcessorStarter
Project to set up basics of a Java annotation processor
Stars: ✭ 19 (-69.35%)
Mutual labels:  annotation-processing

fragmenter

Generates boilerplate code for initializing fragment using annotation processing and performs argument binding while following best practices for initializing a fragment.

  • Eliminates need to create a static function to initialize a fragment
  • Eliminates need to bind the arguments manually

Example

Fragment Class

import com.dilpreet2028.fragmenter_annotations.Fragmenter;
import com.dilpreet2028.fragmenter_annotations.annotations.Arg;
import com.dilpreet2028.fragmenter_annotations.annotations.FragModule;

@FragModule//Need to annotate fragment with @FragModule
public class DemoFragment extends Fragment {
    
    @Arg
    String data; //Annotate variables needed to be initialised with @Arg

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_demo, container, false);
        
        Fragmenter.inject(this);//arguments gets injected automically

        ((TextView) view.findViewById(R.id.tv_text)).setText(data);

        return view;
    }

}

Note: After creating a fragment build the project to allow fragmenter to generate the classes for you.

Fragmenter generates a Builder class i.e. the name of your Fragment with "Builder" as suffix .
In this example Fragmenter creates a DemoFragmentBuilder for DemoFragment

Activity Class

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        String data = "Hello world";
         
        //using the builder class and passing the required variables.
        DemoFragment fragment = DemoFragmentBuilder.newInstance(data);
        
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.content , fragment) 
                .commit();


    }
}

Download

In the root build.gradle file add :

allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }

In your app build.gradle file add:

dependencies {
    compile 'com.github.dilpreet96.fragmenter:fragmenter-annotations:1.0.2'
    annotationProcessor 'com.github.dilpreet96.fragmenter:fragmenter-compiler:1.0.2'
    }

License

Copyright (C) 2017 Dilpreet Singh

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].