kandi background
Explore Kits

ShineButton | This is a UI lib for Android. Effects like shining. | User Interface library

 by   ChadCSong Java Version: v0.2.0 License: MIT

 by   ChadCSong Java Version: v0.2.0 License: MIT

Download this library from

kandi X-RAY | ShineButton Summary

ShineButton is a Java library typically used in User Interface applications. ShineButton has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
This is a UI lib for Android. Effects like shining.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • ShineButton has a medium active ecosystem.
  • It has 4055 star(s) with 543 fork(s). There are 75 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 24 open issues and 25 have been closed. On average issues are closed in 169 days. There are 3 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of ShineButton is v0.2.0
ShineButton Support
Best in #User Interface
Average in #User Interface
ShineButton Support
Best in #User Interface
Average in #User Interface

quality kandi Quality

  • ShineButton has 0 bugs and 0 code smells.
ShineButton Quality
Best in #User Interface
Average in #User Interface
ShineButton Quality
Best in #User Interface
Average in #User Interface

securitySecurity

  • ShineButton has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • ShineButton code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
ShineButton Security
Best in #User Interface
Average in #User Interface
ShineButton Security
Best in #User Interface
Average in #User Interface

license License

  • ShineButton is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
ShineButton License
Best in #User Interface
Average in #User Interface
ShineButton License
Best in #User Interface
Average in #User Interface

buildReuse

  • ShineButton releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
ShineButton Reuse
Best in #User Interface
Average in #User Interface
ShineButton Reuse
Best in #User Interface
Average in #User Interface
Top functions reviewed by kandi - BETA

kandi has reviewed ShineButton and discovered the below as its top functions. This is intended to give you an instant insight into ShineButton implemented functionality, and help decide if they suit your requirements.

  • On drawable .
  • show an animation
  • Do the shake animation
  • Initializes the splash button
  • Initialize the shine parameters .
  • Initialize the data structures .
  • Draw the mask .
  • Creates the canvas .
  • Configures the bounds of the bitmap .
  • Set fullscreen to full screen .

ShineButton Key Features

This is a UI lib for Android. Effects like shining.

Usage

copy iconCopydownload iconDownload
 shineButton = (ShineButton) findViewById(R.id.shine_button);
 shineButton.init(activity);

Support Dialog

copy iconCopydownload iconDownload
shineButton.setFixDialog(dialog);

Maven

copy iconCopydownload iconDownload
<dependency>
  <groupId>com.sackcentury</groupId>
  <artifactId>shinebutton</artifactId>
  <version>1.0.0</version>
  <type>aar</type>
</dependency>

Gradle

copy iconCopydownload iconDownload
buildscript {
    repositories {
        mavenCentral()
    }
}
dependencies {
    compile 'com.sackcentury:shinebutton:1.0.0'
}

License

copy iconCopydownload iconDownload
The MIT License (MIT)

Copyright (c) 2016 Chad Song 

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.

Confused with Likes Counter using Firebase in Android

copy iconCopydownload iconDownload
if(isLiked){ 
    //If already liked then user wants to unlike the post 
    likesRef.setValue(numLikes-1); }
else { 
    //If not liked already then user wants to like the post 
    likesRef.setValue(numLikes+1);
    shineButton.setEnabled(false); 
}
shineButton.setOnCheckStateChangeListener(new ShineButton.OnCheckedChangeListener() { 
@Override 
    public void onCheckedChanged(View view, boolean checked) { 
        if (checked){
            likesRef.setValue(numLikes+1);
        } else {
            likesRef.setValue(numLikes-1);
        }
    } 
});
-----------------------
if(isLiked){ 
    //If already liked then user wants to unlike the post 
    likesRef.setValue(numLikes-1); }
else { 
    //If not liked already then user wants to like the post 
    likesRef.setValue(numLikes+1);
    shineButton.setEnabled(false); 
}
shineButton.setOnCheckStateChangeListener(new ShineButton.OnCheckedChangeListener() { 
@Override 
    public void onCheckedChanged(View view, boolean checked) { 
        if (checked){
            likesRef.setValue(numLikes+1);
        } else {
            likesRef.setValue(numLikes-1);
        }
    } 
});

Community Discussions

Trending Discussions on ShineButton
  • Confused with Likes Counter using Firebase in Android
  • the picture is not displayed and an error occurs when turning off --> Debug Assertion Failed! Expression: is_block_type_valid(header->_block_use)
Trending Discussions on ShineButton

QUESTION

Confused with Likes Counter using Firebase in Android

Asked 2020-Nov-22 at 10:20

I am beginner and I am working on an android Project where users like the post that admin posts for them. The likes are updated to firebase when user clicks on the like button. The Issue is even though the user likes or unlikes the post, the likes count is increasing. Please look into it.

Note:

Log.d(TAG, "Liked onDataChange: "+isLiked);

returns false no matter if we like or unlike the shinebutton. Shinebutton is a library.

Link to its GitHub : Shinebutton Github

onLike Method:

        @Override
        public void onLike(View v, int position) {

            UploadImage selectedItem = mUploads.get(position);
            String selectedKey = selectedItem.getKey();
            final ShineButton shineButton = new ShineButton(Objects.requireNonNull(getActivity()));
            shineButton.setBtnFillColor(RED);
            shineButton.setShapeResource(R.raw.heart);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(100,100);
            shineButton.setLayoutParams(layoutParams);



            final DatabaseReference likesRef = FirebaseDatabase.getInstance().getReference().child("ImageUploads").child(selectedKey).child("likes");
            likesRef.addListenerForSingleValueEvent(new ValueEventListener(){
                @Override
                public void onDataChange(@NotNull DataSnapshot dataSnapshot) {
                    long numLikes = 0;
                    if(dataSnapshot.exists()){
                        numLikes = dataSnapshot.getValue(Long.class);
                    }
                    boolean isLiked = shineButton.isSelected();

                    Log.d(TAG, "Liked onDataChange: "+isLiked);
                    if(isLiked){
                        //If already liked then user wants to unlike the post

                        likesRef.setValue(numLikes-1);

                    }else {
                        //If not liked already then user wants to like the post
                        likesRef.setValue(numLikes+1);
                        shineButton.setEnabled(false);
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });

            ShineButton like  =  layout.findViewById(R.id.like_feed);
            System.out.println(RED);
            like.setBackground(getResources().getDrawable(R.drawable.like_feed_bg));

        }

After the modification of the Code: Now eventhough we like or unlike the count is not increasing or decreasing.

Onlike Method:

            public void onLike(View v, int position) {

            UploadImage selectedItem = mUploads.get(position);
            String selectedKey = selectedItem.getKey();
            final ShineButton shineButton = new ShineButton(Objects.requireNonNull(getActivity()));
            shineButton.setBtnFillColor(RED);
            shineButton.setShapeResource(R.raw.heart);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(100,100);
            shineButton.setLayoutParams(layoutParams);

            final DatabaseReference likesRef = FirebaseDatabase.getInstance().getReference().child("ImageUploads").child(selectedKey).child("likes");
            likesRef.addListenerForSingleValueEvent(new ValueEventListener(){
                @Override
                public void onDataChange(@NotNull final DataSnapshot dataSnapshot) {
                    long numLikes = 0;

                    if(dataSnapshot.exists()){
                        numLikes = dataSnapshot.getValue(Long.class);
                    }

                    final long finalNumLikes = numLikes;

                    shineButton.setOnCheckStateChangeListener(new ShineButton.OnCheckedChangeListener() {

                        @Override
                        public void onCheckedChanged(View view, boolean checked) {


                            if (checked){
                                likesRef.setValue(finalNumLikes-1);
                            }
                            else{
                                likesRef.setValue(finalNumLikes+1);
                            }
                        }
                    });

                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });

            ShineButton like  =  layout.findViewById(R.id.like_feed);
            System.out.println(RED);
            like.setBackground(getResources().getDrawable(R.drawable.like_feed_bg));

        }

ANSWER

Answered 2020-Nov-22 at 09:41

The problem is that you do not check the state of the button being pressed. You can achieve this by doing the following:

Replace:

if(isLiked){ 
    //If already liked then user wants to unlike the post 
    likesRef.setValue(numLikes-1); }
else { 
    //If not liked already then user wants to like the post 
    likesRef.setValue(numLikes+1);
    shineButton.setEnabled(false); 
}

With this:

shineButton.setOnCheckStateChangeListener(new ShineButton.OnCheckedChangeListener() { 
@Override 
    public void onCheckedChanged(View view, boolean checked) { 
        if (checked){
            likesRef.setValue(numLikes+1);
        } else {
            likesRef.setValue(numLikes-1);
        }
    } 
});

You will also have to keep reference of the botton for when you close the application. You can do this using SharedPreferences.

Source https://stackoverflow.com/questions/64951589

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install ShineButton

You can download it from GitHub, Maven.
You can use ShineButton like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the ShineButton component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

When use button on a Dialog.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Compare User Interface Libraries with Highest Quality
Compare User Interface Libraries with Highest Security
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.