Example usage for android.util Log isLoggable

List of usage examples for android.util Log isLoggable

Introduction

In this page you can find the example usage for android.util Log isLoggable.

Prototype

public static native boolean isLoggable(String tag, int level);

Source Link

Document

Checks to see whether or not a log for the specified tag is loggable at the specified level.

Usage

From source file:com.google.android.dialer.provider.DialerProvider.java

private Cursor handleFilter(String[] projection, String filter, int limitInt, Location lastLocation) {
    if (Log.isLoggable("DialerProvider", Log.VERBOSE)) {
        Log.v("DialerProvider", "handleFilter(" + filter + ")");
    }//  w ww. ja va2 s .c o  m

    if (filter != null) {
        JSONArray response = null;

        try {
            filter = URLDecoder.decode(filter, "UTF-8");
            ContentResolver resolver = getContext().getContentResolver();

            int minQueryLen = com.google.android.gsf.Gservices.getInt(resolver,
                    "dialer_nearby_places_min_query_len", 2);
            int maxQueryLen = com.google.android.gsf.Gservices.getInt(resolver,
                    "dialer_nearby_places_max_query_len", 50);
            int radius = com.google.android.gsf.Gservices.getInt(resolver,
                    "dialer_nearby_places_directory_radius_meters", 1000);

            int length = filter.length();
            if (length >= minQueryLen) {
                if (length > maxQueryLen) {
                    filter = filter.substring(0, maxQueryLen);
                }

                Uri.Builder builder = Uri
                        .parse(rewriteUrl("https://www.google.com/complete/search?gs_ri=dialer")).buildUpon()
                        .appendQueryParameter("q", filter).appendQueryParameter("hl",
                                getContext().getResources().getConfiguration().locale.getLanguage());

                builder = builder
                        .appendQueryParameter("sll",
                                String.format("%f,%f", lastLocation.getLatitude(), lastLocation.getLongitude()))
                        .appendQueryParameter("radius", Integer.toString(radius))
                        .appendQueryParameter("gs_gbg", getRandomNoiseString());

                response = getSuggestResponseInJsonArrayFormat(builder.build());

                if (Log.isLoggable("DialerProvider", Log.VERBOSE)) {
                    Log.v("DialerProvider", "Results: " + response);
                }

                Cursor cur = buildResultCursor(projection, response, limitInt);
                if (Log.isLoggable("DialerProvider", Log.VERBOSE)) {
                    Log.v("DialerProvider", "handleFilter(" + filter + "): " + cur.getCount() + " matches");
                }

                return cur;
            }
        } catch (UnsupportedEncodingException e) {
            // TODO: Something should probably go here
        } catch (IOException e) {
            Log.e("DialerProvider", "Failed to execute query", e);
        } catch (JSONException e) {
            Log.e("DialerProvider", "Invalid response to query: " + response, e);
        }
    }

    return null;
}

From source file:info.guardianproject.netcipher.client.SSLConnectionSocketFactory.java

@Override
public Socket createLayeredSocket(final Socket socket, final String target, final int port,
        final HttpContext context) throws IOException {
    final SSLSocket sslsock = (SSLSocket) this.socketfactory.createSocket(socket, target, port, true);
    if (supportedProtocols != null) {
        sslsock.setEnabledProtocols(supportedProtocols);
    } else {/*  w ww  .  ja  v a 2  s .c om*/
        // If supported protocols are not explicitly set, remove all SSL protocol versions
        final String[] allProtocols = sslsock.getEnabledProtocols();
        final List<String> enabledProtocols = new ArrayList<String>(allProtocols.length);
        for (String protocol : allProtocols) {
            if (!protocol.startsWith("SSL")) {
                enabledProtocols.add(protocol);
            }
        }
        if (!enabledProtocols.isEmpty()) {
            sslsock.setEnabledProtocols(enabledProtocols.toArray(new String[enabledProtocols.size()]));
        }
    }
    if (supportedCipherSuites != null) {
        sslsock.setEnabledCipherSuites(supportedCipherSuites);
    }

    /*
        if (this.log.isDebugEnabled()) {
          this.log.debug("Enabled protocols: " + Arrays.asList(sslsock.getEnabledProtocols()));
          this.log.debug("Enabled cipher suites:" + Arrays.asList(sslsock.getEnabledCipherSuites()));
        }
    */

    prepareSocket(sslsock);

    // Android specific code to enable SNI
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Enabling SNI for " + target);
        }
        try {
            Method method = sslsock.getClass().getMethod("setHostname", String.class);
            method.invoke(sslsock, target);
        } catch (Exception ex) {
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "SNI configuration failed", ex);
            }
        }
    }
    // End of Android specific code

    //    this.log.debug("Starting handshake");
    sslsock.startHandshake();
    verifyHostname(sslsock, target);
    return sslsock;
}

From source file:com.mobileglobe.android.customdialer.common.model.AccountTypeManager.java

/**
 * Loads account list and corresponding account types (potentially with data sets). Always
 * called on a background thread.// www. j a v  a2s.  c  om
 */
protected void loadAccountsInBackground() {
    if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
        Log.d(Constants.PERFORMANCE_TAG, "AccountTypeManager.loadAccountsInBackground start");
    }
    TimingLogger timings = new TimingLogger(TAG, "loadAccountsInBackground");
    final long startTime = SystemClock.currentThreadTimeMillis();
    final long startTimeWall = SystemClock.elapsedRealtime();

    // Account types, keyed off the account type and data set concatenation.
    final Map<AccountTypeWithDataSet, AccountType> accountTypesByTypeAndDataSet = Maps.newHashMap();

    // The same AccountTypes, but keyed off {@link RawContacts#ACCOUNT_TYPE}.  Since there can
    // be multiple account types (with different data sets) for the same type of account, each
    // type string may have multiple AccountType entries.
    final Map<String, List<AccountType>> accountTypesByType = Maps.newHashMap();

    final List<AccountWithDataSet> allAccounts = Lists.newArrayList();
    final List<AccountWithDataSet> contactWritableAccounts = Lists.newArrayList();
    final List<AccountWithDataSet> groupWritableAccounts = Lists.newArrayList();
    final Set<String> extensionPackages = Sets.newHashSet();

    final AccountManager am = mAccountManager;

    final SyncAdapterType[] syncs = ContentResolver.getSyncAdapterTypes();
    final AuthenticatorDescription[] auths = am.getAuthenticatorTypes();

    // First process sync adapters to find any that provide contact data.
    for (SyncAdapterType sync : syncs) {
        if (!ContactsContract.AUTHORITY.equals(sync.authority)) {
            // Skip sync adapters that don't provide contact data.
            continue;
        }

        // Look for the formatting details provided by each sync
        // adapter, using the authenticator to find general resources.
        final String type = sync.accountType;
        final AuthenticatorDescription auth = findAuthenticator(auths, type);
        if (auth == null) {
            Log.w(TAG, "No authenticator found for type=" + type + ", ignoring it.");
            continue;
        }

        AccountType accountType;
        if (GoogleAccountType.ACCOUNT_TYPE.equals(type)) {
            accountType = new GoogleAccountType(mContext, auth.packageName);
        } else if (ExchangeAccountType.isExchangeType(type)) {
            accountType = new ExchangeAccountType(mContext, auth.packageName, type);
        } else if (SamsungAccountType.isSamsungAccountType(mContext, type, auth.packageName)) {
            accountType = new SamsungAccountType(mContext, auth.packageName, type);
        } else {
            Log.d(TAG, "Registering external account type=" + type + ", packageName=" + auth.packageName);
            accountType = new ExternalAccountType(mContext, auth.packageName, false);
        }
        if (!accountType.isInitialized()) {
            if (accountType.isEmbedded()) {
                throw new IllegalStateException(
                        "Problem initializing embedded type " + accountType.getClass().getCanonicalName());
            } else {
                // Skip external account types that couldn't be initialized.
                continue;
            }
        }

        accountType.accountType = auth.type;
        accountType.titleRes = auth.labelId;
        accountType.iconRes = auth.iconId;

        addAccountType(accountType, accountTypesByTypeAndDataSet, accountTypesByType);

        // Check to see if the account type knows of any other non-sync-adapter packages
        // that may provide other data sets of contact data.
        extensionPackages.addAll(accountType.getExtensionPackageNames());
    }

    // If any extension packages were specified, process them as well.
    if (!extensionPackages.isEmpty()) {
        Log.d(TAG, "Registering " + extensionPackages.size() + " extension packages");
        for (String extensionPackage : extensionPackages) {
            ExternalAccountType accountType = new ExternalAccountType(mContext, extensionPackage, true);
            if (!accountType.isInitialized()) {
                // Skip external account types that couldn't be initialized.
                continue;
            }
            if (!accountType.hasContactsMetadata()) {
                Log.w(TAG, "Skipping extension package " + extensionPackage + " because"
                        + " it doesn't have the CONTACTS_STRUCTURE metadata");
                continue;
            }
            if (TextUtils.isEmpty(accountType.accountType)) {
                Log.w(TAG, "Skipping extension package " + extensionPackage + " because"
                        + " the CONTACTS_STRUCTURE metadata doesn't have the accountType" + " attribute");
                continue;
            }
            Log.d(TAG, "Registering extension package account type=" + accountType.accountType + ", dataSet="
                    + accountType.dataSet + ", packageName=" + extensionPackage);

            addAccountType(accountType, accountTypesByTypeAndDataSet, accountTypesByType);
        }
    }
    timings.addSplit("Loaded account types");

    Account[] accounts = mAccountManager.getAccounts();
    for (Account account : accounts) {
        boolean syncable = ContentResolver.getIsSyncable(account, ContactsContract.AUTHORITY) > 0;

        if (syncable) {
            List<AccountType> accountTypes = accountTypesByType.get(account.type);
            if (accountTypes != null) {
                // Add an account-with-data-set entry for each account type that is
                // authenticated by this account.
                for (AccountType accountType : accountTypes) {
                    AccountWithDataSet accountWithDataSet = new AccountWithDataSet(account.name, account.type,
                            accountType.dataSet);
                    allAccounts.add(accountWithDataSet);
                    if (accountType.areContactsWritable()) {
                        contactWritableAccounts.add(accountWithDataSet);
                    }
                    if (accountType.isGroupMembershipEditable()) {
                        groupWritableAccounts.add(accountWithDataSet);
                    }
                }
            }
        }
    }

    Collections.sort(allAccounts, ACCOUNT_COMPARATOR);
    Collections.sort(contactWritableAccounts, ACCOUNT_COMPARATOR);
    Collections.sort(groupWritableAccounts, ACCOUNT_COMPARATOR);

    timings.addSplit("Loaded accounts");

    synchronized (this) {
        mAccountTypesWithDataSets = accountTypesByTypeAndDataSet;
        mAccounts = allAccounts;
        mContactWritableAccounts = contactWritableAccounts;
        mGroupWritableAccounts = groupWritableAccounts;
        mInvitableAccountTypes = findAllInvitableAccountTypes(mContext, allAccounts,
                accountTypesByTypeAndDataSet);
    }

    timings.dumpToLog();
    final long endTimeWall = SystemClock.elapsedRealtime();
    final long endTime = SystemClock.currentThreadTimeMillis();

    Log.i(TAG,
            "Loaded meta-data for " + mAccountTypesWithDataSets.size() + " account types, " + mAccounts.size()
                    + " accounts in " + (endTimeWall - startTimeWall) + "ms(wall) " + (endTime - startTime)
                    + "ms(cpu)");

    if (mInitializationLatch != null) {
        mInitializationLatch.countDown();
        mInitializationLatch = null;
    }
    if (Log.isLoggable(Constants.PERFORMANCE_TAG, Log.DEBUG)) {
        Log.d(Constants.PERFORMANCE_TAG, "AccountTypeManager.loadAccountsInBackground finish");
    }

    // Check filter validity since filter may become obsolete after account update. It must be
    // done from UI thread.
    mMainThreadHandler.post(mCheckFilterValidityRunnable);
}

From source file:com.samsung.multiwindow.MultiWindow.java

/**
 * Get the MultiWindow enabled applications and activity names
 * /*from ww  w  . jav a  2 s.  c o  m*/
 * @param windowType
 *            The window type freestyle or splitstyle.
 * @param callbackContext
 *            The callback id used when calling back into JavaScript.
 * 
 */
private void getMultiWindowApps(final String windowType, final CallbackContext callbackContext)
        throws JSONException {

    if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) {
        Log.d(TAG, "Inside getMultiWindowApps");
    }
    cordova.getThreadPool().execute(new Runnable() {

        public void run() {

            JSONArray multiWindowApps = new JSONArray();
            Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);
            List<ResolveInfo> resolveInfos = cordova.getActivity().getPackageManager().queryIntentActivities(
                    intent, PackageManager.GET_RESOLVED_FILTER | PackageManager.GET_META_DATA);

            try {
                // Get the multiwindow enabled applications

                int index = 0;
                for (ResolveInfo r : resolveInfos) {
                    if (r.activityInfo != null && r.activityInfo.applicationInfo.metaData != null) {
                        if (r.activityInfo.applicationInfo.metaData
                                .getBoolean("com.sec.android.support.multiwindow")
                                || r.activityInfo.applicationInfo.metaData
                                        .getBoolean("com.samsung.android.sdk.multiwindow.enable")) {
                            JSONObject appInfo = new JSONObject();
                            boolean bUnSupportedMultiWinodw = false;
                            if (windowType.equalsIgnoreCase("splitstyle")) {
                                if (r.activityInfo.metaData != null) {
                                    String activityWindowStyle = r.activityInfo.metaData
                                            .getString("com.sec.android.multiwindow.activity.STYLE");
                                    if (activityWindowStyle != null) {
                                        ArrayList<String> activityWindowStyles = new ArrayList<String>(
                                                Arrays.asList(activityWindowStyle.split("\\|")));
                                        if (!activityWindowStyles.isEmpty()) {
                                            if (activityWindowStyles.contains("fullscreenOnly")) {
                                                bUnSupportedMultiWinodw = true;
                                            }
                                        }
                                    }
                                }
                            }

                            if (!bUnSupportedMultiWinodw || !windowType.equalsIgnoreCase("splitstyle")) {
                                appInfo.put("packageName", r.activityInfo.applicationInfo.packageName);
                                appInfo.put("activity", r.activityInfo.name);
                                multiWindowApps.put(index++, appInfo);
                            }
                        }
                    }
                }
                callbackContext.success(multiWindowApps);
            } catch (Exception e) {

                callbackContext.error(e.getMessage());
            }

        }
    });
}

From source file:com.samsung.spen.SpenPlugin.java

/**
 * /* ww w .j a  va  2  s  .  c  om*/
 * @param args
 *                 JSON array of options sent from the script.
 * @param surfaceType
 *                int
 * @param callbackContext
 *                CallbackContext
 * @return   options
 *                SpenTrayBarOptions
 * @throws JSONException
 */
private SpenTrayBarOptions createTrayBarOptions(JSONArray args, int surfaceType,
        CallbackContext callbackContext) throws JSONException {
    if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) {
        Log.d(TAG, "Inside createTrayBarOptions");
    }

    String tempId = args.getString(ID);
    if (tempId != null) {
        tempId = tempId.trim();
        if (tempId.length() > MAX_ID_LENGTH) {
            tempId = tempId.substring(0, MAX_ID_LENGTH);
        }
    }

    final String id = tempId;
    if (id == null || id.equals("") || id.equals("null") || !id.matches("^[ !#-)+-.0-9;=@-Z^-{}~]+$")) {
        SpenException.sendPluginResult(SpenExceptionType.INVALID_SURFACE_ID, callbackContext);
        return null;
    }

    int sPenFlags = args.optInt(SPEN_FLAGS, Integer.MIN_VALUE);
    if (sPenFlags == Integer.MIN_VALUE || sPenFlags > Utils.MAX_FLAGS_VALUE
            || sPenFlags < Utils.MIN_FLAGS_VALUE) {
        SpenException.sendPluginResult(SpenExceptionType.INVALID_FLAGS, callbackContext);
        return null;
    }

    int returnType = args.optInt(RETURN_TYPE);
    if (returnType != Utils.RETURN_TYPE_IMAGE_DATA && returnType != Utils.RETURN_TYPE_IMAGE_URI
            && returnType != Utils.RETURN_TYPE_TEXT) {

        SpenException.sendPluginResult(SpenExceptionType.INVALID_RETURN_TYPE, callbackContext);
        return null;
    }

    String backgroundColor = args.getString(BACKGROUND_COLOR);

    String imagePath = args.getString(IMAGE_PATH);
    if (imagePath.equals("") || imagePath.equals("null")) {
        imagePath = null;
    } else {
        imagePath = Uri.decode(imagePath);
        String truncatedPath = truncateQueryPart(imagePath);
        File file = new File(truncatedPath);
        if (file.exists()) {
            imagePath = truncatedPath;
        }
    }

    int bgImageScaleType = args.optInt(BACKGROUND_IMAGE_SCALE_TYPE);
    if (bgImageScaleType != Utils.BACKGROUND_IMAGE_MODE_CENTER
            && bgImageScaleType != Utils.BACKGROUND_IMAGE_MODE_FIT
            && bgImageScaleType != Utils.BACKGROUND_IMAGE_MODE_STRETCH
            && bgImageScaleType != Utils.BACKGROUND_IMAGE_MODE_TILE) {
        bgImageScaleType = Utils.BACKGROUND_IMAGE_MODE_FIT;
    }

    int imageUriScaleType = args.optInt(IMAGE_URI_SCALE_TYPE);
    if (imageUriScaleType != Utils.IMAGE_URI_MODE_CENTER && imageUriScaleType != Utils.IMAGE_URI_MODE_FIT
            && imageUriScaleType != Utils.IMAGE_URI_MODE_TILE
            && imageUriScaleType != Utils.IMAGE_URI_MODE_STRETCH) {
        imageUriScaleType = Utils.IMAGE_URI_MODE_FIT;
    }

    if (surfaceType == Utils.SURFACE_INLINE) {
        if ((sPenFlags & Utils.FLAG_ADD_PAGE) == Utils.FLAG_ADD_PAGE) {
            if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) {
                Log.d(TAG, "Add Page is not supported in Inline");
            }
            sPenFlags = sPenFlags & ~Utils.FLAG_ADD_PAGE;
        }
    } else if (surfaceType == Utils.SURFACE_POPUP) {

        if ((sPenFlags & Utils.FLAG_EDIT) == Utils.FLAG_EDIT) {
            if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) {
                Log.d(TAG, "Edit Page is not supported in Popup");
            }
            sPenFlags = sPenFlags & ~Utils.FLAG_EDIT;
        }

        if ((sPenFlags & Utils.FLAG_PEN) == Utils.FLAG_PEN) {
            if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) {
                Log.d(TAG, "Pen option is provided by default, is not configurable in Popup");
            }
            sPenFlags = sPenFlags & ~Utils.FLAG_PEN;

        }

        if ((sPenFlags & Utils.FLAG_ERASER) == Utils.FLAG_ERASER) {
            if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) {
                Log.d(TAG, "Eraser option is provided by default, is not configurable in Popup");
            }
            sPenFlags = sPenFlags & ~Utils.FLAG_ERASER;

        }

        if ((sPenFlags & Utils.FLAG_UNDO_REDO) == Utils.FLAG_UNDO_REDO) {
            if (Log.isLoggable(Utils.SPEN, Log.DEBUG)) {
                Log.d(TAG, "Undo Redo option is provided by default, is not configurable in Popup");
            }
            sPenFlags = sPenFlags & ~Utils.FLAG_UNDO_REDO;

        }
    } else {
        SpenException.sendPluginResult(SpenExceptionType.INVALID_SURFACE_TYPE, callbackContext);
        return null;
    }

    if ((sPenFlags & Utils.FLAG_TEXT_RECOGNITION) == Utils.FLAG_TEXT_RECOGNITION
            || (sPenFlags & Utils.FLAG_SHAPE_RECOGNITION) == Utils.FLAG_SHAPE_RECOGNITION) {
        sPenFlags = sPenFlags | Utils.FLAG_SELECTION;
    }

    SpenTrayBarOptions options = new SpenTrayBarOptions(sPenFlags);
    options.setId(id);
    options.setIsfeatureEnabled(mSpenState == SPEN_AND_HAND_SUPPORTED ? true : false);
    options.setColor(backgroundColor);
    options.setBgImageScaleType(bgImageScaleType);
    options.setImageUriScaleType(imageUriScaleType);
    options.setReturnType(returnType);
    options.setSurfaceType(surfaceType);
    options.setImagePath(imagePath);
    options.setDensity(mActivity.getApplicationContext().getResources().getDisplayMetrics().density);

    if (surfaceType == Utils.SURFACE_INLINE) {
        long xRect = 0, yRect = 0, width = 0, height = 0, xBodyRect = 0, yBodyRect = 0;
        if (args.isNull(RECTANGLE_X_VALUE) || args.isNull(RECTANGLE_Y_VALUE) || args.isNull(WIDTH)
                || args.isNull(HEIGHT)) {
            SpenException.sendPluginResult(SpenExceptionType.INVALID_INLINE_CORDINATES, callbackContext);
            return null;
        } else {
            xRect = args.optLong(RECTANGLE_X_VALUE, Integer.MIN_VALUE);
            yRect = args.optLong(RECTANGLE_Y_VALUE, Integer.MIN_VALUE);
            width = args.optLong(WIDTH, Integer.MIN_VALUE);
            height = args.optLong(HEIGHT, Integer.MIN_VALUE);
            xBodyRect = args.optLong(BODY_RECTANGLE_X_VALUE, Integer.MIN_VALUE);
            yBodyRect = args.optLong(BODY_RECTANGLE_Y_VALUE, Integer.MAX_VALUE);
            if (xRect == Integer.MIN_VALUE || yRect == Integer.MIN_VALUE || width == Integer.MIN_VALUE
                    || height == Integer.MIN_VALUE || xBodyRect == Integer.MIN_VALUE
                    || yBodyRect == Integer.MIN_VALUE || xRect > (long) Integer.MAX_VALUE
                    || yRect > (long) Integer.MAX_VALUE || width > (long) Integer.MAX_VALUE
                    || height > (long) Integer.MAX_VALUE || xBodyRect > (long) Integer.MAX_VALUE
                    || yBodyRect > (long) Integer.MAX_VALUE) {
                SpenException.sendPluginResult(SpenExceptionType.INVALID_INLINE_CORDINATES, callbackContext);
                return null;
            }
        }
        SurfacePosition surfacePosition = new SurfacePosition(mActivity.getApplicationContext(), (int) width,
                (int) height, (int) xRect - (int) xBodyRect, (int) yRect - (int) yBodyRect);
        if (!surfacePosition.isSurfaceValid(options, mActivity.getApplicationContext())) {
            SpenException.sendPluginResult(SpenExceptionType.INVALID_INLINE_CORDINATES, callbackContext);
            return null;
        }
        options.setSurfacePosition(surfacePosition);
    } else if (surfaceType == Utils.SURFACE_POPUP) {
        long popupWidth = 0, popupHeight = 0;
        popupWidth = args.optLong(POPUP_WIDTH, Integer.MIN_VALUE);
        popupHeight = args.optLong(POPUP_HEIGHT, Integer.MIN_VALUE);
        SurfacePosition surfacePosition = new SurfacePosition(mActivity.getApplicationContext(),
                (int) popupWidth, (int) popupHeight);
        options.setSurfacePosition(surfacePosition);
    }
    return options;
}

From source file:com.moez.QKSMS.model.MediaModelFactory.java

private static MediaModel getGenericMediaModel(Context context, String tag, String src, SMILMediaElement sme,
        PduPart part, RegionModel regionModel) throws IOException, MmsException {
    byte[] bytes = part.getContentType();
    if (bytes == null) {
        throw new IllegalArgumentException("Content-Type of the part may not be null.");
    }//from  w  w w .  j ava 2s  .c  o m

    String contentType = new String(bytes);
    MediaModel media;

    switch (tag) {
    case SmilHelper.ELEMENT_TAG_TEXT:
        media = new TextModel(context, contentType, src, part.getCharset(), part.getData(), regionModel);
        break;
    case SmilHelper.ELEMENT_TAG_IMAGE:
        media = new ImageModel(context, contentType, src, part.getDataUri(), regionModel);
        break;
    case SmilHelper.ELEMENT_TAG_VIDEO:
        media = new VideoModel(context, contentType, src, part.getDataUri(), regionModel);
        break;
    case SmilHelper.ELEMENT_TAG_AUDIO:
        media = new AudioModel(context, contentType, src, part.getDataUri());
        break;
    case SmilHelper.ELEMENT_TAG_REF:
        if (ContentType.isTextType(contentType)) {
            media = new TextModel(context, contentType, src, part.getCharset(), part.getData(), regionModel);
        } else if (ContentType.isImageType(contentType)) {
            media = new ImageModel(context, contentType, src, part.getDataUri(), regionModel);
        } else if (ContentType.isVideoType(contentType)) {
            media = new VideoModel(context, contentType, src, part.getDataUri(), regionModel);
        } else if (ContentType.isAudioType(contentType)) {
            media = new AudioModel(context, contentType, src, part.getDataUri());
        } else {
            Log.d(TAG, "[MediaModelFactory] getGenericMediaModel Unsupported Content-Type: " + contentType);
            media = createEmptyTextModel(context, regionModel);
        }
        break;
    default:
        throw new IllegalArgumentException("Unsupported TAG: " + tag);
    }

    // Set 'begin' property.
    int begin = 0;
    TimeList tl = sme.getBegin();
    if ((tl != null) && (tl.getLength() > 0)) {
        // We only support a single begin value.
        Time t = tl.item(0);
        begin = (int) (t.getResolvedOffset() * 1000);
    }
    media.setBegin(begin);

    // Set 'duration' property.
    int duration = (int) (sme.getDur() * 1000);
    if (duration <= 0) {
        tl = sme.getEnd();
        if ((tl != null) && (tl.getLength() > 0)) {
            // We only support a single end value.
            Time t = tl.item(0);
            if (t.getTimeType() != Time.SMIL_TIME_INDEFINITE) {
                duration = (int) (t.getResolvedOffset() * 1000) - begin;

                if (duration == 0 && (media instanceof AudioModel || media instanceof VideoModel)) {
                    duration = MmsConfig.getMinimumSlideElementDuration();
                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
                        Log.v(TAG, "[MediaModelFactory] compute new duration for " + tag + ", duration="
                                + duration);
                    }
                }
            }
        }
    }

    media.setDuration(duration);

    if (!MmsConfig.getSlideDurationEnabled()) {
        /**
         * Because The slide duration is not supported by mmsc,
         * the device has to set fill type as FILL_FREEZE.
         * If not, the media will disappear while rotating the screen
         * in the slide show play view.
         */
        media.setFill(SMILMediaElement.FILL_FREEZE);
    } else {
        // Set 'fill' property.
        media.setFill(sme.getFill());
    }
    return media;
}

From source file:com.example.jumpnote.android.SyncAdapter.java

public List<ModelJava.Note> getLocallyChangedNotes(ContentProviderClient provider, Account account,
        Date sinceDate) throws RemoteException {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Getting local notes changed since " + Long.toString(sinceDate.getTime()));
    }// w w w  .j  ava  2 s.  c om
    Cursor notesCursor = provider.query(JumpNoteContract.buildNoteListUri(account.name), PROJECTION,
            JumpNoteContract.Notes.MODIFIED_DATE + " > ?", new String[] { Long.toString(sinceDate.getTime()) },
            null);

    List<ModelJava.Note> locallyChangedNotes = new ArrayList<ModelJava.Note>();
    while (notesCursor.moveToNext()) {
        ContentValues values = new ContentValues();
        DatabaseUtils.cursorRowToContentValues(notesCursor, values);
        ModelJava.Note changedNote = new ModelJava.Note(values);
        locallyChangedNotes.add(changedNote);
    }

    notesCursor.close();
    return locallyChangedNotes;
}

From source file:KSView.PercentLayoutHelper.java

/**
 * Iterates over children and restores their original dimensions that were changed for
 * percentage values. Calling this method only makes sense if you previously called
 * {@link PercentLayoutHelper#adjustChildren(int, int)}.
 *//* w  ww. j av a2s.c  o m*/

public void restoreOriginalParams() {
    for (int i = 0, N = mHost.getChildCount(); i < N; i++) {
        View view = mHost.getChildAt(i);
        ViewGroup.LayoutParams params = view.getLayoutParams();
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            LogUtil.d(TAG, "should restore " + view + " " + params);
        }
        if (params instanceof PercentLayoutParams) {
            PercentLayoutInfo info = ((PercentLayoutParams) params).getPercentLayoutInfo();
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                LogUtil.d(TAG, "using " + info);
            }
            if (info != null) {
                if (params instanceof ViewGroup.MarginLayoutParams) {
                    info.restoreMarginLayoutParams((ViewGroup.MarginLayoutParams) params);
                } else {
                    info.restoreLayoutParams(params);
                }
            }
        }
    }
}

From source file:io.requery.android.database.sqlite.SQLiteQueryBuilder.java

/**
 * Perform a query by combining all current settings and the
 * information passed into this method./*  ww  w. j  a v a 2 s .com*/
 *
 * @param db the database to query on
 * @param projectionIn A list of which columns to return. Passing
 *   null will return all columns, which is discouraged to prevent
 *   reading data from storage that isn't going to be used.
 * @param selection A filter declaring which rows to return,
 *   formatted as an SQL WHERE clause (excluding the WHERE
 *   itself). Passing null will return all rows for the given URL.
 * @param selectionArgs You may include ?s in selection, which
 *   will be replaced by the values from selectionArgs, in order
 *   that they appear in the selection. The values will be bound
 *   as Strings.
 * @param groupBy A filter declaring how to group rows, formatted
 *   as an SQL GROUP BY clause (excluding the GROUP BY
 *   itself). Passing null will cause the rows to not be grouped.
 * @param having A filter declare which row groups to include in
 *   the cursor, if row grouping is being used, formatted as an
 *   SQL HAVING clause (excluding the HAVING itself).  Passing
 *   null will cause all row groups to be included, and is
 *   required when row grouping is not being used.
 * @param sortOrder How to order the rows, formatted as an SQL
 *   ORDER BY clause (excluding the ORDER BY itself). Passing null
 *   will use the default sort order, which may be unordered.
 * @param limit Limits the number of rows returned by the query,
 *   formatted as LIMIT clause. Passing null denotes no LIMIT clause.
 * @param cancellationSignal A signal to cancel the operation in progress, or null if none.
 * If the operation is canceled, then {@link OperationCanceledException} will be thrown
 * when the query is executed.
 * @return a cursor over the result set
 * @see android.content.ContentResolver#query(android.net.Uri, String[],
 *      String, String[], String)
 */
public Cursor query(SQLiteDatabase db, String[] projectionIn, String selection, String[] selectionArgs,
        String groupBy, String having, String sortOrder, String limit, CancellationSignal cancellationSignal) {
    if (mTables == null) {
        return null;
    }

    if (mStrict && selection != null && selection.length() > 0) {
        // Validate the user-supplied selection to detect syntactic anomalies
        // in the selection string that could indicate a SQL injection attempt.
        // The idea is to ensure that the selection clause is a valid SQL expression
        // by compiling it twice: once wrapped in parentheses and once as
        // originally specified. An attacker cannot create an expression that
        // would escape the SQL expression while maintaining balanced parentheses
        // in both the wrapped and original forms.
        String sqlForValidation = buildQuery(projectionIn, "(" + selection + ")", groupBy, having, sortOrder,
                limit);
        validateQuerySql(db, sqlForValidation, cancellationSignal); // will throw if query is invalid
    }

    String sql = buildQuery(projectionIn, selection, groupBy, having, sortOrder, limit);

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Performing query: " + sql);
    }
    return db.rawQueryWithFactory(mFactory, sql, selectionArgs, SQLiteDatabase.findEditTable(mTables),
            cancellationSignal); // will throw if query is invalid
}