com.blankj.utilcode.util.LogUtils Java Examples
The following examples show how to use
com.blankj.utilcode.util.LogUtils.
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: PlayerActivity.java From DanDanPlayForAndroid with MIT License | 6 votes |
/** * 上传一条弹幕到弹弹 */ private void uploadDanmu(BaseDanmaku data) { BigDecimal bigDecimal = new BigDecimal(data.getTime() / 1000.00) .setScale(2, BigDecimal.ROUND_HALF_UP); int type = data.getType(); if (type != 1 && type != 4 && type != 5) { type = 1; } String time = bigDecimal.toString(); String mode = type + ""; String color = (data.textColor & 0x00FFFFFF) + ""; String comment = String.valueOf(data.text); DanmuUploadParam uploadParam = new DanmuUploadParam(time, mode, color, comment); UploadDanmuBean.uploadDanmu(uploadParam, episodeId + "", new CommJsonObserver<UploadDanmuBean>(this) { @Override public void onSuccess(UploadDanmuBean bean) { LogUtils.d("upload danmu success: text:" + data.text + " cid:" + bean.getCid()); } @Override public void onError(int errorCode, String message) { ToastUtils.showShort(message); } }, new NetworkConsumer()); }
Example #2
Source File: NewTaskRunnable.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void run() { try { File torrentFile = new File(mTorrent.getTorrentPath()); File saveDirFile = new File(mTorrent.getSaveDirPath()); File resumeFile = new File(Constants.DefaultConfig.torrentResumeFilePath); TorrentInfo torrentInfo = new TorrentInfo(torrentFile); mTorrent.setHash(torrentInfo.infoHash().toHex()); Priority[] priorities = mTorrent.getPriorities(); if (priorities == null || priorities.length != torrentInfo.numFiles()) { LogUtils.e("添加任务失败"); return; } if(callBack.beforeAddTask(mTorrent)) engine.download(torrentInfo, saveDirFile, resumeFile, mTorrent.getPriorities(), null); } catch (Exception ignore) { } }
Example #3
Source File: MainActivity.java From YCAudioPlayer with Apache License 2.0 | 6 votes |
/** * 是当某个按键被按下是触发。所以也有人在点击返回键的时候去执行该方法来做判断 */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { LogUtils.e("触摸监听", "onKeyDown"); if (keyCode == KeyEvent.KEYCODE_BACK) { if (mPlayFragment != null && isPlayFragmentShow) { hidePlayingFragment(); }else { //双击返回桌面 if ((System.currentTimeMillis() - time > 1000)) { ToastUtils.showRoundRectToast("再按一次返回桌面"); time = System.currentTimeMillis(); } else { moveTaskToBack(true); } } return true; } return super.onKeyDown(keyCode, event); }
Example #4
Source File: ResetPasswordPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void reset(ResetPasswordParam param) { getView().showLoading(); PersonalBean.resetPassword(param, new CommJsonObserver<CommJsonEntity>(getLifecycle()) { @Override public void onSuccess(CommJsonEntity commJsonEntity) { getView().hideLoading(); getView().resetSuccess(); } @Override public void onError(int errorCode, String message) { getView().hideLoading(); LogUtils.e(message); ToastUtils.showShort(message); } }, new NetworkConsumer()); }
Example #5
Source File: AnimeDetailPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void getAnimeDetail(String animeId) { getView().showLoading(); AnimeDetailBean.getAnimaDetail(animeId, new CommJsonObserver<AnimeDetailBean>(getLifecycle()) { @Override public void onSuccess(AnimeDetailBean animeDetailBean) { getView().hideLoading(); getView().showAnimeDetail(animeDetailBean); } @Override public void onError(int errorCode, String message) { getView().hideLoading(); LogUtils.e(message); ToastUtils.showShort(message); } }, new NetworkConsumer()); }
Example #6
Source File: SearchPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void downloadTorrent(String magnet) { getView().showDownloadTorrentLoading(); MagnetBean.downloadTorrent(magnet, new CommOtherDataObserver<ResponseBody>() { @Override public void onSuccess(ResponseBody responseBody) { String downloadPath = getView().getDownloadFolder(); downloadPath += Constants.DefaultConfig.torrentFolder; downloadPath += "/" + magnet.substring(20) + ".torrent"; FileIOUtils.writeFileFromIS(downloadPath, responseBody.byteStream()); getView().dismissDownloadTorrentLoading(); getView().downloadTorrentOver(downloadPath, magnet); } @Override public void onError(int errorCode, String message) { getView().dismissDownloadTorrentLoading(); LogUtils.e(message); ToastUtils.showShort("下载种子文件失败"); } }, new NetworkConsumer()); }
Example #7
Source File: LoginPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void login(LoginParam param){ getView().showLoading(); PersonalBean.login(param, new CommJsonObserver<PersonalBean>(getLifecycle()) { @Override public void onSuccess(PersonalBean personalBean) { getView().hideLoading(); AppConfig.getInstance().setLogin(true); AppConfig.getInstance().saveUserScreenName(personalBean.getScreenName()); AppConfig.getInstance().saveUserName(param.getUserName()); AppConfig.getInstance().saveUserImage(personalBean.getProfileImage()); AppConfig.getInstance().saveToken(personalBean.getToken()); AppConfig.getInstance().setLastLoginTime(System.currentTimeMillis()); ToastUtils.showShort("登录成功"); EventBus.getDefault().post(UpdateFragmentEvent.updatePersonal()); getView().launchMain(); } @Override public void onError(int errorCode, String message) { getView().hideLoading(); LogUtils.e(message); ToastUtils.showShort(message); } }, new NetworkConsumer()); }
Example #8
Source File: AnimeListPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void getByTag(int tagId) { getView().showLoading(); AnimeTagBean.getTagAnimeList(tagId+"", new CommJsonObserver<AnimeTagBean>(getLifecycle()) { @Override public void onSuccess(AnimeTagBean animeTagBean) { getView().hideLoading(); getView().refreshTagAnime(animeTagBean); } @Override public void onError(int errorCode, String message) { getView().hideLoading(); getView().refreshTagAnime(null); LogUtils.e(message); } }, new NetworkConsumer()); }
Example #9
Source File: ChangePasswordPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void change(ChangePasswordParam param) { getView().showLoading(); PersonalBean.changePassword(param, new CommJsonObserver<CommJsonEntity>(getLifecycle()) { @Override public void onSuccess(CommJsonEntity commJsonEntity) { getView().hideLoading(); getView().changeSuccess(); } @Override public void onError(int errorCode, String message) { getView().hideLoading(); LogUtils.e(message); ToastUtils.showShort(message); } }, new NetworkConsumer()); }
Example #10
Source File: RxJavaMapActivity.java From AndroidSamples with Apache License 2.0 | 6 votes |
private void rxJavaFlatMap() { Observable.create((ObservableOnSubscribe<Integer>) emitter -> { emitter.onNext(1); emitter.onNext(2); emitter.onNext(3); }).flatMap(integer -> { final List<String> list = new ArrayList<>(); for (int i = 0; i < 3; i++) { list.add("I am value " + integer); } // 10毫秒的延时 return Observable.fromIterable(list).delay(10, TimeUnit.MILLISECONDS); }).subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> LogUtils.e(s)); }
Example #11
Source File: SerializableOkHttpCookies.java From DanDanPlayForAndroid with MIT License | 6 votes |
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { String name = (String) in.readObject(); String value = (String) in.readObject(); long expiresAt = in.readLong(); String domain = (String) in.readObject(); String path = (String) in.readObject(); boolean secure = in.readBoolean(); boolean httpOnly = in.readBoolean(); boolean hostOnly = in.readBoolean(); boolean persistent = in.readBoolean(); LogUtils.i("persistent====>"+persistent); Cookie.Builder builder = new Cookie.Builder(); builder = builder.name(name); builder = builder.value(value); builder = builder.expiresAt(expiresAt); builder = hostOnly ? builder.hostOnlyDomain(domain) : builder.domain(domain); builder = builder.path(path); builder = secure ? builder.secure() : builder; builder = httpOnly ? builder.httpOnly() : builder; clientCookies =builder.build(); }
Example #12
Source File: PlayerActivity.java From DanDanPlayForAndroid with MIT License | 6 votes |
/** * 增加播放历史 */ private void addPlayHistory(int episodeId) { if (episodeId > 0) { PlayHistoryBean.addPlayHistory(episodeId, new CommJsonObserver<CommJsonEntity>(this) { @Override public void onSuccess(CommJsonEntity commJsonEntity) { LogUtils.d("add history success: episodeId:" + episodeId); } @Override public void onError(int errorCode, String message) { LogUtils.e("add history fail: episodeId:" + episodeId + " message:" + message); } }, new NetworkConsumer()); } }
Example #13
Source File: RegisterParam.java From DanDanPlayForAndroid with MIT License | 6 votes |
public void buildHash(Context context) { if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password) || StringUtils.isEmpty(email) || StringUtils.isEmpty(appId) || unixTimestamp == 0){ LogUtils.e("注册信息错误"); ToastUtils.showShort("注册信息错误"); }else { String builder = this.appId + this.email + this.password + this.screenName + this.unixTimestamp + this.userName + SoUtils.getInstance().getDanDanAppSecret(); hash = EncryptUtils.encryptMD5ToString(builder); } }
Example #14
Source File: ResetPasswordParam.java From DanDanPlayForAndroid with MIT License | 6 votes |
public void buildHash(Context context) { if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(email) || StringUtils.isEmpty(appId) || unixTimestamp == 0){ LogUtils.e("注册信息错误"); ToastUtils.showShort("注册信息错误"); }else { String builder = this.appId + this.email + this.unixTimestamp + this.userName + SoUtils.getInstance().getDanDanAppSecret(); hash = EncryptUtils.encryptMD5ToString(builder); } }
Example #15
Source File: PictureActivity.java From AndroidSamples with Apache License 2.0 | 6 votes |
/** * 拍照 */ private void camera() { File file = new File(Config.SAVE_REAL_PATH, System.currentTimeMillis() + ".jpg"); LogUtils.e(file.getPath()); if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //Android7.0以上URI if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //通过FileProvider创建一个content类型的Uri mProviderUri = FileProvider.getUriForFile(this, "com.sdwfqin.sample.fileprovider", file); intent.putExtra(MediaStore.EXTRA_OUTPUT, mProviderUri); //添加这一句表示对目标应用临时授权该Uri所代表的文件 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { mUri = Uri.fromFile(file); intent.putExtra(MediaStore.EXTRA_OUTPUT, mUri); } try { startActivityForResult(intent, RESULT_CODE_1); } catch (ActivityNotFoundException anf) { ToastUtils.showShort("摄像头未准备好!"); } }
Example #16
Source File: MySurfaceView.java From AndroidSamples with Apache License 2.0 | 6 votes |
private void draw() { try { // 获取Canvas对象 mCanvas = mHolder.lockCanvas(); // SurfaceView背景 mCanvas.drawColor(Color.WHITE); mCanvas.drawPath(mPath, mPaint); } catch (Exception e) { LogUtils.e("draw: ", e); } finally { if (mCanvas != null) { // 提交画布内容 mHolder.unlockCanvasAndPost(mCanvas); } } }
Example #17
Source File: PersistentCookieStore.java From DanDanPlayForAndroid with MIT License | 6 votes |
public PersistentCookieStore(Context context) { cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, Context.MODE_PRIVATE); cookies = new HashMap<>(); //将持久化的cookies缓存到内存中 即map cookies Map<String, ?> prefsMap = cookiePrefs.getAll(); for (Map.Entry<String, ?> entry : prefsMap.entrySet()) { String[] cookieNames = TextUtils.split((String) entry.getValue(), ","); for (String name : cookieNames) { String encodedCookie = cookiePrefs.getString(name, null); LogUtils.i("cookies_encodeCookie",name+"===========>" + (encodedCookie != null ? encodedCookie : "null")); if (encodedCookie != null) { Cookie decodedCookie = decodeCookie(encodedCookie); if (decodedCookie != null) { if (!cookies.containsKey(entry.getKey())) { cookies.put(entry.getKey(), new HashMap<>()); } cookies.get(entry.getKey()).put(name, decodedCookie); } } } } }
Example #18
Source File: BroadcastActivity.java From AndroidSamples with Apache License 2.0 | 6 votes |
@Override protected void onStart() { super.onStart(); // 注册普通广播 mReceiver1 = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String str = intent.getStringExtra("name"); LogUtils.i("onReceive(普通广播,动态注册): " + str); } }; IntentFilter filter1 = new IntentFilter(); filter1.addAction("com.sdwfqin.broadcastdemo"); registerReceiver(mReceiver1, filter1); // =================================================== // 注册本地广播 mReceiver2 = new LocalBroadcastReceiver(); IntentFilter filter2 = new IntentFilter(); filter2.addAction("com.sdwfqin.broadcastdemo3"); LocalBroadcastManager.getInstance(BroadcastActivity.this).registerReceiver(mReceiver2, filter2); }
Example #19
Source File: PlayService.java From YCAudioPlayer with Apache License 2.0 | 6 votes |
/** * 播放索引为position的音乐 * @param position 索引 */ public void play(int position) { if (audioMusics.isEmpty()) { return; } if (position < 0) { position = audioMusics.size() - 1; } else if (position >= audioMusics.size()) { //如果是最后一首音乐,则播放时直接播放第一首音乐 position = 0; } mPlayingPosition = position; AudioBean music = audioMusics.get(mPlayingPosition); String id = music.getId(); LogUtils.e("PlayService"+"----id----"+ id); //保存当前播放的musicId,下次进来可以记录状态 long musicId = Long.parseLong(id); SPUtils.getInstance(Constant.SP_NAME).put(Constant.MUSIC_ID,musicId); play(music); }
Example #20
Source File: PersistentCookieStore.java From DanDanPlayForAndroid with MIT License | 6 votes |
public void add(String host, String token, String coo) { Cookie cookie = decodeCookie(coo); if (cookie != null) { LogUtils.i(cookie.toString()); LogUtils.i(cookie.persistent()+""); if (!cookies.containsKey(host)) { cookies.put(host, new HashMap<String, Cookie>()); } cookies.get(host).put(token, cookie); //讲cookies持久化到本地 SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.putString(host, token); prefsWriter.putString(token, encodeCookie(new SerializableOkHttpCookies(cookie))); prefsWriter.apply(); } }
Example #21
Source File: KeyboardActivity.java From Android-UtilCode with Apache License 2.0 | 5 votes |
private boolean isKeyboardShown(View rootView) { final int softKeyboardHeight = 100; Rect frame = new Rect(); rootView.getWindowVisibleDisplayFrame(frame); DisplayMetrics dm = rootView.getResources().getDisplayMetrics(); int heightDiff = rootView.getBottom() - frame.bottom; LogUtils.d("" + rootView.getBottom() + ", " + frame.bottom + ", " + heightDiff); return heightDiff > softKeyboardHeight * dm.density; }
Example #22
Source File: ContactFragment.java From Android-IM with Apache License 2.0 | 5 votes |
private void initGetList() { ContactManager.getFriendList(new GetUserInfoListCallback() { @RequiresApi(api = Build.VERSION_CODES.N) @Override public void gotResult(final int i, String s, List<UserInfo> list) { if (i == 0) { LogUtils.e("Log:好友数" + list .size()); info = list.get(i); mFmContactNo.setVisibility(View.GONE); mFmContactRv.setVisibility(View.VISIBLE); if (list.size() <= 0) { mFmContactRv.setVisibility(View.GONE); mFmContactNo.setVisibility(View.VISIBLE); mFriendsAdapter.setEmptyView(new EmptyView(getContext())); } Collections.reverse(list); mFriendsAdapter.setNewData(list); mFriendsAdapter.loadMoreEnd(); } else { mFmContactRv.setVisibility(View.GONE); mFmContactNo.setVisibility(View.VISIBLE); } mFmContactRefresh.setRefreshing(false); } }); }
Example #23
Source File: LogActivity.java From Android-UtilCode with Apache License 2.0 | 5 votes |
@Override public void run() { LogUtils.v("verbose"); LogUtils.d("debug"); LogUtils.i("info"); LogUtils.w("warn"); LogUtils.e("error"); LogUtils.a("assert"); }
Example #24
Source File: BaseApplication.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
private void initCrash() { CrashUtils.init(new CrashUtils.OnCrashListener() { @Override public void onCrash(String crashInfo, Throwable e) { LogUtils.e(crashInfo); AppUtils.relaunchApp(); } }); }
Example #25
Source File: RetrofitGetActivity.java From AndroidSamples with Apache License 2.0 | 5 votes |
/** * 设置TextView * * @param s */ private void setText(String s) { try { mRetrofit2Tv.setText(s); } catch (Exception e) { LogUtils.e("setText: ", e); } }
Example #26
Source File: CommOtherDataObserver.java From DanDanPlayForAndroid with MIT License | 5 votes |
private String getErrorMessage(Throwable e) { LogUtils.e(e.toString()); if (e instanceof JsonSyntaxException) { LogUtils.i("error", e.toString()); return "数据异常"; } else if (e instanceof UnknownHostException) { LogUtils.i("error", e.toString()); return "网络连接中断"; } else if (e instanceof SocketTimeoutException) { return "服务器繁忙"; } else { return "其它异常: " + e.getClass(); } }
Example #27
Source File: MeTsView.java From AndroidSamples with Apache License 2.0 | 5 votes |
@Override public boolean onTouchEvent(MotionEvent event) { float slop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: LogUtils.i("onTouchEvent: " + "按下"); LogUtils.i("getX: " + event.getX()); LogUtils.i("getY: " + event.getY()); LogUtils.i("getRawX: " + event.getRawX()); LogUtils.i("getRawY: " + event.getRawY()); x = event.getX(); y = event.getY(); break; case MotionEvent.ACTION_MOVE: LogUtils.i("onTouchEvent: " + "移动"); break; case MotionEvent.ACTION_UP: LogUtils.i("onTouchEvent: " + "松开" + x); if (event.getX() - x > slop) { LogUtils.i("onTouchEvent: " + "往右滑动" + event.getX()); } else if (x - event.getX() > slop) { LogUtils.i("onTouchEvent: " + "往左滑动" + event.getX()); } else { LogUtils.i("onTouchEvent: " + "无效滑动" + event.getX()); } x = 0; y = 0; break; default: break; } // 返回true,拦截这个事件 // 返回false,不拦截 return true; }
Example #28
Source File: PswActivity.java From ClockView with Apache License 2.0 | 5 votes |
@Override public void onPermissionsGranted(int requestCode, List<String> perms) { LogUtils.d("onPermissionsGranted:" + requestCode + ":" + perms.size()); if (hasAllNeededPermissions()) { // launch(); Toast.makeText(this, "权限已获取,请安心使用!", Toast.LENGTH_SHORT).show(); } }
Example #29
Source File: OkHttpEngine.java From DanDanPlayForAndroid with MIT License | 5 votes |
public RequestBody joinParams(Map<String, String> paramsMap) { if (paramsMap == null) return new FormBody.Builder().build(); FormBody.Builder builder = new FormBody.Builder(); for (String key : paramsMap.keySet()) { LogUtils.i(key + "========>" + paramsMap.get(key)); builder.add(key, paramsMap.get(key)); } return builder.build(); }
Example #30
Source File: InterceptorUtils.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
/** * 网络缓存拦截器,网络连接时请求服务器,否则从本地缓存中获取 * @return */ public static Interceptor addNetWorkInterceptor(){ Interceptor interceptor = new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (!NetworkUtils.isConnected()) { request = request.newBuilder() .cacheControl(CacheControl.FORCE_CACHE) .build(); LogUtils.d("addNetWorkInterceptor"+ "没有网络链接"); } Response response = chain.proceed(request); if (NetworkUtils.isConnected()) { int maxAge = 0; // 有网络时 设置缓存超时时间0个小时 LogUtils.d("addNetWorkInterceptor"+ "网络已连接,缓存时间为:" + maxAge); response = response.newBuilder() .addHeader("Cache-Control", "public, max-age=" + maxAge) .removeHeader("Pragma")// 清除头信息,因为服务器如果不支持,会返回一些干扰信息,不清除下面无法生效 .build(); } else { int maxStale = Constant.TIME_CACHE; LogUtils.d("addNetWorkInterceptor"+ "网络未连接,缓存时间为:" + maxStale); response = response.newBuilder() .addHeader("Cache-Control", "public, only-if-cached, max-stale=" + maxStale) .removeHeader("Pragma") .build(); } String cookeHeader = response.header("Set-Cookie", ""); LogUtils.e("cookeHeader1-----------"+cookeHeader); return response; } }; return interceptor; }