public void run() {
   try {
     new HttpGetRequest().a(this.a, this.b, this.c, this.d);
   } catch (Exception e) {
     MMLog.e(b, "Problem doing conversion tracking.", e);
   }
 }
 private String a(JSONObject jSONObject) {
   StringBuilder stringBuilder = new StringBuilder();
   try {
     stringBuilder.append("FREQ=").append(jSONObject.getString("frequency")).append(";");
   } catch (JSONException e) {
     MMLog.b(d, "Unable to get calendar event recurrence frequency");
   }
   try {
     stringBuilder
         .append("UNTIL=")
         .append(f.format(DateUtils.parseDate(jSONObject.getString("expires"), e)))
         .append(";");
   } catch (DateParseException e2) {
     MMLog.e(d, "Error parsing calendar event recurrence expiration date");
   } catch (JSONException e3) {
     MMLog.b(d, "Unable to get calendar event recurrence expiration date");
   }
   try {
     JSONArray jSONArray = jSONObject.getJSONArray("daysInWeek");
     CharSequence stringBuilder2 = new StringBuilder();
     int i = 0;
     while (i < jSONArray.length()) {
       stringBuilder2.append(a(jSONArray.getInt(i))).append(",");
       i++;
     }
     stringBuilder.append("BYDAY=").append(stringBuilder2).append(";");
   } catch (JSONException e4) {
     MMLog.b(d, "Unable to get days in week");
   }
   try {
     stringBuilder
         .append("BYMONTHDAY=")
         .append(
             jSONObject
                 .getString("daysInMonth")
                 .replaceAll("\\[", AdTrackerConstants.BLANK)
                 .replaceAll("\\]", AdTrackerConstants.BLANK))
         .append(";");
   } catch (JSONException e5) {
     MMLog.b(d, "Unable to get days in month");
   }
   try {
     stringBuilder
         .append("BYMONTH=")
         .append(
             jSONObject
                 .getString("monthsInYear:")
                 .replaceAll("\\[", AdTrackerConstants.BLANK)
                 .replaceAll("\\]", AdTrackerConstants.BLANK))
         .append(";");
   } catch (JSONException e6) {
     MMLog.b(d, "Unable to get months in year:");
   }
   try {
     stringBuilder.append("BYYEARDAY=").append(jSONObject.getString("daysInYear")).append(";");
   } catch (JSONException e7) {
     MMLog.b(d, "Unable to get days in year");
   }
   return stringBuilder.toString().toUpperCase();
 }
 @TargetApi(14)
 public MMJSResponse addEvent(Map map) {
   MMLog.b(d, "addEvent parameters: " + map);
   if (VERSION.SDK_INT < 14) {
     return MMJSResponse.b("Not supported");
   }
   if (!(map == null || map.get("parameters") == null)) {
     try {
       String str;
       String str2;
       String str3;
       String str4;
       Date date;
       Date parseDate;
       JSONObject jSONObject = new JSONObject((String) map.get("parameters"));
       try {
         str = jSONObject.getString(PlusShare.KEY_CONTENT_DEEP_LINK_METADATA_DESCRIPTION);
       } catch (JSONException e) {
         MMLog.e(d, "Unable to get calendar event description");
         str = null;
       }
       try {
         str2 = jSONObject.getString("summary");
       } catch (JSONException e2) {
         MMLog.b(d, "Unable to get calendar event description");
         str2 = null;
       }
       try {
         String str5 = jSONObject.getString("transparency");
       } catch (JSONException e3) {
         MMLog.b(d, "Unable to get calendar event transparency");
         boolean z = false;
       }
       try {
         String str6 = jSONObject.getString("reminder");
       } catch (JSONException e4) {
         MMLog.b(d, "Unable to get calendar event reminder");
         boolean z2 = false;
       }
       try {
         str3 = jSONObject.getString("location");
       } catch (JSONException e5) {
         MMLog.b(d, "Unable to get calendar event location");
         str3 = null;
       }
       try {
         String str7 = jSONObject.getString("status");
       } catch (JSONException e6) {
         MMLog.b(d, "Unable to get calendar event status");
         boolean z3 = false;
       }
       try {
         str4 = a(jSONObject.getJSONObject("recurrence"));
       } catch (JSONException e7) {
         MMLog.b(d, "Unable to get calendar event recurrence");
         str4 = null;
       }
       try {
         date = DateUtils.parseDate(jSONObject.getString("start"), e);
       } catch (DateParseException e8) {
         MMLog.e(d, "Error parsing calendar event start date");
         date = null;
       } catch (JSONException e9) {
         MMLog.e(d, "Unable to get calendar event start date");
         date = null;
       }
       try {
         parseDate = DateUtils.parseDate(jSONObject.getString("end"), e);
       } catch (DateParseException e10) {
         MMLog.e(d, "Error parsing calendar event end date");
         parseDate = null;
       } catch (JSONException e11) {
         MMLog.b(d, "Unable to get calendar event end date");
         parseDate = null;
       }
       MMLog.b(
           d,
           String.format(
               "Creating calendar event: title: %s, location: %s, start: %s, end: %s, status: %s, summary: %s, rrule: %s",
               new Object[] {str, str3, date, parseDate, obj, str2, str4}));
       if (str == null || date == null) {
         MMLog.e(d, "Description and start must be provided to create calendar event.");
         return MMJSResponse.b("Calendar Event Creation Failed.  Minimum parameters not provided");
       } else {
         Intent data = new Intent("android.intent.action.INSERT").setData(Events.CONTENT_URI);
         if (date != null) {
           data.putExtra("beginTime", date.getTime());
         }
         if (parseDate != null) {
           data.putExtra(Event.END_TIME, parseDate.getTime());
         }
         if (str != null) {
           data.putExtra(PlusShare.KEY_CONTENT_DEEP_LINK_METADATA_TITLE, str);
         }
         if (str2 != null) {
           data.putExtra(PlusShare.KEY_CONTENT_DEEP_LINK_METADATA_DESCRIPTION, str2);
         }
         if (str3 != null) {
           data.putExtra("eventLocation", str3);
         }
         if (str4 != null) {
           data.putExtra("rrule", str4);
         }
         if (obj != null) {
           MMLog.d(d, "Calendar addEvent does not support status");
         }
         if (i != 0) {
           MMLog.d(d, "Calendar addEvent does not support transparency");
         }
         if (i != 0) {
           MMLog.d(d, "Calendar addEvent does not support reminder");
         }
         Context context = (Context) this.b.get();
         if (context != null) {
           IntentUtils.c(context, data);
           Event.a(
               context, Event.INTENT_CALENDAR_EVENT, b((String) map.get("PROPERTY_EXPANDING")));
           return MMJSResponse.a("Calendar Event Created");
         }
       }
     } catch (JSONException e12) {
       MMLog.e(d, "Unable to parse calendar addEvent parameters");
       return MMJSResponse.b("Calendar Event Creation Failed.  Invalid parameters");
     }
   }
   return null;
 }
 protected static synchronized void a(Context context, String str, MMRequest mMRequest) {
   long j;
   long timeInMillis;
   int i = 0;
   synchronized (MMConversionTracker.class) {
     if (!(context == null || str == null)) {
       if (str.length() != 0) {
         GregorianCalendar gregorianCalendar;
         SharedPreferences sharedPreferences =
             context.getSharedPreferences("MillennialMediaSettings", 0);
         boolean z = sharedPreferences.getBoolean("firstLaunch_" + str, true);
         String string = sharedPreferences.getString(a, null);
         Map treeMap = new TreeMap();
         if (mMRequest != null) {
           mMRequest.a(treeMap);
           MMRequest.b(treeMap);
         }
         if (string != null) {
           String[] split = string.split("&");
           int length = split.length;
           while (i < length) {
             String[] split2 = split[i].split("=");
             if (split2.length >= 2) {
               treeMap.put(split2[0], split2[1]);
             }
             i++;
           }
         }
         if (z) {
           Editor edit = sharedPreferences.edit();
           edit.putBoolean("firstLaunch_" + str, false);
           edit.commit();
         }
         try {
           PackageInfo packageInfo =
               context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
           try {
             j = packageInfo.getClass().getField("firstInstallTime").getLong(packageInfo);
           } catch (Exception e) {
             MMLog.e(b, "Error with firstInstallTime", e);
             j = 0;
             if (j <= 0) {
               timeInMillis = j;
             } else {
               gregorianCalendar = new GregorianCalendar();
               gregorianCalendar.setTimeInMillis(j);
               gregorianCalendar.setTimeZone(TimeZone.getTimeZone("GMT"));
               timeInMillis = gregorianCalendar.getTimeInMillis();
             }
             if (MMSDK.a(context)) {
               MMLog.d(b, "No network available for conversion tracking.");
             } else {
               treeMap.put("ua", "Android:" + Build.MODEL);
               treeMap.put("apid", HandShake.a);
               MMSDK.a(context, treeMap);
               ThreadUtils.a(new AnonymousClass_1(str, z, timeInMillis, treeMap));
             }
           }
         } catch (NameNotFoundException e2) {
           MMLog.e(b, "Can't find packagename: ", e2);
         }
         if (j <= 0) {
           gregorianCalendar = new GregorianCalendar();
           gregorianCalendar.setTimeInMillis(j);
           gregorianCalendar.setTimeZone(TimeZone.getTimeZone("GMT"));
           timeInMillis = gregorianCalendar.getTimeInMillis();
         } else {
           timeInMillis = j;
         }
         if (MMSDK.a(context)) {
           MMLog.d(b, "No network available for conversion tracking.");
         } else {
           treeMap.put("ua", "Android:" + Build.MODEL);
           treeMap.put("apid", HandShake.a);
           MMSDK.a(context, treeMap);
           ThreadUtils.a(new AnonymousClass_1(str, z, timeInMillis, treeMap));
         }
       }
     }
   }
 }