diff --git a/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java b/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java index 0fef621..2401afa 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/IRApplication.java @@ -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); diff --git a/android-example/app/src/main/java/net/irext/ircontrol/ui/adapter/IndexAdapter.java b/android-example/app/src/main/java/net/irext/ircontrol/ui/adapter/IndexAdapter.java index 97fd9cd..7c4ca5e 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/ui/adapter/IndexAdapter.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/ui/adapter/IndexAdapter.java @@ -26,10 +26,14 @@ public class IndexAdapter extends BaseAdapter { private List mIndexes; private LayoutInflater mInflater; + private String mBrandName; + private String mOperatorName; - public IndexAdapter(Context ctx, List list) { + public IndexAdapter(Context ctx, List 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; diff --git a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/IndexFragment.java b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/IndexFragment.java index 9e5c655..5a47316 100644 --- a/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/IndexFragment.java +++ b/android-example/app/src/main/java/net/irext/ircontrol/ui/fragment/IndexFragment.java @@ -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 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 diff --git a/android-example/decodesdk/src/main/java/net/irext/decodesdk/IRDecode.java b/android-example/decodesdk/src/main/java/net/irext/decodesdk/IRDecode.java index 792f705..b347f52 100644 --- a/android-example/decodesdk/src/main/java/net/irext/decodesdk/IRDecode.java +++ b/android-example/decodesdk/src/main/java/net/irext/decodesdk/IRDecode.java @@ -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) {