Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
  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;
  }
Exemplo n.º 3
0
  private ArrayList<BaseChannel> getResultData(JSONObject object) {
    ArrayList<BaseChannel> otherHuanChannelList = new ArrayList<BaseChannel>();
    JSONObject error = object.optJSONObject("error");
    String errorCode = error.optString("code");
    Log.i("errorCode", errorCode);
    String errorInfo = error.optString("info");
    Log.i("errorInfo", errorInfo);
    if ("0".equals(errorCode)) {
      JSONArray channels = object.optJSONArray("channels");
      BaseChannel basechannel = null;
      for (int i = 0; i < channels.length(); i++) {
        JSONObject channel = (JSONObject) channels.opt(i);
        String name = channel.optString("name");
        String memo = channel.optString("memo");
        String code = channel.optString("code");
        String type = channel.optString("type");
        String logo = channel.optString("logo");

        basechannel = new BaseChannel();
        basechannel.setName(name);
        basechannel.setMemo(memo);
        basechannel.setCode(code);
        basechannel.setType(type);
        basechannel.setLogo(logo);
        Log.i("name111", name);
        Log.i("memo111", name);
        Log.i("code111", code);
        Log.i("type111", type);
        Log.i("logo111", logo);
        if (code != null && !code.equals("")) {
          /*for (DTVChannelBaseInfo dtvchannel : dtvChannelList) {
          	if (dtvchannel.mstrServiceName.equals(name)) {
          		basechannel.setIndex(dtvchannel.miChannelIndex);
          		BaseChannelDBUtil.getInstance(mContext).save(basechannel);
          		Log.i("index111", dtvchannel.miChannelIndex + "");
          		basechannel = null;
          		break;
          	}
          }*/
          otherHuanChannelList.add(basechannel);
        } else {
          Log.i("no code name=", name);
        }
        basechannel = null;
      }
    }
    return otherHuanChannelList;
  }