Java Code Examples for com.example.android.common.logger.Log#d()

The following examples show how to use com.example.android.common.logger.Log#d() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageWorker.java    From android-DisplayingBitmaps with Apache License 2.0 6 votes vote down vote up
/**
 * Once the image is processed, associates it to the imageView
 */
@Override
protected void onPostExecute(BitmapDrawable value) {
    //BEGIN_INCLUDE(complete_background_work)
    boolean success = false;
    // if cancel was called on this task or the "exit early" flag is set then we're done
    if (isCancelled() || mExitTasksEarly) {
        value = null;
    }

    final ImageView imageView = getAttachedImageView();
    if (value != null && imageView != null) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "onPostExecute - setting bitmap");
        }
        success = true;
        setImageDrawable(imageView, value);
    }
    if (mOnImageLoadedListener != null) {
        mOnImageLoadedListener.onImageLoaded(success);
    }
    //END_INCLUDE(complete_background_work)
}
 
Example 2
Source File: ImageWorker.java    From graphics-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Once the image is processed, associates it to the imageView
 */
@Override
protected void onPostExecute(BitmapDrawable value) {
    //BEGIN_INCLUDE(complete_background_work)
    boolean success = false;
    // if cancel was called on this task or the "exit early" flag is set then we're done
    if (isCancelled() || mExitTasksEarly) {
        value = null;
    }

    final ImageView imageView = getAttachedImageView();
    if (value != null && imageView != null) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "onPostExecute - setting bitmap");
        }
        success = true;
        setImageDrawable(imageView, value);
    }
    if (mOnImageLoadedListener != null) {
        mOnImageLoadedListener.onImageLoaded(success);
    }
    //END_INCLUDE(complete_background_work)
}
 
Example 3
Source File: SafetyNetSampleFragment.java    From android-play-safetynet with Apache License 2.0 6 votes vote down vote up
@Override
public void onFailure(@NonNull Exception e) {
    // An error occurred while communicating with the service.
    mResult = null;

    if (e instanceof ApiException) {
        // An error with the Google Play Services API contains some additional details.
        ApiException apiException = (ApiException) e;
        Log.d(TAG, "Error: " +
                CommonStatusCodes.getStatusCodeString(apiException.getStatusCode()) + ": " +
                apiException.getStatusMessage());
    } else {
        // A different, unknown type of error occurred.
        Log.d(TAG, "ERROR! " + e.getMessage());
    }

}
 
Example 4
Source File: ProvisioningValuesLoader.java    From enterprise-samples with Apache License 2.0 6 votes vote down vote up
private void loadFromFile(HashMap<String, String> values, File file) throws IOException {
    try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
        String line;
        while (null != (line = reader.readLine())) {
            if (line.startsWith("#")) {
                continue;
            }
            int position = line.indexOf("=");
            if (position < 0) { // Not found
                continue;
            }
            String key = line.substring(0, position);
            String value = line.substring(position + 1);
            values.put(key, value);
            Log.d(TAG, key + "=" + value);
        }
    }
}
 
Example 5
Source File: ImageWorker.java    From graphics-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Returns true if the current work has been canceled or if there was no work in
 * progress on this image view.
 * Returns false if the work in progress deals with the same data. The work is not
 * stopped in that case.
 */
public static boolean cancelPotentialWork(Object data, ImageView imageView) {
    //BEGIN_INCLUDE(cancel_potential_work)
    final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);

    if (bitmapWorkerTask != null) {
        final Object bitmapData = bitmapWorkerTask.mData;
        if (bitmapData == null || !bitmapData.equals(data)) {
            bitmapWorkerTask.cancel(true);
            if (BuildConfig.DEBUG) {
                Log.d(TAG, "cancelPotentialWork - cancelled work for " + data);
            }
        } else {
            // The same work is already in progress.
            return false;
        }
    }
    return true;
    //END_INCLUDE(cancel_potential_work)
}
 
Example 6
Source File: ImageCache.java    From android-DisplayingBitmaps with Apache License 2.0 6 votes vote down vote up
/**
 * Clears both the memory and disk cache associated with this ImageCache object. Note that
 * this includes disk access so this should not be executed on the main/UI thread.
 */
public void clearCache() {
    if (mMemoryCache != null) {
        mMemoryCache.evictAll();
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Memory cache cleared");
        }
    }

    synchronized (mDiskCacheLock) {
        mDiskCacheStarting = true;
        if (mDiskLruCache != null && !mDiskLruCache.isClosed()) {
            try {
                mDiskLruCache.delete();
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "Disk cache cleared");
                }
            } catch (IOException e) {
                Log.e(TAG, "clearCache - " + e);
            }
            mDiskLruCache = null;
            initDiskCache();
        }
    }
}
 
Example 7
Source File: BluetoothChatFragment.java    From connectivity-samples with Apache License 2.0 5 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CONNECT_DEVICE_SECURE:
            // When DeviceListActivity returns with a device to connect
            if (resultCode == Activity.RESULT_OK) {
                connectDevice(data, true);
            }
            break;
        case REQUEST_CONNECT_DEVICE_INSECURE:
            // When DeviceListActivity returns with a device to connect
            if (resultCode == Activity.RESULT_OK) {
                connectDevice(data, false);
            }
            break;
        case REQUEST_ENABLE_BT:
            // When the request to enable Bluetooth returns
            if (resultCode == Activity.RESULT_OK) {
                // Bluetooth is now enabled, so set up a chat session
                setupChat();
            } else {
                // User did not enable Bluetooth or an error occurred
                Log.d(TAG, "BT not enabled");
                FragmentActivity activity = getActivity();
                if (activity != null) {
                    Toast.makeText(activity, R.string.bt_not_enabled_leaving,
                            Toast.LENGTH_SHORT).show();
                    activity.finish();
                }
            }
    }
}
 
Example 8
Source File: BluetoothChatFragment.java    From android-BluetoothChat with Apache License 2.0 5 votes vote down vote up
/**
 * Set up the UI and background operations for chat.
 */
private void setupChat() {
    Log.d(TAG, "setupChat()");

    // Initialize the array adapter for the conversation thread
    mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message);

    mConversationView.setAdapter(mConversationArrayAdapter);

    // Initialize the compose field with a listener for the return key
    mOutEditText.setOnEditorActionListener(mWriteListener);

    // Initialize the send button with a listener that for click events
    mSendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Send a message using content of the edit text widget
            View view = getView();
            if (null != view) {
                TextView textView = (TextView) view.findViewById(R.id.edit_text_out);
                String message = textView.getText().toString();
                sendMessage(message);
            }
        }
    });

    // Initialize the BluetoothChatService to perform bluetooth connections
    mChatService = new BluetoothChatService(getActivity(), mHandler);

    // Initialize the buffer for outgoing messages
    mOutStringBuffer = new StringBuffer("");
}
 
Example 9
Source File: BluetoothChatService.java    From connectivity-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Update UI title according to the current state of the chat connection
 */
private synchronized void updateUserInterfaceTitle() {
    mState = getState();
    Log.d(TAG, "updateUserInterfaceTitle() " + mNewState + " -> " + mState);
    mNewState = mState;

    // Give the new state to the Handler so the UI Activity can update
    mHandler.obtainMessage(Constants.MESSAGE_STATE_CHANGE, mNewState, -1).sendToTarget();
}
 
Example 10
Source File: LoggingActivity.java    From android-MultiWindowPlayground with Apache License 2.0 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    // Start logging to UI.
    initializeLogging();

    Log.d(mLogTag, "onStart");
}
 
Example 11
Source File: BluetoothChatService.java    From android-BluetoothChat with Apache License 2.0 5 votes vote down vote up
/**
 * Update UI title according to the current state of the chat connection
 */
private synchronized void updateUserInterfaceTitle() {
    mState = getState();
    Log.d(TAG, "updateUserInterfaceTitle() " + mNewState + " -> " + mState);
    mNewState = mState;

    // Give the new state to the Handler so the UI Activity can update
    mHandler.obtainMessage(Constants.MESSAGE_STATE_CHANGE, mNewState, -1).sendToTarget();
}
 
Example 12
Source File: BluetoothChatService.java    From connectivity-samples with Apache License 2.0 5 votes vote down vote up
public void cancel() {
    Log.d(TAG, "Socket Type" + mSocketType + "cancel " + this);
    try {
        mmServerSocket.close();
    } catch (IOException e) {
        Log.e(TAG, "Socket Type" + mSocketType + "close() of server failed", e);
    }
}
 
Example 13
Source File: LoggingActivity.java    From views-widgets-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();
    // Start logging to UI.
    initializeLogging();

    Log.d(mLogTag, "onStart");
}
 
Example 14
Source File: LoggingActivity.java    From views-widgets-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    super.onMultiWindowModeChanged(isInMultiWindowMode);

    Log.d(mLogTag, "onMultiWindowModeChanged: " + isInMultiWindowMode);
}
 
Example 15
Source File: LoggingActivity.java    From views-widgets-samples with Apache License 2.0 4 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    Log.d(mLogTag, "onPostCreate");
}
 
Example 16
Source File: CardStreamLinearLayout.java    From android-play-places with Apache License 2.0 4 votes vote down vote up
@Override
public void onChildViewRemoved(View parent, View child) {
    Log.d(TAG, "child is removed: " + child);
    mFixedViewList.remove(child);
}
 
Example 17
Source File: ImageCache.java    From graphics-samples with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize the cache, providing all parameters.
 *
 * @param cacheParams The cache parameters to initialize the cache
 */
private void init(ImageCacheParams cacheParams) {
    mCacheParams = cacheParams;

    //BEGIN_INCLUDE(init_memory_cache)
    // Set up memory cache
    if (mCacheParams.memoryCacheEnabled) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Memory cache created (size = " + mCacheParams.memCacheSize + ")");
        }

        // If we're running on Honeycomb or newer, create a set of reusable bitmaps that can be
        // populated into the inBitmap field of BitmapFactory.Options. Note that the set is
        // of SoftReferences which will actually not be very effective due to the garbage
        // collector being aggressive clearing Soft/WeakReferences. A better approach
        // would be to use a strongly references bitmaps, however this would require some
        // balancing of memory usage between this set and the bitmap LruCache. It would also
        // require knowledge of the expected size of the bitmaps. From Honeycomb to JellyBean
        // the size would need to be precise, from KitKat onward the size would just need to
        // be the upper bound (due to changes in how inBitmap can re-use bitmaps).
        mReusableBitmaps =
                Collections.synchronizedSet(new HashSet<SoftReference<Bitmap>>());

        mMemoryCache = new LruCache<String, BitmapDrawable>(mCacheParams.memCacheSize) {

            /**
             * Notify the removed entry that is no longer being cached
             */
            @Override
            protected void entryRemoved(
                    boolean evicted,
                    @NonNull String key,
                    @NonNull BitmapDrawable oldValue,
                    BitmapDrawable newValue
            ) {
                if (oldValue instanceof RecyclingBitmapDrawable) {
                    // The removed entry is a recycling drawable, so notify it
                    // that it has been removed from the memory cache
                    ((RecyclingBitmapDrawable) oldValue).setIsCached(false);
                } else {
                    // The removed entry is a standard BitmapDrawable.
                    // Add the bitmap to a SoftReference set for possible use with inBitmap
                    // later.
                    mReusableBitmaps.add(new SoftReference<>(oldValue.getBitmap()));
                }
            }

            /**
             * Measure item size in kilobytes rather than units which is more practical
             * for a bitmap cache
             */
            @Override
            protected int sizeOf(@NonNull String key, @NonNull BitmapDrawable value) {
                final int bitmapSize = getBitmapSize(value) / 1024;
                return bitmapSize == 0 ? 1 : bitmapSize;
            }
        };
    }
    //END_INCLUDE(init_memory_cache)

    // By default the disk cache is not initialized here as it should be initialized
    // on a separate thread due to disk access.
    if (cacheParams.initDiskCacheOnCreate) {
        // Set up disk cache
        initDiskCache();
    }
}
 
Example 18
Source File: ImageCache.java    From android-DisplayingBitmaps with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize the cache, providing all parameters.
 *
 * @param cacheParams The cache parameters to initialize the cache
 */
private void init(ImageCacheParams cacheParams) {
    mCacheParams = cacheParams;

    //BEGIN_INCLUDE(init_memory_cache)
    // Set up memory cache
    if (mCacheParams.memoryCacheEnabled) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Memory cache created (size = " + mCacheParams.memCacheSize + ")");
        }

        // If we're running on Honeycomb or newer, create a set of reusable bitmaps that can be
        // populated into the inBitmap field of BitmapFactory.Options. Note that the set is
        // of SoftReferences which will actually not be very effective due to the garbage
        // collector being aggressive clearing Soft/WeakReferences. A better approach
        // would be to use a strongly references bitmaps, however this would require some
        // balancing of memory usage between this set and the bitmap LruCache. It would also
        // require knowledge of the expected size of the bitmaps. From Honeycomb to JellyBean
        // the size would need to be precise, from KitKat onward the size would just need to
        // be the upper bound (due to changes in how inBitmap can re-use bitmaps).
        if (Utils.hasHoneycomb()) {
            mReusableBitmaps =
                    Collections.synchronizedSet(new HashSet<SoftReference<Bitmap>>());
        }

        mMemoryCache = new LruCache<String, BitmapDrawable>(mCacheParams.memCacheSize) {

            /**
             * Notify the removed entry that is no longer being cached
             */
            @Override
            protected void entryRemoved(boolean evicted, String key,
                    BitmapDrawable oldValue, BitmapDrawable newValue) {
                if (RecyclingBitmapDrawable.class.isInstance(oldValue)) {
                    // The removed entry is a recycling drawable, so notify it
                    // that it has been removed from the memory cache
                    ((RecyclingBitmapDrawable) oldValue).setIsCached(false);
                } else {
                    // The removed entry is a standard BitmapDrawable

                    if (Utils.hasHoneycomb()) {
                        // We're running on Honeycomb or later, so add the bitmap
                        // to a SoftReference set for possible use with inBitmap later
                        mReusableBitmaps.add(new SoftReference<Bitmap>(oldValue.getBitmap()));
                    }
                }
            }

            /**
             * Measure item size in kilobytes rather than units which is more practical
             * for a bitmap cache
             */
            @Override
            protected int sizeOf(String key, BitmapDrawable value) {
                final int bitmapSize = getBitmapSize(value) / 1024;
                return bitmapSize == 0 ? 1 : bitmapSize;
            }
        };
    }
    //END_INCLUDE(init_memory_cache)

    // By default the disk cache is not initialized here as it should be initialized
    // on a separate thread due to disk access.
    if (cacheParams.initDiskCacheOnCreate) {
        // Set up disk cache
        initDiskCache();
    }
}
 
Example 19
Source File: LoggingActivity.java    From android-MultiWindowPlayground with Apache License 2.0 4 votes vote down vote up
@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    super.onMultiWindowModeChanged(isInMultiWindowMode);

    Log.d(mLogTag, "onMultiWindowModeChanged: " + isInMultiWindowMode);
}
 
Example 20
Source File: CardStreamLinearLayout.java    From sensors-samples with Apache License 2.0 4 votes vote down vote up
@Override
public void startTransition(LayoutTransition transition, ViewGroup container, View
        view, int transitionType) {
    Log.d(TAG, "Start LayoutTransition animation:" + transitionType);
}