Sweet-Mother-of-Json


Source link: https://github.com/jianastrero/Sweet-Mother-of-Json

Sweet-Mother-of-Json

The Sweetest way into connecting to your server

##Installation Add the JitPack repository to your build file then add it in your root build.gradle at the end of repositories:

allprojects {

  repositories {

...

maven {
 url 'https://jitpack.io' 
}

  
}
 
}
 

Add the dependency

dependencies {

  compile 'com.github.jianastrero:Sweet-Mother-of-Json:v2.1' 
}
 

##Usage - Youtube (v1.0) or Instruction v2.1 ####The 1st difference of v1.0 to v2.1 is the name of classes #####SweetConfig -> SweetJsonConfig; Sweet -> SweetJson; ####The 2nd is, the mid sdk is lowered till api 3 ###Youtube

###Instructions Call SweetJsonConfig.setDomain atleast once (recomended to be on the first activity) in your application

SweetJsonConfig.setDomain("192.168.43.33/sweet");
 //when using a local server. this may be mydomain.com 

Extend SweetJson and declare public fields equivalent to post data names. Then call super for the constructor, set the route and set the subclass instance always to this

public class Connect extends SweetJson {

  public String postValue; //this is the value which in php will be taken from $_POST["postValue"]

public Connect(String postValue) {

super();
 //always call super

 setRoute("sweet.php");
 //set the route

setSubclassInstance(this);
  //never changers

 this.postValue=postValue;
  
}
 
}
 

####the code above correspond to this php file:


 echo 'postValue = '.$_POST["postValue"]; 

Lastly, create an instance of your subclass then call submit. if wanted an OnConnectionListener can be set to the instance to listen onBeforeConnectionStart and onAfterConnectionStopped. onAfterConnectionStopped has parameters of result, jsonobject and json array, in which result will always have a value, jsonobject can be null if the result is not a jsonobject else not. and so as with the jsonarray.

Connect connect=new Connect("Sweet Mother Of Json");
 connect.setOnConnectionListener(new Sweet.OnConnectionListener() {

  @Override
  public void onBeforeConnectionStart() {

textView.setText("Connecting to server...");

  
}

@Override
  public void onAfterConnectionStopped(String result, JSONObject jsonObject, JSONArray jsonArray) {

textView.setText(""+result);

  
}
 
}
);
 connect.submit();
 

##Thats it! Now you can easily connect to your server with a short and elegant code :)

Resources

A simple terminal view for old-school rogue-like games.

Speed up your android development by removing boilerplate code.

Current Features:

  • RecyclerUtils - Remove the need to make an adapter everytime, set up recycler adapter in as little as 4 lines.
  • ScrollUtils - Easily hide/show FloationActionButton on scroll when using RecyclerView or NestedScrollView.
  • ToastUtils - Creating toasts are just a function away.
  • SPUtils - Simple DSL for Shared Preferences.
  • ValidatorUtils - Fast and simple text validation.
  • LogUtils - Simple and easy android logging.

This is a compiled working Signalr library for Android. Compile and use for Signalr real-time communication.

A ViewPager with ability to auto scrolling and looping.

A view that displays states of screen like loading, error, empty.

A simple ImageView which allows you to create diagonal cut views easily.

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