コード例 #1
0
ファイル: HijackHistory.java プロジェクト: hschen2k/Lanmitm
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      SessionHolder holder;
      Session session = hijackList.get(position);

      if (row == null) {
        LayoutInflater inflater =
            (LayoutInflater) HijackHistory.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        row = inflater.inflate(R.layout.hijack_list_item, parent, false);
        holder = new SessionHolder();
        holder.favicon = (ImageView) (row != null ? row.findViewById(R.id.server_icon) : null);
        holder.pathText = (TextView) (row != null ? row.findViewById(R.id.server_path) : null);
        holder.domainText = (TextView) (row != null ? row.findViewById(R.id.server_domain) : null);
        holder.dateText = (TextView) (row != null ? row.findViewById(R.id.hijack_date) : null);
        if (row != null) row.setTag(holder);
      } else holder = (SessionHolder) row.getTag();

      String tmp = session.getPath();
      if (holder.pathText != null) holder.pathText.setText(tmp);
      tmp = session.getDomain();
      if (holder.domainText != null) holder.domainText.setText(tmp);

      if (holder.dateText != null) {
        holder.dateText.setText(dateFormat.format(session.getDateTime()));
        holder.dateText.setVisibility(View.VISIBLE);
      }

      return row;
    }
コード例 #2
0
ファイル: HijackHistory.java プロジェクト: hschen2k/Lanmitm
 private Session parseJson(final String json) {
   Session session = null;
   try {
     JSONObject jsonObject = new JSONObject(json);
     session = new Session();
     session.setIp(jsonObject.optString("ip"));
     session.setDomain(jsonObject.optString("domain"));
     session.setPath(jsonObject.optString("path"));
     session.setUserAgent(jsonObject.optString("userAgent"));
     session.setDateTime(parseDateFormat.parse(jsonObject.optString("dateTime")));
     Map<String, BasicClientCookie> cookies = new HashMap<String, BasicClientCookie>();
     JSONObject cookiesObject = jsonObject.optJSONObject("cookies");
     JSONArray cookieArray = cookiesObject.names();
     if (cookieArray != null) {
       for (int i = 0; i < cookieArray.length(); i++) {
         JSONObject cookieObject = cookiesObject.getJSONObject(cookieArray.getString(i));
         BasicClientCookie cookie =
             new BasicClientCookie(
                 cookieObject.optString("name"), cookieObject.optString("value"));
         cookie.setDomain(cookieObject.optString("domain"));
         cookies.put(cookieArray.getString(i), cookie);
       }
     }
     session.setCookies(cookies);
   } catch (JSONException e) {
     e.printStackTrace();
   } catch (ParseException e) {
     e.printStackTrace();
   }
   return session;
 }