LungaSdu / alogcat

Automatically exported from code.google.com/p/alogcat
0 stars 0 forks source link

Enhancement suggestion: Auto-scroll only when at the bottom of the list #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I really like this App. Clean and simple interface. 

I like the auto-scroll feature as well, but often I scroll upwards in the list 
of entries, just to check something out. And when I forget to "pause" the 
playback first, it jacks me down to the bottom again when new entries arrive. 

It got a bit frustrating, so I download the source code and made the following 
changes:

private void cat(String s) {
   ...
   mLogEntryAdapter.add(entry);
   if (mPrefs.isAutoScroll() && isAtBottomOfLog()) {
      mLogList.post(new Runnable() {
         public void run() {
            mLogList.setSelection(mLogEntryAdapter.getCount() - 1);
         }
      });
}

private boolean isAtBottomOfLog() {
   // Add one to getLastVisiblePosition to account 
   // for the new entry just added and not yet scrolled
   return mLogList.getLastVisiblePosition() == -1 ||
     mLogList.getLastVisiblePosition() +1 == mLogList.getCount() -1; 
}

Now it only auto-scrolls if I'm already at the bottom of the list.

Your welcome to use the the above as you see fit, or to disregard it. Thanks 
for a great tool.

/Nicolai

Original issue reported on code.google.com by nicolai....@gmail.com on 3 Mar 2011 at 10:45

GoogleCodeExporter commented 9 years ago
thanks for this. i'll integrate it as soon as i have a chance.

Original comment by jeffrey.blattman@gmail.com on 3 Mar 2011 at 11:01

GoogleCodeExporter commented 9 years ago
fixed. thanks for the code and ideas.

Original comment by jeffrey.blattman@gmail.com on 6 Mar 2011 at 7:09