emojilike-android


Source link: https://github.com/andob/emojilike-android

emojilike-android

Facebook-like "Like with Emoji" library for Android

Just like Facebook's app:

  • long press on like button
  • keep your finger down, swipe left or right
  • release your finger

Show me the code

Step 1. Get it with

allprojects {
  repositories {

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

... dependencies {
  compile 'com.github.andob:emojilike-android:beta2' ...

Step 2. Setup your "emoji-like" activity

This library uses the activity to detect touch events, to prevent sending touch events to RecyclerView/ListView/ScrollView when the EmojiLikeView is visible on screen (when you select an emoji, you can move your finger up/down and the activity will prevent the scrolling view to scroll).

Thus, you will need to extend a class called ActivityWithEmoji

public class FragmentActivitySample extends ActivityWithEmoji {

  @Override
  protected void onCreate(Bundle savedInstanceState)
  {

.....

OR without extending,

public class MainActivity extends AppCompatActivity implements IActivityWithEmoji {

  EmojiLikeTouchDetector emojiLikeTouchDetector;

@Override
  protected void onCreate(Bundle savedInstanceState)
  {

super.onCreate(savedInstanceState);

.....

emojiLikeTouchDetector=new EmojiLikeTouchDetector();

.....
  
}

 //override theese 2 methods if your activity doesn't extend ActivityWithEmoji
  @Override
  public boolean dispatchTouchEvent(MotionEvent event)
  {

boolean shouldCallSuper=emojiLikeTouchDetector.dispatchTouchEvent(event);

if (shouldCallSuper)

 return super.dispatchTouchEvent(event);

return false;
  
}

@Override
  public void configureEmojiLike(EmojiConfig config)
  {

emojiLikeTouchDetector.configure(config);

  
}
 
}

Step 3. Define EmojiLikeView in XML

You can put an EmojiLikeView whereever you want, in an activity, fragment, an item from an adapter (for RecyclerViews or ListViews), etc.

You just need to define the "trigger" view (=the like button, the button that, once long pressed, the view with emojis will be visible on screen)

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Like"

android:id="@+id/likeButton" ....../>

And the view with emojis:

<ro.andreidobrescu.emojilike.EmojiLikeView

android:layout_width="match_parent"

android:layout_height="110dp"

android:id="@+id/emojiView"

android:layout_alignBottom="@+id/likeButton"

android:layout_marginBottom="10dp"/>

Then get them in your activity/fragment/list cell/etc.

Step 4. Configure the emojis

When the activity/fragment/list cell is created, use EmojiConfig class to configure how emojis will behave. Pass a reference to the context to "with" metod (the context will need to implement IActivityWithEmoji or extend ActivityWithEmoji as described above), the "trigger" view to "on" method, and the EmojiLikeView to "open" method. Then, use addEmoji to add emoji objects (with picture and description).

With this class you can personalize the EmojiLikeView, the in and out animation, background image, margins, delays. There is no default background image (the image behind emojis) or in/out animations, so you will probably need to set them as below.

//in onCreate/onCreateView/onBindViewHolder/etc EmojiConfig.with(this)  .on(likeButton)  .open(emojiView)  .addEmoji(new Emoji(R.drawable.like, "Like"))  .addEmoji(new Emoji(R.drawable.haha, "Haha"))  .addEmoji(new Emoji(R.drawable.kiss, "Kiss"))  .addEmoji(new Emoji(R.drawable.sad, "Sad"))  .addEmoji(new Emoji(R.drawable.t, ":P"))  .setEmojiViewInAnimation((AnimationSet)AnimationUtils.loadAnimation(this, R.anim.in_animation))  .setEmojiViewOutAnimation((AnimationSet) AnimationUtils.loadAnimation(this, R.anim.out_animation))  .setBackgroundImage(R.drawable.background_drawable)  .setOnEmojiSelectedListener(new OnEmojiSelectedListener() {

@Override
public void onEmojiSelected(Emoji emoji) {

 Toast.makeText(getContext(), "Selected " + emoji.getDescription(), Toast.LENGTH_SHORT).show();

}
  
}
)  .setup();

For more info look at the sample project.

License

Copyright 2016 Andrei Dobrescu
 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

Commons (commonslib) is a library containing some often used custom views.

Easiest way to use RecyclerView. Reduce boilerplate code! You don't need to write adapters for listing pages anymore!

You can easily pick images and files from any device storage.

Convenient wrapper library to perform network queries using Retrofit and Android Priority Job Queue (Job Manager).

A lightweight, yet powerful ViewPager animation library for Android.

Admobadapter is an Android library that makes it easy to integrate Admob native ads (both Express and Advanced) into ListView/RecyclerView in the way that is shown in the following image/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