Navigator


Source link: https://github.com/aradomski/Navigator

Navigator

Navigator code generator for Android. This library creates boilerplate code useful to start new activities.

Provides Navigator class that keeps all start activity methods with appropriate parameters.

Provides *ParamLoader classes for easy loading parameters from Intents

Provides *ResultFiller classes for easy returning values from Activities by filling Intents

Provides *ResultLoader classes for easy loading results from Activities

Provides *Result classes for keeping results from Activities

##I want to:

Get library from maven and include it in my project

navigator-compiler

navigator-annotations

In project build.gradle file add:

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 

On top of module build.gradle file add:

apply plugin: 'com.neenbedankt.android-apt' 

then add:

 compile 'pl.edu.radomski:navigator-annotations:1.0.0'  apt 'pl.edu.radomski:navigator-compiler:1.0.3' 

in dependencies

Navigate to simple activity

@Navigable public class SimpleActivity extends Activity 
Navigator.simpleActivity(Activity.this);

Navigate to activity with params

@Navigable public class ParamsActivity extends Activity {

 @Param
Integer integerParam;
@Param
String stringParam;
@Param
Book parcelableParam;
  @Override
protected void onCreate(Bundle savedInstanceState) {

 super.onCreate(savedInstanceState);

 ParamsActivityParamLoader.load(this);

}
 
}
Navigator.paramsActivity(Activity.this, 2123, "abcdefgh", book);

Navigate to activity with various groups of params

@Navigable public class GroupedParamsActivity extends Activity {

@Param(group = "firstGroup")
  String stringParam;
  @Param(group = "firstGroup")
  Boolean booleanParam;
  @Param(group = "secondGroup")
  Double doubleParam;
  @Param(group = "secondGroup")
  Integer integerParam;

 @Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

GroupedParamsActivityParamLoader.load(this);

  
}
 
}
Navigator.groupedParamsActivity(Activity.this, 32.12, 2145);
 Navigator.groupedParamsActivity(Activity.this, "abcdefgh", true);

Start Activity for result

@Navigable public class ForResultActivity extends Activity {

  @Result
  String stringResult = "abcdefghijk";

 @Override
  protected View.OnClickListener getOnCloseClickListener() {

return new View.OnClickListener() {

 @Override

 public void onClick(View v) {

  Intent intent = ForResultActivityResultFiller.fillResult(ForResultActivity.this);

  setResult(RESULT_OK, intent);

  finish();

 
}

}
;
  
}
 
}
Navigator.forResultActivityForResult(Activity.this, 123);
 ForResultActivityResultLoader.ForResultActivityResult result3 = ForResultActivityResultLoader.load(data);

Start parameterized Activity for result

@Navigable public class ParamsForResultActivity extends Activity {

@Param(forResult = true)
  Integer integerParam;
  @Param(forResult = true)
  String stringParam;
  @Param(forResult = true)
  Book parcelableParam;

@Result
  String stringResult = "result";

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

ParamsForResultActivityParamLoader.load(this);

  
}

@Override
  protected View.OnClickListener getOnCloseClickListener() {

return new View.OnClickListener() {

 @Override

 public void onClick(View v) {

  Intent intent = ParamsForResultActivityResultFiller.fillResult(ParamsForResultActivity.this);

  setResult(RESULT_OK, intent);

  finish();

 
}

}
;
  
}
 
}
  Navigator.paramsForResultActivityForResult(Activity.this, 123, "abcdefgh", book, 737);
 ParamsForResultActivityResultLoader.ParamsForResultActivityResult result1 = ParamsForResultActivityResultLoader.load(data);

Start activity for various results

@Navigable public class GroupedResultsForResultActivity extends BaseActivity {

@Param(forResult = true)
  Integer returnGroup;

@Result
  String stringResult = "string result";
  @Result(group = "firstGroup")
  Boolean booleanResult = true;
  @Result(group = "secondGroup")
  Double doubleResult =123.5;
  @Result(group = "secondGroup")
  Integer integerResult= 6523;

 @Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

GroupedResultsForResultActivityParamLoader.load(this);

StringBuilder stringBuilder = new StringBuilder();

stringBuilder.append(this.getClass().getCanonicalName());

stringBuilder.append("\n");

stringBuilder.append(this.toString());

classInfo.setText(stringBuilder);

  
}

@Override
  protected View.OnClickListener getOnCloseClickListener() {

return new View.OnClickListener() {

 @Override

 public void onClick(View v) {

  Intent intent = null;

  switch (returnGroup) {

case 1:

 intent = GroupedResultsForResultActivityResultFiller.fillResult(GroupedResultsForResultActivity.this);

 break;

case 2:

 intent = GroupedResultsForResultActivityResultFiller.fillResultfirstGroup(GroupedResultsForResultActivity.this);

 break;

case 3:

 intent = GroupedResultsForResultActivityResultFiller.fillResultsecondGroup(GroupedResultsForResultActivity.this);

 break;

  
}

  setResult(RESULT_OK, intent);

  finish();

 
}

}
;
  
}
 
}
 Navigator.groupedResultsForResultActivityForResult(BaseActivity.this, 1, 123);
 GroupedResultsForResultActivityResultLoader.GroupedResultsForResultActivityResult result4 = GroupedResultsForResultActivityResultLoader.load(data);
  GroupedResultsForResultActivityResultLoader.GroupedResultsForResultActivityFirstGroupResult result5 = GroupedResultsForResultActivityResultLoader.loadFirstGroup(data);
  GroupedResultsForResultActivityResultLoader.GroupedResultsForResultActivitySecondGroupResult result7 = GroupedResultsForResultActivityResultLoader.loadSecondGroup(data);

Create Activity that could be run for result or not.

@Navigable public class ActivityWithResultOption extends BaseActivity {

  @Param(group = "firstGroup", forResult = true)
  String stringParam;
  @Param(group = "firstGroup", forResult = true)
  Boolean booleanParam;
  @Param(group = "secondGroup")
  Double doubleParam;
  @Param(group = "secondGroup")
  Integer integerParam;

 @Result(group = "firstResultGroup")
  String stringResult = "abcdefghijk";
  @Result(group = "firstResultGroup")
  Book bookResult;

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

bookResult = new Book();

bookResult.setAuthor(ForResultActivity.class.getSimpleName());

bookResult.setPublishTime(2012);

bookResult.setBookName("Result");

 StringBuilder stringBuilder = new StringBuilder();

stringBuilder.append(this.getClass().getCanonicalName());

stringBuilder.append("\n");

stringBuilder.append(toString());

classInfo.setText(stringBuilder);

 
}

@Override
  protected View.OnClickListener getOnCloseClickListener() {

return new View.OnClickListener() {

 @Override

 public void onClick(View v) {

  Intent intent = ActivityWithResultOptionResultFiller.fillResultfirstResultGroup(ActivityWithResultOption.this);

  setResult(RESULT_OK, intent);

  finish();

 
}

}
;
  
}
Navigator.activityWithResultOptionFirstGroupForResult(BaseActivity.this, "abcdefgh", true, WITH_RESULT_OPTION_ACTIVITY);
 ActivityWithResultOptionResultLoader.ActivityWithResultOptionFirstResultGroupResult result8 = ActivityWithResultOptionResultLoader.loadFirstResultGroup(data);
Navigator.activityWithResultOptionSecondGroup(BaseActivity.this, 123.53, 25);

Create group of activities

@Navigable(group = "subgroup") public class GroupedActivity extends Activity
Navigator.subgroup.groupedActivity(BaseActivity.this);

Create custom method and support classes name for Activity

@Navigable(name = "customNameWithParams") public class NamedParamsAndResultActivity extends BaseActivity {

@Param(forResult = true)
  Integer integerParam;
  @Param(forResult = true)
  String stringParam;
  @Param(group = "OtherGroup")
  Book parcelableParam;

@Result
  String stringResult = "result";

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

CustomNameWithParamsParamLoader.load(this);

  
}

@Override
  protected View.OnClickListener getOnCloseClickListener() {

return new View.OnClickListener() {

 @Override

 public void onClick(View v) {

  Intent intent = CustomNameWithParamsResultFiller.fillResult(NamedParamsAndResultActivity.this);

  setResult(RESULT_OK, intent);

  finish();

 
}

}
;
  
}
 
}
Navigator.customNameWithParams(BaseActivity.this, 21, "some_string", NAMED_WITH_RESULT);
 Navigator.customNameWithParams(BaseActivity.this, book);
 CustomNameWithParamsResultLoader.CustomNameWithParamsResult result2 = CustomNameWithParamsResultLoader.load(data);

Resources

Casty is a small Android library that provides a simple media player for Chromecast. It's fully consistent with Google Cast v3.

A modern Android oAuth2 library using OkHttp with resource owner password grant types and easy token refreshing. This library aims to provide a solution for the less commonly used resource owner password grant type as well as providing dynamic parameter support that can be used with frameworks that allow for more flexible and dynamic oAuth2 parameters.

Android Starter is a starter project which implements MVP Pattern. It includes libraries:

  • RxJava2
  • RxAndroid
  • Dagger2
  • Butterknife
  • Crashlytics
  • Timber
  • GreenDao
  • Realm
  • Retrofit
  • OkHttp
  • Gson
  • Picasso

Implementation of List Item from Material Design guidelines.

Android Toolbar with marqueeable title / subtitle.

Shareable is a small android library to help implement direct share and social media actions into your android app. For example if you want to share something specifically to Twitter or Facebook.

The API is design to allow you to specify specific social channels to share to using the Builder design pattern. If the app is not available the default is to use all Intent.ACTION_SEND apps on the phone.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes