timber.log.Timber Java Examples
The following examples show how to use
timber.log.Timber.
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: DefaultMiscActions.java From under-the-hood with Apache License 2.0 | 6 votes |
/** * Kills all associated processes */ public static void killProcessesAround(Activity activity) { try { ActivityManager am = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE); String myProcessPrefix = activity.getApplicationInfo().processName; String myProcessName = activity.getPackageManager().getActivityInfo(activity.getComponentName(), 0).processName; for (ActivityManager.RunningAppProcessInfo proc : am.getRunningAppProcesses()) { if (proc.processName.startsWith(myProcessPrefix) && !proc.processName.equals(myProcessName)) { android.os.Process.killProcess(proc.pid); } } } catch (Exception e) { Timber.e(e, "could not kill process"); } finally { android.os.Process.killProcess(android.os.Process.myPid()); } }
Example #2
Source File: WearListenerService.java From wear-notify-for-reddit with Apache License 2.0 | 6 votes |
private void getComments(String permalink) { mRedditService.comments(permalink, "best") .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(comments -> { if (comments == null) { mAnalytics.sendEvent(Logger.LOG_EVENT_GET_COMMENTS, Logger.LOG_EVENT_FAILURE); sendToPath(mGoogleApiClient, Constants.PATH_GET_COMMENTS_RESULT_FAILED); } else { sendComments(comments); mAnalytics.sendEvent(Logger.LOG_EVENT_GET_COMMENTS, Logger.LOG_EVENT_SUCCESS); } }, throwable -> { Timber.e(throwable, "Failed to get comments"); mAnalytics.sendEvent(Logger.LOG_EVENT_GET_COMMENTS, Logger.LOG_EVENT_FAILURE); sendToPath(mGoogleApiClient, Constants.PATH_GET_COMMENTS_RESULT_FAILED); }); }
Example #3
Source File: DebugView.java From u2020 with Apache License 2.0 | 6 votes |
/** * Populates a {@code Spinner} with the values of an {@code enum} and binds it to the value set * in * the mock service. */ private <T extends Enum<T>> void configureResponseSpinner(Spinner spinner, final Class<T> responseClass) { final EnumAdapter<T> adapter = new EnumAdapter<>(getContext(), responseClass); spinner.setEnabled(isMockMode); spinner.setAdapter(adapter); spinner.setSelection(mockResponseSupplier.get(responseClass).ordinal()); RxAdapterView.itemSelections(spinner) .map(adapter::getItem) .filter(item -> item != mockResponseSupplier.get(responseClass)) .subscribe(selected -> { Timber.d("Setting %s to %s", responseClass.getSimpleName(), selected); mockResponseSupplier.set(selected); }); }
Example #4
Source File: BluetoothCentral.java From blessed-android with MIT License | 6 votes |
/** * Make the pairing popup appear in the foreground by doing a 1 sec discovery. * <p> * If the pairing popup is shown within 60 seconds, it will be shown in the foreground. */ public void startPairingPopupHack() { // Check if we are on a Samsung device because those don't need the hack String manufacturer = Build.MANUFACTURER; if (!manufacturer.equals("samsung")) { bluetoothAdapter.startDiscovery(); callBackHandler.postDelayed(new Runnable() { @Override public void run() { Timber.d("popup hack completed"); bluetoothAdapter.cancelDiscovery(); } }, 1000); } }
Example #5
Source File: VoiceActivity.java From africastalking-android with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_voice_dialpad); ButterKnife.bind(this); callBtn.setEnabled(false); try { Timber.i("Setting up pjsip...."); AfricasTalking.initializeVoiceService(this, mRegListener, new Callback<VoiceService>() { @Override public void onSuccess(VoiceService service) { mService = service; } @Override public void onFailure(Throwable throwable) { Timber.e(throwable.getMessage()); } }); } catch (Exception ex) { Timber.e(ex.getMessage()); } }
Example #6
Source File: DebounceSearchEmitterFragment.java From RxJava-Android-Samples with Apache License 2.0 | 6 votes |
private DisposableObserver<TextViewTextChangeEvent> _getSearchObserver() { return new DisposableObserver<TextViewTextChangeEvent>() { @Override public void onComplete() { Timber.d("--------- onComplete"); } @Override public void onError(Throwable e) { Timber.e(e, "--------- Woops on error!"); _log("Dang error. check your logs"); } @Override public void onNext(TextViewTextChangeEvent onTextChangeEvent) { _log(format("Searching for %s", onTextChangeEvent.text().toString())); } }; }
Example #7
Source File: AlexaCommandManagerImpl.java From mirror with Apache License 2.0 | 6 votes |
@Override public void doAuthentication() { mAlexaManager.logIn(new AuthorizationCallback() { @Override public void onCancel() { } @Override public void onSuccess() { mEnabled = true; } @Override public void onError(Exception e) { mEnabled = false; Timber.e(e, "Error trying to login to amazon"); } }); }
Example #8
Source File: RandomContentController.java From CodePolitan with Apache License 2.0 | 6 votes |
public void loadRandomTag() { presenter.showLoading(); CodePolitanApi.pluck() .getApi() .getTags(BenihUtils.randInt(1, 5)) .compose(BenihScheduler.pluck().applySchedulers(BenihScheduler.Type.IO)) .flatMap(tagListResponse -> Observable.just(tagListResponse.getResult())) .map(tags -> tags.get(BenihUtils.randInt(0, tags.size() - 1))) .subscribe(tag -> { this.tag = tag; if (presenter != null) { presenter.showRandomTag(tag); presenter.dismissLoading(); } }, throwable -> { if (presenter != null) { Timber.d(throwable.getMessage()); presenter.showError(new Throwable(ErrorEvent.LOAD_RANDOM_TAG)); presenter.dismissLoading(); } }); }
Example #9
Source File: BluetoothPeripheral.java From blessed-android with MIT License | 6 votes |
/** * Request a different connection priority. * <p> * Use the standard parameters for Android: CONNECTION_PRIORITY_BALANCED, CONNECTION_PRIORITY_HIGH, or CONNECTION_PRIORITY_LOW_POWER. There is no callback for this function. * * @param priority the requested connection priority * @return true if request was enqueued, false if not */ public boolean requestConnectionPriority(final int priority) { // Enqueue the request connection priority command and complete is immediately as there is no callback for it boolean result = commandQueue.add(new Runnable() { @Override public void run() { if (isConnected()) { if (!bluetoothGatt.requestConnectionPriority(priority)) { Timber.e("could not set connection priority"); } else { Timber.d("requesting connection priority %d", priority); } completedCommand(); } } }); if (result) { nextCommand(); } else { Timber.e("could not enqueue request connection priority command"); } return result; }
Example #10
Source File: PitchPresenter.java From Android-Guitar-Tuner with Apache License 2.0 | 6 votes |
public void startPlayingNote(final double noteFrequency) { pitchPlayerDisposable = pitchPlayer.startPlaying(noteFrequency) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(() -> { }, error -> { Timber.e(error, "Error Starting Pitch Playback."); boolean showAction = retryCount < RETRY_COUNT_MAX; int description = showAction ? R.string.pitch_player_error_playing_note_description_with_action : R.string.pitch_player_error_playing_note_description_without_action; view.onErrorPlayingNote( description, showAction, R.string.pitch_player_error_playing_note_action, R.color.snack_bar_action_color ); }); }
Example #11
Source File: MainActivity.java From openshop.io-android with MIT License | 6 votes |
/** * Method clear fragment backStack (back history). On bottom of stack will remain Fragment added by {@link #addInitialFragment()}. */ private void clearBackStack() { Timber.d("Clearing backStack"); FragmentManager manager = getSupportFragmentManager(); if (manager.getBackStackEntryCount() > 0) { if (BuildConfig.DEBUG) { for (int i = 0; i < manager.getBackStackEntryCount(); i++) { Timber.d("BackStack content_%d= id: %d, name: %s", i, manager.getBackStackEntryAt(i).getId(), manager.getBackStackEntryAt(i).getName()); } } FragmentManager.BackStackEntry first = manager.getBackStackEntryAt(0); manager.popBackStackImmediate(first.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } Timber.d("backStack cleared."); // TODO maybe implement own fragment backStack handling to prevent banner fragment recreation during clearing. // http://stackoverflow.com/questions/12529499/problems-with-android-fragment-back-stack }
Example #12
Source File: SplashActivity.java From openshop.io-android with MIT License | 6 votes |
/** * Load available shops from server. */ private void requestShops() { if (layoutIntroScreen.getVisibility() != View.VISIBLE) progressDialog.show(); GsonRequest<ShopResponse> getShopsRequest = new GsonRequest<>(Request.Method.GET, EndPoints.SHOPS, null, ShopResponse.class, new Response.Listener<ShopResponse>() { @Override public void onResponse(@NonNull ShopResponse response) { Timber.d("Get shops response: %s", response.toString()); setSpinShops(response.getShopList()); if (progressDialog != null) progressDialog.cancel(); animateContentVisible(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { if (progressDialog != null) progressDialog.cancel(); MsgUtils.logAndShowErrorMessage(activity, error); finish(); } }); getShopsRequest.setRetryPolicy(MyApplication.getDefaultRetryPolice()); getShopsRequest.setShouldCache(false); MyApplication.getInstance().addToRequestQueue(getShopsRequest, CONST.SPLASH_REQUESTS_TAG); }
Example #13
Source File: EventDiskCache.java From matomo-sdk-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@NonNull public synchronized List<Event> uncache() { List<Event> events = new ArrayList<>(); if (!isCachingEnabled()) return events; long startTime = System.currentTimeMillis(); while (!mEventContainer.isEmpty()) { File head = mEventContainer.poll(); if (head != null) { events.addAll(readEventFile(head)); if (!head.delete()) Timber.tag(TAG).e("Failed to delete cache container %s", head.getPath()); } } checkCacheLimits(); long stopTime = System.currentTimeMillis(); Timber.tag(TAG).d("Uncaching of %d events took %dms", events.size(), (stopTime - startTime)); return events; }
Example #14
Source File: ScaleMeasurement.java From openScale with GNU General Public License v3.0 | 6 votes |
public void add(final ScaleMeasurement summand) { try { Field[] fields = getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); Object value = field.get(this); if (value != null && Float.class.isAssignableFrom(value.getClass())) { field.set(this, (float)value + (float)field.get(summand)); } field.setAccessible(false); } count++; } catch (IllegalAccessException e) { Timber.e(e); } }
Example #15
Source File: KeyStoreHelper.java From xmrwallet with Apache License 2.0 | 6 votes |
private static PrivateKey getPrivateKey(String alias) { try { KeyStore ks = KeyStore .getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE); ks.load(null); //KeyStore.Entry entry = ks.getEntry(alias, null); PrivateKey privateKey = (PrivateKey) ks.getKey(alias, null); if (privateKey == null) { Timber.w("No key found under alias: %s", alias); return null; } return privateKey; } catch (IOException | NoSuchAlgorithmException | CertificateException | UnrecoverableEntryException | KeyStoreException ex) { throw new IllegalStateException(ex); } }
Example #16
Source File: PermissionUtil.java From AndroidBase with Apache License 2.0 | 6 votes |
/** * 请求外部存储的权限 */ public static void externalStorage(final RequestPermission requestPermission, RxPermissions rxPermissions, final IView 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(RxUtils.<Boolean>bindToLifecycle(view)) .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 #17
Source File: updateComicDatabase.java From Easy_xkcd with Apache License 2.0 | 6 votes |
void createNoMediaFile() { if (!prefHelper.nomediaCreated()) { File sdCard = prefHelper.getOfflinePath(); File dir = new File(sdCard.getAbsolutePath() + "/easy xkcd/"); if (!dir.exists()) { dir.mkdirs(); } File nomedia = new File(dir, ".nomedia"); try { boolean created = nomedia.createNewFile(); Timber.d("created .nomedia in external storage: %s", created); prefHelper.setNomediaCreated(); } catch (IOException e) { Timber.e(e); } } }
Example #18
Source File: MainActivity.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.M) private void startAirplaneModeSystemActivity() { try { Intent intent = new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS); startActivityForResult(intent, AIRPLANE_MODE_ACTIVITY_RESULT); } catch (ActivityNotFoundException ex) { Timber.w(ex, "startAirplaneModeSystemActivity(): Could not open Settings to change airplane mode"); MyApplication.handleSilentException(ex); showCannotOpenAndroidSettingsDialog(); } }
Example #19
Source File: MyDuka.java From LNMOnlineAndroidSample with Apache License 2.0 | 5 votes |
protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } }
Example #20
Source File: StreamPageFragment.java From zapp with MIT License | 5 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FragmentStreamPageBinding binding = FragmentStreamPageBinding.inflate(inflater, container, false); rootView = binding.getRoot(); errorText = binding.textError; Bundle args = getArguments(); ChannelModel channel = (ChannelModel) args.getSerializable(ARGUMENT_CHANNEL_MODEL); if (channel != null) { ImageView logoView = binding.imageChannelLogo; logoView.setImageResource(channel.getDrawableId()); logoView.setContentDescription(channel.getName()); errorText.setBackgroundColor(channel.getColor()); errorText.setOnClickListener(view -> onErrorViewClick()); if (channel.getSubtitle() != null) { TextView subtitleText = binding.textChannelSubtitle; subtitleText.setText(channel.getSubtitle()); } } else { Timber.w("channel argument is null"); } return rootView; }
Example #21
Source File: AppManager.java From MVPArms with Apache License 2.0 | 5 votes |
/** * 获取指定 {@link Activity} class 的实例,没有则返回 null(同一个 {@link Activity} class 有多个实例,则返回最早创建的实例) * * @param activityClass * @return */ public Activity findActivity(Class<?> activityClass) { if (mActivityList == null) { Timber.tag(TAG).w("mActivityList == null when findActivity(Class)"); return null; } for (Activity activity : mActivityList) { if (activity.getClass().equals(activityClass)) { return activity; } } return null; }
Example #22
Source File: ServicePlayerController.java From Jockey with Apache License 2.0 | 5 votes |
@Override public void setMultiRepeatCount(int count) { execute(() -> { try { mBinding.setMultiRepeatCount(count); runOnMainThread(() -> { mMultiRepeatCount.setValue(count); }); } catch (RemoteException exception) { Timber.e(exception, "Failed to set multi-repeat count"); invalidateAll(); } }); }
Example #23
Source File: MemoryServiceWriter.java From Android-Developer-Toolbelt with Apache License 2.0 | 5 votes |
private MethodSpec createOnBind() { CodeBlock code = CodeBlock.builder() .addStatement("$T.d(\"onBind: \" + intent)", Timber.class) .addStatement("return mMessenger.getBinder()") .build(); return MethodSpec.methodBuilder("onBind") .addAnnotation(Override.class) .addModifiers(Modifier.PUBLIC) .addParameter(ClassName.get(Intent.class), "intent") .returns(ClassName.get(IBinder.class)) .addCode(code) .build(); }
Example #24
Source File: ErrorsFragment.java From Hentoid with Apache License 2.0 | 5 votes |
private void onErrorsChanged(PagedList<Content> result) { Timber.i(">>Errors changed ! Size=%s", result.size()); // Update list visibility mEmptyText.setVisibility(result.isEmpty() ? View.VISIBLE : View.GONE); // Update displayed books itemAdapter.submitList(result/*, this::differEndCallback*/); }
Example #25
Source File: LineTest.java From mapbox-plugins-android with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testLineGapWidth() { validateTestSetup(); setupAnnotation(); Timber.i("line-gap-width"); invoke(mapboxMap, (uiController, mapboxMap) -> { assertNotNull(line); line.setLineGapWidth(0.3f); assertEquals((Float) line.getLineGapWidth(), (Float) 0.3f); }); }
Example #26
Source File: SecureSharedPreferences.java From armadillo with Apache License 2.0 | 5 votes |
public SecureSharedPreferences(SharedPreferences sharedPreferences, EncryptionProtocol.Factory encryptionProtocolFactory, RecoveryPolicy recoveryPolicy, @Nullable char[] password, boolean supportVerifyPassword) { Timber.d("create new secure shared preferences"); this.sharedPreferences = sharedPreferences; this.factory = encryptionProtocolFactory; this.recoveryPolicy = recoveryPolicy; this.password = factory.obfuscatePassword(password); this.supportVerifyPassword = supportVerifyPassword; init(); }
Example #27
Source File: GattTransaction.java From bitgatt with Mozilla Public License 2.0 | 5 votes |
/** * Will likely need to be called from {@link com.fitbit.bluetooth.fbgatt.strategies.Strategy} subclasses, * public for this reason. * @param callback The gatt transaction callback * @param result The transaction result */ @CallSuper public void callCallbackWithTransactionResultAndRelease(GattTransactionCallback callback, TransactionResult result) { // to deal with transaction changes after the callback is null if(callback != null) { callback.onTransactionComplete(result); } else { Timber.i("The callback was null, not delivering result: %s, but releasing", result); // fixing https://console.firebase.google.com/project/api-project-625585532877/crashlytics/app/android:com.fitbit.betabit.FitbitMobile.hockeyapp/issues/5ca51fcbf8b88c296348095d?time=last-seven-days&sessionId=5CAB9C94031500014AB702C03F806B64_DNE_8_v2 } release(); }
Example #28
Source File: WalletFragment.java From xmrwallet with Apache License 2.0 | 5 votes |
void setActivityTitle(Wallet wallet) { if (wallet == null) return; walletTitle = wallet.getName(); String watchOnly = (wallet.isWatchOnly() ? getString(R.string.label_watchonly) : ""); walletSubtitle = wallet.getAccountLabel(); activityCallback.setTitle(walletTitle, walletSubtitle); Timber.d("wallet title is %s", walletTitle); }
Example #29
Source File: LoginActivity.java From xmrwallet with Apache License 2.0 | 5 votes |
private void processUriIntent(Intent intent) { String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { synchronized (this) { uri = intent.getDataString(); Timber.d("URI Intent %s", uri); HelpFragment.display(getSupportFragmentManager(), R.string.help_uri); } } }
Example #30
Source File: PlayerService.java From Jockey with Apache License 2.0 | 5 votes |
@Override public void seekTo(int position) { if (!isMusicPlayerReady()) { Timber.i("PlayerService.seekTo(): Service is not ready. Dropping command"); return; } try { mService.musicPlayer.seekTo(position); } catch (RuntimeException exception) { Timber.e(exception, "Remote call to PlayerService.seekTo() failed"); throw exception; } }