updated Android example for i18n
This commit is contained in:
@@ -21,7 +21,8 @@ public class IRApplication extends com.activeandroid.app.Application {
|
|||||||
|
|
||||||
private static final String TAG = IRApplication.class.getSimpleName();
|
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";
|
private static final String APP_NAME = "/irext-server";
|
||||||
|
|
||||||
public WebAPIs mWeAPIs = WebAPIs.getInstance(ADDRESS, APP_NAME);
|
public WebAPIs mWeAPIs = WebAPIs.getInstance(ADDRESS, APP_NAME);
|
||||||
|
|||||||
@@ -26,10 +26,14 @@ public class IndexAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
private List<RemoteIndex> mIndexes;
|
private List<RemoteIndex> mIndexes;
|
||||||
private LayoutInflater mInflater;
|
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.mIndexes = list;
|
||||||
this.mInflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
this.mInflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
this.mBrandName = brandName;
|
||||||
|
this.mOperatorName = operatorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,9 +65,9 @@ public class IndexAdapter extends BaseAdapter {
|
|||||||
}
|
}
|
||||||
RemoteIndex index = mIndexes.get(position);
|
RemoteIndex index = mIndexes.get(position);
|
||||||
if (index.getCategoryId() != Constants.CategoryID.STB.getValue()) {
|
if (index.getCategoryId() != Constants.CategoryID.STB.getValue()) {
|
||||||
holder.textName.setText(index.getBrandName() + " " + (position + 1));
|
holder.textName.setText(mBrandName + " " + (position + 1));
|
||||||
} else {
|
} else {
|
||||||
holder.textName.setText(index.getOperatorName() + " " + (position + 1));
|
holder.textName.setText(mOperatorName + " " + (position + 1));
|
||||||
}
|
}
|
||||||
holder.textMap.setText(index.getRemoteMap());
|
holder.textMap.setText(index.getRemoteMap());
|
||||||
return convertView;
|
return convertView;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import net.irext.ircontrol.ui.adapter.IndexAdapter;
|
|||||||
import net.irext.ircontrol.utils.FileUtils;
|
import net.irext.ircontrol.utils.FileUtils;
|
||||||
import net.irext.ircontrol.utils.MessageUtil;
|
import net.irext.ircontrol.utils.MessageUtil;
|
||||||
import net.irext.webapi.model.Brand;
|
import net.irext.webapi.model.Brand;
|
||||||
|
import net.irext.webapi.model.Category;
|
||||||
import net.irext.webapi.model.City;
|
import net.irext.webapi.model.City;
|
||||||
import net.irext.webapi.model.RemoteIndex;
|
import net.irext.webapi.model.RemoteIndex;
|
||||||
import net.irext.webapi.model.StbOperator;
|
import net.irext.webapi.model.StbOperator;
|
||||||
@@ -51,40 +52,30 @@ public class IndexFragment extends BaseCreateFragment {
|
|||||||
private List<RemoteIndex> mIndexes;
|
private List<RemoteIndex> mIndexes;
|
||||||
private RemoteIndex mCurrentIndex;
|
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 IndexAdapter mIndexAdapter;
|
||||||
|
|
||||||
private MsgHandler mMsgHandler;
|
private MsgHandler mMsgHandler;
|
||||||
private IRApplication mApp;
|
private IRApplication mApp;
|
||||||
|
|
||||||
public IndexFragment() {
|
public IndexFragment() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listIndexes() {
|
private void listIndexes() {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Brand brand = mParent.getCurrentBrand();
|
mIndexes = mApp.mWeAPIs.listRemoteIndexes(mParent.getCurrentCategory().getId(),
|
||||||
City city = mParent.getCurrentCity();
|
mBrandId, mCityCode, mOperatorId);
|
||||||
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);
|
|
||||||
if (null == mIndexes) {
|
if (null == mIndexes) {
|
||||||
mIndexes = new ArrayList<>();
|
mIndexes = new ArrayList<>();
|
||||||
}
|
}
|
||||||
@@ -131,15 +122,16 @@ public class IndexFragment extends BaseCreateFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveRemoteControl() {
|
private void saveRemoteControl() {
|
||||||
|
// TODO: update brand and operator name i18n
|
||||||
RemoteControl remoteControl = new RemoteControl();
|
RemoteControl remoteControl = new RemoteControl();
|
||||||
remoteControl.setCategoryId(mCurrentIndex.getCategoryId());
|
remoteControl.setCategoryId(mCurrentIndex.getCategoryId());
|
||||||
remoteControl.setCategoryName(mCurrentIndex.getCategoryName());
|
remoteControl.setCategoryName(mCategoryName);
|
||||||
remoteControl.setBrandId(mCurrentIndex.getBrandId());
|
remoteControl.setBrandId(mCurrentIndex.getBrandId());
|
||||||
remoteControl.setBrandName(mCurrentIndex.getBrandName());
|
remoteControl.setBrandName(mBrandName);
|
||||||
remoteControl.setCityCode(mCurrentIndex.getCityCode());
|
remoteControl.setCityCode(mCurrentIndex.getCityCode());
|
||||||
remoteControl.setCityName(mCurrentIndex.getCityName());
|
remoteControl.setCityName(mCityName);
|
||||||
remoteControl.setOperatorId(mCurrentIndex.getOperatorId());
|
remoteControl.setOperatorId(mCurrentIndex.getOperatorId());
|
||||||
remoteControl.setOperatorName(mCurrentIndex.getOperatorName());
|
remoteControl.setOperatorName(mOperatorName);
|
||||||
remoteControl.setProtocol(mCurrentIndex.getProtocol());
|
remoteControl.setProtocol(mCurrentIndex.getProtocol());
|
||||||
remoteControl.setRemote(mCurrentIndex.getRemote());
|
remoteControl.setRemote(mCurrentIndex.getRemote());
|
||||||
remoteControl.setRemoteMap(mCurrentIndex.getRemoteMap());
|
remoteControl.setRemoteMap(mCurrentIndex.getRemoteMap());
|
||||||
@@ -150,7 +142,7 @@ public class IndexFragment extends BaseCreateFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refreshIndexes() {
|
private void refreshIndexes() {
|
||||||
mIndexAdapter = new IndexAdapter(mParent, mIndexes);
|
mIndexAdapter = new IndexAdapter(mParent, mIndexes, mBrandName, mOperatorName);
|
||||||
mIndexList.setAdapter(mIndexAdapter);
|
mIndexList.setAdapter(mIndexAdapter);
|
||||||
mIndexList.onRefreshComplete();
|
mIndexList.onRefreshComplete();
|
||||||
}
|
}
|
||||||
@@ -165,6 +157,25 @@ public class IndexFragment extends BaseCreateFragment {
|
|||||||
mMsgHandler = new MsgHandler(this);
|
mMsgHandler = new MsgHandler(this);
|
||||||
mApp = (IRApplication) this.getActivity().getApplication();
|
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 = (PullToRefreshListView) view.findViewById(R.id.lv_index_list);
|
||||||
mIndexList.setOnRefreshListener(new PullToRefreshListView.OnRefreshListener() {
|
mIndexList.setOnRefreshListener(new PullToRefreshListView.OnRefreshListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -48,9 +48,7 @@ public class IRDecode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private 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) {
|
public int openFile(int category, int subCate, String fileName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user