com.example.android.common.logger.Log Java Examples

The following examples show how to use com.example.android.common.logger.Log. 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: ImageFetcher.java    From graphics-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void closeCacheInternal() {
    super.closeCacheInternal();
    synchronized (mHttpDiskCacheLock) {
        if (mHttpDiskCache != null) {
            try {
                if (!mHttpDiskCache.isClosed()) {
                    mHttpDiskCache.close();
                    mHttpDiskCache = null;
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "HTTP cache closed");
                    }
                }
            } catch (IOException e) {
                Log.e(TAG, "closeCacheInternal - " + e);
            }
        }
    }
}
 
Example #2
Source File: MainActivity.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #3
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 #4
Source File: BluetoothChatService.java    From connectivity-samples with Apache License 2.0 6 votes vote down vote up
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
    mState = STATE_LISTEN;
}
 
Example #5
Source File: MainActivity.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #6
Source File: ProvisioningValuesLoader.java    From android-NfcProvisioning with Apache License 2.0 6 votes vote down vote up
private void gatherAdminExtras(HashMap<String, String> values) {
    Properties props = new Properties();
    Set<String> keys = new HashSet<>(values.keySet());
    for (String key : keys) {
        if (key.startsWith("android.app.extra")) {
            continue;
        }
        props.put(key, values.get(key));
        values.remove(key);
    }
    StringWriter sw = new StringWriter();
    try{
        props.store(sw, "admin extras bundle");
        values.put(DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE,
                sw.toString());
        Log.d(TAG, "Admin extras bundle=" + values.get(
                DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE));
    } catch (IOException e) {
        Log.e(TAG, "Unable to build admin extras bundle");
    }
}
 
Example #7
Source File: ImageFetcher.java    From android-DisplayingBitmaps with Apache License 2.0 6 votes vote down vote up
@Override
protected void closeCacheInternal() {
    super.closeCacheInternal();
    synchronized (mHttpDiskCacheLock) {
        if (mHttpDiskCache != null) {
            try {
                if (!mHttpDiskCache.isClosed()) {
                    mHttpDiskCache.close();
                    mHttpDiskCache = null;
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "HTTP cache closed");
                    }
                }
            } catch (IOException e) {
                Log.e(TAG, "closeCacheInternal - " + e);
            }
        }
    }
}
 
Example #8
Source File: BluetoothChatService.java    From connectivity-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Start the ConnectThread to initiate a connection to a remote device.
 *
 * @param device The BluetoothDevice to connect
 * @param secure Socket Security type - Secure (true) , Insecure (false)
 */
public synchronized void connect(BluetoothDevice device, boolean secure) {
    Log.d(TAG, "connect to: " + device);

    // Cancel any thread attempting to make a connection
    if (mState == STATE_CONNECTING) {
        if (mConnectThread != null) {
            mConnectThread.cancel();
            mConnectThread = null;
        }
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    // Start the thread to connect with the given device
    mConnectThread = new ConnectThread(device, secure);
    mConnectThread.start();
    // Update UI title
    updateUserInterfaceTitle();
}
 
Example #9
Source File: MainActivity.java    From android-play-safetynet with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());
    if (Build.VERSION.SDK_INT < 23) {
        //noinspection deprecation
        logFragment.getLogView().setTextAppearance(this, R.style.Log);
    } else {
        logFragment.getLogView().setTextAppearance(R.style.Log);
    }
    logFragment.getLogView().setBackgroundColor(Color.WHITE);

    Log.i(TAG, "Ready");
}
 
Example #10
Source File: MainActivity.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #11
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 #12
Source File: MainActivity.java    From graphics-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Create a chain of targets that will receive log data
 */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #13
Source File: BluetoothChatService.java    From android-BluetoothChat with Apache License 2.0 6 votes vote down vote up
/**
 * Start the ConnectThread to initiate a connection to a remote device.
 *
 * @param device The BluetoothDevice to connect
 * @param secure Socket Security type - Secure (true) , Insecure (false)
 */
public synchronized void connect(BluetoothDevice device, boolean secure) {
    Log.d(TAG, "connect to: " + device);

    // Cancel any thread attempting to make a connection
    if (mState == STATE_CONNECTING) {
        if (mConnectThread != null) {
            mConnectThread.cancel();
            mConnectThread = null;
        }
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    // Start the thread to connect with the given device
    mConnectThread = new ConnectThread(device, secure);
    mConnectThread.start();
    // Update UI title
    updateUserInterfaceTitle();
}
 
Example #14
Source File: ImageFetcher.java    From android-DisplayingBitmaps with Apache License 2.0 6 votes vote down vote up
@Override
protected void clearCacheInternal() {
    super.clearCacheInternal();
    synchronized (mHttpDiskCacheLock) {
        if (mHttpDiskCache != null && !mHttpDiskCache.isClosed()) {
            try {
                mHttpDiskCache.delete();
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "HTTP cache cleared");
                }
            } catch (IOException e) {
                Log.e(TAG, "clearCacheInternal - " + e);
            }
            mHttpDiskCache = null;
            mHttpDiskCacheStarting = true;
            initHttpDiskCache();
        }
    }
}
 
Example #15
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #16
Source File: MainActivity.java    From android-CardReader with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #17
Source File: MainActivity.java    From android-play-places with Apache License 2.0 6 votes vote down vote up
/**
 * Callback invoked when a place has been selected from the PlaceAutocompleteFragment.
 */
@Override
public void onPlaceSelected(Place place) {
    Log.i(TAG, "Place Selected: " + place.getName());

    // Format the returned place's details and display them in the TextView.
    mPlaceDetailsText.setText(formatPlaceDetails(getResources(), place.getName(), place.getId(),
            place.getAddress(), place.getPhoneNumber(), place.getWebsiteUri()));

    CharSequence attributions = place.getAttributions();
    if (!TextUtils.isEmpty(attributions)) {
        mPlaceAttribution.setText(Html.fromHtml(attributions.toString()));
    } else {
        mPlaceAttribution.setText("");
    }
}
 
Example #18
Source File: ImageFetcher.java    From graphics-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void clearCacheInternal() {
    super.clearCacheInternal();
    synchronized (mHttpDiskCacheLock) {
        if (mHttpDiskCache != null && !mHttpDiskCache.isClosed()) {
            try {
                mHttpDiskCache.delete();
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "HTTP cache cleared");
                }
            } catch (IOException e) {
                Log.e(TAG, "clearCacheInternal - " + e);
            }
            mHttpDiskCache = null;
            mHttpDiskCacheStarting = true;
            initHttpDiskCache();
        }
    }
}
 
Example #19
Source File: MainActivity.java    From connectivity-samples with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());
    logFragment.getLogView().setTextAppearance(this, R.style.Log);
    logFragment.getLogView().setBackgroundColor(Color.WHITE);

    Log.i(TAG, "Ready");
}
 
Example #20
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #21
Source File: MainActivity.java    From android-SwipeRefreshListFragment with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #22
Source File: ImageCache.java    From graphics-samples 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 #23
Source File: BluetoothChatService.java    From connectivity-samples with Apache License 2.0 6 votes vote down vote up
public void run() {
    Log.i(TAG, "BEGIN mConnectedThread");
    byte[] buffer = new byte[1024];
    int bytes;

    // Keep listening to the InputStream while connected
    while (mState == STATE_CONNECTED) {
        try {
            // Read from the InputStream
            bytes = mmInStream.read(buffer);

            // Send the obtained bytes to the UI Activity
            mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer)
                    .sendToTarget();
        } catch (IOException e) {
            Log.e(TAG, "disconnected", e);
            connectionLost();
            break;
        }
    }
}
 
Example #24
Source File: MainActivity.java    From android-SwipeRefreshMultipleViews with Apache License 2.0 6 votes vote down vote up
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
Example #25
Source File: MyCloudProvider.java    From android-StorageProvider with Apache License 2.0 5 votes vote down vote up
@Override
public Cursor queryDocument(String documentId, String[] projection)
        throws FileNotFoundException {
    Log.v(TAG, "queryDocument");

    // Create a cursor with the requested projection, or the default projection.
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeFile(result, documentId, null);
    return result;
}
 
Example #26
Source File: GestureListener.java    From android-BasicGestureDetect with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
    // A confirmed single-tap event has occurred.  Only called when the detector has
    // determined that the first tap stands alone, and is not part of a double tap.
    Log.i(TAG, "Single tap confirmed" + getTouchType(e));
    return false;
}
 
Example #27
Source File: SampleActivityBase.java    From android-play-safetynet with Apache License 2.0 5 votes vote down vote up
/** Set up targets to receive log data */
public void initializeLogging() {
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    // Wraps Android's native log framework
    LogWrapper logWrapper = new LogWrapper();
    Log.setLogNode(logWrapper);

    Log.i(TAG, "Ready");
}
 
Example #28
Source File: SampleActivityBase.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
/** Set up targets to receive log data */
public void initializeLogging() {
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    // Wraps Android's native log framework
    LogWrapper logWrapper = new LogWrapper();
    Log.setLogNode(logWrapper);

    Log.i(TAG, "Ready");
}
 
Example #29
Source File: SampleActivityBase.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
/** Set up targets to receive log data */
public void initializeLogging() {
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    // Wraps Android's native log framework
    LogWrapper logWrapper = new LogWrapper();
    Log.setLogNode(logWrapper);

    Log.i(TAG, "Ready");
}
 
Example #30
Source File: BluetoothChatService.java    From android-BluetoothChat with Apache License 2.0 5 votes vote down vote up
public void run() {
    Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType);
    setName("ConnectThread" + mSocketType);

    // Always cancel discovery because it will slow down a connection
    mAdapter.cancelDiscovery();

    // Make a connection to the BluetoothSocket
    try {
        // This is a blocking call and will only return on a
        // successful connection or an exception
        mmSocket.connect();
    } catch (IOException e) {
        // Close the socket
        try {
            mmSocket.close();
        } catch (IOException e2) {
            Log.e(TAG, "unable to close() " + mSocketType +
                    " socket during connection failure", e2);
        }
        connectionFailed();
        return;
    }

    // Reset the ConnectThread because we're done
    synchronized (BluetoothChatService.this) {
        mConnectThread = null;
    }

    // Start the connected thread
    connected(mmSocket, mmDevice, mSocketType);
}