updated Android example for i18n

This commit is contained in:
2017-06-18 18:52:19 +08:00
parent c5327f8717
commit 4ebbf1f3b2
4 changed files with 48 additions and 34 deletions

View File

@@ -21,7 +21,8 @@ public class IRApplication extends com.activeandroid.app.Application {
private static final String TAG = IRApplication.class.getSimpleName();
private static final String ADDRESS = "http://irext.net:8080";
// private static final String ADDRESS = "http://irext.net";
private static final String ADDRESS = "http://192.168.1.100:8080";
private static final String APP_NAME = "/irext-server";
public WebAPIs mWeAPIs = WebAPIs.getInstance(ADDRESS, APP_NAME);

View File

@@ -26,10 +26,14 @@ public class IndexAdapter extends BaseAdapter {
private List<RemoteIndex> mIndexes;
private LayoutInflater mInflater;
private String mBrandName;
private String mOperatorName;
public IndexAdapter(Context ctx, List<RemoteIndex> list) {
public IndexAdapter(Context ctx, List<RemoteIndex> list, String brandName, String operatorName) {
this.mIndexes = list;
this.mInflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.mBrandName = brandName;
this.mOperatorName = operatorName;
}
@Override
@@ -61,9 +65,9 @@ public class IndexAdapter extends BaseAdapter {
}
RemoteIndex index = mIndexes.get(position);
if (index.getCategoryId() != Constants.CategoryID.STB.getValue()) {
holder.textName.setText(index.getBrandName() + " " + (position + 1));
holder.textName.setText(mBrandName + " " + (position + 1));
} else {
holder.textName.setText(index.getOperatorName() + " " + (position + 1));
holder.textName.setText(mOperatorName + " " + (position + 1));
}
holder.textMap.setText(index.getRemoteMap());
return convertView;

View File

@@ -18,6 +18,7 @@ import net.irext.ircontrol.ui.adapter.IndexAdapter;
import net.irext.ircontrol.utils.FileUtils;
import net.irext.ircontrol.utils.MessageUtil;
import net.irext.webapi.model.Brand;
import net.irext.webapi.model.Category;
import net.irext.webapi.model.City;
import net.irext.webapi.model.RemoteIndex;
import net.irext.webapi.model.StbOperator;
@@ -51,40 +52,30 @@ public class IndexFragment extends BaseCreateFragment {
private List<RemoteIndex> mIndexes;
private RemoteIndex mCurrentIndex;
private int mBrandId = 0;
private String mCityCode = "";
private String mOperatorId = "";
private String mCategoryName = "";
private String mCityName = "";
private String mBrandName = "";
private String mOperatorName = "";
private IndexAdapter mIndexAdapter;
private MsgHandler mMsgHandler;
private IRApplication mApp;
public IndexFragment() {
}
private void listIndexes() {
new Thread() {
@Override
public void run() {
Brand brand = mParent.getCurrentBrand();
City city = mParent.getCurrentCity();
StbOperator operator = mParent.getCurrentOperator();
int brandId = 0;
String cityCode = null;
String operatorId = null;
if (null != brand) {
brandId = brand.getId();
}
if (null != city) {
cityCode = city.getCode();
}
if (null != operator) {
operatorId = operator.getOperatorId();
}
mIndexes = mApp.mWeAPIs.listRemoteIndexes(mParent.getCurrentCategory().getId(), brandId,
cityCode, operatorId);
mIndexes = mApp.mWeAPIs.listRemoteIndexes(mParent.getCurrentCategory().getId(),
mBrandId, mCityCode, mOperatorId);
if (null == mIndexes) {
mIndexes = new ArrayList<>();
}
@@ -131,15 +122,16 @@ public class IndexFragment extends BaseCreateFragment {
}
private void saveRemoteControl() {
// TODO update brand and operator name i18n
RemoteControl remoteControl = new RemoteControl();
remoteControl.setCategoryId(mCurrentIndex.getCategoryId());
remoteControl.setCategoryName(mCurrentIndex.getCategoryName());
remoteControl.setCategoryName(mCategoryName);
remoteControl.setBrandId(mCurrentIndex.getBrandId());
remoteControl.setBrandName(mCurrentIndex.getBrandName());
remoteControl.setBrandName(mBrandName);
remoteControl.setCityCode(mCurrentIndex.getCityCode());
remoteControl.setCityName(mCurrentIndex.getCityName());
remoteControl.setCityName(mCityName);
remoteControl.setOperatorId(mCurrentIndex.getOperatorId());
remoteControl.setOperatorName(mCurrentIndex.getOperatorName());
remoteControl.setOperatorName(mOperatorName);
remoteControl.setProtocol(mCurrentIndex.getProtocol());
remoteControl.setRemote(mCurrentIndex.getRemote());
remoteControl.setRemoteMap(mCurrentIndex.getRemoteMap());
@@ -150,7 +142,7 @@ public class IndexFragment extends BaseCreateFragment {
}
private void refreshIndexes() {
mIndexAdapter = new IndexAdapter(mParent, mIndexes);
mIndexAdapter = new IndexAdapter(mParent, mIndexes, mBrandName, mOperatorName);
mIndexList.setAdapter(mIndexAdapter);
mIndexList.onRefreshComplete();
}
@@ -165,6 +157,25 @@ public class IndexFragment extends BaseCreateFragment {
mMsgHandler = new MsgHandler(this);
mApp = (IRApplication) this.getActivity().getApplication();
Category category = mParent.getCurrentCategory();
Brand brand = mParent.getCurrentBrand();
City city = mParent.getCurrentCity();
StbOperator operator = mParent.getCurrentOperator();
mCategoryName = category.getName();
if (null != city) {
mCityName = city.getName();
mCityCode = city.getCode();
}
if (null != operator) {
mOperatorName = operator.getOperatorName();
mOperatorId = operator.getOperatorId();
}
if (null != brand) {
mBrandName = brand.getName();
mBrandId = brand.getId();
}
mIndexList = (PullToRefreshListView) view.findViewById(R.id.lv_index_list);
mIndexList.setOnRefreshListener(new PullToRefreshListView.OnRefreshListener() {
@Override

View File

@@ -48,9 +48,7 @@ public class IRDecode {
}
private IRDecode() {
String libPath = "/develop/irext/core/src/ir_decoder/cmake-build-debug/libirda_decoder.so";
System.out.println("loading decode library " + libPath);
System.load(libPath);
}
public int openFile(int category, int subCate, String fileName) {