From 7ae0b2f0e1c016c22f87cc9677dda1755629ff91 Mon Sep 17 00:00:00 2001 From: Christian Frost Date: Sun, 29 Apr 2012 10:40:23 +0200 Subject: [PATCH 1/2] Added runtime movie sorting --- .../controller/MovieListController.java | 26 ++++++++++++++++++- src/org/xbmc/api/type/SortType.java | 1 + src/org/xbmc/httpapi/client/VideoClient.java | 6 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) 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..9e9e5707 100644 --- a/src/org/xbmc/httpapi/client/VideoClient.java +++ b/src/org/xbmc/httpapi/client/VideoClient.java @@ -38,6 +38,7 @@ import org.xbmc.httpapi.Connection; import android.graphics.Bitmap; +import android.util.Log; /** * Takes care of everything related to the video database. @@ -81,6 +82,7 @@ public void setHost(Host host) { * @return All movies */ public ArrayList getMovies(INotifiableManager manager, int sortBy, String sortOrder, boolean hideWatched) { + Log.d("database","getmovies"); StringBuilder sb = new StringBuilder(); sb.append(SELECT_MOVIES); sb.append(WHERE_MOVIES); @@ -437,6 +439,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 */ } } From 86e6812e6f92e5554ecbdbc163b2933c00076a9c Mon Sep 17 00:00:00 2001 From: Christian Frost Date: Sun, 29 Apr 2012 10:43:15 +0200 Subject: [PATCH 2/2] Removed debug --- src/org/xbmc/httpapi/client/VideoClient.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/org/xbmc/httpapi/client/VideoClient.java b/src/org/xbmc/httpapi/client/VideoClient.java index 9e9e5707..b37ca741 100644 --- a/src/org/xbmc/httpapi/client/VideoClient.java +++ b/src/org/xbmc/httpapi/client/VideoClient.java @@ -38,7 +38,6 @@ import org.xbmc.httpapi.Connection; import android.graphics.Bitmap; -import android.util.Log; /** * Takes care of everything related to the video database. @@ -82,7 +81,6 @@ public void setHost(Host host) { * @return All movies */ public ArrayList getMovies(INotifiableManager manager, int sortBy, String sortOrder, boolean hideWatched) { - Log.d("database","getmovies"); StringBuilder sb = new StringBuilder(); sb.append(SELECT_MOVIES); sb.append(WHERE_MOVIES);