GithubHelp home page GithubHelp logo

webianks / popupbubble Goto Github PK

View Code? Open in Web Editor NEW
381.0 14.0 60.0 280 KB

:parking: Easily add and customise "New Post" popup button with the feeds (RecyclerView) of your app.

License: Apache License 2.0

Java 100.00%
recyclerview animation bubble

popupbubble's Introduction

Android Arsenal Open Source Love License

PopupBubble

Easily Add "New Post" popup button with the feeds (recyclerview) of your app.

Min SDK

Minimum sdk is 14 and support is limited to recyclerview for now.

Add With Gradle Dependency

compile 'com.webianks.library:popup-bubble:1.0.5'

Maven:

<dependency>
  <groupId>com.webianks.library</groupId>
  <artifactId>popup-bubble</artifactId>
  <version>1.0.5</version>
  <type>pom</type>
</dependency>

Add PopupBubble to layout

<com.webianks.library.PopupBubble
  android:id="@+id/popup_bubble"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
/>

Positioning of this view can be done according to the need. By default it should be placed in top center. Also it should be placed below recyclerview in layout so that it shows on top of recyclerview.

Example positioning

If its inside RelativeLayout then

<com.webianks.library.PopupBubble
  android:layout_margin="16dp"
  android:id="@+id/popup_bubble"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerHorizontal="true"
/>

Customization Through XML

<!--Change background Color-->
    app:pb_backgroundColor="?attr/colorPrimary"
<!--Change text -->
    app:pb_text="New Stories"
<!--Change text color-->
    app:pb_textColor="#ffffff"
<!--Show/Hide Icon inside the button. By default its true.-->
    app:pb_showIcon="false"
<!--Change icon color-->
    app:pb_iconColor="#ffffff"
<!--Set Different Icons-->
    app:pb_icon="@drawable/ic_new.png"
<!--Set different fonts-->
    app:pb_font="iran_sans_mobile.ttf"
        

Example : Full Customization

<com.webianks.library.PopupBubble
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_margin="16dp"
  android:id="@+id/popup_bubble"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerHorizontal="true"
  app:pb_backgroundColor="?attr/colorPrimary"
  app:pb_iconColor="#ffffff"
  app:pb_text="New Stories"
  app:pb_textColor="#ffffff"
  app:pb_icon="@drawable/ic_keyboard_arrow_up_white_18dp"
  app:pb_font="iran_sans_mobile.ttf"
/>

#Access the bubble from Java

PopupBubble popupBubble = (PopupBubble) findViewById(R.id.popup_bubble);

Add listener if you want to know when the bubble is clicked

popupBubble.setPopupBubbleListener(new PopupBubble.PopupBubbleClickListener() {
            @Override
            public void bubbleClicked(Context context) {
  
                //popup_bubble is clicked  
            }
        });

Attach with your RecyclerView

 //necessary to add
popupBubble.setRecyclerView(recyclerView);

#Helper Methods Hide/Show PopupBubble according to your need

popupBubble.hide();
popupBubble.show();

Control Animations Set false if you dont want any animations. Default value is true.

popupBubble.withAnimation(false);

Update text dynamically Call this method before the activate method to set the new text.

popupBubble.updateText("10 new stories");

Update icon dynamically Call this method before the activate method to set the new Icon.

popupBubble.updateIcon(R.drawable.new_icon);

Update typeface of text dynamically Call this method before the activate method to set the new Typeface.

popupBubble.updateTypeFace(myCustomTypeface);

Most Important

Now download/fetch new content in background and then notify your recyclerview adapter about range of items added and finally activate the PopupBubble to make it appear with animation (if not set false).

//Own logic for fetching new content
 .....      
adapter.notifyItemRangeInserted(0,size_of_new_items_added); // size_of_new_items_added = 10 if 10 new items are added.
popupBubble.activate(); 
    

License

PopupBubble library for Android
Copyright (c) 2016 Ramankit Singh (http://github.com/webianks).

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.

popupbubble's People

Contributors

needsst avatar omidheshmatinia avatar rayliverified avatar webianks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

popupbubble's Issues

URGENT: Improper Library Manifest

The library manifest should not have a application declaration. This causes errors in Android's preview rendering such as NoClassFoundException and Class Could Not Be Instantiated for support views. Removing declaration allows popup to be displayed correctly and Android previews to work properly.

Fixed in PR #12

Problems with Android Studio 3.2.0

After the update that I made today I was having problems with my Gradle build and I found that the now resource items with type "id" like this
<item name="image_view" type="id">image_view</item> are no more supported and the build fails.
An item with type "id" should be empty <item name="image_view" type="id"/> or should contain a resource file <item name="image_view" type="id">@id/example</item>.

Please fix.

Feedback PopupBubble Error

If add this version api 'com.webianks.library:popup-bubble:1.0.5', build have error, if remove the error will disappear

Error:

Duplicate symbol in table with resource type 'styleable' and symbol name 'AlertDialog'

image
image

Material animations?

Currently, it feels slow and not according to the material style. IMO the bubble should drop down and the animation should be fast (~300ms).

Feature Improvements

This is a great library but there are UI quirks and extensible functionality that I would like to add. Here is a list of what I feel is needed.

  • isActivated() method. Get if PopupBubble is active. Currently, there is no way to know if a popup bubble exists and recreating a popup bubble reruns the animation.
  • Disable hide when scroll up. Scrolling up hides popup bubble. Should be option to disable as this behavior is sometimes wonky.

I'll be working on these changes in my fork and hopefully have a PR ready at the end of this weekend.

Android studio gradle error

Hi, can anyone help me with this error? It's my first time installing and using android studio in my computer and this happened:

Build command failed.

Error while executing process C:\Users\Guisinga Family\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Guisinga Family\AndroidStudioProjects\MyApplication\app -BC:\Users\Guisinga Family\AndroidStudioProjects\MyApplication\app.externalNativeBuild\cmake\release\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-16 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Guisinga Family\AndroidStudioProjects\MyApplication\app\build\intermediates\cmake\release\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=C:\Users\Guisinga Family\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=C:\Users\Guisinga Family\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Guisinga Family\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}

-- Check for working C compiler: C:/Users/Guisinga Family/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe

-- Check for working C compiler: C:/Users/Guisinga Family/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken

/Users/Guisinga Family/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File

It fails with the following output:

Change Dir: C:/Users/Guisinga Family/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeTmp

Run Build Command:"C:/Users/Guisinga

Family/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"

"cmTC_df859"

[1/2] Building C object CMakeFiles/cmTC_df859.dir/testCCompiler.c.o

FAILED:

C:\Users\GUISIN1\AppData\Local\Android\Sdk\NDK-BU1\TOOLCH1\llvm\prebuilt\WINDOW1\bin\clang.exe

--target=armv7-none-linux-androideabi16 --gcc-toolchain="C:/Users/Guisinga

Family/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"

--sysroot="C:/Users/Guisinga

Family/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem

C:/Users/Guisinga

Family/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi

-g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong

-no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16

-mthumb -Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o

CMakeFiles/cmTC_df859.dir/testCCompiler.c.o -c "C:\Users\Guisinga

Family\AndroidStudioProjects\MyApplication\app.externalNativeBuild\cmake\release\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"

error: no such file or directory:

'Family/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'

ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.

Call Stack (most recent call first):

CMakeLists.txt

-- Configuring incomplete, errors occurred!

See also "C:/Users/Guisinga Family/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeOutput.log".

See also "C:/Users/Guisinga Family/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/release/armeabi-v7a/CMakeFiles/CMakeError.log".

Build command failed.

Error while executing process C:\Users\Guisinga Family\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {-HC:\Users\Guisinga Family\AndroidStudioProjects\MyApplication\app -BC:\Users\Guisinga Family\AndroidStudioProjects\MyApplication\app.externalNativeBuild\cmake\debug\armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-16 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Guisinga Family\AndroidStudioProjects\MyApplication\app\build\intermediates\cmake\debug\obj\armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=C:\Users\Guisinga Family\AppData\Local\Android\Sdk\ndk-bundle -DCMAKE_CXX_FLAGS= -DCMAKE_TOOLCHAIN_FILE=C:\Users\Guisinga Family\AppData\Local\Android\Sdk\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=C:\Users\Guisinga Family\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\ninja.exe -GAndroid Gradle - Ninja}

-- Check for working C compiler: C:/Users/Guisinga Family/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe

-- Check for working C compiler: C:/Users/Guisinga Family/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- broken

/Users/Guisinga Family/AppData/Local/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe" is not able to compile a simple test program.
Open File

It fails with the following output:

Change Dir: C:/Users/Guisinga Family/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeTmp

Run Build Command:"C:/Users/Guisinga

Family/AppData/Local/Android/Sdk/cmake/3.6.4111459/bin/ninja.exe"

"cmTC_e6acd"

[1/2] Building C object CMakeFiles/cmTC_e6acd.dir/testCCompiler.c.o

FAILED:

C:\Users\GUISIN1\AppData\Local\Android\Sdk\NDK-BU1\TOOLCH1\llvm\prebuilt\WINDOW1\bin\clang.exe

--target=armv7-none-linux-androideabi16 --gcc-toolchain="C:/Users/Guisinga

Family/AppData/Local/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64"

--sysroot="C:/Users/Guisinga

Family/AppData/Local/Android/Sdk/ndk-bundle/sysroot" -isystem

C:/Users/Guisinga

Family/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi

-g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong

-no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16

-mthumb -Wa,--noexecstack -Wformat -Werror=format-security -fPIE -o

CMakeFiles/cmTC_e6acd.dir/testCCompiler.c.o -c "C:\Users\Guisinga

Family\AndroidStudioProjects\MyApplication\app.externalNativeBuild\cmake\debug\armeabi-v7a\CMakeFiles\CMakeTmp\testCCompiler.c"

error: no such file or directory:

'Family/AppData/Local/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi'

ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.

Call Stack (most recent call first):

CMakeLists.txt

-- Configuring incomplete, errors occurred!

See also "C:/Users/Guisinga Family/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeOutput.log".

See also "C:/Users/Guisinga Family/AndroidStudioProjects/MyApplication/app/.externalNativeBuild/cmake/debug/armeabi-v7a/CMakeFiles/CMakeError.log".

QUESTION: How to NOT show popup if RecyclerView is at top

I am looking for a way to detect when the RecyclerView is already at the top position and not show the popup bubble if that is the case. Currently, if the RecyclerView is already at the top, then the Popup Bubble shows anyways. To dismiss it, the user must scroll down and then up again. I would prefer not to show the Popup Bubble in the first place. Does anyone know how to detect if the RecyclerView is already at the top?

Calling hide and then show quickly hides the bubble

If I click the bubble and hide animation starts, and then for some reason in my UI I need to quickly show it again, the hide animation is not cancelled.

This means that the bubble is hidden even though I wanted it to show, i.e.:

  1. Click bubble (auto-hide with animation).
  2. Within the animation time I do show().
  3. Now (1) will hide the bubble even though I want to override (1) because I called show() in (2).

Add downwards pointing arrow

Hangouts got a popup like bubble displaying "Jump to latest" at the bottom of the RecyclerView (scroll list). It got a down pointing arrow. So to be able to mimic that behaviour it would be nice if you could add a down pointing arrow.

(I can also do a pull req if you want me to).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.