diff --git a/src/org/xbmc/android/remote/presentation/controller/MovieListController.java b/src/org/xbmc/android/remote/presentation/controller/MovieListController.java index d7c60404..2a59b336 100644 --- a/src/org/xbmc/android/remote/presentation/controller/MovieListController.java +++ b/src/org/xbmc/android/remote/presentation/controller/MovieListController.java @@ -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; @@ -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); } @@ -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); } diff --git a/src/org/xbmc/api/type/SortType.java b/src/org/xbmc/api/type/SortType.java index 9b985881..6c194498 100644 --- a/src/org/xbmc/api/type/SortType.java +++ b/src/org/xbmc/api/type/SortType.java @@ -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; } \ No newline at end of file diff --git a/src/org/xbmc/httpapi/client/VideoClient.java b/src/org/xbmc/httpapi/client/VideoClient.java index 901ea235..b37ca741 100644 --- a/src/org/xbmc/httpapi/client/VideoClient.java +++ b/src/org/xbmc/httpapi/client/VideoClient.java @@ -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 */ } }