host config view

This commit is contained in:
MooN 2025-12-04 10:32:31 +06:30
parent 20417eb811
commit eed7dd4680
4 changed files with 378 additions and 198 deletions

View File

@ -1,46 +0,0 @@
package com.utsmm.kbz.ui.settings;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.utsmm.kbz.databinding.ItemHostConfigBinding;
import java.util.ArrayList;
import java.util.List;
public class HostConfigAdapter extends RecyclerView.Adapter<HostConfigAdapter.Holder> {
private List<HostConfigItem> list = new ArrayList<>();
public void setList(List<HostConfigItem> newList){
this.list = newList;
notifyDataSetChanged();
}
@NonNull
@Override
public HostConfigAdapter.Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ItemHostConfigBinding binding = ItemHostConfigBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new Holder(binding);
}
@Override
public void onBindViewHolder(@NonNull HostConfigAdapter.Holder holder, int position) {
holder.binding.setItem(list.get(position));
}
@Override
public int getItemCount() {
return list.size();
}
static class Holder extends RecyclerView.ViewHolder {
ItemHostConfigBinding binding;
Holder(ItemHostConfigBinding bind){
super(bind.getRoot());
binding = bind;
}
}
}

View File

@ -2,6 +2,11 @@ package com.utsmm.kbz.ui.settings;
import static androidx.databinding.DataBindingUtil.getBinding; import static androidx.databinding.DataBindingUtil.getBinding;
import static com.utsmyanmar.baselib.BaseApplication.sunmiPrinterService;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -10,6 +15,7 @@ import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import android.os.RemoteException;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -21,6 +27,7 @@ import com.nexgo.oaf.apiv3.DeviceEngine;
import com.nexgo.oaf.apiv3.DeviceInfo; import com.nexgo.oaf.apiv3.DeviceInfo;
import com.nexgo.oaf.apiv3.SdkResult; import com.nexgo.oaf.apiv3.SdkResult;
import com.nexgo.oaf.apiv3.device.printer.AlignEnum; import com.nexgo.oaf.apiv3.device.printer.AlignEnum;
import com.nexgo.oaf.apiv3.device.printer.GrayLevelEnum;
import com.nexgo.oaf.apiv3.device.printer.Printer; import com.nexgo.oaf.apiv3.device.printer.Printer;
import com.utsmm.kbz.BR; import com.utsmm.kbz.BR;
import com.utsmm.kbz.R; import com.utsmm.kbz.R;
@ -28,11 +35,22 @@ import com.utsmm.kbz.config.Constants;
import com.utsmm.kbz.databinding.FragmentHostConfigBinding; import com.utsmm.kbz.databinding.FragmentHostConfigBinding;
import com.utsmyanmar.baselib.fragment.DataBindingFragment; import com.utsmyanmar.baselib.fragment.DataBindingFragment;
import com.utsmyanmar.baselib.util.DataBindingConfig; import com.utsmyanmar.baselib.util.DataBindingConfig;
import com.utsmyanmar.baselib.util.DialogCallback;
import com.utsmyanmar.paylibs.PayLibsUtils;
import com.utsmyanmar.paylibs.print.PaperRollStatusCallback;
import com.utsmyanmar.paylibs.print.PrintHelper;
import com.utsmyanmar.paylibs.utils.LogUtil;
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation; import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation;
import com.utsmyanmar.paylibs.utils.print_utils.BitmapUtils;
import java.util.Objects;
public class HostConfigFragment extends DataBindingFragment { public class HostConfigFragment extends DataBindingFragment {
private HostConfigViewModel viewModel; private HostConfigViewModel viewModel;
protected Printer printer;
int FONT_NORMAL = 20;
int FONT_HEADER = 28;
@Override @Override
protected void initViewModel() { protected void initViewModel() {
@ -50,6 +68,7 @@ public class HostConfigFragment extends DataBindingFragment {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
FragmentHostConfigBinding binding = (FragmentHostConfigBinding) this.binding; FragmentHostConfigBinding binding = (FragmentHostConfigBinding) this.binding;
viewModel.loadConfig();
} }
@Override @Override
@ -80,118 +99,146 @@ public class HostConfigFragment extends DataBindingFragment {
} }
public void onPrint(){ public void onPrint(){
startPrintProcess();
} }
} }
} private void startPrintProcess() {
//public void onClickPrintConfig() { DeviceEngine engine = APIProxy.getDeviceEngine(requireContext());
// printer = engine.getPrinter();
// DeviceEngine deviceEngine = APIProxy.getDeviceEngine(requireContext()); int printerStatus = printer.getStatus();
// Printer printer = deviceEngine.getPrinter(); if(printerStatus != SdkResult.Success){
// DeviceInfo deviceInfo = deviceEngine.getDeviceInfo(); Log.e("Print Config", "Printer Error: " + printerStatus);
// return;
// int FONT_NORMAL = 24; }
// int FONT_HEADER = 32; printer.setGray(GrayLevelEnum.LEVEL_2);
// printer.setTypeface(Typeface.SANS_SERIF);
// int status = printer.getStatus(); SystemParamsOperation sp = SystemParamsOperation.getInstance();
// if (status != SdkResult.Success) {
// Log.d("Printer", "Printer error: " + status);
// return; Bitmap bitmap = BitmapFactory.decodeResource(requireContext().getResources(), com.utsmyanmar.paylibs.R.drawable.print_kbz_logo);
// } printLogo(bitmap);
// printer.appendPrnStr("\n", FONT_NORMAL, AlignEnum.CENTER, false);
// SystemParamsOperation sp = SystemParamsOperation.getInstance(); printer.appendPrnStr("TERMINAL CONFIGURATION", FONT_HEADER, AlignEnum.CENTER, true);
// printer.appendPrnStr("\n", FONT_NORMAL, AlignEnum.CENTER, false);
// String addr1 = sp.getMerchantAddress(); printer.appendPrnStr(sp.getMerchantName(), FONT_NORMAL, AlignEnum.LEFT, false);
// String addr2 = sp.getMerchantAddress2(); printer.appendPrnStr(sp.getMerchantPhoneNo(), FONT_NORMAL, AlignEnum.LEFT, false);
// String phone = sp.getMerchantPhoneNo(); printer.appendPrnStr(sp.getMerchantAddress(), FONT_NORMAL, AlignEnum.CENTER, false);
// if (addr2 == null) addr2 = ""; printer.appendPrnStr(sp.getMerchantAddress2(), FONT_NORMAL, AlignEnum.CENTER, false);
// if (phone == null || phone.trim().isEmpty()) phone = ""; printer.appendPrnStr("\n--------------------------------\n", FONT_NORMAL, AlignEnum.LEFT, false);
// printer.appendPrnStr("PRIMARY HOST", FONT_NORMAL, AlignEnum.LEFT, true);
// printer.setGray(getGrayLevel()); printer.appendPrnStr("Name : " + sp.getHostName(), FONT_NORMAL, AlignEnum.LEFT, false);
// printer.appendPrnStr("TID : " + sp.getTerminalId(), FONT_NORMAL, AlignEnum.LEFT, false);
// // ================== Header ================== printer.appendPrnStr("MID : " + sp.getMerchantId(), FONT_NORMAL, AlignEnum.LEFT, false);
// printer.appendPrnStr("==== Device Configs ====", FONT_HEADER, AlignEnum.CENTER, true); String ipAddress = sp.getIpAddress();
// printer.appendPrnStr(" ", FONT_NORMAL, AlignEnum.CENTER, false); String[] ipAndPort = splitIpAndPort(ipAddress);
// String ip = ipAndPort[0];
// if(!TextUtils.isEmpty(addr1)) String port = ipAndPort[1];
// printer.appendPrnStr(addr1, FONT_NORMAL, AlignEnum.CENTER, true); printer.appendPrnStr("Primary Ip : " + ip, FONT_NORMAL, AlignEnum.LEFT, true);
// if(!TextUtils.isEmpty(addr2)) printer.appendPrnStr("Primary Port : " + port, FONT_NORMAL, AlignEnum.LEFT, true);
// printer.appendPrnStr(addr2, FONT_NORMAL, AlignEnum.CENTER, true); String secIpAddress = sp.getSecIpAddress();
// if(!TextUtils.isEmpty(phone)) String[] secIpAndPort = splitIpAndPort(secIpAddress);
// printer.appendPrnStr(phone, FONT_NORMAL, AlignEnum.CENTER, true); String secIp = secIpAndPort[0];
// String secPort = secIpAndPort[1];
// printer.appendPrnStr(" ", FONT_NORMAL, AlignEnum.CENTER, false); printer.appendPrnStr("Secondary Ip : " + secIp, FONT_NORMAL, AlignEnum.LEFT, true);
// printer.appendPrnStr("Secondary Port : " + secPort, FONT_NORMAL, AlignEnum.LEFT, true);
// printer.appendPrnStr("Currency Code : " + sp.getCurrencyType(), FONT_NORMAL, AlignEnum.LEFT, true);
// // ================== Device Info ================== printer.appendPrnStr("\n--------------------------------\n", FONT_NORMAL, AlignEnum.LEFT, false);
// printer.appendPrnStr("Device S/N", deviceInfo.getSn(), FONT_NORMAL, true);
// printer.appendPrnStr(" ", FONT_NORMAL, AlignEnum.CENTER, false); if (!TextUtils.isEmpty(sp.getSecHostName())) {
// printer.appendPrnStr("SECONDARY HOST", FONT_NORMAL, AlignEnum.LEFT, true);
// printer.appendPrnStr("Name : " + sp.getSecHostName(), FONT_NORMAL, AlignEnum.LEFT, false);
// // ================== Host Section ================== printer.appendPrnStr("TID : " + sp.getSecHostTerminalId(), FONT_NORMAL, AlignEnum.LEFT, false);
// printer.appendPrnStr("HOSTS", FONT_HEADER, AlignEnum.LEFT, true); printer.appendPrnStr("MID : " + sp.getSecHostMerchantId(), FONT_NORMAL, AlignEnum.LEFT, false);
// printer.appendPrnStr(" ", FONT_NORMAL, AlignEnum.CENTER, false); String secHostIpAddress = sp.getSecHostIpAddress();
// String[] secHostIpAndPort = splitIpAndPort(secHostIpAddress);
// // ---- Primary Host ---- String secHostIp = secHostIpAndPort[0];
// printer.appendPrnStr("Name :", sp.getHostName(), FONT_NORMAL, false); String secHostPort = secHostIpAndPort[1];
// printTwoColWrapped(printer, "IP :", sp.getIpAddress(), FONT_NORMAL, false); printer.appendPrnStr("Primary Ip : " + secHostIp, FONT_NORMAL, AlignEnum.LEFT, true);
// printTwoColWrapped(printer, "Sec IP :", sp.getSecIpAddress(), FONT_NORMAL, false); printer.appendPrnStr("Primary Port : " + secHostPort, FONT_NORMAL, AlignEnum.LEFT, true);
// printer.appendPrnStr("MID :", sp.getMerchantId(), FONT_NORMAL, false); String secHostSecIpAddress = sp.getSecHostSecIpAddress();
// printer.appendPrnStr("TID :", sp.getTerminalId(), FONT_NORMAL, false); String[] SecHostSecIpAndPort = splitIpAndPort(secHostSecIpAddress);
// String secHostSecIp = SecHostSecIpAndPort[0];
// printer.appendPrnStr("--------------------------------", FONT_NORMAL, AlignEnum.LEFT, false); String secHostSecPort = SecHostSecIpAndPort[1];
// printer.appendPrnStr("Secondary Ip : " + secHostSecIp, FONT_NORMAL, AlignEnum.LEFT, true);
// // ---- Secondary Host ---- printer.appendPrnStr("Secondary Port : " + secHostSecPort, FONT_NORMAL, AlignEnum.LEFT, true);
// if (!TextUtils.isEmpty(sp.getSecHostName())) { printer.appendPrnStr("Currency Code : " + sp.getCurrencyType(), FONT_NORMAL, AlignEnum.LEFT, true);
// printer.appendPrnStr("\n--------------------------------\n", FONT_NORMAL, AlignEnum.LEFT, false);
// printer.appendPrnStr("Name :", sp.getSecHostName(), FONT_NORMAL, false); }
// printTwoColWrapped(printer, "IP :", sp.getSecHostIpAddress(), FONT_NORMAL, false);
// printTwoColWrapped(printer, "Sec IP :", sp.getSecHostSecIpAddress(), FONT_NORMAL, false); printer.startPrint(true, ret -> {
// printer.appendPrnStr("MID :", sp.getSecHostMerchantId(), FONT_NORMAL, false); Log.d("Print", "Print result = " + ret);
// printer.appendPrnStr("TID :", sp.getSecHostTerminalId(), FONT_NORMAL, false); });
// }
// printer.appendPrnStr("--------------------------------", FONT_NORMAL, AlignEnum.LEFT, false);
// } private String[] splitIpAndPort(String raw) {
// if (raw == null || raw.trim().isEmpty()) {
// // ================== Start Printing ================== return new String[]{"", ""};
// printer.startPrint(true, ret -> { }
// if(ret == SdkResult.Success){
// Log.d("Printer", "Print success"); raw = raw.trim();
// } else {
// Log.d("Printer", "Print failed: " + ret); // If starts with http/https
// } if (raw.startsWith("http://") || raw.startsWith("https://")) {
// });
//} // Attempt to extract host + port via URL
// try {
//private void printTwoColWrapped(Printer p, String left, String right, int font, Boolean isBold) { java.net.URL url = new java.net.URL(raw);
//
// if (right == null) right = ""; String host = url.getHost(); // hostname or IP
// int port = url.getPort(); // -1 if no port
// int maxRight = 24; // recommended width for right column String path = url.getPath(); // /api or /
//
// // If right text fits print normally // If port exists split normally
// if (right.length() <= maxRight) { if (port != -1) {
// p.appendPrnStr(left, right, font, isBold); return new String[]{
// return; host, // e.g. 10.10.10.10
// } String.valueOf(port) // e.g. 5000
// };
// // Otherwise wrap it }
// int start = 0;
// boolean firstLine = true; // No port do NOT split
// return new String[]{ raw, "" };
// while (start < right.length()) {
// int end = Math.min(start + maxRight, right.length()); } catch (Exception e) {
// String part = right.substring(start, end); // fail-safe: do not split
// return new String[]{ raw, "" };
// if (firstLine) { }
// p.appendPrnStr(left, part, font, isBold); }
// firstLine = false;
// } else { // Normal "IP:Port" split
// // subsequent lines: blank left column int idx = raw.lastIndexOf(":");
// p.appendPrnStr(" ", part, font, isBold);
// } if (idx == -1) {
// return new String[]{ raw, "" };
// start += maxRight; }
// }
//} return new String[]{
raw.substring(0, idx),
raw.substring(idx + 1)
};
}
private void printLogo(Bitmap logoBitmap) {
try {
if (logoBitmap == null || printer == null) return;
Bitmap bmp = logoBitmap;
// Max printable width = 384px
if (bmp.getWidth() > 384) {
int newHeight = (int) (bmp.getHeight() * (384f / bmp.getWidth()));
bmp = Bitmap.createScaledBitmap(bmp, 384, newHeight, true);
}
printer.appendPrnStr("\n", FONT_NORMAL, AlignEnum.CENTER, false);
printer.appendImage(bmp, AlignEnum.CENTER);
printer.appendPrnStr("\n", FONT_NORMAL, AlignEnum.CENTER, false);
} catch (Exception e) {
Log.e("PRINT", "Logo error: " + e.getMessage());
}
}
}

View File

@ -1,26 +1,123 @@
package com.utsmm.kbz.ui.settings; package com.utsmm.kbz.ui.settings;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation; import com.utsmyanmar.paylibs.utils.core_utils.SystemParamsOperation;
public class HostConfigViewModel extends ViewModel { public class HostConfigViewModel extends ViewModel {
public String merchantAddress1; public MutableLiveData<String> merchantName = new MutableLiveData<>();
public String merchantAddress2; public MutableLiveData<String> merchantPhone = new MutableLiveData<>();
public String merchantPhoneNumber; public MutableLiveData<String> merchantAddress1 = new MutableLiveData<>();
public String merchantName; public MutableLiveData<String> merchantAddress2 = new MutableLiveData<>();
public String merchantPhone;
// Primary Host
public MutableLiveData<String> hostName = new MutableLiveData<>();
public MutableLiveData<String> tid = new MutableLiveData<>();
public MutableLiveData<String> mid = new MutableLiveData<>();
public MutableLiveData<String> primaryIp = new MutableLiveData<>();
public MutableLiveData<String> primaryPort = new MutableLiveData<>();
public MutableLiveData<String> secondaryIp = new MutableLiveData<>();
public MutableLiveData<String> secondaryPort = new MutableLiveData<>();
public MutableLiveData<String> currencyCode = new MutableLiveData<>();
// Secondary Host
public MutableLiveData<String> secHostName = new MutableLiveData<>();
public MutableLiveData<String> secHostTid = new MutableLiveData<>();
public MutableLiveData<String> secHostMid = new MutableLiveData<>();
public MutableLiveData<String> secHostPrimaryIp = new MutableLiveData<>();
public MutableLiveData<String> secHostPrimaryPort = new MutableLiveData<>();
public MutableLiveData<String> secHostSecondaryIp = new MutableLiveData<>();
public MutableLiveData<String> secHostSecondaryPort = new MutableLiveData<>();
public void loadConfig() {
public HostConfigViewModel(){
SystemParamsOperation sp = SystemParamsOperation.getInstance(); SystemParamsOperation sp = SystemParamsOperation.getInstance();
merchantAddress1 = sp.getMerchantAddress();
merchantAddress2 = sp.getMerchantAddress2(); // Merchant Info
merchantPhoneNumber = sp.getMerchantPhoneNo(); merchantName.setValue(sp.getMerchantName());
merchantName = sp.getMerchantName(); merchantPhone.setValue(sp.getMerchantPhoneNo());
merchantPhone = sp.getMerchantPhoneNo(); merchantAddress1.setValue(sp.getMerchantAddress());
merchantAddress2.setValue(sp.getMerchantAddress2());
// PRIMARY HOST
hostName.setValue(sp.getHostName());
tid.setValue(sp.getTerminalId());
mid.setValue(sp.getMerchantId());
String[] pri = split(sp.getIpAddress());
primaryIp.setValue(pri[0]);
primaryPort.setValue(pri[1]);
String[] sec = split(sp.getSecIpAddress());
secondaryIp.setValue(sec[0]);
secondaryPort.setValue(sec[1]);
currencyCode.setValue(sp.getCurrencyType() != null ? sp.getCurrencyType().toString() : "");
if (sp.getSecHostName() != null && !sp.getSecHostName().isEmpty()) {
secHostName.setValue(sp.getSecHostName());
secHostTid.setValue(sp.getSecHostTerminalId());
secHostMid.setValue(sp.getSecHostMerchantId());
String[] shp = split(sp.getSecHostIpAddress());
secHostPrimaryIp.setValue(shp[0]);
secHostPrimaryPort.setValue(shp[1]);
String[] shs = split(sp.getSecHostSecIpAddress());
secHostSecondaryIp.setValue(shs[0]);
secHostSecondaryPort.setValue(shs[1]);
}
} }
private String saftString(String s){ private String[] split(String raw) {
return s == null ? "" : s; if (raw == null || raw.trim().isEmpty()) {
return new String[]{"", ""};
}
raw = raw.trim();
// If starts with http/https
if (raw.startsWith("http://") || raw.startsWith("https://")) {
// Attempt to extract host + port via URL
try {
java.net.URL url = new java.net.URL(raw);
String host = url.getHost(); // hostname or IP
int port = url.getPort(); // -1 if no port
String path = url.getPath(); // /api or /
// If port exists split normally
if (port != -1) {
return new String[]{
host, // e.g. 10.10.10.10
String.valueOf(port) // e.g. 5000
};
}
// No port do NOT split
return new String[]{ raw, "" };
} catch (Exception e) {
// fail-safe: do not split
return new String[]{ raw, "" };
}
}
// Normal "IP:Port" split
int idx = raw.lastIndexOf(":");
if (idx == -1) {
return new String[]{ raw, "" };
}
return new String[]{
raw.substring(0, idx),
raw.substring(idx + 1)
};
} }
} }

View File

@ -6,6 +6,7 @@
<data> <data>
<import type="android.view.View"/> <import type="android.view.View"/>
<import type="android.text.TextUtils" />
<variable <variable
name="viewModel" name="viewModel"
type="com.utsmm.kbz.ui.settings.HostConfigViewModel" /> type="com.utsmm.kbz.ui.settings.HostConfigViewModel" />
@ -48,38 +49,119 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<!-- HEADER -->
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:text="TERMINAL CONFIGURATION"
android:gravity="center"
android:text="TERMINAL CONFIGURATION" android:text="TERMINAL CONFIGURATION"
/> android:gravity="center"
<TextView android:textStyle="bold"
android:layout_width="match_parent" android:textSize="18sp"
android:layout_height="wrap_content" android:paddingBottom="12dp"/>
tools:text="Merchant Name"
android:text='@{viewModel.merchantName}'
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Phone"
android:text='@{viewModel.merchantPhone}'
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Address1"
android:text="@{viewModel.merchantAddress1}"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Address2"
android:text="@{viewModel.merchantAddress2}"
/>
<!-- Merchant Info -->
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="@{viewModel.merchantName}" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="@{viewModel.merchantPhone}" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="@{viewModel.merchantAddress1}" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text="@{viewModel.merchantAddress2}" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="--------------------------------"
android:paddingTop="8dp"
android:paddingBottom="8dp"/>
<!-- PRIMARY HOST -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="PRIMARY HOST"
android:textStyle="bold" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Name : " + viewModel.hostName}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"TID : " + viewModel.tid}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"MID : " + viewModel.mid}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Primary Ip : " + viewModel.primaryIp}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Primary Port : " + viewModel.primaryPort}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Secondary Ip : " + viewModel.secondaryIp}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Secondary Port : " + viewModel.secondaryPort}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Currency Code : " + viewModel.currencyCode}' />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="--------------------------------"
android:paddingTop="8dp"
android:paddingBottom="8dp"/>
<!-- SECONDARY HOST (only if exists) -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility='@{!viewModel.secHostName.isEmpty() ? View.VISIBLE : View.GONE}'>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SECONDARY HOST"
android:textStyle="bold" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Name : " + viewModel.secHostName}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"TID : " + viewModel.secHostTid}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"MID : " + viewModel.secHostMid}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Primary Ip : " + viewModel.secHostPrimaryIp}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Primary Port : " + viewModel.secHostPrimaryPort}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Secondary Ip : " + viewModel.secHostSecondaryIp}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Secondary Port : " + viewModel.secHostSecondaryPort}' />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content"
android:text='@{"Currency Code : " + viewModel.currencyCode}' />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="--------------------------------"
android:paddingTop="8dp"
android:paddingBottom="8dp"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>