Giter Site home page Giter Site logo

naseemakhtar994 / piri Goto Github PK

View Code? Open in Web Editor NEW

This project forked from savepopulation/piri

0.0 1.0 0.0 104 KB

Piri is a lightweight annotation processing library that generates static factory methods which create new intents for activities in Android.

Java 100.00%

piri's Introduction

piri

Piri is a lightweight annotation processing library that generates static factory methods which creates new intents for activities in Android.

How to use?

Add PiriActivity annotation to your Activity.

@PiriActivity
public class YourActivity extends AppCompatActivity {
...
}

And start YourActivity from another Activity.

public class MainActivity extends AppCompatActivity {
...
 navButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final Intent intent = Piri.newIntentForYourActivity(MainActivity.this);
                startActivity(intent);
            }
        });
...
}

If you want to pass data to YourActivity with Piri add PiriParam annotation to your fields in your Activity and receive data from bundle.

@PiriActivity
public class YourActivity extends AppCompatActivity {
    
    @PiriParam(key = "extra_id")
    private Long id;

    @PiriParam(key = "extra_name")
    private String name;
    
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_your);

        final Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            id = bundle.getLong("extra_id");
            name = bundle.getString("extra_name");
        }

        // INIT UI
        ...
    }
}

And start YourActivity like the following:

public class MainActivity extends AppCompatActivity {
...

 final Long id = 1234567890L;
 final String name = "PiriExample";
 navButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final Intent intent = Piri.newIntentForYourActivity(MainActivity.this,id,name);
                startActivity(intent);
            }
        });
...
}

piri's People

Contributors

savepopulation avatar iammert avatar vbauer avatar

Watchers

Naseem Akhtar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.