Java Code Examples for timber.log.Timber#d()

The following examples show how to use timber.log.Timber#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: ProductsRecyclerAdapter.java    From openshop.io-android with MIT License 6 votes vote down vote up
/**
 * Define required image quality. On really big screens is higher quality always requested.
 *
 * @param highResolution true for better quality.
 */
public void defineImagesQuality(boolean highResolution) {
    DisplayMetrics dm = context.getResources().getDisplayMetrics();
    int densityDpi = dm.densityDpi;
    // On big screens and wifi connection load high res images always
    if (((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE)
            && MyApplication.getInstance().isWiFiConnection()) {
        loadHighRes = true;
    } else if (highResolution) {
        // Load high resolution images only on better screens.
        loadHighRes = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_NORMAL)
                && densityDpi >= DisplayMetrics.DENSITY_XHIGH;
    } else {
        // otherwise
        loadHighRes = false;
    }

    Timber.d("Image high quality selected: %s", loadHighRes);
    notifyDataSetChanged();
}
 
Example 2
Source File: SplashActivity.java    From TowerCollector with Mozilla Public License 2.0 6 votes vote down vote up
private void ensureDatabaseUpToDate() {
    int currentDbVersion = MeasurementsDatabase.getDatabaseVersion(MyApplication.getApplication());
    if (currentDbVersion != MeasurementsDatabase.DATABASE_FILE_VERSION) {
        Timber.d("ensureDatabaseUpToDate(): Upgrading database");
        databaseUpgradeRunning = true;
        showDetailsMessage();
        // show progress dialog only when migrating database
        DatabaseUpgradeTask databaseMigrationTask = new DatabaseUpgradeTask(this, currentDbVersion);
        databaseMigrationTask.upgrade();
        hideDetailsMessage();
        databaseUpgradeRunning = false;
    }
    // Load last measurement and stats into cache
    MeasurementsDatabase.getInstance(MyApplication.getApplication()).getLastMeasurement();
    MeasurementsDatabase.getInstance(MyApplication.getApplication()).getMeasurementsStatistics();
}
 
Example 3
Source File: PeripheralScannerTest.java    From bitgatt with Mozilla Public License 2.0 6 votes vote down vote up
@Test
//this is flaky in instrumentation without a previous bonded device
@Ignore
public void testSetFilterName() {
    // started
    final List<GattConnection>[] connections = new List[]{new ArrayList()};
    assertTrue(FitbitGatt.getInstance().isInitialized());
    assertFalse(FitbitGatt.getInstance().getPeripheralScanner().isScanning());
    FitbitGatt.getInstance().getPeripheralScanner().resetFilters();
    FitbitGatt.getInstance().getPeripheralScanner().setDeviceNameFilters(names);
    FitbitGatt.getInstance().initializeScanner(appContext);
    FitbitGatt.getInstance().getPeripheralScanner().startHighPriorityScan(appContext);
    assertTrue(FitbitGatt.getInstance().getPeripheralScanner().isScanning());
    CountDownLatch cdl = new CountDownLatch(1);
    handler.postDelayed(() -> {
        FitbitGatt.getInstance().getPeripheralScanner().cancelScan(appContext);
        connections[0] = FitbitGatt.getInstance().getMatchingConnectionsForDeviceNames(names);
        cdl.countDown();
    }, 10000);
    verifyCountDown(cdl, 11);
    assertFalse(FitbitGatt.getInstance().isScanning());
    for (GattConnection connection : connections[0]) {
        Timber.d(connection.getDevice().getName());
    }
    assertTrue(connections[0].size() > 0);
}
 
Example 4
Source File: AdafruitPwm.java    From android-robocar with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void reset() {
  if (debug) {
    Timber.d("Resetting PCA9685 MODE1 (without SLEEP) and MODE2.");
  }

  setAllPwm(0, 0);
  writeRegByteWrapped(__MODE2, (byte) __OUTDRV);
  writeRegByteWrapped(__MODE1, (byte) __ALLCALL);
  sleepWrapped(0.005); // wait for oscillator

  byte mode1 = readRegByteWrapped(__MODE1);
  mode1 = (byte) (mode1 & ~__SLEEP); // wake up (reset sleep)
  writeRegByteWrapped(__MODE1, mode1);
  sleepWrapped(0.005); // wait for oscillator
}
 
Example 5
Source File: MapFragment.java    From mirror with Apache License 2.0 5 votes vote down vote up
@Override
public void onStop() {
    Timber.d("onStop()");
    super.onStop();
    mState.onStop();

    final MapPresenter presenter = resolvePresenter();
    if (presenter != null) {
        presenter.onViewStop(this);
    }
}
 
Example 6
Source File: BluetoothCommunication.java    From openScale with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set indication flag on for the Bluetooth device.
 *
 * @param characteristic the Bluetooth UUID characteristic
 */
protected void setIndicationOn(UUID service, UUID characteristic) {
    Timber.d("Invoke set indication on " + BluetoothGattUuid.prettyPrint(characteristic));
    if(btPeripheral.getService(service) != null) {
        stopMachineState();
        BluetoothGattCharacteristic currentTimeCharacteristic = btPeripheral.getCharacteristic(service, characteristic);
        btPeripheral.setNotify(currentTimeCharacteristic, true);
    }
}
 
Example 7
Source File: WalletActivity.java    From xmrwallet with Apache License 2.0 5 votes vote down vote up
private void onWalletRescan() {
    try {
        final WalletFragment walletFragment = (WalletFragment)
                getSupportFragmentManager().findFragmentByTag(WalletFragment.class.getName());
        getWallet().rescanBlockchainAsync();
        synced = false;
        walletFragment.unsync();
        invalidateOptionsMenu();
    } catch (ClassCastException ex) {
        Timber.d(ex.getLocalizedMessage());
        // keep calm and carry on
    }
}
 
Example 8
Source File: IoUtils.java    From Pioneer with Apache License 2.0 5 votes vote down vote up
public static boolean copyFile(ContentResolver contentResolver, Uri src, File dst) {
    InputStream inputStream;
    try {
        inputStream = contentResolver.openInputStream(src);
    } catch (FileNotFoundException e) {
        Timber.d(e, "[copyFile] Couldn't open uri input");
        return false;
    }
    try {
        return copyStream(inputStream, dst);
    } finally {
        close(inputStream);
    }
}
 
Example 9
Source File: DemoModule.java    From AndroidPlayground with MIT License 5 votes vote down vote up
@ActivityScope
@Provides
DemoInjectDependency provideDemoInjectDependency(
        DemoInjectDependencyImpl demoInjectDependency) {
    Timber.d("provideDemoInjectDependency, DemoInjectDependencyImpl: "
            + demoInjectDependency);
    return demoInjectDependency;
}
 
Example 10
Source File: ArtikCloudManager.java    From mirror with Apache License 2.0 4 votes vote down vote up
private void createFirehoseWebsocket() {
    try {
        mFirehoseWS = new FirehoseWebSocket(mAccessToken, mControlDeviceId, null, null, null, new ArtikCloudWebSocketCallback() {
            @Override
            public void onOpen(int i, String s) {
                Timber.d("FirehoseWebSocket::onOpen: registering %s", mControlDeviceId);
            }

            @Override
            public void onMessage(MessageOut messageOut) {
                Timber.d("FirehoseWebSocket::onMessage: %s", messageOut.toString());
                broadcastAction(messageOut);
            }

            @Override
            public void onAction(ActionOut actionOut) {
            }

            @Override
            public void onAck(Acknowledgement acknowledgement) {
            }

            @Override
            public void onClose(int code, String reason, boolean remote) {
                Timber.w("FirehoseWebSocket::onClose: code: %s; reason: %s", code, reason);
                mFirehoseWS = null;
            }

            @Override
            public void onError(WebSocketError error) {
                Timber.e("FirehoseWebSocket::onError: %s", error.getMessage());
            }

            @Override
            public void onPing(long timestamp) {
            }
        });
    } catch (URISyntaxException | IOException e) {
        Timber.e(e, e.getMessage());
    }
}
 
Example 11
Source File: LocalCommentDataStore.java    From OfflineSampleApp with Apache License 2.0 4 votes vote down vote up
/**
 * Deletes a comment
 */
public Completable delete(Comment comment) {
    Timber.d("deleting comment with id %s", comment.getId());

    return Completable.fromAction(() -> commentDao.delete(comment));
}
 
Example 12
Source File: WearListenerService.java    From wear-notify-for-reddit with Apache License 2.0 4 votes vote down vote up
@Override public void onMessageReceived(MessageEvent messageEvent) {
    Timber.d("onMessageReceived, path: " + messageEvent.getPath());
    if (messageEvent.getPath().equals(Constants.PATH_REFRESH)) {
        WakefulIntentService.sendWakefulWork(this, RetrieveService.getFromWearableIntent(this));
    }
}
 
Example 13
Source File: ExternalBroadcastReceiver.java    From TowerCollector with Mozilla Public License 2.0 4 votes vote down vote up
private void showCollectorPermissionsDenied(Context context) {
    Timber.d("showCollectorPermissionsDenied(): Cannot start collector due to denied permissions");
    Toast.makeText(context, R.string.permission_collector_denied_intent_message, Toast.LENGTH_LONG).show();
}
 
Example 14
Source File: FormValidationCombineLatestFragment.java    From RxJava-Android-Samples with Apache License 2.0 4 votes vote down vote up
private void _combineLatestEvents() {

    _disposableObserver =
        new DisposableSubscriber<Boolean>() {
          @Override
          public void onNext(Boolean formValid) {
            if (formValid) {
              _btnValidIndicator.setBackgroundColor(
                  ContextCompat.getColor(getContext(), R.color.blue));
            } else {
              _btnValidIndicator.setBackgroundColor(
                  ContextCompat.getColor(getContext(), R.color.gray));
            }
          }

          @Override
          public void onError(Throwable e) {
            Timber.e(e, "there was an error");
          }

          @Override
          public void onComplete() {
            Timber.d("completed");
          }
        };

    Flowable.combineLatest(
            _emailChangeObservable,
            _passwordChangeObservable,
            _numberChangeObservable,
            (newEmail, newPassword, newNumber) -> {
              boolean emailValid = !isEmpty(newEmail) && EMAIL_ADDRESS.matcher(newEmail).matches();
              if (!emailValid) {
                _email.setError("Invalid Email!");
              }

              boolean passValid = !isEmpty(newPassword) && newPassword.length() > 8;
              if (!passValid) {
                _password.setError("Invalid Password!");
              }

              boolean numValid = !isEmpty(newNumber);
              if (numValid) {
                int num = Integer.parseInt(newNumber.toString());
                numValid = num > 0 && num <= 100;
              }
              if (!numValid) {
                _number.setError("Invalid Number!");
              }

              return emailValid && passValid && numValid;
            })
        .subscribe(_disposableObserver);
  }
 
Example 15
Source File: PlainTextFileLogger.java    From android-ponewheel with MIT License 4 votes vote down vote up
public static File createLogFile(long rideId, String rideDate, Database database) {
        File file = new File( PlainTextFileLogger.getLoggingPath() + "/owlogs_" + rideDate + ".csv");
        if (file.exists()) {
            boolean deleted = file.delete();
            Timber.d("deleted?" + deleted);
        }
        try {
            FileOutputStream writer = new FileOutputStream(file, true);
            BufferedOutputStream output = new BufferedOutputStream(writer);

            StringBuilder stringBuilder = new StringBuilder();
            List<String> headers = database.attributeDao().getDistinctKeysFromRide(rideId);
            HashMap<String, String> keyValueOrderKeeper = new LinkedHashMap<>();
            headers.add(0, "time");
            headers.add("gps_lat");
            headers.add("gps_long");
            for (String header : headers) {
                if (stringBuilder.length() > 0) {
                    stringBuilder.append(',');
                }
                stringBuilder.append(header);
                keyValueOrderKeeper.put(header, "");
            }
            stringBuilder.append('\n');
            output.write(stringBuilder.toString().getBytes());

            List<Moment> moments = database.momentDao().getFromRide(rideId);
//                Long referenceTime = null;
            for (Moment moment : moments) {
                stringBuilder.setLength(0); // reset
                keyValueOrderKeeper.values().clear();

                long time = moment.getDate().getTime();

                // do we need relative time?
//                    if (referenceTime == null) {
//                        referenceTime = time;
//                    }
//                    time = time - referenceTime;
                stringBuilder.append(Long.toString(time));

                List<Attribute> attributes = database.attributeDao().getFromMoment(moment.id);
                for (Attribute attribute : attributes) {
                    String k = attribute.getKey();
                    String v = attribute.getValue();
                    if ( k.equals("battery_cells") && v != null) {
                        keyValueOrderKeeper.put(k, "\"" + v.replaceAll("\n",",") + "\"");
                    } else {
                        keyValueOrderKeeper.put(k, v);
                    }
                }
                keyValueOrderKeeper.put("gps_lat", moment.getGpsLat());
                keyValueOrderKeeper.put("gps_long", moment.getGpsLong());

                for (String value : keyValueOrderKeeper.values()) {
                    if (stringBuilder.length() > 0) {
                        stringBuilder.append(',');
                    }
                    stringBuilder.append(value);
                }
                stringBuilder.append('\n');
                output.write(stringBuilder.toString().getBytes());
            }

            output.flush();
            output.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return file;
    }
 
Example 16
Source File: BluetoothStandardWeightProfile.java    From openScale with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onBluetoothNotify(UUID characteristic, byte[] value) {
    BluetoothBytesParser parser = new BluetoothBytesParser(value);

    if(characteristic.equals(BluetoothGattUuid.CHARACTERISTIC_CURRENT_TIME)) {
        Date currentTime = parser.getDateTime();
        Timber.d(String.format("Received device time: %s", currentTime));
    }
    else if(characteristic.equals(BluetoothGattUuid.CHARACTERISTIC_WEIGHT_MEASUREMENT)) {
        handleWeightMeasurement(value);
    }
    else if(characteristic.equals(BluetoothGattUuid.CHARACTERISTIC_BODY_COMPOSITION_MEASUREMENT)) {
        handleBodyCompositionMeasurement(value);
    }
    else if(characteristic.equals(BluetoothGattUuid.CHARACTERISTIC_BATTERY_LEVEL)) {
        int batteryLevel = parser.getIntValue(FORMAT_UINT8);
        Timber.d(String.format("Received battery level %d%%", batteryLevel));
    }
    else if(characteristic.equals(BluetoothGattUuid.CHARACTERISTIC_MANUFACTURER_NAME_STRING)) {
        String manufacturer = parser.getStringValue(0);
        Timber.d(String.format("Received manufacturer: %s", manufacturer));
    }
    else if(characteristic.equals(BluetoothGattUuid.CHARACTERISTIC_MODEL_NUMBER_STRING)) {
        String modelNumber = parser.getStringValue(0);
        Timber.d(String.format("Received modelnumber: %s", modelNumber));
    }
    else if(characteristic.equals(BluetoothGattUuid.CHARACTERISTIC_USER_CONTROL_POINT)) {
        if(value[0]==UDS_CP_RESPONSE) {
            switch (value[1]) {
                case UDS_CP_REGISTER_NEW_USER:
                    if (value[2] == UDS_CP_RESP_VALUE_SUCCESS) {
                        int userIndex = value[3];
                        Timber.d(String.format("Created user %d", userIndex));
                    } else {
                        Timber.e("ERROR: could not register new user");
                    }
                    break;
                case UDS_CP_CONSENT:
                    if (value[2] == UDS_CP_RESP_VALUE_SUCCESS) {
                        Timber.d("Success user consent");
                    } else if (value[2] == UDS_CP_RESP_USER_NOT_AUTHORIZED) {
                        Timber.e("Not authorized");
                    }
                    break;
                default:
                    Timber.e("Unhandled response");
                    break;
            }
        }
    } else {
        Timber.d(String.format("Got data: <%s>", byteInHex(value)));
    }
}
 
Example 17
Source File: ExternalBroadcastReceiver.java    From TowerCollector with Mozilla Public License 2.0 4 votes vote down vote up
private void showGpsNotAvailable(Context context) {
    Timber.d("showGpsNotAvailable(): Cannot start collector because GPS is not available");
    Toast.makeText(context, R.string.collector_gps_unavailable, Toast.LENGTH_LONG).show();
}
 
Example 18
Source File: DownloadNotificationDeleteReceiver.java    From Hentoid with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    ContentQueueManager.getInstance().resetDownloadCount();
    Timber.d("Download count reset to 0");
}
 
Example 19
Source File: ChatPeerFlow.java    From BLEMeshChat with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Called when data is acknowledged as sent to the peer passed to this instance's constructor
 * @return whether this flow is complete and should not receive further events.
 */
public boolean onDataSent(byte[] data) throws UnexpectedDataException {
    // When data is ack'd we should be in a local-peer writing state
    if ((!mPeerIsHost && (mState == State.CLIENT_WRITE_ID || (mState == State.CLIENT_WRITE_MSGS && !mIsComplete))) ||
        (mPeerIsHost && (mState == State.HOST_WRITE_ID || (mState == State.HOST_WRITE_MSGS && !mIsComplete)))) {

        throw new IllegalStateException(String.format("onDataSent invalid state %s for local as %s", mState, mPeerIsHost ? "client" : "host"));

    }

    Timber.d("Sent data %s", DataUtil.bytesToHex(data));

    byte type = mProtocol.getPacketType(data);

    // TODO : Perhaps we should cache last sent item to avoid deserializing bytes we've
    // just serialized in sendData
    switch (mState) {
        case HOST_WRITE_ID:
        case CLIENT_WRITE_ID:

            switch(type) {
                case IdentityPacket.TYPE:

                    IdentityPacket sentIdPkt = mProtocol.deserializeIdentity(data);
                    mDataStore.createOrUpdateRemotePeerWithProtocolIdentity(sentIdPkt);
                    // We can only report the identity sent once we know the peer's identity
                    // We also always want to send our own identity first
                    if (mRemoteIdentity != null) {
                        Timber.d("Marked identity %s delivered to %s", sentIdPkt.alias, mRemoteIdentity.alias);
                        mDataStore.markIdentityDeliveredToPeer(sentIdPkt, mRemoteIdentity);
                    }

                    mIdentityOutbox.poll();

                    sendAsAppropriate();
                    break;

                case NoDataPacket.TYPE:

                    incrementStateAndSendAsAppropriate();
                    break;

                default:
                    throw new UnexpectedDataException(String.format("Expected IdentityPacket (type %d). Got type %d", IdentityPacket.TYPE, type));

            }
            break;

        case HOST_WRITE_MSGS:
        case CLIENT_WRITE_MSGS:

            switch(type) {
                case MessagePacket.TYPE:

                    MessagePacket msgPkt = mProtocol.deserializeMessageWithIdentity(data, mRemoteIdentity);
                    Message msg = mDataStore.createOrUpdateMessageWithProtocolMessage(msgPkt);
                    // Mark incoming messages as delivered to sender
                    mDataStore.markMessageDeliveredToPeer(msgPkt, mRemoteIdentity);
                    mCallback.onMessageSent(this, msg, mDataStore.getPeerByPubKey(mRemoteIdentity.publicKey));

                    mMessageOutbox.poll();

                    sendAsAppropriate();
                    break;

                case NoDataPacket.TYPE:

                    incrementStateAndSendAsAppropriate();
                    break;

                default:
                    throw new UnexpectedDataException(String.format("Expected MessagePacket (type %d). Got type %d", MessagePacket.TYPE, type));

            }

            break;

        default:
            Timber.e("Flow received unexpected response from client peer");
    }
    return mIsComplete;
}
 
Example 20
Source File: MainActivity.java    From Easy_xkcd with Apache License 2.0 4 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    Timber.d("onResume called");
    mNavView.setCheckedItem(currentFragmentToNavId());
}