Giter VIP home page Giter VIP logo

phoenix's Introduction

Android Arsenal Yalantis

Phoenix Pull-to-Refresh

This project aims to provide a simple and customizable pull to refresh implementation. Made in [Yalantis] (https://yalantis.com/?utm_source=github)

Check this [project on Dribbble] (https://dribbble.com/shots/1650317-Pull-to-Refresh-Rentals)
Check this [project on Behance] (https://www.behance.net/gallery/20411445/Mobile-Animations-Interactions)

alt text

#Usage

For a working implementation, Have a look at the Sample Project - sample

  1. Include the library as local library project.

    compile 'com.yalantis:phoenix:1.2.3'

  2. Include the PullToRefreshView widget in your layout.

    <com.yalantis.phoenix.PullToRefreshView
        android:id="@+id/pull_to_refresh"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <ListView
            android:id="@+id/list_view"
            android:divider="@null"
            android:dividerHeight="0dp"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    
    </com.yalantis.phoenix.PullToRefreshView>
  3. In your onCreate method refer to the View and setup OnRefreshListener.

    mPullToRefreshView = (PullToRefreshView) findViewById(R.id.pull_to_refresh);
    mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mPullToRefreshView.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mPullToRefreshView.setRefreshing(false);
                }
            }, REFRESH_DELAY);
        }
     });

#Customization

To customize drawables you can change:

  • sun.png - Sun image
  • sky.png - background image
  • buildings.png - foreground image

Misc

If you need to change progress state:

	mPullToRefreshView.setRefreshing(boolean isRefreshing)

#Compatibility

  • Android GINGERBREAD 2.3+

Changelog

Version: 1.2

  • Sample updated with RecyclerView example
  • Showing the refresh view just in it's bounds. (Issue with transparent / empty ListView)
  • Possibility to set refresh view padding

Version: 1.0

  • Initial Build

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to [email protected] And do let us know if you have any questions or suggestion regarding the animation.

P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for Android (iOS) better than better. Stay tuned!

License

Copyright 2017, Yalantis

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.

phoenix's People

Contributors

aenterhy avatar alexzaitsev avatar apisov avatar edbaev avatar shliama avatar warko-san 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  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

phoenix's Issues

Phoenix doesnt work on Samsung Galaxy S2

I added Phoenix to my project and it works fine with Sony Xperia. However, I can't scroll to refresh when testing my app on Samsung Galaxy S2. Do you have similar issue on that device? What might be the problem?

Resource name "type" conflicts with other lib

I'm not sure, which exactly, but I can't even sync gradle with this lib. Debug values contains following code

<declare-styleable name="LiveLockScreen"><attr format="string" name="settingsActivity"/><attr name="type">
         <flag name="experience" value="1"/>
         <flag name="event" value="2"/>
     </attr></declare-styleable>

can I use this library like this?

<com.yalantis.phoenix.PullToRefreshView
    android:id="@+id/pull_to_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</com.yalantis.phoenix.PullToRefreshView>

If I use the library like this, it can't pull to refresh, how can I do it ?

Padding disappear after refresh

I set padding top and padding bottom to the list view and the padding disappears after refresh. I want to set clipToPadding of the listview to false, so moving the padding to PullToRefreshView will not work in my case.

Scroll doesn't work with complex layouts

This might be fixed with this PR: #31

If you watch the .gif below, you'll see that I can scroll this ListView down and up if I continue the touch. Once the touch has been lifted from the screen and you swipe down it starts show the refresh view. Normal behavior should not show this unless at the top of the ListView.

Was this by design?

phoenixscrollissue

bug for oom

java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:822)
at android.graphics.Bitmap.createBitmap(Bitmap.java:799)
at android.graphics.Bitmap.createBitmap(Bitmap.java:731)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:607)
at com.yzm.sleep.sunrefresh.SunRefreshView.createBitmaps(SunRefreshView.java:109)
at com.yzm.sleep.sunrefresh.SunRefreshView.initiateDimens(SunRefreshView.java:103)
at com.yzm.sleep.sunrefresh.SunRefreshView$1.run(SunRefreshView.java:80)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5049)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)

Create view success ,but got a TableNotFoundException when query

I create a hbase table use create 'pay_psa_info6',{NAME=>'cf'}
then load data which exported from online use the shell hbase org.apache.hadoop.hbase.mapreduce.Import pay_psa_info6 /tmp/part-m-00000

scan the hbase table
image

then I create view CREATE VIEW "pay_psa_info6" (pk VARCHAR PRIMARY KEY, "cf"."c" integer);

select * from pay_psa_info6;
Error: ERROR 1012 (42M03): Table undefined. tableName=PAY_PSA_INFO6 (state=42M03,code=1012)
org.apache.phoenix.schema.TableNotFoundException: ERROR 1012 (42M03): Table undefined. tableName=PAY_PSA_INFO6
at org.apache.phoenix.compile.FromCompiler$BaseColumnResolver.createTableRef(FromCompiler.java:577)
at org.apache.phoenix.compile.FromCompiler$SingleTableColumnResolver.(FromCompiler.java:391)
at org.apache.phoenix.compile.FromCompiler.getResolverForQuery(FromCompiler.java:228)
at org.apache.phoenix.compile.FromCompiler.getResolverForQuery(FromCompiler.java:206)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:482)
at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:456)
at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:302)
at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:291)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:290)
at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:283)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1830)
at sqlline.Commands.execute(Commands.java:822)
at sqlline.Commands.sql(Commands.java:732)
at sqlline.SqlLine.dispatch(SqlLine.java:813)
at sqlline.SqlLine.begin(SqlLine.java:686)
at sqlline.SqlLine.start(SqlLine.java:398)
at sqlline.SqlLine.main(SqlLine.java:291)

Integration with observable list view

I'm using pull-to-refresh-rentals with observable scroll view (https://github.com/ksoichiro/Android-ObservableScrollView) in my application (the code is almost identical to the StickyHeaderListView sample code in observable-scrollview source code). However the pull to refresh image (the sky and building) gets covered by the toolbars provided by observablescrollview.

I've played a lot with the padding and layout-margintop of pull-to-refresh but it seems that there is no decent solution for this. I tried to use some code trick to add and remove layout-margin top to pull to refresh but it leads to strange not smooth behavior. Another not-so-good solution is to set the setVisibility of toolbars to VISIBILITY.GONE in onRefresh() but not a very good solution.

I attached a screenshot of the problem during the pull to refresh action. You can see the two redundant big white spaces (white spaces beneath the toolbars appear during pull to refresh) and also the pictures are covered by toolbars.

I was wondering if there is a way to make these two libraries work together in peace :)

cant use in eclipse

in eclipse I add all need jar but cant work in my android 4.4 when running

OutOfMemoryError

java.lang.OutOfMemoryError:
at android.graphics.Bitmap.nativeCreate(Native Method:0)
at android.graphics.Bitmap.createBitmap(Bitmap.java:922)
at android.graphics.Bitmap.createBitmap(Bitmap.java:895)
at android.graphics.Bitmap.createBitmap(Bitmap.java:827)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:703)
at com.yalantis.phoenix.refresh_view.SunRefreshView.createBitmaps(SunRefreshView.java:110)
at com.yalantis.phoenix.refresh_view.SunRefreshView.initiateDimens(SunRefreshView.java:102)
at com.yalantis.phoenix.refresh_view.SunRefreshView$1.run(SunRefreshView.java:79)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5433)
at java.lang.reflect.Method.invokeNative(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method:0)

bug with some Sasmung devices

i have copied your SunRefreshView and made my own with my own icons

in most of the devices is workin ok but in some samsung devices and some sony i am getting this error:

ava.lang.NullPointerException
at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1083)
at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:827)
at com.yalantis.phoenix.refresh_view.LoadingRefreshView.drawSun(LoadingRefreshView.java:213)
at com.yalantis.phoenix.refresh_view.LoadingRefreshView.draw(LoadingRefreshView.java:156)
at android.widget.ImageView.onDraw(ImageView.java:1040)
at android.view.View.draw(View.java:15400)
at android.view.View.getDisplayList(View.java:14294)
at android.view.View.getDisplayList(View.java:14336)
at android.view.View.draw(View.java:15114)
at android.view.ViewGroup.drawChild(ViewGroup.java:3319)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3162)
at android.view.View.draw(View.java:15403)
at android.view.View.getDisplayList(View.java:14294)
at android.view.View.getDisplayList(View.java:14336)
at android.view.View.draw(View.java:15114)
at android.view.ViewGroup.drawChild(ViewGroup.java:3319)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3155)
at android.view.View.draw(View.java:15403)
at android.view.View.getDisplayList(View.java:14294)
at android.view.View.getDisplayList(View.java:14336)
at android.view.View.draw(View.java:15114)
at android.view.ViewGroup.drawChild(ViewGroup.java:3319)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3155)
at android.view.View.draw(View.java:15403)
at android.support.v4.view.ViewPager.draw(ViewPager.java:2257)
at android.view.View.getDisplayList(View.java:14294)
at android.view.View.getDisplayList(View.java:14336)
at android.view.View.draw(View.java:15114)
at android.view.ViewGroup.drawChild(ViewGroup.java:3319)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3155)
at android.view.View.getDisplayList(View.java:14289)
at android.view.View.getDisplayList(View.java:14336)
at android.view.View.draw(View.java:15114)
at android.view.ViewGroup.drawChild(ViewGroup.java:3319)
at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1089)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3155)
at android.view.View.getDisplayList(View.java:14289)
at android.view.View.getDisplayList(View.java:14336)
at android.view.View.draw(View.java:15114)
at android.view.ViewGroup.drawChild(ViewGroup.java:3319)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3155)
at android.view.View.getDisplayList(View.java:14289)
at android.view.View.getDisplayList(View.java:14336)
at android.view.View.draw(View.java:15114)
at android.view.ViewGroup.drawChild(ViewGroup.java:3319)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3155)
at android.view.View.getDisplayList(View.java:14289)
at android.view.View.getDisplayList(View.java:14336)
at android.view.View.draw(View.java:15114)
at android.view.ViewGroup.drawChild(ViewGroup.java:3319)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3155)
at android.view.View.draw(View.java:15403)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2583)
at android.view.View.getDisplayList(View.java:14294)
at android.view.View.getDisplayList(View.java:14336)
at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1585)
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1457)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2779)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2645)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2213)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1256)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6632)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:813)
at android.view.Choreographer.doCallbacks(Choreographer.java:613)
at android.view.Choreographer.doFrame(Choreographer.java:583)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:799)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5598)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)

problem when scrolling up

i have a problem when try to scroll up as the screenshot

screenshot_2016-07-16-11-22-57
my xml
`

<com.yalantis.phoenix.PullToRefreshView
    android:id="@+id/pull_to_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v7.widget.RecyclerView
            android:id="@+id/home_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            />
        <View
            android:id="@+id/home_empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/home"
            android:clickable="false"
            android:visibility="gone"
            />
    </RelativeLayout>

</com.yalantis.phoenix.PullToRefreshView>

</RelativeLayout>

`

Unable to customize sun.png

When I add a sun.png, I get the error Duplicate file.
\app\build\intermediates\res\debug\drawable-xxhdpi\sun.png: Original is here. The version qualifier may be implied.

I assume, I would need to set the merger to use my project's sun.png, but not sure how to do it.

Recycler smoothScrollToPosition has a strange behavior

When I use Recycler in PullToRefresh, by calling smoothScrollToPosition(0) a strange behavior occurred.
When Recycler is exactly at the top of the first cell, it scrolls to the bottom of it otherwise, it scrolls to the top of the first cell!
It just happened when I use PullToRefresh!

PullToRefreshLayout is always visible

PullToRefreshLayout should be visible only when you start dragging it down. Now it is always visible and I have to set the background of the recyclerView to 100% opacity.

Out of Memory errors

When using your library, even with very small images after a while I always get OOM errors

Size of the Background Animation in Master/Detail Pane Layout

The thing is that If you are using the Android Studio template for Master/Detail Flow's there is a bug in the sizing of the Background Animation. It seems that your code uses the Device width as the Animation width - but It should use the fragment/activity width instead.

bildschirmfoto 2015-03-16 um 22 49 52

I hope you get what I mean.

Apply padding in Parent Layout

I've noticed that you handle bottom padding in scroll back. That would cause much time in "measure".
I catched a systrace of your "scroll back":

trace

I understand why you need this logic, View.offsetTopAndBottom would destroy the bottom padding. But this not handled in scroll down yet. Actually, you can notify user to set padding in parent layout such as following code, and handle padding logic in onLayout() of PullToRefreshView.

<com.yalantis.phoenix.PullToRefreshView
        android:id="@+id/pull_to_refresh"
        android:padding="10dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <ListView
        android:id="@+id/yalantis_list_view"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</com.yalantis.phoenix.PullToRefreshView>

bug with oom had happen more than 573 in my project

java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:575)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:410)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:433)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:463)
at com.yalantis.phoenix.refresh_view.SunRefreshView.createBitmaps(SunRefreshView.java:108)
at com.yalantis.phoenix.refresh_view.SunRefreshView.initiateDimens(SunRefreshView.java:104)
at com.yalantis.phoenix.refresh_view.SunRefreshView$1.run(SunRefreshView.java:81)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5062)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)

基本信息
首次发生时间 最近发生时间 出现次数 版本
2015-11-20 16:16:21 2015-11-24 18:49:33 573 2.2
qq 20151126120534

How can i disable it programatically?

Hello, is it possible to disable it programatically,because i want it to be active only when specific view is touched and not the rest of the layout?

Thanks in advance :)
Great lib btw !

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.