ImageSliderWithSwipes


Source link: https://github.com/myinnos/ImageSliderWithSwipes

ImageSliderWithSwipes

This is an Image slider with swipes, Here we used Volley to load URL's from JSON! Here we make it very easy way to load images from Internet and We customized the description font(OpenSans).

First of all thanks to AndroidImageSlider, Here You can easily load images from an internet URL, drawable, or file. And there are many kinds of amazing animations you can choose. Happy Coding!

Kindly use the following links to use this library:

In build.gradle (Project)

allprojects {

repositories {

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

And then in the other gradle file(may be your app gradle or your own module library gradle, but never add in both of them to avoid conflict.)

dependencies {
  compile 'com.github.myinnos:ImageSliderWithSwipes:1.0.2' 
}

Example

Create Android Project (set name ImageSliderWithSwipes)
Add permissions to AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Add dependencies for Loading Images from URL's(Here we used Volley)
dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:appcompat-v7:25.1.0'
  compile 'com.github.myinnos:ImageSliderWithSwipes:1.0.1'
  compile 'com.mcxiaoke.volley:library:1.0.+' 
}
Copy this code in to activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:custom="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<in.myinnos.imagesliderwithswipeslibrary.SliderLayout

android:id="@+id/slider"

android:layout_width="match_parent"

android:layout_height="match_parent"

custom:auto_cycle="true"

custom:indicator_visibility="visible"

custom:pager_animation="Stack"

custom:pager_animation_span="1100" />  </RelativeLayout>
Copy this code in to MainActivity.java
public class MainActivity extends AppCompatActivity implements BaseSliderView.OnSliderClickListener {

private SliderLayout mDemoSlider;

// Billionaires json url
  private static final String getURL = "http://api.androidhive.info/json/movies.json";
  HashMap<String, String> url_maps;

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mDemoSlider = (SliderLayout) findViewById(R.id.slider);

 // Creating volley request obj

JsonArrayRequest billionaireReq = new JsonArrayRequest(getURL,

  new Response.Listener<JSONArray>() {

@Override

public void onResponse(JSONArray response) {

 url_maps = new HashMap<String, String>();

 // Parsing json

 for (int i = 0; i < response.length();
 i++) {

  try {

 JSONObject obj = response.getJSONObject(i);

url_maps.put(obj.getString("title") + " - " + obj.getString("releaseYear"), obj.getString("image"));

}
 catch (JSONException e) {

e.printStackTrace();

  
}

 
}

  for (String name : url_maps.keySet()) {

  TextSliderView textSliderView = new TextSliderView(MainActivity.this);

  // initialize a SliderLayout

  textSliderView

 .description(name)

.descriptionSize(20)

 .image(url_maps.get(name))

 .setScaleType(BaseSliderView.ScaleType.CenterCrop)

 .setOnSliderClickListener(MainActivity.this);

//add your extra information

  textSliderView.bundle(new Bundle());

  textSliderView.getBundle().putString("extra", name);

mDemoSlider.addSlider(textSliderView);

 
}

}

  
}
, new Response.ErrorListener() {

 @Override

 public void onErrorResponse(VolleyError error) {

  Toast.makeText(getApplicationContext(), "network issue: please enable wifi/mobile data", Toast.LENGTH_SHORT).show();

 
}

}
);

 // Adding request to request queue

AppController.getInstance().addToRequestQueue(billionaireReq);

 mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Stack);

mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Top);

mDemoSlider.setCustomAnimation(new DescriptionAnimation());

mDemoSlider.setDuration(4000);

 mDemoSlider.setPresetTransformer("Stack");

}

@Override
  protected void onStop() {

// To prevent a memory leak on rotation, make sure to call stopAutoCycle() on the slider before activity or fragment is destroyed

mDemoSlider.stopAutoCycle();

super.onStop();

  
}

@Override
  public void onSliderClick(BaseSliderView slider) {

Toast.makeText(this, slider.getBundle().get("extra") + "", Toast.LENGTH_SHORT).show();

  
}
  
}
 

Apps using ImageSliderWithSwipes

If you are using ImageSliderWithSwipes in your app and would like to be listed here, please let us know by opening a new issue!

Thanks

Contact

Prabhakar Thota

License

Copyright 2017 MyInnos  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. 

Resources

material-drawer is a custom drawer implementation for Material design apps.

A single EditText instead of a classical form. This Library is a library implementation of flavienlaurent's "Single input form". Very inspired by the Minimal Format Interface.

Implement any form with only one EditText. The idea here is to pack a multiple input form in one field. As a result, the user input is easier and a more fluent process.

Also, TextSwitcher got completely rediscovered to animate the form: title, error message. It's very basic but simple to use.

Android-Iconics is a library to use (almost) any alternative iconfont in your projects. It allows you to add any Android-Iconics compatible typeface-library-addon to your project and you are able to start using that font.

Fork is the fastest way to execute Android instrumentation test suites by Shazam developers.

A Gradle plugin that adds Fork test tasks for Android instrumentation tests.

Gwen is a simple library that allows writing acceptance tests in a Given-When-Then syntax.

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