HallScheme


Source link: https://github.com/Nublo/HallScheme

HallScheme

Description

HallScheme is a lightweight simple library for creating rectangle halls.

Demo

Integration

1) Add as a dependency to your build.gradle:

dependencies {

  compile 'com.github.Nublo:hallscheme:1.1.1' 
}

2) Add by.anatoldeveloper.ZoomableImage to your layout XML file. Content is automatically centered within free space.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

<by.anatoldeveloper.hallscheme.view.ZoomableImageView

android:id="@+id/zoomable_image"

android:layout_width="match_parent"

android:layout_height="match_parent" />  </RelativeLayout>

3) Customize Seat interface:

public class SeatExample implements Seat {

public int id;
  public int color = Color.RED;
  public String marker;
  public String selectedSeatMarker;
  public HallScheme.SeatStatus status;

@Override
  public int id() {

return id;
  
}

@Override
  public int color() {

return color;
  
}

@Override
  public String marker() {

return marker;
  
}

@Override
  public String selectedSeat() {

return selectedSeatMarker;
  
}

@Override
  public HallScheme.SeatStatus status() {

return status;
  
}

@Override
  public void setStatus(HallScheme.SeatStatus status) {

this.status = status;
  
}
  
}
 

4) Attach ZoomableImage to HallScheme and add a 2-dimesional Seat array:

ZoomableImageView imageView = (ZoomableImageView) rootView.findViewById(R.id.zoomable_image);
 Seat seats[][] = new Seat[10][10]; HallScheme scheme = new HallScheme(imageView, seats, getActivity());
 

5) Set SeatListener to HallScheme to handle click events on seats:

scheme.setSeatListener(new SeatListener() {

  @Override

 public void selectSeat(int id) {

  Toast.makeText(getActivity(), "select seat " + id, Toast.LENGTH_SHORT).show();

 
}

  @Override

 public void unSelectSeat(int id) {

  Toast.makeText(getActivity(), "unSelect seat " + id, Toast.LENGTH_SHORT).show();

 
}

 
}
);
 

Seat interface

To use the library you should implement custom Seat. It has the following methods:

a) int id() should return current id for current Seat. It will also be later returned when you attach SeatListener for scheme.

b) int color() should return the color of the checked Seat.

c) String marker() should return text representation for empty Seat. For example you can use it to see row and column.

d) String selectedSeat(); should return Seat number when the Seat is checked.

e) HallScheme.SeatStatus status(); should return current state of the Seat. The following statuses are supported:

  • FREE - seat is free and can be checked;
  • CHOSEN - seat is chosen and can be unchecked;
  • BUSY - seat cannot be used;
  • INFO - the seat is empty, but you can use to show some text there;
  • EMPTY - the seat is empty.

f) void setStatus(HallScheme.SeatStatus status); update current Seat status.

Features:

a) Zoomable image.

Zooming can be enabled/disabled either from code:

imageView.setZoomByDoubleTap(false);

or from xml:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:hallscheme="http://schemas.android.com/apk/res"  android:orientation="vertical"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:background="#FFD8E2E6">
<by.anatoldeveloper.hallscheme.view.ZoomableImageView

android:id="@+id/zoomable_image"

android:layout_width="match_parent"

android:layout_height="match_parent"

hallscheme:doubleTap="false"/> </RelativeLayout> 

b) Fling while touching image.

c) Smooth animation available either on double tap or on gesture move.

d) Showing scheme scene from any of 4 sides.

hallScheme.setScenePosition(ScenePosition.NORTH);

  • NORTH
  • SOUTH
  • EAST
  • WEST

e) Adding text to show row or hall numbers.

f) Handling clicking on seats on your scheme.

g) Full customization for drawing:

  • Setting background color for scheme:

    scheme.setBackgroundColor(Color.RED);
    
  • Setting color for BUSY seats:

    scheme.setUnavailableSeatBackgroundColor(Color.RED);
    
  • Setting background color for CHOSEN seats:

    scheme.setChosenSeatBackgroundColor(Color.RED);
    
  • Setting text color for CHOSEN seats:

    scheme.setChosenSeatTextColor(Color.RED);
    
  • Setting color for INFO seats:

    scheme.setMarkerColor(Color.RED);
    
  • Setting text color for Scene:

    scheme.setScenePaintColor(Color.RED);
    
  • Setting background color for Scene:

    scheme.setSceneBackgroundColor(Color.RED);
    
  • Setting custom typeface for Scene:

    scheme.setTypeface(typeface);
    

h) Setting custom name for scene:

scheme.setSceneName("Custom name");
  

i) Setting limit of checked seats and set listener for this event:

scheme.setMaxSelectedSeats(4);
 scheme.setMaxSeatsClickListener(new MaxSeatsClickListener() {

  @Override
  public void maxSeatsReached(int id) {

// Do something
  
}
 
}
);
 

By default it is unlimitted. So user can check as many seats as he wants.

j) Programmatically click on scheme:

scheme.clickSchemeProgrammatically(3, 4);
 

So if seat was checked it becomes unchecked and Seatlistener will be notified. If seat was unchecked and limit is not reached seat becomes checked and SeatListener will be notified, otherway(when limit reached) seat will not be checked and MaxSeatsListener will be notified.

k) Adding seat areas.

Seat area will be drawn like a solid rectangle on scene and can have size from 1x1 block to all scheme. When user is clicking on seat area listener will be notified. Clicking on seat area is not counting in maxSelectedSeats.

You can see how to use seat areas in examples. Main principle like with seats. You should set left top corner, width, height and color. Name for seat area is not used in current library implementation.

Restrictions

Image is currently drawing on standart Bitmap. Maximum size of Bitmap depends on underlying OpenGL implementation and it varies depending on device. It shouldn't be less then 2048x2048. With current implementation your hall dimension(either rows or columns) shouldn't be more then 58. Maximum scheme that can be drawn is 58x58. Of course, if you know that devices using your app will have bigger maximum size - you can draw larger schemes.

ChangeLog

Version 1.1.1:

  • Remove dependency from appcompat library

Version 1.1.0:

  • Ability to set custom typeface
  • Disable zooming by double tap
  • Programmatically click seat on scheme
  • Limiting checked seats
  • Added seat areas

License

The MIT License (MIT)  Copyright (c) 2016 Varyvonchyk Anatol  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 

Resources

Folding tabbar menu for Android. You can easily add a nice animated tab menu to your app.

A component to print "flying" text with pretty animation.

"Pull to refresh" and "Load more" for RecyclerView.

Simple BubbleTextView.

Device Year Class is an Android library that implements a simple algorithm that maps a device's RAM, CPU cores, and clock speed to the year where those combination of specs were considered high end. This allows a developer to easily modify application behavior based on the capabilities of the phone's hardware.

Urc

Uniform Resource Creator is an Android (working for Java-generic) library that helps user to create URLs for RESTful apis.

The path syntax is taken from Slim framework, so it is in the form of /static/:argument.

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