add reverse sort
This commit is contained in:
parent
1089f4ed51
commit
7a8f349f37
@ -20,24 +20,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
-->
|
-->
|
||||||
<RadioGroup
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/sort_direction"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="10dip"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<RadioButton
|
<CheckBox
|
||||||
style="@style/AlertDialogItem"
|
android:id="@+id/reverse_sort"
|
||||||
android:id="@+id/ascending"
|
android:layout_marginLeft="?android:attr/listPreferredItemPaddingLeft"
|
||||||
android:text="@string/ascending"
|
android:text="@string/reverse_sort"
|
||||||
android:layout_width="0px"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_weight="1" />
|
</LinearLayout>
|
||||||
<RadioButton
|
|
||||||
style="@style/AlertDialogItem"
|
|
||||||
android:id="@+id/descending"
|
|
||||||
android:text="@string/descending"
|
|
||||||
android:layout_width="0px"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
</RadioGroup>
|
|
||||||
|
@ -320,4 +320,5 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
<string name="permission_request_summary">Vanilla Music needs read permission to display your music library</string>
|
<string name="permission_request_summary">Vanilla Music needs read permission to display your music library</string>
|
||||||
<string name="ok">Ok</string>
|
<string name="ok">Ok</string>
|
||||||
|
<string name="reverse_sort">Reverse sort</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -53,12 +53,12 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewParent;
|
import android.view.ViewParent;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.HorizontalScrollView;
|
import android.widget.HorizontalScrollView;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RadioGroup;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.SearchView;
|
import android.widget.SearchView;
|
||||||
@ -827,14 +827,8 @@ public class LibraryActivity
|
|||||||
return true;
|
return true;
|
||||||
case MENU_SORT: {
|
case MENU_SORT: {
|
||||||
MediaAdapter adapter = (MediaAdapter)mCurrentAdapter;
|
MediaAdapter adapter = (MediaAdapter)mCurrentAdapter;
|
||||||
int mode = adapter.getSortMode();
|
LinearLayout header = (LinearLayout)getLayoutInflater().inflate(R.layout.sort_dialog, null);
|
||||||
int check;
|
CheckBox reverseSort = (CheckBox)header.findViewById(R.id.reverse_sort);
|
||||||
if (mode < 0) {
|
|
||||||
check = R.id.descending;
|
|
||||||
mode = ~mode;
|
|
||||||
} else {
|
|
||||||
check = R.id.ascending;
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] itemIds = adapter.getSortEntries();
|
int[] itemIds = adapter.getSortEntries();
|
||||||
String[] items = new String[itemIds.length];
|
String[] items = new String[itemIds.length];
|
||||||
@ -843,8 +837,11 @@ public class LibraryActivity
|
|||||||
items[i] = res.getString(itemIds[i]);
|
items[i] = res.getString(itemIds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioGroup header = (RadioGroup)getLayoutInflater().inflate(R.layout.sort_dialog, null);
|
int mode = adapter.getSortMode();
|
||||||
header.check(check);
|
if (mode < 0) {
|
||||||
|
mode =~ mode;
|
||||||
|
reverseSort.setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.sort_by);
|
builder.setTitle(R.string.sort_by);
|
||||||
@ -954,9 +951,10 @@ public class LibraryActivity
|
|||||||
// subtract 1 for header
|
// subtract 1 for header
|
||||||
int which = list.getCheckedItemPosition() - 1;
|
int which = list.getCheckedItemPosition() - 1;
|
||||||
|
|
||||||
RadioGroup group = (RadioGroup)list.findViewById(R.id.sort_direction);
|
CheckBox reverseSort = (CheckBox)list.findViewById(R.id.reverse_sort);
|
||||||
if (group.getCheckedRadioButtonId() == R.id.descending)
|
if (reverseSort.isChecked()) {
|
||||||
which = ~which;
|
which = ~which;
|
||||||
|
}
|
||||||
|
|
||||||
mPagerAdapter.setSortMode(which);
|
mPagerAdapter.setSortMode(which);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user