etsy / AndroidStaggeredGrid

An Android staggered grid view which supports multiple columns with rows of varying sizes.
https://github.com/etsy/AndroidStaggeredGrid
4.76k stars 1.13k forks source link

Set selection doesn't work for the first time when data gets loaded #135

Closed abhirb1 closed 9 years ago

abhirb1 commented 9 years ago

When i use set selection for the first time when data gets loaded in grid it doesn't work but when i scroll the list then it works..I don't know how? Can anyone help me here?

Tim1008 commented 9 years ago

Me too.the Set selection doesn't work! Is anyone know how to fix it???

abhirb1 commented 9 years ago

@Tim1008 Hey hi, have you solve this?

abhirb1 commented 9 years ago

Hi @Tim1008 ,

I have found the solution to this issue,You will have to go into ExtendableListView and in

    public void setSelection(final int position) {
    if (position >= 0) {
        mLayoutMode = LAYOUT_SYNC;
        mSpecificTop = getListPaddingTop();

        mFirstPosition = 0;
        if (mNeedSync) { // this is always false for the first time, so you will have to make sure it      comes in this if
            mSyncPosition = position;
            mSyncRowId = mAdapter.getItemId(position);
        }
        requestLayout();
    }
}

for the first time it doesn't go to need sync if condition so that you will have to make sure mNeedSync variable is true.I have added a custom method for that in this class as

   public void setNeedSync(boolean value) {
    mNeedSync = value;
}

and that's it.

Tim1008 commented 9 years ago

Hi @abhirb1 , thank you for your enthusiasm. But didn't use this project now.

iceve commented 9 years ago

body { width: 100% !important; min-width: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; margin: 0; padding: 0; } .ExternalClass { width: 100%; } .ExternalClass { line-height: 100%; }

backgroundTable {

margin: 0; padding: 0; width: 100% !important; line-height: 100% !important; } img { outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; width: auto; max-width: 100%; float: left; clear: both; display: block; } body { color: #222222; font-family: "Helvetica", "Arial", sans-serif; font-weight: normal; padding: 0; margin: 0; text-align: left; line-height: 1.3; } body { font-size: 14px; line-height: 19px; } a:hover { color: #2795b6 !important; } a:active { color: #2795b6 !important; } a:visited { color: #2ba6cb !important; } h1 a:active { color: #2ba6cb !important; } h2 a:active { color: #2ba6cb !important; } h3 a:active { color: #2ba6cb !important; } h4 a:active { color: #2ba6cb !important; } h5 a:active { color: #2ba6cb !important; } h6 a:active { color: #2ba6cb !important; } h1 a:visited { color: #2ba6cb !important; } h2 a:visited { color: #2ba6cb !important; } h3 a:visited { color: #2ba6cb !important; } h4 a:visited { color: #2ba6cb !important; } h5 a:visited { color: #2ba6cb !important; } h6 a:visited { color: #2ba6cb !important; } table.button:hover td { background: #2795b6 !important; } table.button:visited td { background: #2795b6 !important; } table.button:active td { background: #2795b6 !important; } table.button:hover td a { color: #fff !important; } table.button:visited td a { color: #fff !important; } table.button:active td a { color: #fff !important; } table.button:hover td { background: #2795b6 !important; } table.tiny-button:hover td { background: #2795b6 !important; } table.small-button:hover td { background: #2795b6 !important; } table.medium-button:hover td { background: #2795b6 !important; } table.large-button:hover td { background: #2795b6 !important; } table.button:hover td a { color: #ffffff !important; } table.button:active td a { color: #ffffff !important; } table.button td a:visited { color: #ffffff !important; } table.tiny-button:hover td a { color: #ffffff !important; } table.tiny-button:active td a { color: #ffffff !important; } table.tiny-button td a:visited { color: #ffffff !important; } table.small-button:hover td a { color: #ffffff !important; } table.small-button:active td a { color: #ffffff !important; } table.small-button td a:visited { color: #ffffff !important; } table.medium-button:hover td a { color: #ffffff !important; } table.medium-button:active td a { color: #ffffff !important; } table.medium-button td a:visited { color: #ffffff !important; } table.large-button:hover td a { color: #ffffff !important; } table.large-button:active td a { color: #ffffff !important; } table.large-button td a:visited { color: #ffffff !important; } table.secondary:hover td { background: #d0d0d0 !important; color: #555; } table.secondary:hover td a { color: #555 !important; } table.secondary td a:visited { color: #555 !important; } table.secondary:active td a { color: #555 !important; } table.success:hover td { background: #457a1a !important; } table.alert:hover td { background: #970b0e !important; } body.outlook p { display: inline !important; } body { color: #222222; font-family: "Verdana", "Helvetica", "Arial", sans-serif; } .rating a:active { text-decoration: underline; color: #ffffff !important; } .rating a:visited { text-decoration: underline; color: #ffffff !important; } .rating a:hover { color: #000000 !important; } @media only screen and (max-width: 600px) { table[class="body"] img { width: auto !important; height: auto !important; } table[class="body"] center { min-width: 0 !important; } table[class="body"] .container { width: 95% !important; } table[class="body"] .row { width: 100% !important; display: block !important; } table[class="body"] .wrapper { display: block !important; padding-right: 0 !important; } table[class="body"] .columns { table-layout: fixed !important; float: none !important; width: 100% !important; padding-right: 0px !important; padding-left: 0px !important; display: block !important; } table[class="body"] .column { table-layout: fixed !important; float: none !important; width: 100% !important; padding-right: 0px !important; padding-left: 0px !important; display: block !important; } table[class="body"] .wrapper.first .columns { display: table !important; } table[class="body"] .wrapper.first .column { display: table !important; } table[class="body"] table.columns td { width: 100% !important; } table[class="body"] table.column td { width: 100% !important; } table[class="body"] .columns td.one { width: 8.333333% !important; } table[class="body"] .column td.one { width: 8.333333% !important; } table[class="body"] .columns td.two { width: 16.666666% !important; } table[class="body"] .column td.two { width: 16.666666% !important; } table[class="body"] .columns td.three { width: 25% !important; } table[class="body"] .column td.three { width: 25% !important; } table[class="body"] .columns td.four { width: 33.333333% !important; } table[class="body"] .column td.four { width: 33.333333% !important; } table[class="body"] .columns td.five { width: 41.666666% !important; } table[class="body"] .column td.five { width: 41.666666% !important; } table[class="body"] .columns td.six { width: 50% !important; } table[class="body"] .column td.six { width: 50% !important; } table[class="body"] .columns td.seven { width: 58.333333% !important; } table[class="body"] .column td.seven { width: 58.333333% !important; } table[class="body"] .columns td.eight { width: 66.666666% !important; } table[class="body"] .column td.eight { width: 66.666666% !important; } table[class="body"] .columns td.nine { width: 75% !important; } table[class="body"] .column td.nine { width: 75% !important; } table[class="body"] .columns td.ten { width: 83.333333% !important; } table[class="body"] .column td.ten { width: 83.333333% !important; } table[class="body"] .columns td.eleven { width: 91.666666% !important; } table[class="body"] .column td.eleven { width: 91.666666% !important; } table[class="body"] .columns td.twelve { width: 100% !important; } table[class="body"] .column td.twelve { width: 100% !important; } table[class="body"] td.offset-by-one { padding-left: 0 !important; } table[class="body"] td.offset-by-two { padding-left: 0 !important; } table[class="body"] td.offset-by-three { padding-left: 0 !important; } table[class="body"] td.offset-by-four { padding-left: 0 !important; } table[class="body"] td.offset-by-five { padding-left: 0 !important; } table[class="body"] td.offset-by-six { padding-left: 0 !important; } table[class="body"] td.offset-by-seven { padding-left: 0 !important; } table[class="body"] td.offset-by-eight { padding-left: 0 !important; } table[class="body"] td.offset-by-nine { padding-left: 0 !important; } table[class="body"] td.offset-by-ten { padding-left: 0 !important; } table[class="body"] td.offset-by-eleven { padding-left: 0 !important; } table[class="body"] table.columns td.expander { width: 1px !important; } table[class="body"] .right-text-pad { padding-left: 10px !important; } table[class="body"] .text-pad-right { padding-left: 10px !important; } table[class="body"] .left-text-pad { padding-right: 10px !important; } table[class="body"] .text-pad-left { padding-right: 10px !important; } table[class="body"] .hide-for-small { display: none !important; } table[class="body"] .show-for-desktop { display: none !important; } table[class="body"] .show-for-small { display: inherit !important; } table[class="body"] .hide-for-desktop { display: inherit !important; } } @media screen { @font-face { font-family: 'Roboto Slab'; font-style: normal; font-weight: 700; src: local('Roboto Slab Bold'), local('RobotoSlab-Bold'), url(http://themes.googleusercontent.com/static/fonts/robotoslab/v3/dazS1PrQQuCxC3iOAJFEJRbnBKKEOwRKgsHDreGcocg.woff) format('woff'); } }

                Email Delivery Failure Notice  

                What Happened? There was an issue delivering your message to:  

                 li@alvazan.com   

                Why? The domain name of the email address is not valid  

                     Advertisement |  Prefer no ads?  

                What's next?  

               Check the "alvazan.com" part of the email address for misspellings or missing letters. (If you find an error, you might need to correct it in your contacts list or address book too.) 

               If necessary, contact your recipient another way (e.g., phone or text message) to confirm their email address. 

                 Prefer step by step assistance?   

                 Learn more about this bounce message    

                Rate this email:  Helpful  Somewhat helpful  Not helpful  

                     bounce.io  908 Main Street, Suite 360, Louisville, Colorado Copyright © 2014 bounce.io, All rights reserved. Help
sandeep-m commented 8 years ago

@abhirb1 Hi Abhi...I tried in th way you mention.But It is Crashing the app

ChrisMpitzios commented 8 years ago

it does scroll the gridview but if you try to scroll down immediatelly after the setselection execution it doesnot scroll. You have to scroll a little up and then you can scroll down.