⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcalendarprovider_v10v20.java

📁 goolge phone 目前没有开放的android 平台的源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        map.put("selected", Integer.valueOf(Integer.parseInt("1")));
        map.put("_sync_id", "content://syncmltestcalendar/calendars/1");
        map.put("_sync_account", "user");
        uri = null;
        context.getContentResolver().insert(ContentURI.create("content://settings/googlelogin"), mapu);
        uri = context.createPackageContext("com.google.android.syncmltestcalendar", 1).getContentResolver().insert(android.provider.SyncMLTestCalendar.Calendars.CONTENT_URI, map);
        return (int)uri.getPathLeafId();
        Exception e;
        e;
        e.printStackTrace();
        return 0;
    }

    int delete(ContentURI uri, String selection)
        throws Exception
    {
        if(provider != null)
            return provider.delete(uri, selection, null);
        else
            return mIContentProvider.delete(uri, selection, null);
    }

    int update(ContentURI uri, ContentValues map)
        throws Exception
    {
        if(provider != null)
            return provider.update(uri, map, null, null);
        else
            return mIContentProvider.update(uri, map, null, null);
    }

    private ContentValues getCalendarMap(VNode vnode)
    {
        ContentValues calmap = new ContentValues();
        Iterator i$ = vnode.propList.iterator();
        do
        {
            if(!i$.hasNext())
                break;
            PropertyNode prop = (PropertyNode)i$.next();
            if(prop.propName.equalsIgnoreCase("TZ"))
                calmap.put("timezone", prop.propValue);
        } while(true);
        calmap.put("name", "fromS-vCalendar");
        calmap.put("displayName", "fromS-vCalendar");
        calmap.put("selected", Integer.valueOf(Integer.parseInt("0")));
        return calmap;
    }

    private ContentValues getEventMap(VNode vnode, String curCalId)
    {
        ContentValues eventmap = new ContentValues();
        Time time = new Time();
        eventmap.put("calendar_id", curCalId);
        Iterator i$ = vnode.propList.iterator();
        do
        {
            if(!i$.hasNext())
                break;
            PropertyNode prop = (PropertyNode)i$.next();
            if(prop.propName.equalsIgnoreCase("DESCRIPTION") && !isNull(prop.propValue))
                eventmap.put("description", prop.propValue);
            if(prop.propName.equalsIgnoreCase("DTEND") && !isNull(prop.propValue) && time.parse2445(prop.propValue))
                eventmap.put("dtend", Long.valueOf(time.toMillis()));
            if(prop.propName.equalsIgnoreCase("DTSTART") && !isNull(prop.propValue) && time.parse2445(prop.propValue))
                eventmap.put("dtstart", Long.valueOf(time.toMillis()));
            if(prop.propName.equalsIgnoreCase("DUE") && !isNull(prop.propValue))
                eventmap.put("duration", prop.propValue);
            if(prop.propName.equalsIgnoreCase("SUMMARY") && !isNull(prop.propValue))
                eventmap.put("title", prop.propValue);
            if(prop.propName.equalsIgnoreCase("COMPLETED") && !isNull(prop.propValue) && time.parse2445(prop.propValue))
                eventmap.put("lastDate", Long.valueOf(time.toMillis()));
            if(prop.propName.equalsIgnoreCase("LOCATION") && !isNull(prop.propValue))
                eventmap.put("eventLocation", prop.propValue);
            if(prop.propName.equalsIgnoreCase("RRULE") && !isNull(prop.propValue))
                eventmap.put("rrule", prop.propValue);
            ContentValues remindermap = new ContentValues();
            remindermap.put("minutes", Integer.valueOf(-1));
            if(prop.propName.equalsIgnoreCase("AALARM"))
            {
                remindermap.put("method", Integer.valueOf(1));
                reminderList.add(remindermap);
                eventmap.put("hasAlarm", Integer.valueOf(Integer.parseInt("1")));
            }
            if(prop.propName.equalsIgnoreCase("DALARM"))
            {
                remindermap.put("method", Integer.valueOf(0));
                reminderList.add(remindermap);
                eventmap.put("hasAlarm", Integer.valueOf(Integer.parseInt("1")));
            }
            if(prop.propName.equalsIgnoreCase("MALARM"))
            {
                remindermap.put("method", Integer.valueOf(2));
                reminderList.add(remindermap);
                eventmap.put("hasAlarm", Integer.valueOf(Integer.parseInt("1")));
            }
            if(prop.propName.equalsIgnoreCase("PALARM"))
            {
                remindermap.put("method", Integer.valueOf(0));
                reminderList.add(remindermap);
                eventmap.put("hasAlarm", Integer.valueOf(Integer.parseInt("1")));
            }
            if(prop.propName.equalsIgnoreCase("STATUS"))
            {
                if(prop.propValue.equalsIgnoreCase("TENTATIVE"))
                    eventmap.put("eventStatus", Integer.valueOf(0));
                if(prop.propValue.equalsIgnoreCase("CONFIRMED"))
                    eventmap.put("eventStatus", Integer.valueOf(1));
                if(prop.propValue.equalsIgnoreCase("CANCELLED"))
                    eventmap.put("eventStatus", Integer.valueOf(2));
            }
        } while(true);
        return eventmap;
    }

    private void judgeVersion(String vcalStr)
    {
        if(version == null)
        {
            int verIdx = vcalStr.indexOf("\nVERSION:");
            if(verIdx == -1)
            {
                version = "vcalendar1.0";
            } else
            {
                String verStr = vcalStr.substring(verIdx, vcalStr.indexOf("\n", verIdx + 1));
                if(verStr.indexOf("1.0") > 0)
                    version = "vcalendar1.0";
                else
                if(verStr.indexOf("2.0") > 0)
                    version = "vcalendar2.0";
                else
                    version = "vcalendar1.0";
            }
        }
        if(version.equals("vcalendar1.0"))
            mParser = new VCalParser();
        if(version.equals("vcalendar2.0"))
            mParser = new VCalParser_V20();
    }

    private String listToString(List list)
    {
        StringBuilder typeListB = new StringBuilder("");
        String type;
        for(Iterator i$ = list.iterator(); i$.hasNext(); typeListB.append(type).append(";"))
            type = (String)i$.next();

        String typeList = typeListB.toString();
        if(typeList.endsWith(";"))
            return typeList.substring(0, typeList.length() - 1);
        else
            return typeList;
    }

    private int getFirstID_CAL()
        throws Exception
    {
        Cursor c = context.createPackageContext("com.google.android.syncmltestcalendar", 1).getContentResolver().query(android.provider.SyncMLTestCalendar.Calendars.CONTENT_URI, null, null, null, null);
        if(c == null)
            return -1;
        if(c.next())
        {
            int id = c.getInt(c.getColumnIndex("_id"));
            c.close();
            return id;
        } else
        {
            c.close();
            return -1;
        }
    }

    private int getNextMaxID_EVENT()
        throws Exception
    {
        if(curEventid == -1)
        {
            Cursor c = context.createPackageContext("com.google.android.syncmltestcalendar", 1).getContentResolver().query(android.provider.SyncMLTestCalendar.Events.CONTENT_URI, null, null, null, "Events._id desc");
            int maxid = 0;
            if(c.next())
                maxid = c.getInt(c.getColumnIndex("_id"));
            c.close();
            curEventid = maxid + 1;
            return curEventid;
        } else
        {
            return ++curEventid;
        }
    }

    private static boolean isNull(String str)
    {
        return str == null || str.trim().equals("");
    }

    private String verifyVCal(String vcalStr)
    {
        judgeVersion(vcalStr);
        vcalStr = vcalStr.replaceAll("\r\n", "\n");
        String strlist[] = vcalStr.split("\n");
        StringBuffer v21str = new StringBuffer("");
        for(int i = 0; i < strlist.length; i++)
            if(strlist[i].indexOf(":") < 0)
            {
                if(strlist[i].length() == 0 && strlist[i + 1].indexOf(":") > 0)
                    v21str.append(strlist[i]).append("\r\n");
                else
                    v21str.append(" ").append(strlist[i]).append("\r\n");
            } else
            {
                v21str.append(strlist[i]).append("\r\n");
            }

        System.out.println((new StringBuilder()).append("==after verify:\r\n").append(v21str.toString()).toString());
        return v21str.toString();
    }

    ContentProvider provider;
    VParser mParser;
    VDataBuilder mBuilder;
    public static final String VERSION_VCALENDAR10 = "vcalendar1.0";
    public static final String VERSION_VCALENDAR20 = "vcalendar2.0";
    String version;
    Context context;
    int curEventid;
    ArrayList reminderList;
    private IContentProvider mIContentProvider;
    private static final String mRootURI = "content://syncmltestcalendar";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -