Rx.Widgets


Source link: https://github.com/andrefio/Rx.Widgets

Rx.Widgets

Materially inspired widgets and views.

Use

ExpandableButtonGroup

Add the widget to your view:

 <io.andref.rx.widgets.ExpandableButtonGroupLayout

android:layout_height="wrap_content"

android:layout_width="match_parent"

android:padding="16dp"

app:rxw_backgroundTint="@color/colorAccent"

app:rxw_drawableLess="@drawable/ic_expand_less_black_24dp"

app:rxw_drawableMore="@drawable/ic_expand_more_black_24dp"

app:rxw_drawableTint="@android:color/white"

app:rxw_itemsPerRow="4"

app:rxw_lessText="@string/less"

app:rxw_moreText="@string/more"/> 

All the available attributes are above and should be self explanatory. Please open an issue if there's one you'd like to see.

Next, give the view some items to display:

 List<ExpandableButtonGroup.Item> items = new ArrayList<>();

  items.add([...])

final ExpandableButtonGroup expandableButtonGroup = (ExpandableButtonGroup) findViewById(R.id.expandable_button_group);

  expandableButtonGroup.setItems(items);

The view won't do anything until you subscribe to the exposed observables:


  // Subscribe to "less" button clicks.

expandableButtonGroup.lessItemClicks()

  .subscribe(new Action1<Void>()

  {

@Override

public void call(Void aVoid)

{

 expandableButtonGroup.showLessItems();

}

  
}
);

 // Subscribe to "more" button clicks.

expandableButtonGroup.moreItemClicks()

  .subscribe(new Action1<Void>()

  {

@Override

public void call(Void aVoid)

{

 expandableButtonGroup.showMoreItems();

}

  
}
);

  // Subscribe to all the other item clicks.

expandableButtonGroup.itemClicks()

  .subscribe(new Action1<ExpandableButtonGroup.Item>()

  {

@Override

public void call(ExpandableButtonGroup.Item item)

{

 Toast.makeText(getBaseContext(), item.getText(), Toast.LENGTH_SHORT).show();

}

  
}
);

ListViewCard

Add the widget to your view:

 <io.andref.rx.widgets.ListViewCard

android:id="@+id/list_view_card"

android:layout_height="wrap_content"

android:layout_margin="16dp"

android:layout_width="match_parent"

app:rxw_avatarAlpha="1"

app:rxw_avatarTint="@color/colorAccent"

app:rxw_buttonText="@string/button_to_click"

app:rxw_denseLayout="true"

app:rxw_iconAlpha=".27"/>

All the available attributes are above and should be self explanatory. Please open an issue if there's one you'd like to see.

Next, give the view some items to display:


  List<ListViewCard.Item> listViewCardItems = new ArrayList<>();

listViewCardItems.add([...]);

 mListViewCard = (ListViewCard) findViewById(R.id.list_view_card);

mListViewCard.setItems(listViewCardItems);
 

To handle the clicks you must subscribe to the exposed observables:

 listViewCard.itemClicks()

 .subscribe(new Action1<ListViewCard.Item>()

 {

  @Override

  public void call(ListViewCard.Item item)

  {

Toast.makeText(getBaseContext(), item.getLine1(), Toast.LENGTH_SHORT).show();

  
}

 
}
);

 listViewCard.iconClicks()

 .subscribe(new Action1<ListViewCard.Item>()

 {

  @Override

  public void call(ListViewCard.Item item)

  {

Toast.makeText(getBaseContext(), "Icon Clicked", Toast.LENGTH_SHORT).show();

  
}

 
}
);

listViewCard.buttonClicks()

 .subscribe(new Action1<Void>()

 {

  @Override

  public void call(Void aVoid)

  {

Toast.makeText(getBaseContext(), "Button Clicked", Toast.LENGTH_SHORT).show();

  
}

 
}
);
 

Fun Fact: Even though this widget is called ListViewCard it does not contain a ListView. So, why call it that? Because we felt it best conveyed what this widget is supposed to do: Display a list of items inside a card.

Friendly Reminder

Don't forget to unsubscribe when you're done observing!

Note

This library is under active development so expect some breaking changes as we ramp up. We'll note these changes in the release notes.

Binaries

Add the JitPack repository to your root build.gradle at the end of repositories:

 allprojects {

repositories {

 ...

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

}

 
}

And then add this library to your project:

dependencies {

compile 'io.andref:Rx.Widgets:1.1.0'
 
}

Or if you want a specific revision:

dependencies {

compile 'io.andref:Rx.Widgets:5dda428'
 
}

License

Copyright 2016 Michael De Soto

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

A repository to show how to use some of gradle features.

Here we have some samples and gradle files to be used to help you to automate some tasks for your project.

A gradle task to send files to slack.

Have you ever wanted a more sophisticated <include /> on your XML files? You don't need to create a custom ViewGroup anymore!

This is a simple executor, because sometimes the default exec task does not work as expected.

A simple task to trigger some terminal commands from gradle.

Android number picker library.

A share button with smooth animation.

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