Skip to content

Commit

Permalink
gifs added, bintray credentials added
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-ritik committed Aug 11, 2018
1 parent 5efe686 commit 7922cf3
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 36 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![platform](https://img.shields.io/badge/Platform-Android-yellow.svg?style=flat-square)](https://www.android.com)
[![API](https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=flat-square)](https://android-arsenal.com/api?level=16s)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[ ![Download](https://api.bintray.com/packages/dev-ritik/EmojiReactionView/EmojiReactionView/images/download.svg) ](https://bintray.com/dev-ritik/EmojiReactionView/EmojiReactionView/_latestVersion)

An Android library to make Emoji Reactions on imageviews in a manner Instagram does this!.

Expand All @@ -13,10 +14,27 @@ An Android library to make Emoji Reactions on imageviews in a manner Instagram d
- <b>Optimum performance</b> : Efforts have been made to keep memory usage as small as possible.
- <b>Unharmed image</b> : The library doesn't change/modify the image, so every modification of image as imageview is possible

## Example
Below is the two sample for usage of the library:

<img src="/sample/simple.gif" align="left" width="370" height="330">
<img src="/sample/recycler.gif" align="right" width="370" height="330">

# Usage
Just add the following dependency in your app's `build.gradle`
```groovy
repositories {
maven {
url 'https://dl.bintray.com/dev-ritik/EmojiReactionView/'
}
}
dependencies {
implementation 'com.ritik:emojireactionlibrary:1.0.0'
}
```

## Example
Add the following code in your xml file
```xml
<com.ritik.emojireactionlibrary.EmojiReactionView
Expand Down
44 changes: 34 additions & 10 deletions app/src/main/java/com/ritik/emojireactionview/FeedAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,51 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, final int positio
holder.photo.setOnEmojiClickListener(new ClickInterface() {
@Override
public void onEmojiClicked(int emojiIndex, int x, int y) {
if (x != -1)
Toast.makeText(context, "Emoji " + emojiIndex+" selected!", Toast.LENGTH_SHORT).show();
String message;
if (x != -1) {
switch (emojiIndex) {
case 0:
message = " Great!! ";
break;
case 1:
message = " Hehe ";
break;
case 2:
message = " Loved... ";
break;
case 3:
message = " Shocked!! ";
break;
case 4:
message = " Sad... ";
break;
case 5:
message = " Lit!! ";
break;
default:
message = " ** ";
}
Toast.makeText(context,message, Toast.LENGTH_SHORT).show();
}
feed.setClickedEmoji(emojiIndex);
}

@Override
public void onEmojiUnclicked(int emojiIndex, int x, int y) {
if (x != -1)
Toast.makeText(context, "Emoji " + emojiIndex +" removed", Toast.LENGTH_SHORT).show();
// if (x != -1)
// Toast.makeText(context, "Emoji " + emojiIndex +" removed", Toast.LENGTH_SHORT).show();
}
});

// always after listener for changes
holder.photo.setClickedEmojiNumber(feed.getClickedEmoji());

holder.photo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(context, "clicked", Toast.LENGTH_SHORT).show();
}
});
// holder.photo.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// Toast.makeText(context, "clicked", Toast.LENGTH_SHORT).show();
// }
// });

holder.messageTextView.setText(feed.getMessage());
holder.timeTextView.setText(feed.getTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -40,12 +39,12 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,

feeds.add(new Feed("Adam", R.drawable.feed8, "Nov 6,11:52 AM", "The journey not the arrival matters.", -1));
feeds.add(new Feed("Alina", R.drawable.feed9, "Nov 6,11:52 AM", "Just living is not enough...", -1));
feeds.add(new Feed("Moore", R.drawable.feed3, "Nov 6,11:52 AM", "Quotes .... truth!! life", -1));
feeds.add(new Feed("James", R.drawable.feed4, "Nov 6,11:52 AM", "The dog is the perfect portrait subject. He doesn't pose. He isn't aware of the camera.", -1));
feeds.add(new Feed("Emily", R.drawable.feed10, "Nov 6,11:52 AM", "Dream as if you’ll live forever, live as if you’ll die today.", -1));
feeds.add(new Feed("Moore", R.drawable.feed3, "Nov 6,11:52 AM", "Quotes .... truth!! life", -1));
feeds.add(new Feed("Thomson", R.drawable.feed5, "Nov 6,11:52 AM", "I spent 90 percent of my money on women and drink. The rest I wasted!", -1));
feeds.add(new Feed("William", R.drawable.feed6, "Nov 6,11:52 AM", "Music is my medicine!!", -1));
feeds.add(new Feed("Olivia", R.drawable.feed7, "Nov 6,11:52 AM", "It's refreshing to have some time off from wondering whether I look fat.", -1));
feeds.add(new Feed("Emily", R.drawable.feed10, "Nov 6,11:52 AM", "Dream as if you’ll live forever, live as if you’ll die today.", -1));
feeds.add(new Feed("Sophia", R.drawable.feed1, "Nov 6,11:52 AM", "Adventure may hurt you but monotony will kill you.", -1));
mRecyclerView.setAdapter(mAdapter);

Expand Down
47 changes: 35 additions & 12 deletions app/src/main/java/com/ritik/emojireactionview/SimpleExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -36,26 +35,50 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
clickedEmoji = savedInstanceState.getInt("emojiNumber");
myImage.setClickedEmojiNumber(clickedEmoji);
}

myImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getActivity(), "clicked!!", Toast.LENGTH_SHORT).show();
}
});
//
// myImage.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// Toast.makeText(getActivity(), "clicked!!", Toast.LENGTH_SHORT).show();
// }
// });

myImage.setOnEmojiClickListener(new ClickInterface() {
@Override
public void onEmojiClicked(int emojiIndex, int x, int y) {
if (x != -1)
Toast.makeText(getActivity(),"Emoji " + emojiIndex+" selected!", Toast.LENGTH_SHORT).show();
String message;
if (x != -1) {
switch (emojiIndex) {
case 0:
message = " Great!! ";
break;
case 1:
message = " Hehe ";
break;
case 2:
message = " Loved... ";
break;
case 3:
message = " Shocked!! ";
break;
case 4:
message = " Sad... ";
break;
case 5:
message = " Lit!! ";
break;
default:
message = " ** ";
}
Toast.makeText(getActivity(),message, Toast.LENGTH_SHORT).show();
}
clickedEmoji = emojiIndex;
}

@Override
public void onEmojiUnclicked(int emojiIndex, int x, int y) {
if (x != -1)
Toast.makeText(getActivity(), "Emoji " + emojiIndex +" removed", Toast.LENGTH_SHORT).show();
// if (x != -1)
// Toast.makeText(getActivity(), "Emoji " + emojiIndex +" removed", Toast.LENGTH_SHORT).show();
}
});
return view;
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
29 changes: 27 additions & 2 deletions emojireactionlibrary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 27
ext {
bintrayRepo = 'EmojiReactionView'
bintrayName = 'EmojiReactionView'

publishedGroupId = 'com.ritik'
libraryName = 'EmojiReactionView'
artifact = 'emojireactionlibrary'

libraryDescription = 'An Android library to make Emoji Reactions on imageviews in a manner Instagram does this!'

siteUrl = 'https://github.com/dev-ritik/EmojiReactionView'
gitUrl = 'https://github.com/dev-ritik/EmojiReactionView.git'

libraryVersion = '1.0.0'

developerId = 'dev-ritik'
developerName = 'Ritik Kumar'
developerEmail = '[email protected]'

licenseName = 'The MIT License'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]
}

android {
compileSdkVersion 27

defaultConfig {
minSdkVersion 19
Expand Down Expand Up @@ -32,3 +54,6 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.animation.AccelerateInterpolator;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.Random;
Expand All @@ -34,7 +34,7 @@
* This class does all the background work related to displaying emoji on the canvas
*/

public class EmojiReactionView extends AppCompatImageView {
public class EmojiReactionView extends ImageView {

/// General variables

Expand Down Expand Up @@ -333,7 +333,7 @@ public void setPanelAnimWorking() {
invalidate();
}

public void setOnEmojiClickListener(@Nullable ClickInterface l) {
public void setOnEmojiClickListener(ClickInterface l) {
// Set the listener to the clickedEmojiNumber
this.mClickInterface = l;
}
Expand Down Expand Up @@ -566,7 +566,7 @@ public void onAnimationEnd(Animator animation) {
emojiRisinginit();
}
});
animator.setDuration(600);
animator.setDuration(500);
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
}
Expand Down Expand Up @@ -600,7 +600,7 @@ public void onAnimationEnd(Animator animation) {
clickedRadius = (int) (panelEmojiSide * 0.65);
}
});
animator.setDuration(600);
animator.setDuration(500);
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
}
Expand Down Expand Up @@ -721,7 +721,8 @@ public boolean onTouchEvent(MotionEvent event) {
emojiClicked = true;
}
}
return super.onTouchEvent(event);
super.onTouchEvent(event);
return true;
} else if (!wasSwiping && event.getAction() == MotionEvent.ACTION_MOVE) {
// swiping gesture detected
wasSwiping = true;
Expand Down
Binary file added sample/recycler.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/simple.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7922cf3

Please sign in to comment.