Commit 8fd8514c authored by Mygod's avatar Mygod

Refine layout for #598

parent 0aad8f13
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" xmlns:app="http://schemas.android.com/apk/res-auto"
android:clickable="true" android:layout_height="wrap_content"
android:foreground="@android:color/transparent" android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_height="260dp"
android:layout_width="match_parent"
android:layout_margin="8dp" android:layout_margin="8dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:clickable="true"
app:cardElevation="5dp" app:cardElevation="5dp"
app:cardBackgroundColor="#EEEEEE" app:cardBackgroundColor="#EEEEEE">
>
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<include layout="@layout/toolbar_light_dark"/> <include layout="@layout/toolbar_light_dark"/>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/profilesList" android:id="@+id/profilesList"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent"/> android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
</LinearLayout>
\ No newline at end of file
...@@ -27,11 +27,7 @@ class ShadowsocksQuickSwitchActivity extends AppCompatActivity { ...@@ -27,11 +27,7 @@ class ShadowsocksQuickSwitchActivity extends AppCompatActivity {
def bind(item: Profile) { def bind(item: Profile) {
this.item = item this.item = item
text.setText(item.name) text.setText(item.name)
if (item.id == ShadowsocksApplication.profileId) { text.setChecked(item.id == ShadowsocksApplication.profileId)
text.setChecked(true)
} else {
text.setChecked(false)
}
} }
def onClick(v: View) { def onClick(v: View) {
...@@ -74,5 +70,8 @@ class ShadowsocksQuickSwitchActivity extends AppCompatActivity { ...@@ -74,5 +70,8 @@ class ShadowsocksQuickSwitchActivity extends AppCompatActivity {
profilesList.setLayoutManager(lm) profilesList.setLayoutManager(lm)
profilesList.setItemAnimator(new DefaultItemAnimator) profilesList.setItemAnimator(new DefaultItemAnimator)
profilesList.setAdapter(profilesAdapter) profilesList.setAdapter(profilesAdapter)
if (ShadowsocksApplication.profileId >= 0) lm.scrollToPosition(profilesAdapter.profiles.zipWithIndex.collectFirst {
case (profile, i) if profile.id == ShadowsocksApplication.profileId => i + 1
}.getOrElse(0))
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment