Skip to content

Commit

Permalink
Merge remote-tracking branch 'chrfrost/master'
Browse files Browse the repository at this point in the history
Merging in pull request freezy#33, which adds runtime sorting to movie views.
  • Loading branch information
bitgangsta committed Sep 23, 2012
2 parents 2193f7d + 86e6812 commit d70ae15
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,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 @@ -260,6 +261,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 @@ -326,6 +334,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

0 comments on commit d70ae15

Please sign in to comment.