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

Support drag and drop moving of favourites #970

Merged
merged 7 commits into from
May 6, 2018
Merged

Conversation

psykzz
Copy link
Collaborator

@psykzz psykzz commented Apr 29, 2018

int currentPos = favAppsList.indexOf(id);
if(currentPos == -1) {
Log.e(TAG, "Couldn't find id in favAppsList");
// TODO: Perhaps we should throw a better error here?
Copy link
Owner

Choose a reason for hiding this comment

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

Logging should be fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

public void setFavoritePosition(MainActivity context, String id, int position) {
String favApps = PreferenceManager.getDefaultSharedPreferences(this.context).
getString("favorite-apps-list", "");
List<String> favAppsList = new ArrayList<>(Arrays.asList(favApps.split(";")));
Copy link
Owner

Choose a reason for hiding this comment

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

I think it would be safer to use DataHandler.getFavorites(), because some favorites might exist in the list but not have an associated POJO, which would make all your calculations wrong.

Using getFavorites, you should be able to compare with the Pojo id and get an index that is guaranteed correct

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Spoke offline, but because im actually getting the favourite by id from the string list in preferences im getting the right position so this isn't a problem.

getString("favorite-apps-list", "");
List<String> favAppsList = new ArrayList<>(Arrays.asList(favApps.split(";")));

return favAppsList.indexOf(id);
Copy link
Owner

Choose a reason for hiding this comment

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

same comment here as above, you might have some weird use cases when users have an item in their favorits that they uninstalled since then, using getFavorites() should remove this problem

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As above

@Neamar
Copy link
Owner

Neamar commented May 3, 2018

I've tested, and it's really good :)

Just one small potential issue, but there is no ripple anymore when you click on a favorite. On a new device this isn't noticeable, but on older devices I think the feedback is important to know that the touch has registered. Do you think it can be added back?

Additionally cleanup dismiss popup and tone up move sensitivity
@psykzz
Copy link
Collaborator Author

psykzz commented May 4, 2018

@Neamar looked into the ripple effect, im not doing anything to explicitly remove it so im not sure how to keep it or bring it back.

@TBog
Copy link
Collaborator

TBog commented May 4, 2018

Does the popup still receive touch events now that you dismiss it on ACTION_DOWN?

@psykzz
Copy link
Collaborator Author

psykzz commented May 6, 2018

@TBog yeah it does

@Neamar Neamar merged commit be1fe18 into Neamar:master May 6, 2018
@Neamar
Copy link
Owner

Neamar commented May 6, 2018

Thanks! Works well :)

@TBog
Copy link
Collaborator

TBog commented May 7, 2018

Should we reopen #837 ?

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.

3 participants