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