Code Monkey home page Code Monkey logo

astickyheader's Introduction

AStickyHeader

Buy Me a Coffee at ko-fi.com

AStickyHeader

AStickyHeader is a simple library for adding Sticky Headers to ListView or GridView. Usage is very simple, it supports all kinds of Adapters.

Quick Start

AStickyHeader is available as an AAR, so you can use it by just adding the following dependency to your build.gradle.

buildscript {
    repositories {
        jcenter()
    }
}
...

dependencies {
     compile 'dev.dworks.libs:astickyheader:0.1.0'
}
...

Sample App

Get it on Google Play

Developed By

License

Copyright 2016 Hari Krishna Dulipudi

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.

Bitdeli Badge

astickyheader's People

Contributors

1hakr avatar bitdeli-chef avatar enthuan avatar intrications avatar soarcn 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

astickyheader's Issues

Fixed Column With destroy sections

If i set a fixed columnNum then i see no sections. By checking the code it looks like support only for columnNum=AUTO-FIT. I would make the grid more dynamic for different column numbers and no fixed column width.

java.lang.NullPointerException android:numColumns="auto_fit"

if I set android:numColumns="auto_fit" in PinnedSectionGridView, I have crash.

04-27 10:00:51.673 3408-3408/dev.dworks.libs.astickyheader.sample E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at dev.dworks.libs.astickyheader.ui.PinnedSectionGridView.ensureShadowForPosition(PinnedSectionGridView.java:279)
at dev.dworks.libs.astickyheader.ui.PinnedSectionGridView$1.onScroll(PinnedSectionGridView.java:131)
at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1326)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5055)
at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3193)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:3467)
at android.view.View.dispatchTouchEvent(View.java:7127)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2170)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1905)
at dev.dworks.libs.astickyheader.ui.PinnedSectionGridView.dispatchTouchEvent(PinnedSectionGridView.java:484)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1925)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1379)
at android.app.Activity.dispatchTouchEvent(Activity.java:2396)
at android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchTouchEvent(ActionBarActivityDelegateICS.java:268)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1873)
at android.view.View.dispatchPointerEvent(View.java:7307)
at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3172)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3117)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4153)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4132)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4224)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:163)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4203)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4243)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:523)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

I need different column numder on different device and orientation.
Library does not support "auto_fit"?

Library is not compatible with CursorAdapters

I am trying to wrap my CursorAdaptor subclass with the SimpleSectionedListAdapter class and it is giving me an issue:

    java.lang.IllegalStateException: this should only be called when the cursor is valid
            at android.widget.CursorAdapter.getView(CursorAdapter.java:243)

Looking at the code from the SSLA class it seems like it's trying to call the cursor adapter's getView method. Obviously that won't work for CursorAdapters

Headers appear on last column when android:gravity attribute is missing

When using PinnedSectionGridView, I noticed that removing the android:gravity="center" attribute will break header functionality, where headers will oddly appear on the last column of the GridView.

This is also happening in the sample project, in activity_grid.xml.

Granted, I'm developing on API level 15, which is rather old. Not sure if this could be related.

Help

Is there a quick guide on how to use it?

Some suggestions to the library...

I have some suggestions and remarks of how to improve the code of the library.

Here are things i've modified to the code and added a link to download:

  1. many of the files on the library itself aren't needed or doesn't belong to it, and many aren't even used.
    in fact, no resource is really needed by the library.
  2. the jar file of the support library isn't needed here, as it's already provided in ABS. This can (and will) cause compilation errors when using newer versions of the support library (or of ABS).
  3. there are many Lint warnings about too-new APIs. I really hope they are false positives. I've already tested the sample project and it works fine on Android 2.3 .
    There are also other less-important warnings (like un-needed check of null, double ";" characters,...) .
  4. The color resource "white" wasn't found anywhere. It should either be declared or something else should be used (like
    "@android:color/white" instead of "@color/white" ) .

Here are things I think should be added:

  1. the SimpleSectionedGridAdapter is too hard to customize, especially the header part. it could be nice to be able to have an abstract function called "handleHeaderView" instead of using a layout resource Id and an id of the textview within it.

  2. there is no usage of the ViewHolder design pattern (watch "the world of listView" lecture for more information). this could make a smoother experience.

  3. HeaderLayout isn't really needed. you can change the layout of whatever view that was used there, and update it, for example:

    layoutParams = header.getLayoutParams();
    layoutParams.width = getHeaderSize();
    header.setLayoutParams(layoutParams);
    

For some reason I can't find out how to upload files here, so I've uploaded to a third party website (google drive). Here is a minimized version of the projects:
https://drive.google.com/file/d/0B_nrUhQ0MIgwdFRaNnNVR3QycDA/edit?usp=sharing

Please let me know what you think about it.

Scrolling to a desired position not working

I have tried,

  1. gridView.setSelection()
  2. gridView.smoothScrollToPosition()
  3. gridView.requestPositionToScreen()

given a position none of these methods jump to / scroll to respective position on the grid. Please let me know if there are any alternative.

Not able to implement Scroll to grid view index based on user input

I am using <dev.dworks.libs.astickyheader.ui.PinnedSectionGridView>.
Based on a floating list popup window index click I want to focus ( scroll) to that part of grid view.

I am passing the selection index to go to that section of gridview but nothing seems to happen.

GridView is not scrolling to selected position in grid view.

When selection happens I am saving the current position.
int index = gridview.getFirstVisiblePosition(); And when you come back to the gridview then trying to do
gridview.smoothScrollToPosition(int index)

                //gridView.setSelection(position);
                int index = gridView.getFirstVisiblePosition();

                ListAdapter adapter = gridView.getAdapter();

                gridView.smoothScrollToPosition(index + position);

notifyDataSetChanged does not work

when i do:
mSimpleSectionedGridAdapter.notifyDataSetChanged();
it doesn't work, till i touch the view.so could you help me to find out why it performs that?

i found : setSections(Section... sections) -->Only the original thread that created a view hierarchy can touch its views.so use Handler to update the view .

stretchMode causing problems with section header display

Ideally, I would use:

android:stretchMode="spacingWidthUniform"

in my gridView. However, doing so causes the section header view to behave very strangely. Whilst floating, it starts at some point in the first column of the grid view and extends to the right-hand side, or, if the gravity is changed, it moves to the right or off the left of the screen. Putting fixed gaps makes it work, but doesn't look so good in landscape.

Rounded corners on section header view

Putting rounded corners as the background:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="@color/MTPDarkGreen" />
    <corners android:radius="10dp" />
</shape>

It works except that the enclosing rectangle has a white background, which can't be changed. I'm using a colour background on the grid view so it looks a little odd. Is there a way of changing the background to, say, transparent?

disable sticky in gridview

Hi.
I am using your library in my project.
Now, How to i can disable sticky in gridview (allow gridview scroll same as normal, still keep header but no sticky them when scroll on first) ?

Sorry for my English.
Thanks so much.

setSections method change request

I think it would be good to change the setSections method in SimpleSectionedAdapter from

public void setSections(Section[] sections)

to

public void setSections(Section... sections)

It would not change the way it used to called, but better for the case only one section been used.

Header Fails to work

Thanks for the sharing!
It seems that i would not run the apps as some of the java codes are not installed in the eclipse.
I have installed the git plugin but it seems that I have still missed some important steps.

Great if you would provide some hints!!

stickyheader

Api level requirement

Hi
In the example and all the manifest put as min api 8, but in the code explispe caims at least api level 16.
getPaddingRight(),getNumColumns(),getNumColumns(), needs an api over 8....

  public void setGridView(GridView gridView){
        if(!(gridView instanceof PinnedSectionGridView)){
            throw new IllegalArgumentException("Does your grid view extends          PinnedSectionGridView?");
        }
        mGridView = gridView;
        mStrechMode = gridView.getStretchMode();
        mWidth = gridView.getWidth() - (mGridView.getPaddingLeft() + mGridView.getPaddingRight());
        mNumColumns = ((PinnedSectionGridView)gridView).getNumColumns();
        requestedColumnWidth = ((PinnedSectionGridView)gridView).getNumColumns();
        requestedHorizontalSpacing = ((PinnedSectionGridView)gridView).getHorizontalSpacing();
    }

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.