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 LocalChannelUtil(Context context) { this.mContext = context; mHuanChannelDBUtil = HuanChannelDBUtil.getInstance(context); mBaseChannelDBUtil = BaseChannelDBUtil.getInstance(context); mNetChannelDBUtil = NetChannelDBUtil.getInstance(context); mBaseChannels = new ArrayList<BaseChannel>(); mOtherChannels = new ArrayList<BaseChannel>(); }
/** 功能一:更新别名库 */ public void updateBaseChannelDB() { Log.d( TAG, "\n\nLocalChannelUtil>>updateBaseChannelDB startTime = " + System.currentTimeMillis()); // 1.更新本地频道库 localChannelDBHasChanged = mHuanChannelDBUtil.updateLocalChannelDB(); // 2.生成本地别名库 // if (localChannelDBHasChanged && dtvChannelListHasChanged) { // mBaseChannelDBUtil.updateBaseChannelDB(getBaseChannels(getDtvChannelList())); // } updateBaseChannelList(); Log.d(TAG, "LocalChannelUtil>>updateBaseChannelDB endTime = " + System.currentTimeMillis()); }
/** 取得欢网频道列表 */ public ArrayList<BaseChannel> getHuanChannelList() { return mHuanChannelDBUtil.getAllChannels(); }