Commit 7194ec08 authored by DESKTOP-NFGF3PG\zxa01's avatar DESKTOP-NFGF3PG\zxa01

add no content UI

parent 2bf070bb
Pipeline #40 canceled with stages
...@@ -23,7 +23,6 @@ public class Api { ...@@ -23,7 +23,6 @@ public class Api {
private static ApiInterface api; private static ApiInterface api;
public static ApiInterface getApi() { public static ApiInterface getApi() {
if (api == null) {
Retrofit retrofit = new Retrofit.Builder() Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://" + Config.getConfig().getGateway()) .baseUrl("http://" + Config.getConfig().getGateway())
.client(new OkHttpClient.Builder() .client(new OkHttpClient.Builder()
...@@ -34,7 +33,6 @@ public class Api { ...@@ -34,7 +33,6 @@ public class Api {
.build(); .build();
api = retrofit.create(ApiInterface.class); api = retrofit.create(ApiInterface.class);
}
return api; return api;
} }
......
...@@ -37,6 +37,7 @@ public class DeviceModel extends BaseObservable { ...@@ -37,6 +37,7 @@ public class DeviceModel extends BaseObservable {
@Override @Override
public void onFailure(Call<List<Device>> call, Throwable t) { public void onFailure(Call<List<Device>> call, Throwable t) {
devicesMLD.setValue(null);
Log.e("readDevices - onFailure()", t.getMessage(), t); Log.e("readDevices - onFailure()", t.getMessage(), t);
} }
} }
......
...@@ -16,6 +16,7 @@ import java.util.List; ...@@ -16,6 +16,7 @@ import java.util.List;
public class DeviceViewModel extends ViewModel { public class DeviceViewModel extends ViewModel {
public ObservableBoolean isLoading = new ObservableBoolean(true); public ObservableBoolean isLoading = new ObservableBoolean(true);
public ObservableBoolean isNoContent = new ObservableBoolean(true);
private DeviceModel deviceModel = new DeviceModel(); private DeviceModel deviceModel = new DeviceModel();
private DeviceAdapter adapter = new DeviceAdapter(R.layout.recycler_view_device, this); private DeviceAdapter adapter = new DeviceAdapter(R.layout.recycler_view_device, this);
private Context context; private Context context;
...@@ -67,6 +68,7 @@ public class DeviceViewModel extends ViewModel { ...@@ -67,6 +68,7 @@ public class DeviceViewModel extends ViewModel {
public void setAdapter(List<Device> devices) { public void setAdapter(List<Device> devices) {
isLoading.set(false); isLoading.set(false);
isNoContent.set(devices == null);
adapter.setDevices(devices); adapter.setDevices(devices);
} }
......
...@@ -35,6 +35,7 @@ public class RecordModel extends BaseObservable { ...@@ -35,6 +35,7 @@ public class RecordModel extends BaseObservable {
@Override @Override
public void onFailure(Call<List<PrivacyChoiceResponse>> call, Throwable t) { public void onFailure(Call<List<PrivacyChoiceResponse>> call, Throwable t) {
privacyChoiceResponsesMLD.setValue(null);
Log.e("fetchRecord - onFailure()", t.getMessage(), t); Log.e("fetchRecord - onFailure()", t.getMessage(), t);
} }
}); });
......
...@@ -16,6 +16,7 @@ import java.util.List; ...@@ -16,6 +16,7 @@ import java.util.List;
public class RecordViewModel extends ViewModel { public class RecordViewModel extends ViewModel {
public ObservableBoolean isLoading = new ObservableBoolean(true); public ObservableBoolean isLoading = new ObservableBoolean(true);
public ObservableBoolean isNoContent = new ObservableBoolean(true);
private RecordModel recordModel = new RecordModel(); private RecordModel recordModel = new RecordModel();
private RecordAdapter adapter = new RecordAdapter(R.layout.recycler_view_record, this); private RecordAdapter adapter = new RecordAdapter(R.layout.recycler_view_record, this);
private Context context; private Context context;
...@@ -69,6 +70,7 @@ public class RecordViewModel extends ViewModel { ...@@ -69,6 +70,7 @@ public class RecordViewModel extends ViewModel {
public void setAdapter(List<PrivacyChoiceResponse> privacyChoiceResponses) { public void setAdapter(List<PrivacyChoiceResponse> privacyChoiceResponses) {
isLoading.set(false); isLoading.set(false);
isNoContent.set(privacyChoiceResponses == null);
adapter.setPrivacyChoiceResponses(privacyChoiceResponses); adapter.setPrivacyChoiceResponses(privacyChoiceResponses);
} }
......
...@@ -47,6 +47,16 @@ ...@@ -47,6 +47,16 @@
android:src="@drawable/ic_add_black_24dp" android:src="@drawable/ic_add_black_24dp"
app:backgroundTint="@color/colorPrimary" /> app:backgroundTint="@color/colorPrimary" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/no_content"
android:textAlignment="center"
android:textSize="@dimen/font"
android:visibility="@{viewModel.isLoading &amp;&amp; viewModel.isNoContent ? View.GONE : View.VISIBLE}" />
</FrameLayout> </FrameLayout>
</layout> </layout>
...@@ -59,6 +59,16 @@ ...@@ -59,6 +59,16 @@
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
android:textSize="@dimen/font"
android:text="@string/no_content"
android:visibility="@{viewModel.isLoading &amp;&amp; viewModel.isNoContent ? View.GONE : View.VISIBLE}" />
</FrameLayout> </FrameLayout>
</layout> </layout>
\ No newline at end of file
...@@ -66,12 +66,12 @@ ...@@ -66,12 +66,12 @@
android:layout_marginTop="@dimen/margin_sm" android:layout_marginTop="@dimen/margin_sm"
android:layout_marginBottom="@dimen/margin_sm" android:layout_marginBottom="@dimen/margin_sm"
android:textColor="@color/colorWhite" android:textColor="@color/colorWhite"
android:background="@drawable/green_radius_background" android:background="@{true ? @drawable/green_radius_background : @drawable/red_radius_background }"
android:paddingLeft="@dimen/padding_sm" android:paddingLeft="@dimen/padding_sm"
android:paddingTop="@dimen/padding_xs" android:paddingTop="@dimen/padding_xs"
android:paddingRight="@dimen/padding_sm" android:paddingRight="@dimen/padding_sm"
android:paddingBottom="@dimen/padding_xs" android:paddingBottom="@dimen/padding_xs"
android:text="同意" android:text="@{true ? @string/record_accept : @string/record_reject }"
android:textSize="@dimen/font_sm" android:textSize="@dimen/font_sm"
tools:text="同意" /> tools:text="同意" />
<TextView <TextView
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
<string name="bind_button_cancel">返回</string> <string name="bind_button_cancel">返回</string>
<string name="bind_qrcode_error">格式錯誤</string> <string name="bind_qrcode_error">格式錯誤</string>
<!--Detail--> <!--Detail-->
<string name="detail_preference_setting">隱私選項設定</string> <string name="detail_preference_setting">隱私選項設定</string>
<string name="detail_detect_report">檢測報告下載</string> <string name="detail_detect_report">檢測報告下載</string>
...@@ -38,6 +37,9 @@ ...@@ -38,6 +37,9 @@
<!--Record--> <!--Record-->
<string name="record_title">隱私選擇記錄</string> <string name="record_title">隱私選擇記錄</string>
<string name="record_view">檢視</string> <string name="record_view">檢視</string>
<string name="record_accept">同意</string>
<string name="record_reject">拒絕</string>
<!--Login--> <!--Login-->
<string name="action_sign_in">登入</string> <string name="action_sign_in">登入</string>
...@@ -51,10 +53,8 @@ ...@@ -51,10 +53,8 @@
<string name="error_incorrect_password">This password is incorrect</string> <string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string> <string name="error_field_required">This field is required</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<!--Common--> <!--Common-->
<string name="dialog">dialog</string> <string name="dialog">dialog</string>
<string name="no_content">查無資料</string>
</resources> </resources>
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