public ArrayList<BaseChannel> getBaseChannels( ArrayList<DTVChannelBaseInfo> dtvChannels) { // 加入DTV频道列表参数 /*ArrayList<BaseChannel> baseChannels = new ArrayList<BaseChannel>(); ArrayList<BaseChannel> otherChannels = new ArrayList<BaseChannel>();*/ mBaseChannels.clear(); mOtherChannels.clear(); ArrayList<BaseChannel> huanChannels = mHuanChannelDBUtil.getAllChannels(); if (dtvChannels != null && dtvChannels.size() > 0) { if (huanChannels != null && huanChannels.size() > 0) { for (DTVChannelBaseInfo dtvChannel : dtvChannels) { boolean flag = false; BaseChannel baseChannel = null; for (BaseChannel huanChannel : huanChannels) { if (fullWidthToHalfWidth(dtvChannel.mstrServiceName.toLowerCase()) .equals(fullWidthToHalfWidth(huanChannel.getName().toLowerCase()))) { /*本地频道和欢网频道匹配,生成别名库*/ Log.d( TAG, "LocalChannelUtil>>name=" + dtvChannel.mstrServiceName + ";index=" + dtvChannel.miChannelIndex); baseChannel = new BaseChannel(); baseChannel.setName(dtvChannel.mstrServiceName); baseChannel.setIndex(dtvChannel.miChannelIndex); baseChannel.setCode(huanChannel.getCode()); baseChannel.setType(huanChannel.getType()); baseChannel.setLogo(huanChannel.getLogo()); mBaseChannels.add(baseChannel); baseChannel = null; flag = true; break; } } if (!flag) { /*本地频道和欢网频道不匹配,保存不匹配频道*/ Log.d( TAG, "LocalChannelUtil>>dtvChannel.mstrServiceName=" + dtvChannel.mstrServiceName + ";dtvChannel.miChannelIndex=" + dtvChannel.miChannelIndex); baseChannel = new BaseChannel(); baseChannel.setName(dtvChannel.mstrServiceName); baseChannel.setIndex(dtvChannel.miChannelIndex); mOtherChannels.add(baseChannel); baseChannel = null; } } } else { Log.i(TAG, "LocalChannelUtil>>huanChannels is null, can't creat baseChannelDB"); } } else { Log.i(TAG, "LocalChannelUtil>>dtvChannels is null, no need baseChannelDB"); } Log.i(TAG, "LocalChannelUtil>>baseChannels.size=" + mBaseChannels.size()); Log.i(TAG, "LocalChannelUtil>>otherChannels.size=" + mOtherChannels.size()); return mBaseChannels; }
private ArrayList<BaseChannel> getNameList(ArrayList<BaseChannel> channelNames) { ArrayList<BaseChannel> huanLocalChannels = new ArrayList<BaseChannel>(); BaseChannel huanLocalChannel = null; String memo = null; String[] splits = null; for (int i = 0; i < channelNames.size(); i++) { BaseChannel baseName = channelNames.get(i); String name = baseName.getName(); String code = baseName.getCode(); String type = baseName.getType(); if (type.equals("0") || type.equals("local")) type = "other"; String logo = baseName.getLogo(); // 添加一条本地频道到本地列表 Log.d(TAG, "LocalChannelUtil>>getNameList>>add name huanLocalChannel, name =" + name); huanLocalChannel = new BaseChannel(); huanLocalChannel.setName(name); huanLocalChannel.setCode(code); huanLocalChannel.setType(type); huanLocalChannel.setLogo(logo); huanLocalChannels.add(huanLocalChannel); huanLocalChannel = null; // 添加别名频道到本地列表 memo = baseName.getMemo(); if (memo != null && memo.length() > 0) { splits = memo.split(","); if (splits == null || splits.length == 0) { continue; } for (int j = 0; j < splits.length; j++) { Log.d( TAG, "LocalChannelUtil>>getNameList>>add memo huanLocalChannel, name =" + splits[j]); huanLocalChannel = new BaseChannel(); huanLocalChannel.setName(splits[j]); huanLocalChannel.setCode(code); huanLocalChannel.setType(type); huanLocalChannel.setLogo(logo); huanLocalChannels.add(huanLocalChannel); huanLocalChannel = null; } } } Log.d( TAG, "LocalChannelUtil>>getNameList>>huanLocalChannels.size()=" + huanLocalChannels.size()); return huanLocalChannels; }
private ArrayList<BaseChannel> resolveData(Context context, String in) { ArrayList<BaseChannel> channelNames = new ArrayList<BaseChannel>(); Gson gson = new Gson(); JsonParser parser = new JsonParser(); JsonArray jsonArray = parser.parse(in).getAsJsonArray(); for (int i = 0; i < jsonArray.size(); i++) { JsonElement el = jsonArray.get(i); BaseChannel data = gson.fromJson(el, BaseChannel.class); channelNames.add(data); Log.i(TAG, "\ndata=" + data.toString()); Log.i(TAG, "[name]" + data.getName()); Log.i(TAG, "[index]" + data.getIndex()); if (data.getMemo() != null) { Log.i(TAG, "[momo]" + data.getMemo()); } Log.i(TAG, "[code]" + data.getCode()); Log.i(TAG, "[type]" + data.getType()); Log.i(TAG, "[logo]" + data.getLogo()); } return channelNames; }