DisqusSDK-Android


Source link: https://github.com/jjhesk/DisqusSDK-Android

DisqusSDK-Android

This is the simple library for https://disqus.com/ developed on Android.

About

This library implements the Disqus API for use in Android applications. This librar is ongoing

Gradle settings

repositories {

 maven {
 url 'https://dl.bintray.com/jjhesk/maven' 
}
 
}
 dependencies {

 compile 'DisqusSDK-Android:disqus:0.2.7' 
}

API RoadMap Support

  • Post comments
  • Post Comments more flexible
  • Updated authentication OAuth2.0 standard
  • Additional support for the CacheUrl mechanism
  • enable extending from fragment. PostCommentFragment
  • setup the activity for login
  • construct the configuration object

Installation

  • enable extending from fragment. PostCommentFragment
  • setup the activity for login
  • construct the configuration object

Using AuthorizeActivity

  1. Use AuthorizeUtils.createIntent to create a new Intent with your application settings.
  2. Start the activity with startActivityForResult.
  3. Implement 'onActivityResult' to get the access token object:
 @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

// Check which request we're responding to

if (requestCode == DisqusClient.authorization_intent_id) {

 // Make sure the request was successful

 if (resultCode == RESULT_CANCELED) {

  Toast.makeText(this, getResources().getString(com.hkm.disqus.R.string.failurelogin), Toast.LENGTH_LONG);

 
}

 if (resultCode == RESULT_OK) {

  AccessToken token = (AccessToken) data.getExtras().getParcelable(AuthorizeActivity.EXTRA_ACCESS_TOKEN);

  addLine(token.accessToken);

  release_pending_content();

 
}

}

  
}

 protect void release_pending_content(){

  if (appending_post_content != null) {

 postPost(appending_post_content, post_post_id);

 appending_post_content = null;

}

  
}
 
  1. ApiConfiguration Object Sample: The forum name will be used as the following reference:

" https://disqus.com/api/3.0/threads/set.json?forum=\(forumShortName)&api_key=\(apiKey)&thread=ident:\(postID)%20\(domain)/?p=\(postID)"

public class DqUtil {

  public static ApiConfig genConfig() {

ApiConfig conf = new ApiConfig(

  BuildConfig.DISQUS_API_KEY,

  BuildConfig.DISQUS_DEFAULT_ACCESS,

  RestAdapter.LogLevel.BASIC);

 conf

 .setForumName("__forum_name__")

 .setApiSecret(BuildConfig.DISQUS_SECRET)

 .setRedirectUri(BuildConfig.DISQUS_REDIRECT_URI);

  return conf;
  
}
 
}

Standard options

  • API key - mandatory for all requests.
  • Access token - required for requests that require authentication.
  • Referrer - required for some requests that perform domain checks, should match a domain in your Disqus app settings.
  • Log level - set the Retrofit logging level, see Square's docs for details.

Other options

  • API secret - intended for server to server requests as an alternative to the API key/access token and provided for completeness. Can be used from a mobile app but this presents security risks and is not recommended.

Create client

As of version 0.9.0 the library is using Retrofit for requests.

The ApiClient can be used to create Disqus resource objects based on the Retrofit interfaces defined in the me.philio.disqus.api.resources package. It works as a wrapper to the Retrofit RestAdapter and configures the adapter and deserialisation options for Gson.

 ApiClient apiClient = new ApiClient(apiConfig);

Create resource and make requests

 Applications applications = apiClient.createApplications();

  Response<Usage> usage = applications.listUsage("MyApp", 7);

All resources and requests match the naming conventions defined in the Disqus API documentation, but often method signatures are kept as simple as possible.

Advance Sample Code

  setup.createThreads().listPostByIDAsync(comment_id, "hypebeast", cb);

private void getPost() {

try {

 base.getComments("1008680 http://hypebeast.com/?p=1008680", new Callback<com.hkm.disqus.api.model.Response<List<Post>>>() {

  @Override

  public void success(com.hkm.disqus.api.model.Response<List<Post>> posts, Response response) {

 com.hkm.disqus.api.model.Response<List<Post>> d = posts;

 Log.d(TAG, "now its working now");

  
}

@Override

  public void failure(RetrofitError error) {

Log.d(TAG, error.getMessage());

  
}

 
}
);

}
 catch (ApiException e) {

 
}

  
}
 

In general:

  • Named parameters are required and should not be null.

  • Optional parameters can be provided as a Map where applicable, refer to the Disqus documentation for details of optional parameters.

Response format

All requests will return a Response object. Typical responses contain an error code (which will always be 0 as errors throw exceptions), an optional cursor (which can be used for pagination) and some data which is a generic type.

The data is usually an object or list of objects and for the majority of requests will be one of the models defined in the API package. Some requests return empty structures so to avoid parsing issues the data type is either Object or List<Object>, the response data for these requests can be disregarded.

Known issues

Disqus issues

  1. The cancel button for the authorisation page doesn't work.
  2. Related param has no effect when used with Blacklists.list() method.
  3. update after post thread doesnt work.

Resources

A custom layout that fills given width or height as per the original ratio of each child.

If given width or height is exceeded, it largely replicates the behavior of LinearLayout.

What RatioFillLayout offers:

  • Orientation: horizontal, vertical
  • Gravity: top, bottom, left, right, centerhorizontal, centervertical

What is iSortBox? Just like what it says: Simplify sorting!

This framework achieves a goal which makes sorting easier, moreover, you will benefit from what it provides such as pre-processing, converting, grouping and filtering.

As the name iSortBox, the letter 'i' means input and the letter 'o' means output, as for the details on how to complete the work, all are encapsulated in iSortBox.

Android Gradle plugin generates App Shortcuts shortcuts.xml for build flavors with different applicationId.

When it useful?

If you look at the official documentation of static App Shortcuts, you'll see that for each intent you need to set the android:targetPackage. But, what if you have different applicationId in different flavors?

In this case, you'll need copy your shortcuts.xml in two folder dev and prod with single difference. And if you create a new flavor with different applicationId you need to copy it again. Since at this moment we do not have any built-in merge tools applicationId from build.gradle to the shortcuts.xml this gradle plugin will be useful.

Starter boilerplate projects for Android, with Components Architecture implemented, written completely in Kotlin. Variations include Rx, Realm & Dagger usage.

Neuronizer offers the opportunity to order your thoughts, ideas and tasks in categories to recognise the information you need as fast as possible.

Features

  • Add, remove and update notes
  • Add, remove and update ToDo lists
  • Sort everything as you wish
  • Designed for simple and fast usage
  • Encrypted storage of data, on device only
  • Create widgets
  • Categorisation in ToDo lists
  • Mark tasks as done
  • Add details to each task
  • Share ToDo lists

The library is a small widget for image cropping in Instagram-like style. Written in Kotlin.

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