mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-24 09:13:04 +02:00
Hide user selector when there is only one user
This commit is contained in:
@@ -74,6 +74,7 @@ import lecho.lib.hellocharts.view.PieChartView;
|
|||||||
public class OverviewFragment extends Fragment implements FragmentUpdateListener {
|
public class OverviewFragment extends Fragment implements FragmentUpdateListener {
|
||||||
|
|
||||||
private View overviewView;
|
private View overviewView;
|
||||||
|
private View userLineSeparator;
|
||||||
|
|
||||||
private TextView txtTitleUser;
|
private TextView txtTitleUser;
|
||||||
private TextView txtTitleLastMeasurement;
|
private TextView txtTitleLastMeasurement;
|
||||||
@@ -109,6 +110,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
overviewView = inflater.inflate(R.layout.fragment_overview, container, false);
|
overviewView = inflater.inflate(R.layout.fragment_overview, container, false);
|
||||||
|
userLineSeparator = overviewView.findViewById(R.id.userLineSeparator);
|
||||||
|
|
||||||
context = overviewView.getContext();
|
context = overviewView.getContext();
|
||||||
|
|
||||||
@@ -215,19 +217,22 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
|||||||
ArrayList<ScaleUser> scaleUserList = OpenScale.getInstance(getContext()).getScaleUserList();
|
ArrayList<ScaleUser> scaleUserList = OpenScale.getInstance(getContext()).getScaleUserList();
|
||||||
|
|
||||||
int posUser = 0;
|
int posUser = 0;
|
||||||
int pos = 0;
|
|
||||||
|
|
||||||
for (ScaleUser scaleUser : scaleUserList) {
|
for (ScaleUser scaleUser : scaleUserList) {
|
||||||
spinUserAdapter.add(scaleUser.user_name);
|
spinUserAdapter.add(scaleUser.user_name);
|
||||||
|
|
||||||
if (scaleUser.id == currentScaleUser.id) {
|
if (scaleUser.id == currentScaleUser.id) {
|
||||||
posUser = pos;
|
posUser = spinUserAdapter.getCount() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spinUser.setSelection(posUser, true);
|
spinUser.setSelection(posUser, true);
|
||||||
|
|
||||||
|
// Hide user selector when there is only one user
|
||||||
|
int visibility = spinUserAdapter.getCount() < 2 ? View.GONE : View.VISIBLE;
|
||||||
|
txtTitleUser.setVisibility(visibility);
|
||||||
|
spinUser.setVisibility(visibility);
|
||||||
|
userLineSeparator.setVisibility(visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
<View
|
<View
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
android:id="@+id/userLineSeparator"
|
||||||
android:background="@android:color/darker_gray"/>
|
android:background="@android:color/darker_gray"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
<View
|
<View
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
android:id="@+id/userLineSeparator"
|
||||||
android:background="@android:color/darker_gray"/>
|
android:background="@android:color/darker_gray"/>
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user