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: chat-sdk-android-push-firebase   File: FirebaseEventsManager.java   Source Code and License 12 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 2
Project: chat-sdk-android-push-firebase   File: FirebaseEventsManager.java   Source Code and License 11 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 3
Project: android-robocar   File: TiltControllerActivity.java   Source Code and License 11 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 4
Project: q-mail   File: Settings.java   Source Code and License 11 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 5
Project: FinalProject   File: ActivityYourFeedFragment.java   Source Code and License 10 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 6
Project: q-mail   File: SmtpTransport.java   Source Code and License 10 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 7
Project: EosCommander   File: PRNGFixes.java   Source Code and License 10 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 8
Project: fast-list   File: User.java   Source Code and License 8 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 9
Project: BuildingDebugFeatures   File: DebugBroadcastReceiver.java   Source Code and License 8 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 10
Project: q-mail   File: Address.java   Source Code and License 8 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: GitHub   File: SearchFragment.java   Source Code and License 8 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 12
Project: xmrwallet   File: SendSuccessWizardFragment.java   Source Code and License 8 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 13
Project: MVVMArms   File: ApiResponse.java   Source Code and License 7 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 14
Project: Quran   File: QuranFileUtils.java   Source Code and License 7 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 15
Project: FinalProject   File: UserHugCounterActivity.java   Source Code and License 7 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 16
Project: yyox   File: PermissionUtil.java   Source Code and License 7 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 17
Project: InstantAppStarter   File: ApiErrorUtils.java   Source Code and License 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 18
Project: yyox   File: PermissionUtil.java   Source Code and License 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 19
Project: xmrwallet   File: SendBtcConfirmWizardFragment.java   Source Code and License 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 20
Project: app-android   File: AstaApp.java   Source Code and License 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    if (BuildConfig.DEBUG) {
        Timber.plant(new Timber.DebugTree());
    }
    Timber.i("AstaApp started");
}
 
Example 21
Project: chat-sdk-android-push-firebase   File: ChatSDKAbstractThreadsListAdapter.java   Source Code and License 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 22
Project: AndroidBackendlessChat   File: FirebaseEventsManager.java   Source Code and License 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 23
Project: xmrwallet   File: WalletService.java   Source Code and License 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 24
Project: q-mail   File: DeferredFileBody.java   Source Code and License 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 25
Project: chat-sdk-android-push-firebase   File: FirebaseEventsManager.java   Source Code and License 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 26
Project: GongXianSheng   File: HomePagePresenter.java   Source Code and License 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 27
Project: DOUSalaries   File: NetworkModule.java   Source Code and License 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 28
Project: AndroidBackendlessChat   File: ChatSDKProfileHelper.java   Source Code and License 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 29
Project: mapbox-navigation-android   File: PollyPlayer.java   Source Code and License 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 30
Project: fast_face_android   File: DlibDemoApp.java   Source Code and License 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 31
Project: q-mail   File: AccountSetupBasics.java   Source Code and License 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 32
Project: GitHub   File: SelectedCountToolbarPresenter.java   Source Code and License 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 33
Project: android-robocar   File: RCDriver.java   Source Code and License 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 34
Project: q-mail   File: LocalStore.java   Source Code and License 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 35
Project: NeiHanDuanZiTV   File: SplashPresenter.java   Source Code and License 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 36
Project: GitHub   File: SampleApplication.java   Source Code and License 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 37
Project: android-robocar   File: GameControllerActivity.java   Source Code and License 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 38
Project: secretknock   File: MainActivity.java   Source Code and License 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 39
Project: disclosure-android-app   File: ApkAnalyzer.java   Source Code and License 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 40
Project: starcraft-2-build-player   File: EditBuildActivity.java   Source Code and License 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 41
Project: CodeWatch   File: ProjectDetailsFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void onValueSelected(Entry e, Highlight h) {
    Timber.d(e.toString());
    switch (CHART_ID) {
        case LANGUAGE_CHART_ID:
            if (!isExpandedMap.get(expandLanguages.getId())) {
                onExpand(expandLanguages);
            }
            languageHighlightedEntryX = h.getX();
            resetAdapter(languagesListview, languageListAdapter, ((PieEntry) e).getLabel());
            break;
        case OS_CHART_ID:
            if (!isExpandedMap.get(expandOs.getId())) {
                onExpand(expandOs);
            }
            osHighlightedEntryX = h.getX();
            resetAdapter(osListview, osListAdapter, ((PieEntry) e).getLabel());
            break;
        case EDITORS_CHART_ID:
            if (!isExpandedMap.get(expandEditors.getId())) {
                onExpand(expandEditors);
            }
            editorHighlightedEntryX = h.getX();
            resetAdapter(editorsListView, editorsListAdapter, ((PieEntry) e).getLabel());
            break;
        default: //common code
            break;
    }
}
 
Example 42
Project: secretknock   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void initializeRecorder() {
	clickSubscription = RxView.clicks(recordingMessage)
			.compose(collectTapSequence())
			.subscribe(new Subscriber<List<TimeInterval<Void>>>() {
				@Override
				public void onCompleted() {
					Timber.v("tapsSubscriber onCompleted");
				}

				@Override
				public void onError(Throwable e) {
					Timber.v(e, "ruh roh");
				}

				@Override
				public void onNext(List<TimeInterval<Void>> durations) {
					Timber.v("onNext");

					if (patternIsValid(durations)) {
						storePattern(durations);
						activateLock();
					} else {
						Timber.v("pattern invalid");
						Toast.makeText(MainActivity.this, R.string.pattern_invalid, Toast.LENGTH_SHORT).show();
						Handler handler = new Handler();
						handler.post(()-> initializeRecorder());
					}

				}
			}
	);

}
 
Example 43
Project: androidthings-kuman-sm9   File: MainViewModel.java   Source Code and License 5 votes vote down vote up
public void onLed0Clicked() {
    try {
        mPwrA53A.setLed0Value(true);
    } catch (IOException e) {
        Timber.e(e);
    }
}
 
Example 44
Project: disclosure-android-app   File: AppDetailPresenter.java   Source Code and License 5 votes vote down vote up
private void fetchAppUpdates() {
  subscriptions.add(appService.byPackageName(app.packageName())
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(app -> {
        this.app = app;
        initView(app);
      }, throwable -> Timber.d(throwable, "while fetching apps")));
}
 
Example 45
Project: xmrwallet   File: LoginActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Timber.d("onCreate()");
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        // we don't store anything ourselves
    }

    setContentView(R.layout.activity_login);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    toolbar.setOnButtonListener(new Toolbar.OnButtonListener() {
        @Override
        public void onButton(int type) {
            switch (type) {
                case Toolbar.BUTTON_BACK:
                    onBackPressed();
                    break;
                case Toolbar.BUTTON_CLOSE:
                    finish();
                    break;
                case Toolbar.BUTTON_DONATE:
                    DonationFragment.display(getSupportFragmentManager());
                    break;
                case Toolbar.BUTTON_NONE:
                default:
                    Timber.e("Button " + type + "pressed - how can this be?");
            }
        }
    });

    if (Helper.getWritePermission(this)) {
        if (savedInstanceState == null) startLoginFragment();
    } else {
        Timber.i("Waiting for permissions");
    }
}
 
Example 46
Project: q-mail   File: ImapConnection.java   Source Code and License 5 votes vote down vote up
public void sendContinuation(String continuation) throws IOException {
    outputStream.write(continuation.getBytes());
    outputStream.write('\r');
    outputStream.write('\n');
    outputStream.flush();

    if (K9MailLib.isDebug() && DEBUG_PROTOCOL_IMAP) {
        Timber.v("%s>>> %s", getLogId(), continuation);
    }
}
 
Example 47
Project: FinalProject   File: MessageActivity.java   Source Code and License 5 votes vote down vote up
private void uploadFile(Uri fileUri) {
    File file = new File(String.valueOf(fileUri));

    // create RequestBody instance from file
    RequestBody requestFile =
            RequestBody.create(MediaType.parse("multipart/form-data"), file);

    // MultipartBody.Part is used to send also the actual file name
    MultipartBody.Part body =
            MultipartBody.Part.createFormData("file", file.getName(), requestFile);

    // finally, execute the request
    try {
        application.getWebService()
                .uploadFile(body)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<String>() {
                    @Override
                    public void onNext(String response) {
                        Timber.d("file url " + response);
                        chatMessage(response);
                        setImageFileUrl(response);
                     //   setImageFileUrl(response);
                    //    MySharedPreferences.registerImageUrl(preferences, response);

                    }
                });
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
Example 48
Project: Android-MVVM-Example   File: DataModel.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the list of videos cached on device.
 *
 * Also automatically triggers the process of fetching up-to-date list of videos from server.
 */
public Observable<RealmResults<Video>> getVideos(boolean forceFetchFromServer) {
    if (forceFetchFromServer || isTimeForServerCall()) {
        Timber.d("Going to call server for up-to-date list of videos. Forced: %s", forceFetchFromServer);
        fetchVideosFromServer(null);
    } else {
        Timber.d("Too early to refresh video list from server. Just load a cached copy from realm");
    }

    return RxRealm.RealmResultsObservable.from(
            mRealm
                    .where(Video.class)
                    .findAllSortedAsync("created", Sort.DESCENDING)
    ).filter(videos -> videos.isLoaded());
}
 
Example 49
Project: android-robocar   File: RCDriver.java   Source Code and License 5 votes vote down vote up
public void turnLeft(@Nes30Manager.ButtonCode int keyCode, boolean isDown) {
  preCheck(keyCode, isDown);
  if (isUpOrDownPressed) {
    return;
  }

  Timber.d("Turning left.");
  motorFrontLeft.run(AdafruitMotorHat.BACKWARD);
  motorFrontRight.run(AdafruitMotorHat.BACKWARD);
  motorBackLeft.run(AdafruitMotorHat.FORWARD);
  motorBackRight.run(AdafruitMotorHat.FORWARD);
}
 
Example 50
Project: q-mail   File: DecoderUtil.java   Source Code and License 5 votes vote down vote up
private static String decodeEncodedWord(String body, int begin, int end, Message message) {
    int qm1 = body.indexOf('?', begin + 2);
    if (qm1 == end - 2)
        return null;

    int qm2 = body.indexOf('?', qm1 + 1);
    if (qm2 == end - 2)
        return null;

    String mimeCharset = body.substring(begin + 2, qm1);
    String encoding = body.substring(qm1 + 1, qm2);
    String encodedText = body.substring(qm2 + 1, end - 2);

    String charset;
    try {
        charset = CharsetSupport.fixupCharset(mimeCharset, message);
    } catch (MessagingException e) {
        return null;
    }

    if (encodedText.isEmpty()) {
        Timber.w("Missing encoded text in encoded word: '%s'", body.substring(begin, end));
        return null;
    }

    if (encoding.equalsIgnoreCase("Q")) {
        return decodeQ(encodedText, charset);
    } else if (encoding.equalsIgnoreCase("B")) {
        return DecoderUtil.decodeB(encodedText, charset);
    } else {
        Timber.w("Warning: Unknown encoding in encoded word '%s'", body.substring(begin, end));
        return null;
    }
}
 
Example 51
Project: q-mail   File: Accounts.java   Source Code and License 5 votes vote down vote up
/**
 * Show that account's inbox or folder-list
 * or return false if the account is not available.
 * @param account the account to open ({@link SearchAccount} or {@link Account})
 * @return false if unsuccessful
 */
private boolean onOpenAccount(BaseAccount account) {
    if (account instanceof SearchAccount) {
        SearchAccount searchAccount = (SearchAccount)account;
        MessageList.actionDisplaySearch(this, searchAccount.getRelatedSearch(), false, false);
    } else {
        Account realAccount = (Account)account;
        if (!realAccount.isEnabled()) {
            onActivateAccount(realAccount);
            return false;
        } else if (!realAccount.isAvailable(this)) {
            String toastText = getString(R.string.account_unavailable, account.getDescription());
            Toast toast = Toast.makeText(getApplication(), toastText, Toast.LENGTH_SHORT);
            toast.show();

            Timber.i("refusing to open account that is not available");
            return false;
        }
        if (QMail.FOLDER_NONE.equals(realAccount.getAutoExpandFolderId())) {
            FolderList.actionHandleAccount(this, realAccount);
        } else {
            LocalSearch search = new LocalSearch(realAccount.getAutoExpandFolderId());
            search.addAllowedFolder(realAccount.getAutoExpandFolderId());
            search.addAccountUuid(realAccount.getUuid());
            MessageList.actionDisplaySearch(this, search, false, true);}
    }
    return true;
}
 
Example 52
Project: MoligyMvpArms   File: FragmentLifecycle.java   Source Code and License 5 votes vote down vote up
@Override
public void onFragmentPaused(FragmentManager fm, Fragment f) {
    Timber.w(f.toString() + " - onFragmentPaused");
    FragmentDelegate fragmentDelegate = fetchFragmentDelegate(f);
    if (fragmentDelegate != null) {
        fragmentDelegate.onPause();
    }
}
 
Example 53
Project: androidthings-kuman-sm9   File: GoogleApiClientRepository.java   Source Code and License 5 votes vote down vote up
private void handleOnConnectionResult(String endpointId, ConnectionResolution resolution) {
    Timber.d("onConnectionResult");
    if (resolution.getStatus().isSuccess()) {
        if (!mRemotePeerEndpoints.contains(endpointId)) {
            mRemotePeerEndpoints.add(endpointId);
        }
        Timber.d("Connected! (endpointId=" + endpointId + ")");
    } else {
        Timber.w("Connection to " + endpointId + " failed. Code: " + resolution.getStatus().getStatusCode());
    }
}
 
Example 54
Project: q-mail   File: LocalFolder.java   Source Code and License 5 votes vote down vote up
public void purgeToVisibleLimit(final MessageRemovalListener listener) throws MessagingException {
    // don't purge messages while a Search is active since it might throw away search results
    if (Search.isActive()) {
        return;
    }

    if (visibleLimit == 0) {
        return;
    }

    open(OPEN_MODE_RW);

    localStore.getDatabase().execute(false, new DbCallback<Void>() {
        @Override
        public Void doDbWork(final SQLiteDatabase db) {
            Cursor cursor = db.rawQuery("SELECT uid " +
                            "FROM messages " +
                            "WHERE empty = 0 AND deleted = 0 AND folder_id = ? ORDER BY date DESC " +
                            " LIMIT -1 OFFSET ?",
                    new String[] { Long.toString(getDatabaseId()), Integer.toString(visibleLimit) });

            try {
                while (cursor.moveToNext()) {
                    String uid = cursor.getString(0);
                    LocalMessage localMessage = getMessage(uid);

                    if (listener != null) {
                        listener.messageRemoved(localMessage);
                    }
                    destroyMessage(localMessage);
                }
            } catch (Exception e) {
                Timber.d(e, "Got an exception");
            } finally {
                Utility.closeQuietly(cursor);
            }
            return null;
        }
    });
}
 
Example 55
Project: android-robocar   File: DebugActivity.java   Source Code and License 5 votes vote down vote up
private void setupWebServer() {
  LocalWebServer localWebServer = new LocalWebServer(this);
  try {
    localWebServer.start(NanoHTTPD.SOCKET_READ_TIMEOUT, true);
  } catch (IOException e) {
    Timber.e(e, "Failed to start local web server.");
  }

  Timber.d("IP address: %s", LocalWebServer.getIpAddress(this));
}
 
Example 56
Project: superglue   File: LumberYard.java   Source Code and License 5 votes vote down vote up
public Timber.Tree tree() {
  return new Timber.DebugTree() {
    @Override protected void log(int priority, String tag, String message, Throwable t) {
      addEntry(new Entry(priority, tag, message));
    }
  };
}
 
Example 57
Project: cleaninsights-android-sdk   File: CustomVariables.java   Source Code and License 5 votes vote down vote up
/**
 * @param index  index accepts values from 1 to 5.
 * @param values packed key/value pair
 * @return super.put result or null if key is null or value length is not equals 2
 */
public JSONArray put(String index, JSONArray values) {
    if (values.length() != 2 || index == null) {
        Timber.tag(LOGGER_TAG).w("values.length() should be equal 2");
        return null;
    }
    return mVars.put(index, values);
}
 
Example 58
Project: superglue   File: DebugDataModule.java   Source Code and License 5 votes vote down vote up
@Provides @Singleton Picasso providePicasso(OkHttpClient client, Application app) {
  Picasso.Builder builder = new Picasso.Builder(app).downloader(new OkHttp3Downloader(client));
  builder.listener((picasso, uri, exception) -> {
    Timber.e(exception, "Error while loading image %s", uri);
  });
  return builder.build();
}
 
Example 59
Project: q-mail   File: SmtpTransport.java   Source Code and License 5 votes vote down vote up
private void parseOptionalSizeValue(Map<String, String> extensions) {
    if (extensions.containsKey("SIZE")) {
        String optionalsizeValue = extensions.get("SIZE");
        if (optionalsizeValue != null && !"".equals(optionalsizeValue)) {
            try {
                largestAcceptableMessage = Integer.parseInt(optionalsizeValue);
            } catch (NumberFormatException e) {
                if (K9MailLib.isDebug() && DEBUG_PROTOCOL_SMTP) {
                    Timber.d(e, "Tried to parse %s and get an int", optionalsizeValue);
                }
            }
        }
    }
}
 
Example 60
Project: MVVMArms   File: FragmentLifecycle.java   Source Code and License 5 votes vote down vote up
@Override
public void onFragmentViewCreated(FragmentManager fm, Fragment f, View v, Bundle savedInstanceState) {
    super.onFragmentViewCreated(fm, f, v, savedInstanceState);
    FragmentDelegate fragmentDelegate = fetchFragmentDelegate(f);
    if (fragmentDelegate != null) {
        Timber.i("%s ---> onFragmentViewCreated", f.toString());
        fragmentDelegate.onCreateView(v, savedInstanceState);
    }
}