felipecsl / quickreturn Goto Github PK
View Code? Open in Web Editor NEWAndroid ListView that implements the QuickReturn UI pattern. Written from scratch with focus on performance.
Home Page: http://felipecsl.com/QuickReturn
License: MIT License
Android ListView that implements the QuickReturn UI pattern. Written from scratch with focus on performance.
Home Page: http://felipecsl.com/QuickReturn
License: MIT License
Is there any way to have the quick return layer start out hidden and only come out when the list is scrolled?
I don't see any public methods to manually set the state of the view.
Obrigado!
Hi @felipecsl
I like your QuickReturn, but I can not use it in a RecyclerView.
Could you add RecyclerView to your library?
Thanks.
Hi Felipe,
is it possible to open #12 again and answer my second comment?
Thank you.
If you set the position of the listview, like if you change following code in your sample, then you've got a very ugly visual bug. :)
Any ideas how to solve that?
Line 65:
if (viewGroup instanceof AbsListView) {
int numColumns = (viewGroup instanceof GridView) ? 3 : 1;
ListView absListView = (ListView) viewGroup;
absListView.setAdapter(new QuickReturnAdapter(adapter, numColumns));
absListView.setSelectionFromTop(100, 30); // Add this line
}
It seems like this lib doesn't support scrollView...
Hi,
i try your component and seems that is not compatible with swiperefreshlayout when we have top view. Because top view is "front of" listView, the view of swiperefreshlayout isn't displayed (it's behind "top view"...)
Have you a suggest to have this 2 components together ?
Hi @felipecsl
Maybe I'm wrong, but I think OnItemClickListener works incorrect:
position=0 for header
position=1 for first list item
So, should I manually decrement position into the onItemClick()?
You say: "Automatically adjusts the ListView/GridView to prevent it from being hidden behind the target view, when it is placed at the top of the list."
But when we have a target view at bottom and a listView which have an height close to height of screen, the target view bottom hide last row.
How to fix it ?
My "target view" is a button. It often (1/3 of the time?) throws this error when being clicked:
02-25 21:59:26.460 21264-21264/com.androidfu.nowplaying.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.androidfu.nowplaying.app, PID: 21264
java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
at android.widget.ListView.dispatchDraw(ListView.java:3307)
at android.view.View.draw(View.java:15117)
at android.widget.AbsListView.draw(AbsListView.java:4083)
at android.view.View.updateDisplayListIfDirty(View.java:14048)
at android.view.View.getDisplayList(View.java:14071)
at android.view.View.draw(View.java:14838)
at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
at android.view.View.updateDisplayListIfDirty(View.java:14043)
at android.view.View.getDisplayList(View.java:14071)
at android.view.View.draw(View.java:14838)
at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
at android.view.View.updateDisplayListIfDirty(View.java:14043)
at android.view.View.getDisplayList(View.java:14071)
at android.view.View.draw(View.java:14838)
at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
at android.view.View.updateDisplayListIfDirty(View.java:14043)
at android.view.View.getDisplayList(View.java:14071)
at android.view.View.draw(View.java:14838)
at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
at android.view.View.draw(View.java:15117)
at com.android.internal.widget.ActionBarOverlayLayout.draw(ActionBarOverlayLayout.java:501)
at android.view.View.updateDisplayListIfDirty(View.java:14048)
at android.view.View.getDisplayList(View.java:14071)
at android.view.View.draw(View.java:14838)
at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
at android.view.View.draw(View.java:15117)
at android.widget.FrameLayout.draw(FrameLayout.java:592)
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2595)
at android.view.View.updateDisplayListIfDirty(View.java:14048)
at android.view.View.getDisplayList(View.java:14071)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:266)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:272)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:311)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2492)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2337)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1968)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
hi,
I have integrated quick return in my custom listview but i couldn't get click of some random rows
i have total of 4 buttons on each row with different different click events. Majorly found this issue in first and last position of listview
listview is populating from database and at the same time am getting latest values from server and by using notifydatasetcahnge am repopulating listview
I've come across an error with the adapter using a list view with certain mobile phones.
Genymotion HTC one - API Level 18
sony xperia c5303 - API Level 18
sony xxperia Z1 - API Level 14
java.lang.NullPointerException
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:548)
at android.view.View.measure(View.java:15848)
at com.felipecsl.quickreturn.library.widget.QuickReturnAdapter.getView(QuickReturnAdapter.java:99)
line 99:
v.measure(View.MeasureSpec.makeMeasureSpec( parent.getWidth() / numColumns , View.MeasureSpec.AT_MOST), heightMeasureSpec);
what could be causing the error? It works fine on other phones ive tested i.e nexus 5.
I investigate the code and see that QuickReturn use a dummy invisible row to prevent the first item of listview overlap by the QuickReturn target
...
if (position < numColumns) {
if (convertView == null)
v = new View(parent.getContext());
else
v = convertView;
v.setLayoutParams(new AbsListView.LayoutParams(
AbsListView.LayoutParams.MATCH_PARENT,
targetViewHeight));
finalHeight = targetViewHeight;
}
...
But by using this technique, the scroll thumb of scroll bar will be hidden by the quickreturn target when we scroll to top also.
Could you modify the code to add a dummy header instead of dummy row to prevent this happen?
The ic_launcher.png files is not used in the library. Please remove them to make the library smaller.
Hi @felipecsl
I like your QuickReturn, but I can not add my own scroll listener:
mList.setOnScrollListener(new EndlessScrollListener() {...});
As I see you're changed onScrollListener in the constructor QuickReturnAttacher
listView.setOnScrollListener(this);
Could you implement Composite pattern here?
http://en.wikipedia.org/wiki/Composite_pattern
http://stackoverflow.com/questions/5465204/how-can-i-set-up-multiple-listeners-for-one-event
In the sample, in the list view's onScroll method.
Re-produce step:
Scroll up and make the top target disappear, then the firstVisibleItem is immediately 1 which should be 0.
It will be bigger than expected if you continue to scroll up.
_I have bang my head to combine those two together without succesfully.I currently use the pull to refresh list mention below:
https://github.com/johannilsson/android-pulltorefresh
_But when i combine with Quick return, the behaviour is not as expected, when scrolldown, the sticky view only show with half of the height.
_I would like to ask if it is possible to combine QuickReturn with the pullToRefresh pattern?
Doesn't seem to be available in 1.4.0. Is there a new way to attach a scrollListener?
I Like Your Code...
nullpointer exception on grid view custom baseadapter @felipecsl
I changed count items to 20 and add items with different height:
Issues:
Video: https://drive.google.com/file/d/0B7RpBUvV8W8WX3dvOHNFRnV6MTQ/edit?usp=sharing
When the dividerHeight is positive (e.g. 5dp) for the ListView, quickReturnTarget is repeatedly shown at divider spaces when scrolling, causing an unnatural feeling.
Hi. Your library added permission READ_PHONE_STATE and app has a problem during install (e.g. avast antivirus detect it how dangerous app).
Please take a look my log manifest-merger-release-report.txt
android:uses-permission#android.permission.WRITE_EXTERNAL_STORAGE
IMPLIED from AndroidManifest.xml:2:1 reason: com.felipecsl.quickreturn has a targetSdkVersion < 4
android:uses-permission#android.permission.READ_PHONE_STATE
IMPLIED from AndroidManifest.xml:2:1 reason: com.felipecsl.quickreturn has a targetSdkVersion < 4
android:uses-permission#android.permission.READ_EXTERNAL_STORAGE
IMPLIED from AndroidManifest.xml:2:1 reason: com.felipecsl.quickreturn requested WRITE_EXTERNAL_STORAGE
My ListView has the OnItemLongClickListener, and after wrapping the listAdapter with your library's one, all onLongClick events are delivered to the next Item in the list instead of the one being tapped. Should I make a crutch?
PS
I guess the point is the same as in "onItemClick wrong position #7" issue, however, the index had to be decremented there. Maybe the way it was fixed causes misbehavior of longClick?
One thing that happened when I used both CardsLib (Top Colored Material card) with QuickReturn (https://github.com/felipecsl/QuickReturn) is that the app wil crash when I scroll down near the bottom. It's okay when it's still far from the bottom.
This is the warning I got:
You are using generic adapter. Pay attention: your adapter has to call cardArrayAdapter#getView method.
This is how I set the adapter:
listView.setAdapter(mCardArrayAdapter);
listView.setAdapter(new QuickReturnAdapter(mCardArrayAdapter));
I've posted this issue in CardsLib git too:
Hi,
is it possible to enable top and bottom quickreturnviews at same time for same listview?
Thank you.
When I use your library for an ArrayAdapter with viewtypecount > 1. The recycled view in getView is not match with view type. I found the solution in your QuickReturnAdapter.java, just change to the following lines:
@Override
public int getItemViewType(final int position) {
if (position < numColumns)
return wrappedAdapter.getViewTypeCount();
return wrappedAdapter.getItemViewType(position - numColumns);
}
Could you take a look at this fix:)
Thanks,
-Tuan
You library works great but with one major problem.
When I try to select an item in the list, it always selects the item next to it, like if I select the first one, it selects the second one and so on.
Can you please provide a solution to this problem?
Thanks in advance.
Hello,
Is it possible to implement hide/show of target view manually?
My action bar contains a button which switch items layout and so item's height will changed.
When listview has a top padding, bottom view gets the same bottom padding initially, when you scroll padding goes away.
It is caused by getComputedScrollY method, without - view.getTop() it is in correct place, however quick return just appears / disappears without smooth transition.
Hi. Is there a way to prevent the blank area on the target view (as you scroll up) or is this is an existing issue (I didn't see it in the issues list)? I've tried setting the target view's height as not only 0, but other +/- values, as well. I've also tried leaving it off, but the issue persists. Please help. Hopefully there is an easy fix. This library is great, otherwise. Thank you!
Here is a video demonstrating the issue.
Here is my code:
activity_main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/testTextView"
android:layout_width="match_parent"
android:layout_height="90dp"
android:paddingLeft="10dp"
android:gravity="center_vertical"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@android:color/white"
android:background="@android:color/black"
android:textStyle="bold"
android:text="Test Title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_light"/>
</LinearLayout>
act_student_menu_item.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/studentMenuContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="8dp"
android:layout_centerVertical="true"
android:orientation="horizontal">
<ImageView
android:id="@+id/studentPhotoIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerInParent="true"
android:src="@drawable/icon_photo_grey" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_toRightOf="@+id/studentPhotoIcon"
android:layout_centerInParent="true"
android:orientation="vertical">
<TextView
android:id="@+id/studentNameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:textColor="@android:color/white"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/studentPointsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="@android:color/white"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
onCreate in MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// The list view to show/hide on scroll.
ListView listView = (ListView) findViewById(android.R.id.list);
TextView testTextView = (TextView) findViewById(R.id.testTextView);
TestAdapter testAdapter = new TestAdapter(this, android.R.layout.simple_spinner_item,
getListData());
// Wrap the adapter with QuickReturnAdapter.
listView.setAdapter(new QuickReturnAdapter(testAdapter));
// Attach QuickReturn Attacher, which takes care of all of the hide/show functionality.
QuickReturnAttacher qrAttacher = QuickReturnAttacher.forView(listView);
/**
* Add a quick return targetView to the attacher.
* You can pass a position argument (POSITION_TOP or POSITION_BOTTOM). You can also optionally pass the size of
* the target view, which will be used to offset the list height, preventing it from hiding content behind the
* target view.
*/
qrAttacher.addTargetView(testTextView, QuickReturnTargetView.POSITION_TOP, 0);
}
TestAdapter.java
public class TestAdapter extends ArrayAdapter<StudentMenuItem> {
private final Context currentContext;
private List<StudentMenuItem> studentMenuItems;
ImageView studentPhotoIcon;
TextView studentNameText;
public TestAdapter(Context context, int layoutResourceId, List<StudentMenuItem> studentMenuItems) {
super(context, layoutResourceId, studentMenuItems);
currentContext = context;
this.studentMenuItems = studentMenuItems;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View studentMenuOption = convertView;
if (studentMenuOption == null) {
LayoutInflater inflater = (LayoutInflater) currentContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
studentMenuOption = inflater.inflate(R.layout.act_student_menu_item, parent, false);
}
StudentMenuItem current = studentMenuItems.get(position);
studentNameText = (TextView) studentMenuOption.findViewById(R.id.studentNameText);
studentNameText.setText(current.getStudentName());
TextView studentPointsText = (TextView) studentMenuOption.findViewById(R.id.studentPointsText);
studentPointsText.setText(current.getStudentPoints());
studentPhotoIcon = (ImageView) studentMenuOption.findViewById(R.id.studentPhotoIcon);
return studentMenuOption;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return getDropDownView(position, convertView, parent);
}
}
Note: getListData()
just returns List<StudentMenuItem>
to populate the list.
if we initialize Quick Return with the listview and then call listview.onRestoreInstanceState(state) which will make the list view restore it previous instance (scroll to last value). The QuickReturnTarget will become unstable and will hide/show randomly when scroll up or down.
Anyone has solution for this?
In the ScrollView option, only the top QuickReturn target appears and disappears. The bottom QuickReturn target stays as it is.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.