Java Code Examples for timber.log.Timber

The following are top voted examples for showing how to use timber.log.Timber. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: InstantAppStarter   File: ApiErrorUtils.java   View source code 6 votes vote down vote up
@Override
public  String getErrorMessage(Throwable t) {
    String errorMessage = "OOPs!! Something went wrong";

    Timber.d(t);

    if (t instanceof HttpException) {
        errorMessage = "Errorcode"+((HttpException) t).code()+" "+t.getLocalizedMessage();
    } else if (t instanceof SocketTimeoutException) {
        errorMessage = "Internet Problem";
    } else if (t instanceof IOException) {
        errorMessage = "Internet Problem";
    }

    Throwable cause = t.getCause();
    if (cause instanceof RaveException) {
        errorMessage = "Server Bug: "+cause.getLocalizedMessage();
    }

    return errorMessage;
}
 
Example 2
Project: yyox   File: PermissionUtil.java   View source code 6 votes vote down vote up
/**
 * 请求外部存储的权限
 */
public static void externalStorage(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView view, RxErrorHandler errorHandler) {
    //先确保是否已经申请过摄像头,和写入外部存储的权限
    boolean isPermissionsGranted =
            rxPermissions
                    .isGranted(Manifest.permission.WRITE_EXTERNAL_STORAGE);

    if (isPermissionsGranted) {//已经申请过,直接执行操作
        requestPermission.onRequestPermissionSuccess();
    } else {//没有申请过,则申请
        rxPermissions
                .request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                .compose(PermissionUtil.<Boolean>bindToLifecycle(view))//使用RXlifecycle,使subscription和activity一起销毁
                .subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
                    @Override
                    public void onNext(Boolean granted) {
                        if (granted) {
                            Timber.tag(TAG).d("request WRITE_EXTERNAL_STORAGE and CAMERA success");
                            requestPermission.onRequestPermissionSuccess();
                        } else {
                            view.showMessage("request permissons failure");
                        }
                    }
                });
    }
}
 
Example 3
Project: xmrwallet   File: SendBtcConfirmWizardFragment.java   View source code 6 votes vote down vote up
private void showProgress(int stage, String progressText) {
    Timber.d("showProgress(%d)", stage);
    inProgress = stage;
    switch (stage) {
        case STAGE_A:
            evStageA.showProgress(progressText);
            break;
        case STAGE_B:
            evStageB.showProgress(progressText);
            break;
        case STAGE_C:
            evStageC.showProgress(progressText);
            break;
        default:
            throw new IllegalStateException("unknown stage " + stage);
    }
}
 
Example 4
Project: MVVMArms   File: ApiResponse.java   View source code 6 votes vote down vote up
public Integer getNextPage() {
    String next = links.get(NEXT_LINK);
    if (next == null) {
        return null;
    }
    Matcher matcher = PAGE_PATTERN.matcher(next);
    if (!matcher.find() || matcher.groupCount() != 1) {
        return null;
    }
    try {
        return Integer.parseInt(matcher.group(1));
    } catch (NumberFormatException ex) {
        Timber.w("cannot parse next page from %s", next);
        return null;
    }
}
 
Example 5
Project: chat-sdk-android-push-firebase   File: FirebaseEventsManager.java   View source code 6 votes vote down vote up
/** Removes an app event by tag.*/
@Override
public boolean removeEventByTag(String tag){

    if (DEBUG) Timber.v("removeEventByTag, Tag: %s", tag);

    if (StringUtils.isEmpty(tag)){
        return false;
    }

    Event e = events.remove(tag);
    
    if (e != null)
    {
        if (DEBUG) Timber.i("killing event, Tag: %s", e.getTag());
        e.kill();
    }
    
    return e != null;
}
 
Example 6
Project: fast-list   File: User.java   View source code 6 votes vote down vote up
public static Object getChangePayload(User oldUser, User newUser) {
  Bundle bundle = new Bundle();
  if (!TextUtils.equals(oldUser.getAvatar(), newUser.getAvatar())) {
    bundle.putString(KEY_AVATAR, newUser.getAvatar());
  }
  if (!TextUtils.equals(oldUser.getName(), newUser.getName())) {
    bundle.putString(KEY_NAME, newUser.getName());
  }
  if (!TextUtils.equals(oldUser.getDesc(), newUser.getDesc())) {
    bundle.putString(KEY_DESC, newUser.getDesc());
  }
  if (bundle.size() == 0) {
    return null;
  }
  Timber.d("getChangePayload | size: %d", bundle.size());
  return bundle;
}
 
Example 7
Project: android-robocar   File: TiltControllerActivity.java   View source code 6 votes vote down vote up
private void setSpeed(Integer left, Integer right) {

        Integer leftSpeed = left==null || left==mLastLeftSpeed? null:left;
        Integer rightSpeed = right==null || right==mLastRightSpeed? null:right;

            if(leftSpeed!=null) mLeftSpeedTextView.setText(""+left);
            if(rightSpeed!=null) mRightSpeedTextView.setText(""+right);

        try {
            com.zugaldia.robocar.mobile.client.RobocarClient service= new RobocarRestClient("http://"+this.mBaseUrl);
            service.setSpeed(leftSpeed, rightSpeed);
            if(left!=null) mLastLeftSpeed = left;
            if(right!=null) mLastRightSpeed = right;
        }catch(Exception e) {
            Toast.makeText(this, "Unable to communicate with Robocar: "+e.getMessage(), Toast.LENGTH_SHORT).show();
            Timber.d(e.getMessage());
        }
    }
 
Example 8
Project: BuildingDebugFeatures   File: DebugBroadcastReceiver.java   View source code 6 votes vote down vote up
void handleIntent(Context context, @NonNull Intent intent) {
    String intentAction = intent.getAction();

    if (intentAction == null || !PR_NOTIFICATION.equals(intentAction)) {
        return;
    }
    Timber.d("processing " + PR_NOTIFICATION);

    Bundle extras = intent.getExtras();
    if (extras == null) {
        return;
    }

    final String username = extras.getString("username");
    Timber.d("username " + username);

    IntentUtils.triggerPRNotification(context, username);
}
 
Example 9
Project: chat-sdk-android-push-firebase   File: FirebaseEventsManager.java   View source code 6 votes vote down vote up
@Override
public boolean onThreadDetailsChanged(final String threadId) {
    if (DEBUG) Timber.i("onThreadDetailsChanged");

    for (Event e : events.values())
    {
        if (e  == null)
            continue;

        
        if (StringUtils.isNotEmpty(e.getEntityId()) && !threadId.equals(e.getEntityId()))
            continue;

        if(e instanceof BatchedEvent)
            ((BatchedEvent) e).add(Event.Type.ThreadEvent, threadId);

        e.onThreadDetailsChanged(threadId);
    }

     return false;
}
 
Example 10
Project: q-mail   File: Address.java   View source code 6 votes vote down vote up
/**
 * Parse a comma separated list of addresses in RFC-822 format and return an
 * array of Address objects.
 *
 * @param addressList
 * @return An array of 0 or more Addresses.
 */
public static Address[] parse(String addressList) {
    if (TextUtils.isEmpty(addressList)) {
        return EMPTY_ADDRESS_ARRAY;
    }
    List<Address> addresses = new ArrayList<>();
    try {
        MailboxList parsedList =  DefaultAddressParser.DEFAULT.parseAddressList(addressList).flatten();

        for (int i = 0, count = parsedList.size(); i < count; i++) {
            Mailbox mailbox = parsedList.get(i);
            addresses.add(new Address(mailbox.getLocalPart() + "@" + mailbox.getDomain(), mailbox.getName(), false));
        }
    } catch (MimeException pe) {
        Timber.e(pe, "MimeException in Address.parse()");
        //but we do an silent failover : we just use the given string as name with empty address
        addresses.add(new Address(null, addressList, false));
    }
    return addresses.toArray(EMPTY_ADDRESS_ARRAY);
}
 
Example 11
Project: Quran   File: QuranFileUtils.java   View source code 6 votes vote down vote up
private static void deleteFileOrDirectory(File file) {
  if (file.isDirectory()) {
    File[] subFiles = file.listFiles();
    // subFiles is null on some devices, despite this being a directory
    int length = subFiles == null ? 0 : subFiles.length;
    for (int i = 0; i < length; i++) {
      File sf = subFiles[i];
      if (sf.isFile()) {
        if (!sf.delete()) {
          Timber.e("Error deleting %s", sf.getPath());
        }
      } else {
        deleteFileOrDirectory(sf);
      }
    }
  }
  if (!file.delete()) {
    Timber.e("Error deleting %s", file.getPath());
  }
}
 
Example 12
Project: FinalProject   File: ActivityYourFeedFragment.java   View source code 6 votes vote down vote up
@Override
public void onLoadMore() {

    if (response.size() == 25){
        try {
            currentPage += 1;
            loadNextPage();
            progressBar.setVisibility(View.GONE);
            isLoading = true;

        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        Timber.d("nothing");
    }

}
 
Example 13
Project: q-mail   File: SmtpTransport.java   View source code 6 votes vote down vote up
private void handleTemporaryFailure(String username, NegativeSmtpReplyException negativeResponseFromOldToken)
    throws IOException, MessagingException {
    // Token was invalid

    //We could avoid this double check if we had a reasonable chance of knowing
    //if a token was invalid before use (e.g. due to expiry). But we don't
    //This is the intended behaviour per AccountManager

    Timber.v(negativeResponseFromOldToken, "Authentication exception, re-trying with new token");
    try {
        attemptXoauth2(username);
    } catch (NegativeSmtpReplyException negativeResponseFromNewToken) {
        if (negativeResponseFromNewToken.getReplyCode() != SMTP_AUTHENTICATION_FAILURE_ERROR_CODE) {
            throw negativeResponseFromNewToken;
        }

        //Okay, we failed on a new token.
        //Invalidate the token anyway but assume it's permanent.
        Timber.v(negativeResponseFromNewToken, "Authentication exception for new token, permanent error assumed");

        oauthTokenProvider.invalidateToken(username);

        handlePermanentFailure(negativeResponseFromNewToken);
    }
}
 
Example 14
Project: FinalProject   File: UserHugCounterActivity.java   View source code 6 votes vote down vote up
private void initializeData() {

        application.getWebService()
                .getInteractionPosts(likeCounter, MySharedPreferences.getUserId(preferences), MySharedPreferences.getUserToken(preferences))
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .retryWhen(new RetryWithDelay(3,2000))
                .subscribe(new BaseSubscriber<PostSuperUserListModel>() {
                    @Override
                    public void onNext(PostSuperUserListModel response) {
                        showRecycleWithDataFilled(response);
                        progressFrame.setVisibility(View.GONE);
                    }
                    @Override
                    public void onError(Throwable e) {
                        progressFrame.setVisibility(View.GONE);
                        try {
                            Timber.e(e.getMessage());
                      //      Toast.makeText(UserHugCounterActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                        }catch (Exception ex){
                            ex.printStackTrace();
                        }
                    }
                });
    }
 
Example 15
Project: EosCommander   File: PRNGFixes.java   View source code 6 votes vote down vote up
@Override
protected void engineSetSeed(byte[] bytes) {
    try {
        OutputStream out;
        synchronized (sLock) {
            out = getUrandomOutputStream();
        }
        out.write(bytes);
        out.flush();
    } catch (IOException e) {
        // On a small fraction of devices /dev/urandom is not writable.
        // Log and ignore.
        Timber.w("Failed to mix seed into " + URANDOM_FILE);
    } finally {
        mSeeded = true;
    }
}
 
Example 16
Project: GitHub   File: SearchFragment.java   View source code 6 votes vote down vote up
@Override public void render(SearchViewState viewState) {
  Timber.d("render %s", viewState);
  if (viewState instanceof SearchViewState.SearchNotStartedYet) {
    renderSearchNotStarted();
  } else if (viewState instanceof SearchViewState.Loading) {
    renderLoading();
  } else if (viewState instanceof SearchViewState.SearchResult) {
    renderResult(((SearchViewState.SearchResult) viewState).getResult());
  } else if (viewState instanceof SearchViewState.EmptyResult) {
    renderEmptyResult();
  } else if (viewState instanceof SearchViewState.Error) {
    Timber.e(((SearchViewState.Error) viewState).getError());
    renderError();
  } else {
    throw new IllegalArgumentException("Don't know how to render viewState " + viewState);
  }
}
 
Example 17
Project: q-mail   File: Settings.java   View source code 6 votes vote down vote up
/**
 * Convert settings from the internal representation to the string representation used in the
 * preference storage.
 *
 * @param settings
 *         The map of settings to convert.
 * @param settingDescriptions
 *         The structure containing the {@link SettingsDescription} objects that will be used
 *         to convert the setting values.
 *
 * @return The settings converted to the string representation used in the preference storage.
 */
public static Map<String, String> convert(Map<String, Object> settings,
        Map<String, TreeMap<Integer, SettingsDescription>> settingDescriptions) {
    Map<String, String> serializedSettings = new HashMap<>();

    for (Entry<String, Object> setting : settings.entrySet()) {
        String settingName = setting.getKey();
        Object internalValue = setting.getValue();

        TreeMap<Integer, SettingsDescription> versionedSetting = settingDescriptions.get(settingName);
        Integer highestVersion = versionedSetting.lastKey();
        SettingsDescription settingDesc = versionedSetting.get(highestVersion);

        if (settingDesc != null) {
            String stringValue = settingDesc.toString(internalValue);

            serializedSettings.put(settingName, stringValue);
        } else {
            Timber.w("Settings.convert() called with a setting that should have been removed: %s", settingName);
        }
    }

    return serializedSettings;
}
 
Example 18
Project: xmrwallet   File: SendSuccessWizardFragment.java   View source code 6 votes vote down vote up
@Override
public void onResumeFragment() {
    super.onResumeFragment();
    Timber.d("onResumeFragment()");
    Helper.hideKeyboard(getActivity());

    final TxData txData = sendListener.getTxData();
    tvTxAddress.setText(txData.getDestinationAddress());
    String paymentId = txData.getPaymentId();
    if ((paymentId != null) && (!paymentId.isEmpty())) {
        tvTxPaymentId.setText(txData.getPaymentId());
    } else {
        tvTxPaymentId.setText("-");
    }

    final PendingTx committedTx = sendListener.getCommittedTx();
    if (committedTx != null) {
        tvTxId.setText(committedTx.txId);
        bCopyTxId.setEnabled(true);
        bCopyTxId.setImageResource(R.drawable.ic_content_copy_black_24dp);
        tvTxAmount.setText(getString(R.string.send_amount, Helper.getDisplayAmount(committedTx.amount)));
        tvTxFee.setText(getString(R.string.send_fee, Helper.getDisplayAmount(committedTx.fee)));
    }
    sendListener.enableDone();
}
 
Example 19
Project: chat-sdk-android-push-firebase   File: ChatSDKAbstractThreadsListAdapter.java   View source code 6 votes vote down vote up
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {

    if (killed)
        return;

    // If response was not immidate, i.e  image was cached we show the default image while loading
    if (isImmediate && response.getBitmap() == null)
    {
        setDefaultImg(threadListItem);
        return;
    }

    // Set the response to the image.
    if (response.getBitmap() != null) {
        if (DEBUG) Timber.i("Loading thread picture from url");

        // load image into imageview
        imgIcon.setImageBitmap(response.getBitmap());
    }
}
 
Example 20
Project: yyox   File: PermissionUtil.java   View source code 6 votes vote down vote up
/**
     * 请求打电话权限
     */
    public static void callPhone(final RequestPermission requestPermission, RxPermissions rxPermissions, final BaseView view, RxErrorHandler errorHandler) {
//先确保是否已经申请过权限
        boolean isPermissionsGranted =
                rxPermissions
                        .isGranted(Manifest.permission.CALL_PHONE);

        if (isPermissionsGranted) {//已经申请过,直接执行操作
            requestPermission.onRequestPermissionSuccess();
        } else {//没有申请过,则申请
            rxPermissions
                    .request(Manifest.permission.CALL_PHONE)
                    .compose(PermissionUtil.<Boolean>bindToLifecycle(view))//使用RXlifecycle,使subscription和activity一起销毁
                    .subscribe(new ErrorHandleSubscriber<Boolean>(errorHandler) {
                        @Override
                        public void onNext(Boolean granted) {
                            if (granted) {
                                Timber.tag(TAG).d("request SEND_SMS success");
                                requestPermission.onRequestPermissionSuccess();
                            } else {
                                view.showMessage("request permissons failure");
                            }
                        }
                    });
        }
    }
 
Example 21
Project: AndroidBackendlessChat   File: FirebaseEventsManager.java   View source code 6 votes vote down vote up
/** Removes an app event by tag.*/
@Override
public boolean removeEventByTag(String tag){

    if (DEBUG) Timber.v("removeEventByTag, Tag: %s", tag);

    if (StringUtils.isEmpty(tag)){
        return false;
    }

    Event e = events.remove(tag);
    
    if (e != null)
    {
        if (DEBUG) Timber.i("killing event, Tag: %s", e.getTag());
        e.kill();
    }
    
    return e != null;
}
 
Example 22
Project: xmrwallet   File: WalletService.java   View source code 6 votes vote down vote up
private Wallet openWallet(String walletName, String walletPassword) {
    String path = Helper.getWalletFile(getApplicationContext(), walletName).getAbsolutePath();
    showProgress(20);
    Wallet wallet = null;
    WalletManager walletMgr = WalletManager.getInstance();
    Timber.d("WalletManager testnet=%s", walletMgr.isTestNet());
    showProgress(30);
    if (walletMgr.walletExists(path)) {
        Timber.d("open wallet %s", path);
        wallet = walletMgr.openWallet(path, walletPassword);
        showProgress(60);
        Timber.d("wallet opened");
        Wallet.Status status = wallet.getStatus();
        Timber.d("wallet status is %s", status);
        if (status != Wallet.Status.Status_Ok) {
            Timber.d("wallet status is %s", status);
            WalletManager.getInstance().close(wallet); // TODO close() failed?
            wallet = null;
            // TODO what do we do with the progress??
            // TODO tell the activity this failed
            // this crashes in MyWalletListener(Wallet aWallet) as wallet == null
        }
    }
    return wallet;
}
 
Example 23
Project: q-mail   File: DeferredFileBody.java   View source code 6 votes vote down vote up
private void writeMemoryToFile() throws IOException {
    if (file != null) {
        throw new IllegalStateException("Body is already file-backed!");
    }
    if (data == null) {
        throw new IllegalStateException("Data must be fully written before it can be read!");
    }

    Timber.d("Writing body to file for attachment access");

    file = fileFactory.createFile();
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(data);
    fos.close();

    data = null;
}
 
Example 24
Project: chat-sdk-android-push-firebase   File: FirebaseEventsManager.java   View source code 6 votes vote down vote up
@Override
public boolean onUserAddedToThread(String threadId, final String userId) {
    if (DEBUG) Timber.i("onUserAddedToThread");

    for (Event e : events.values())
    {
        if (e == null)
            continue;

        if (StringUtils.isNotEmpty(e.getEntityId())  && StringUtils.isNotEmpty(threadId)
                &&  !e.getEntityId().equals(threadId) )
            continue;

        if(e instanceof BatchedEvent)
            ((BatchedEvent) e).add(Event.Type.ThreadEvent, threadId);

        e.onUserAddedToThread(threadId, userId);
    }

    return false;
}
 
Example 25
Project: GongXianSheng   File: HomePagePresenter.java   View source code 5 votes vote down vote up
public void syncReturnOrders() {
    checkViewAttached();
    RxUtil.unsubscribe(mReturnOrderSubscription);
    mReturnOrderSubscription = mDataManager.syncReturnOrders()
            .observeOn(AndroidSchedulers.mainThread())
            .subscribeOn(Schedulers.io())
            .subscribe(new Subscriber<ReturnOrderListResponse>() {
                @Override
                public void onCompleted() {
                }

                @Override
                public void onError(Throwable e) {
                    Timber.e(e, "There was an error loading the ribots.");
                    getMvpView().showReturnOrdersError();
                }

                @Override
                public void onNext(ReturnOrderListResponse returnOrderListResponse) {
                    if (returnOrderListResponse.getList().isEmpty()) {
                        getMvpView().showReturnOrdersEmpty();
                    } else {
                        getMvpView().showReturnOrders(returnOrderListResponse.getList());
                    }
                }
            });
}
 
Example 26
Project: DOUSalaries   File: NetworkModule.java   View source code 5 votes vote down vote up
@Provides
@DouAppScope
public HttpLoggingInterceptor loggingInterceptor() {
    HttpLoggingInterceptor interceptor =
            new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
                @Override public void log(String message) {
                    Timber.i(message);
                }
            });
    interceptor.setLevel(BuildConfig.DEBUG ?
            HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
    return interceptor;
}
 
Example 27
Project: AndroidBackendlessChat   File: ChatSDKProfileHelper.java   View source code 5 votes vote down vote up
/** Only for current user.*/
public Promise<String[], BError, SaveImageProgress> saveProfilePicToServer(String path){
    Bitmap image = ImageUtils.getCompressed(path);

    Bitmap thumbnail = ImageUtils.getCompressed(path,
            BDefines.ImageProperties.MAX_IMAGE_THUMBNAIL_SIZE,
            BDefines.ImageProperties.MAX_IMAGE_THUMBNAIL_SIZE);

    return BNetworkManager.sharedManager().getNetworkAdapter().uploadImage(
            image, thumbnail)
            .done(new DoneCallback<String[]>() {
                @Override
                public void onDone(String[] data) {
                    // Saving the image to backendless.
                    final BUser currentUser = BNetworkManager.sharedManager().getNetworkAdapter().currentUserModel();

                    currentUser.setMetaPictureUrl(data[0]);
                    currentUser.setMetaPictureThumbnail(data[1]);

                    BNetworkManager.sharedManager().getNetworkAdapter().pushUser();
                }
            })
            .fail(new FailCallback<BError>() {
                @Override
                public void onFail(BError error) {
                    if (DEBUG)
                        Timber.e("Backendless Exception while saving profile pic, message: %s", error.message);
                }
            });
}
 
Example 28
Project: mapbox-navigation-android   File: PollyPlayer.java   View source code 5 votes vote down vote up
private void setDataSource(String instruction) {
  try {
    pollyMediaPlayer.setDataSource(instruction);
  } catch (IOException ioException) {
    Timber.e("Unable to set data source for the media pollyMediaPlayer! %s",
      ioException.getMessage());
  }
}
 
Example 29
Project: fast_face_android   File: DlibDemoApp.java   View source code 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (BuildConfig.DEBUG) {
        Timber.plant(new Timber.DebugTree());
        //Timber.plant(new DebugLogFileTree(Environment.getExternalStorageDirectory().toString()));
    } else {
        Timber.plant(new ReleaseTree());
    }
}
 
Example 30
Project: q-mail   File: AccountSetupBasics.java   View source code 5 votes vote down vote up
private String getOwnerName() {
    String name = null;
    try {
        name = getDefaultAccountName();
    } catch (Exception e) {
        Timber.e(e, "Could not get default account name");
    }

    if (name == null) {
        name = "";
    }
    return name;
}
 
Example 31
Project: GitHub   File: SelectedCountToolbarPresenter.java   View source code 5 votes vote down vote up
@Override protected void bindIntents() {

    clearSelectionDisposal = intent(SelectedCountToolbarView::clearSelectionIntent)
        .doOnNext(ignore -> Timber.d("intent: clear selection"))
        .subscribe(aBoolean -> clearSelectionRelay.onNext(aBoolean));

    deleteSelectedItemsDisposal =
        intent(SelectedCountToolbarView::deleteSelectedItemsIntent)
            .doOnNext(items -> Timber.d("intent: delete selected items "+items))
            .subscribe(aBoolean -> deleteSelectedItemsRelay.onNext(aBoolean));

    subscribeViewState(selectedCountObservable, SelectedCountToolbarView::render);
  }
 
Example 32
Project: android-robocar   File: RCDriver.java   View source code 5 votes vote down vote up
public void moveForward(@Nes30Manager.ButtonCode int keyCode, boolean isDown) {
  preCheck(keyCode, isDown);

  Timber.d("Moving forward.");
  motorFrontLeft.run(AdafruitMotorHat.FORWARD);
  motorFrontRight.run(AdafruitMotorHat.BACKWARD);
  motorBackLeft.run(AdafruitMotorHat.BACKWARD);
  motorBackRight.run(AdafruitMotorHat.FORWARD);
}
 
Example 33
Project: q-mail   File: LocalStore.java   View source code 5 votes vote down vote up
public void clear() throws MessagingException {
    if (QMail.isDebug()) {
        Timber.i("Before prune size = %d", getSize());
    }

    deleteAllMessageDataFromDisk();

    if (QMail.isDebug()) {
        Timber.i("After prune / before compaction size = %d", getSize());
        Timber.i("Before clear folder count = %d", getFolderCount());
        Timber.i("Before clear message count = %d", getMessageCount());
        Timber.i("After prune / before clear size = %d", getSize());
    }

    database.execute(false, new DbCallback<Void>() {
        @Override
        public Void doDbWork(final SQLiteDatabase db) {
            // We don't care about threads of deleted messages, so delete the whole table.
            db.delete("threads", null, null);

            // Don't delete deleted messages. They are essentially placeholders for UIDs of messages that have
            // been deleted locally.
            db.delete("messages", "deleted = 0", null);

            // We don't need the search data now either
            db.delete("messages_fulltext", null, null);

            return null;
        }
    });

    compact();

    if (QMail.isDebug()) {
        Timber.i("After clear message count = %d", getMessageCount());
        Timber.i("After clear size = %d", getSize());
    }
}
 
Example 34
Project: NeiHanDuanZiTV   File: SplashPresenter.java   View source code 5 votes vote down vote up
public void initDataAndToNextPage() {
    // TODO: 2017/8/26 休眠1000ms后判断是否进入首页 或者展示引导页面
    Schedulers.newThread().createWorker().schedule(() -> {
        Timber.d("一秒后跳转页面");
        final Class[] mClass = {MainActivity.class};
        AndroidSchedulers.mainThread().createWorker().schedule(() -> {
            Timber.d("开始执行");
            if (DBUtils.getInstance(mApplication).isFirstEnterApp())
                mClass[0] = GuideActivity.class;
            Intent intent = new Intent(mApplication, mClass[0]);
            mRootView.launchActivity(intent);
            mRootView.killMyself();
        });
    }, 1, TimeUnit.SECONDS);
}
 
Example 35
Project: GitHub   File: SampleApplication.java   View source code 5 votes vote down vote up
@Override public void onCreate() {
  super.onCreate();
  if (LeakCanary.isInAnalyzerProcess(this)) {
    // This process is dedicated to LeakCanary for heap analysis.
    // You should not init your app in this process.
    return;
  }
  refWatcher = LeakCanary.install(this);
  Timber.d("Starting Application");
}
 
Example 36
Project: android-robocar   File: GameControllerActivity.java   View source code 5 votes vote down vote up
private void setSpeed(Integer left, Integer right) {
    if(left!=null)
        this.leftSpeedTextView.setText(""+left);
    if(right!=null)
        this.rightSpeedTextView.setText(""+right);
    try {
        RobocarClient service= new RobocarRestClient("http://"+this.webserviceUrlTextView.getText());
        service.setSpeed(left, right);
    }catch(Exception e) {
        Toast.makeText(this, "Unable to communicate with Robocar: "+e.getMessage(), Toast.LENGTH_SHORT).show();
        Timber.d(e.getMessage());
    }
}
 
Example 37
Project: secretknock   File: MainActivity.java   View source code 5 votes vote down vote up
Observable.Transformer<Void, List<TimeInterval<Void>>> collectTapSequence() {
	return observable -> observable
			.observeOn(Schedulers.io())
			.doOnNext(clickEvent -> Timber.d("tap"))
			.timeInterval()
			.skip(1)
			.timeout(timeInterval -> Observable.timer(1500, TimeUnit.MILLISECONDS), Observable.empty())
			.toList()
			.observeOn(AndroidSchedulers.mainThread());
}
 
Example 38
Project: disclosure-android-app   File: ApkAnalyzer.java   View source code 5 votes vote down vote up
public boolean usesLibrary(String packageName) {
  String currentThread = Thread.currentThread().getName();
  Timber.v("%s : Searching for package %s in app %s", currentThread, packageName,
      apk.getApp().label());

  int index = Collections.binarySearch(classes, packageName, (currentItem, key) -> {
    if (currentItem.startsWith(key)) {
      return 0;
    }
    return currentItem.compareTo(key);
  });
  return index >= MIN_INDEX;
}
 
Example 39
Project: starcraft-2-build-player   File: EditBuildActivity.java   View source code 5 votes vote down vote up
private BuildEditorTabView getCurrentlyVisibleEditorTab() {
    Fragment fragment = mPagerAdapter.getRegisteredFragment(mPager.getCurrentItem());
    if (fragment == null) {
        Timber.e("Warning: registered fragment was null in getCurrentlyVisibleEditorTab, returning default BuildEditorTabView impl.");
        return BuildEditorTabView.DefaultBuildEditorTabView;
    }
    if (fragment instanceof BuildEditorTabView) {
        Timber.d("current editor tab = " + fragment);
        return (BuildEditorTabView) fragment;
    } else {
        throw new IllegalStateException(String.format("Fragment \"%s\" from EditBuildPagerAdapter must implement BuildEditorTabView",
                fragment));
    }
}
 
Example 40
Project: app-android   File: AstaApp.java   View source code 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (BuildConfig.DEBUG) {
        Timber.plant(new Timber.DebugTree());
    }
    Timber.i("AstaApp started");
}