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

Runtime sorting for movies #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public class MovieListController extends ListController implements IController {
public static final int MENU_SORT_BY_RATING_DESC = 26;
public static final int MENU_SORT_BY_DATE_ADDED_ASC = 27;
public static final int MENU_SORT_BY_DATE_ADDED_DESC = 28;

public static final int MENU_SORT_BY_RUNTIME_ASC = 29;
public static final int MENU_SORT_BY_RUNTIME_DESC = 30;

private Actor mActor;
private Genre mGenre;
Expand Down Expand Up @@ -233,6 +234,13 @@ public void onCreateOptionsMenu(Menu menu) {
sortMenu.add(2, MENU_SORT_BY_RATING_DESC, 0, "by Rating descending");
sortMenu.add(2, MENU_SORT_BY_DATE_ADDED_ASC, 0, "by Date Added ascending");
sortMenu.add(2, MENU_SORT_BY_DATE_ADDED_DESC, 0, "by Date Added descending");

/* Implemented by Christian Frost - begin */
sortMenu.add(2, MENU_SORT_BY_RUNTIME_ASC, 0, "by Runtime ascending");
sortMenu.add(2, MENU_SORT_BY_RUNTIME_DESC, 0, "by Runtime descending");
/* Implemented by Christian Frost - end */


// menu.add(0, MENU_SWITCH_VIEW, 0, "Switch view").setIcon(R.drawable.menu_view);
createShowHideWatchedToggle(menu);
}
Expand Down Expand Up @@ -299,6 +307,22 @@ public void onOptionsItemSelected(MenuItem item) {
ed.commit();
fetch();
break;
/* Implemented by Christian Frost - begin */
case MENU_SORT_BY_RUNTIME_ASC:
ed = mActivity.getPreferences(Context.MODE_PRIVATE).edit();
ed.putInt(AbstractManager.PREF_SORT_BY_PREFIX + AbstractManager.PREF_SORT_KEY_MOVIE, SortType.RUNTIME);
ed.putString(AbstractManager.PREF_SORT_ORDER_PREFIX + AbstractManager.PREF_SORT_KEY_MOVIE, SortType.ORDER_ASC);
ed.commit();
fetch();
break;
case MENU_SORT_BY_RUNTIME_DESC:
ed = mActivity.getPreferences(Context.MODE_PRIVATE).edit();
ed.putInt(AbstractManager.PREF_SORT_BY_PREFIX + AbstractManager.PREF_SORT_KEY_MOVIE, SortType.RUNTIME);
ed.putString(AbstractManager.PREF_SORT_ORDER_PREFIX + AbstractManager.PREF_SORT_KEY_MOVIE, SortType.ORDER_DESC);
ed.commit();
fetch();
break;
/* Implemented by Christian Frost - end */
default:
super.onOptionsItemSelected(item);
}
Expand Down
1 change: 1 addition & 0 deletions src/org/xbmc/api/type/SortType.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public abstract class SortType {
public static final int EPISODE_TITLE = 9;
public static final int EPISODE_RATING = 10;
public static final int DATE_ADDED = 11;
public static final int RUNTIME = 12;

public static final int DONT_SORT = -1;
}
4 changes: 4 additions & 0 deletions src/org/xbmc/httpapi/client/VideoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ private String moviesOrderBy(int sortBy, String sortOrder) {
return " ORDER BY ROUND(c05, 2) " + sortOrder;
case SortType.DATE_ADDED:
return " ORDER BY files.idFile " + sortOrder;
/* Implemented by Christian Frost - begin */
case SortType.RUNTIME:
return " ORDER BY CAST(c11 as INT) " + sortOrder;
/* Implemented by Christian Frost - end */
}
}

Expand Down