Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in capacity for a SortableListPreference #1

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

kd7uiy
Copy link

@kd7uiy kd7uiy commented Dec 29, 2013

I've added a new demo which I think will be of some interest. I know I'm planning on using it in my current project a couple of times. It's a SortableListPreference, which I've added to the demo activity. I think it will be of use to others, so I'm handing it back to you with the hopes that you can add it to your project, making it available for others to use as well.

@JayH5
Copy link
Owner

JayH5 commented Dec 30, 2013

Thanks for this.

There is something wrong with the diff, however, possibly due to the edit that you are using doing strange things to whitespace/newlines. See here: http://stackoverflow.com/questions/6134066

Also, there are a few small style fixes I'd like to make.

My branch is just one of many unofficially maintained copies of the original project so I understand if you don't have much reason to put a lot of time and effort into this pull request but I'm willing to work through these changes with you if you want. Let me know what suits you.

@kd7uiy
Copy link
Author

kd7uiy commented Dec 30, 2013

Jamie,

I'm certainly willing to put the effort into it. I put a fair bit of effort
to add the sortable preference list, as I'm planning on using it for my
project, I feel it's a way to give back to the open source community which
I owe so much to. It seems like yours is one of the more active ones
around. I'm using Windows, I suspect that the original is Unix. I'm going
to try to submit it again and give it a shot. Feel free to many any style
changes as well.

Ben

On Mon, Dec 30, 2013 at 12:36 PM, Jamie Hewland [email protected]:

Thanks for this.

There is something wrong with the diff, however, possibly due to the edit
that you are using doing strange things to whitespace/newlines. See here:
http://stackoverflow.com/questions/6134066

Also, there are a few small style fixes I'd like to make.

My branch is just one of many unofficially maintained copies of the
original project so I understand if you don't have much reason to put a lot
of time and effort into this pull request but I'm willing to work through
these changes with you if you want. Let me know what suits you.


Reply to this email directly or view it on GitHubhttps://github.com//pull/1#issuecomment-31357387
.

Ben Pearson
http://www.kd7uiy.com

@JayH5
Copy link
Owner

JayH5 commented Dec 30, 2013

Mine? More active? Cool.

OK, so a few style notes on the changes overall:

  1. The rest of DSLV uses 4-space tabs. From the new files you've added it looks like you've used 2-space tabs
  2. Be consistent with code block formatting. Put the opening brace on the same line as the starting (if/for) statement, e.g.:
if (true)
{
    do.x();
}

Should be:

if (true) {
    do.x();
}

...also you should avoid if/for statements with no braces as per the Android code style guidelines.

  1. Use consistent spacing around symbols. There should be spacing on either side of all curly braces as well as colons in for loops.

Style tweaks are obviously easier/quicker things for me to spot...actual code fixes take more time...but I will add a few in the diff.

Thanks again.

@@ -640,7 +640,7 @@ public ListAdapter getInputAdapter() {
}
}

private class AdapterWrapper implements WrapperListAdapter {
private class AdapterWrapper extends BaseAdapter implements WrapperListAdapter {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will prevent a crash in the demo app. Warp just crashes without
it. Looking around, this seemed like the best solution, and it works well,
but if you have another one, I'm opened to it.

Ben.

On Mon, Dec 30, 2013 at 2:35 PM, Jamie Hewland [email protected]:

In library/src/com/mobeta/android/dslv/DragSortListView.java:

@@ -640,7 +640,7 @@ public ListAdapter getInputAdapter() {
}
}

  • private class AdapterWrapper implements WrapperListAdapter {
  • private class AdapterWrapper extends BaseAdapter implements WrapperListAdapter {

Is there a reason for this change?


Reply to this email directly or view it on GitHubhttps://github.com//pull/1/files#r8590130
.

Ben Pearson
http://www.kd7uiy.com

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just going to combine the rest of the comments into a single email.

  1. Yes, that blurb of code is required on KitKit, or else it will crash. If
    you've seen a rash of releases recently "To fix a crash on KitKat", I bet
    that's what it is.
  2. I'm going to keep the exceptions in place, instead of returning -1. I'd
    rather thrown an exception in the case that something isn't right, because
    it's easier to debug exceptions. And the exception thrown has actually
    saved me a few times when debugging... I did change it to
    IllegalStateException, per your suggestion, however.
  3. I'm not entirely sure what you meant about the space/tabs. I've
    "corrected indentation" on Eclipse, hopefully that clears it up.
  4. No problem being a stickler. Part of the reason I wanted to do this was
    to get someone else to look at a major block of code that combines things
    that I've never done before, and it helps to have a second set of eyes.
    I've rarely had someone who actually was a stickler about code look at
    mine, so...
  5. The main setting blurb, was that about the comments there? Essentially,
    they came from Android when you create a new project, but I can get rid of
    them, if you want. I'm guessing it was the last line, the inherited
    document, so I removed that.
  6. As far as your project being one of the more active, well, I admittedly
    looked at recent updates to pick one. Still, I'm planning on sticking with
    your code base, should I update the code, so...

In addition to your changes, I made a few other changes as well, and tested
it out. Primarily, I ran Lint and cleaned up a few things, including
outside of the code I touched, so that's why a whole bunch of files were
touched. I also found a bug in another class, which caused a crash in
Background Handle. I'm not 100% confident of the fix, but it should do for
now...

Ben

On Mon, Dec 30, 2013 at 4:55 PM, Ben Pearson [email protected] wrote:

This change will prevent a crash in the demo app. Warp just crashes
without it. Looking around, this seemed like the best solution, and it
works well, but if you have another one, I'm opened to it.

Ben.

On Mon, Dec 30, 2013 at 2:35 PM, Jamie Hewland [email protected]:

In library/src/com/mobeta/android/dslv/DragSortListView.java:

@@ -640,7 +640,7 @@ public ListAdapter getInputAdapter() {
}
}

  • private class AdapterWrapper implements WrapperListAdapter {
  • private class AdapterWrapper extends BaseAdapter implements WrapperListAdapter {

Is there a reason for this change?


Reply to this email directly or view it on GitHubhttps://github.com//pull/1/files#r8590130
.

Ben Pearson
http://www.kd7uiy.com

Ben Pearson
http://www.kd7uiy.com

@JayH5
Copy link
Owner

JayH5 commented Dec 30, 2013

Apologies for being kind of a stickler...

Handle, and probably other classes that extend DSLVFragment.
@kd7uiy
Copy link
Author

kd7uiy commented Dec 30, 2013

The change to the core library prevents a crash. As far as other changes:

  1. Yes, that blurb of code is required on KitKit, or else it will crash. If you've seen a rash of releases recently "To fix a crash on KitKat", I bet that's what it is.
  2. I'm going to keep the exceptions in place, instead of returning -1. I'd rather thrown an exception in the case that something isn't right, because it's easier to debug exceptions. And the exception thrown has actually saved me a few times when debugging... I did change it to IllegalStateException, per your suggestion, however.
  3. I'm not entirely sure what you meant about the space/tabs. I've "corrected indentation" on Eclipse, hopefully that clears it up.
  4. No problem being a stickler. Part of the reason I wanted to do this was to get someone else to look at a major block of code that combines things that I've never done before, and it helps to have a second set of eyes. I've rarely had someone who actually was a stickler about code look at mine, so...
  5. The main setting blurb, was that about the comments there? Essentially, they came from Android when you create a new project, but I can get rid of them, if you want. I'm guessing it was the last line, the inherited document, so I removed that.
  6. As far as your project being one of the more active, well, I admittedly looked at recent updates to pick one. Still, I'm planning on sticking with your code base, should I update the code, so...

In addition to your changes, I made a few other changes as well, and tested it out. Primarily, I ran Lint and cleaned up a few things, including outside of the code I touched, so that's why a whole bunch of files were touched. I also found a bug in another class, which caused a crash in Background Handle. I'm not 100% confident of the fix, but it should do for now...

@JayH5
Copy link
Owner

JayH5 commented Dec 31, 2013

Cool, thanks this is looking good. I won't have time to look at this properly until probably late in the day tomorrow.
Have a good New Year's 🎉

@kd7uiy
Copy link
Author

kd7uiy commented Jan 10, 2014

Just curious if you've gotten to this anytime recently. Hope you had a good New Years!

@@ -0,0 +1,271 @@
/*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely this should be in the library and not the demo app?

@kd7uiy
Copy link
Author

kd7uiy commented Jan 13, 2014

I can go ahead and make the move, I think you are right that it fits well as a library application. I'll do that shortly when I get a chance, hopefully this week.

@kd7uiy
Copy link
Author

kd7uiy commented Jan 26, 2014

To put this in the main library will require more work that I'm going to be able to do for a while. Specifically, it needs to get references for the list item, and text handles, and while I'm confident I could do it, it'd take a while.

Bottom line is, it works now as a reference, and if I find the time sometime soon I'll try and get it ported to the main library. I leave it up to you if you want to include it in your list of demo apps.

Finished the process to convert DragSortListPreference to a part of the
main library. It now doesn't depend on external resources, and can be
controlled via styleables.
@kd7uiy
Copy link
Author

kd7uiy commented Mar 6, 2014

Had the time to finish it now, I now have DragSortListPreference, and an example of how to use it. The documentation should probably still be updated, but overall, it looks like it'll work.

@JayH5
Copy link
Owner

JayH5 commented Mar 7, 2014

Thanks, looking good 👍

I'll review this properly over the weekend. Just two things before that:

  1. Can you make sure you use unix-style line endings (or get your git to convert them for you).
  2. This needs a bit of git work. Can you squash your 12 commits into 1? I think this also needs to be rebased against my fork as I've made some changes since this pull request was first opened.

woudt and others added 8 commits August 9, 2014 22:16
Fix bug where an empty preference set would lead to an IllegalStateException
- Add check to onScroll in DragSortController in response to instances seen when these events were null.
Update to gradle 1.12 and update build tools [build]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants