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

add no content UI

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