com.blankj.utilcode.util.ToastUtils Java Examples
The following examples show how to use
com.blankj.utilcode.util.ToastUtils.
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: 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 #2
Source File: PlayMusicFragment.java From YCAudioPlayer with Apache License 2.0 | 6 votes |
private void switchPlayMode() { int playMode = SPUtils.getInstance(Constant.SP_NAME).getInt(Constant.PLAY_MODE, 0); PlayModeEnum mode = PlayModeEnum.valueOf(playMode); switch (mode) { case LOOP: mode = PlayModeEnum.SHUFFLE; ToastUtils.showShort(R.string.mode_shuffle); break; case SHUFFLE: mode = PlayModeEnum.SINGLE; ToastUtils.showShort(R.string.mode_one); break; case SINGLE: mode = PlayModeEnum.LOOP; ToastUtils.showShort(R.string.mode_loop); break; default: break; } SPUtils.getInstance(Constant.SP_NAME).put(Constant.PLAY_MODE, mode.value()); initPlayMode(); }
Example #3
Source File: SmbFilePresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void openFile(List<SmbFileInfo> smbFileInfoList, String fileName) { if (!CommonUtils.isMediaFile(fileName)) { ToastUtils.showShort("不是可播放的视频文件"); return; } if (!ServiceUtils.isServiceRunning(SmbService.class)) { ToastUtils.showShort("共享服务未启动,无法播放"); return; } //文件Url由开启监听的IP和端口及视频地址组成 String httpUrl = "http://" + SmbServer.SMB_IP + ":" + SmbServer.SMB_PORT; String videoUrl = httpUrl + "/smb/" + fileName; SmbServer.SMB_FILE_NAME = fileName; //是否自动加载同名字幕 if (AppConfig.getInstance().isAutoLoadLocalSubtitle()) { String zimuName = checkZimuExist(smbFileInfoList, fileName); if (zimuName != null) { loadSmbSubtitlePlay(videoUrl, zimuName); return; } } getView().launchPlayerActivity(videoUrl, ""); }
Example #4
Source File: BaseActivity.java From YCAudioPlayer with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { if (BaseConfig.INSTANCE.isNight()) { setTheme(getDarkTheme()); } super.onCreate(savedInstanceState); setContentView(getContentView()); ButterKnife.bind(this); //避免切换横竖屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); StateAppBar.setStatusBarColor(this,R.color.redTab); if (mPresenter != null){ mPresenter.subscribe(); } initView(); initListener(); if(!NetworkUtils.isConnected()){ ToastUtils.showShort("请检查网络是否连接"); } initData(); }
Example #5
Source File: CleanActivity.java From Android-UtilCode with Apache License 2.0 | 6 votes |
@Override public void onWidgetClick(View view) { switch (view.getId()) { case R.id.btn_clean_internal_cache: ToastUtils.showShort("cleanInternalCache" + CleanUtils.cleanInternalCache()); break; case R.id.btn_clean_internal_files: ToastUtils.showShort("cleanInternalFiles" + CleanUtils.cleanInternalFiles()); break; case R.id.btn_clean_internal_databases: ToastUtils.showShort("cleanInternalDbs" + CleanUtils.cleanInternalDbs()); break; case R.id.btn_clean_internal_sp: ToastUtils.showShort("cleanInternalSP" + CleanUtils.cleanInternalSP()); break; case R.id.btn_clean_external_cache: ToastUtils.showShort("cleanExternalCache" + CleanUtils.cleanExternalCache()); break; } }
Example #6
Source File: ImagePreviewActivity.java From DanDanPlayForAndroid with MIT License | 6 votes |
private void saveBitmap(Bitmap bitmap){ try { //make folder File folder = new File(Constants.DefaultConfig.imageFolder); if (!folder.exists()) folder.mkdirs(); //make file File coverFile = new File(folder, CommonUtils.getCurrentFileName("COV", ".jpg")); if (coverFile.exists()) { coverFile.delete(); } coverFile.createNewFile(); //save FileOutputStream fos = new FileOutputStream(coverFile); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); ToastUtils.showLong("保存成功:"+coverFile.getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); ToastUtils.showShort("保存失败"); } }
Example #7
Source File: MainActivity.java From V2EX with GNU General Public License v3.0 | 6 votes |
@Override public void onBackPressed() { if (drawerLayout.isDrawerOpen(Gravity.START)){ drawerLayout.closeDrawer(Gravity.START); }else{ if ((System.currentTimeMillis() - mLatestBackPressed) < 1000){ finish(); Observable.timer(500, TimeUnit.MILLISECONDS).subscribe(new RxObserver<Long>() { @Override public void _onNext(Long aLong) { System.exit(0); } }); }else{ mLatestBackPressed = System.currentTimeMillis(); ToastUtils.showShort("再按一次返回键退出"); } } }
Example #8
Source File: TopicActivity.java From V2EX with GNU General Public License v3.0 | 6 votes |
@Override public boolean onFailed(String msg) { mSwipeRefreshLayout.setRefreshing(false); ToastUtils.showShort(msg); if ((null != mErrorMsg) && !mErrorMsg.equals(msg)){ TextView mTvError = new TextView(TopicActivity.this); mTvError.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 600)); mTvError.setTextSize(25); mTvError.setTextColor(getColorAccent()); mTvError.setGravity(Gravity.CENTER); mTvError.setText(msg); mLlHeader.removeAllViews(); mLlHeader.addView(mTvError); mErrorMsg = msg; } return true; }
Example #9
Source File: CrashDialog.java From DanDanPlayForAndroid with MIT License | 6 votes |
@OnClick({R.id.dialog_cancel_iv, R.id.copy_log_tv}) public void onViewClicked(View view) { switch (view.getId()) { case R.id.dialog_cancel_iv: CrashDialog.this.dismiss(); break; case R.id.copy_log_tv: ClipboardManager clipboardManagerMagnet = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData mClipDataMagnet = ClipData.newPlainText("Label", content); if (clipboardManagerMagnet != null) { clipboardManagerMagnet.setPrimaryClip(mClipDataMagnet); ToastUtils.showShort("已复制错误日志"); } break; } }
Example #10
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 #11
Source File: EditNotePresenter.java From SuperNote with GNU General Public License v3.0 | 6 votes |
@Override public void toCamera(Activity activity) { try { setFile(activity); createImageFile(); Uri imageUri; if (Build.VERSION.SDK_INT >= 24) { imageUri = FileProvider.getUriForFile(activity, mView.getActivity().getPackageName()+".provider", mImageFile); } else { imageUri = Uri.fromFile(mImageFile); } Intent getImageByCamera = new Intent("android.media.action.IMAGE_CAPTURE"); getImageByCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); activity.startActivityForResult(getImageByCamera, REQUEST_CODE_TO_CAMERA); } catch (Exception e) { ToastUtils.showShort("打开相机失败"); } }
Example #12
Source File: MainActivity.java From V2EX with GNU General Public License v3.0 | 6 votes |
/** * 检查每日签到状态 */ private void checkDailySignIn(){ UserService.signIn(true, new ResponseListener<Integer>() { @Override public void onComplete(Integer result) { sSignIn = result; mAccount.setSign(result); if (sSignIn >= 0){ if (Config.getConfig(ConfigRefEnum.CONFIG_AUTO_CHECK)) signIn(); } updateMenu(); setUserStatus(); } @Override public boolean onFailed(String msg) { ToastUtils.showShort(msg); return true; } }); }
Example #13
Source File: SearchPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void search(String text, int type, int subgroup) { MagnetBean.searchMagnet(text, type, subgroup, new CommOtherDataObserver<MagnetBean>(getLifecycle()) { @Override public void onSuccess(MagnetBean magnetBean) { if (magnetBean != null && magnetBean.getResources() != null) { getView().refreshSearch(magnetBean.getResources()); } } @Override public void onError(int errorCode, String message) { LogUtils.e(message); ToastUtils.showShort(message); } }, new NetworkConsumer()); }
Example #14
Source File: PersonalInfoActivity.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void initListener() { screenNameRl.setOnClickListener(this); passwordRl.setOnClickListener(this); loginOutBt.setOnClickListener(v -> { if (AppConfig.getInstance().isLogin()) { AppConfig.getInstance().setLogin(false); AppConfig.getInstance().saveUserName(""); AppConfig.getInstance().saveUserScreenName(""); AppConfig.getInstance().saveUserImage(""); AppConfig.getInstance().saveToken(""); EventBus.getDefault().post(UpdateFragmentEvent.updatePersonal()); launchActivity(LoginActivity.class); PersonalInfoActivity.this.finish(); } else { ToastUtils.showShort("请先登录再进行此操作"); } }); }
Example #15
Source File: FolderPresenterImpl.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public void bindAllZimu(List<VideoBean> videoList, String folderPath) { int count = 0; String zimuDownloadFolder = AppConfig.getInstance().getDownloadFolder() + Constants.DefaultConfig.subtitleFolder; for (VideoBean videoBean : videoList){ String zimuPath = CommonPlayerUtils.getSubtitlePath(videoBean.getVideoPath(), zimuDownloadFolder); if (!TextUtils.isEmpty(zimuPath)){ DataBaseManager.getInstance() .selectTable("file") .update() .param("zimu_path", zimuPath) .where("file_path", videoBean.getVideoPath()) .postExecute(); count++; } } getVideoList(folderPath); ToastUtils.showLong("成功,共为"+count+"视频绑定字幕"); }
Example #16
Source File: DialogScreenShot.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_screen_shot); shotIv = findViewById(R.id.shot_iv); shotCancelBt = findViewById(R.id.shot_cancel_bt); shotSaveBt = findViewById(R.id.shot_save_bt); shotIv.setImageBitmap(bitmap); shotCancelBt.setOnClickListener(v -> DialogScreenShot.this.dismiss()); shotSaveBt.setOnClickListener(v -> { String path = saveImage(bitmap); if (path == null) { ToastUtils.showShort("保存截图失败"); } else { ToastUtils.showLong("保存成功:" + path); } DialogScreenShot.this.dismiss(); }); }
Example #17
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 #18
Source File: LoginParam.java From DanDanPlayForAndroid with MIT License | 6 votes |
public void buildHash(Context context) { if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password) || StringUtils.isEmpty(appId) || unixTimestamp == 0){ LogUtils.e("登录信息错误"); ToastUtils.showShort("登录信息错误"); }else { String builder = this.appId + this.password + this.unixTimestamp + this.userName + SoUtils.getInstance().getDanDanAppSecret(); hash = EncryptUtils.encryptMD5ToString(builder); } }
Example #19
Source File: ImagePresenter.java From SuperNote with GNU General Public License v3.0 | 6 votes |
private void deleteFile(final Activity activity){ new AsyncTask<String,Integer,Boolean>(){ @Override protected void onPreExecute() { mView.showLoading("删除中..."); } @Override protected Boolean doInBackground(String... params) { return FileUtils.deleteFile(getImageFile(activity)); } @Override protected void onPostExecute(Boolean aBoolean) { mView.unShowLoading(); if(aBoolean){ mView.setResultAndFinish(); } else { ToastUtils.showShort("删除失败"); } } }.execute(); }
Example #20
Source File: ShooterSubActivity.java From DanDanPlayForAndroid with MIT License | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.about_download) { new CommonDialog.Builder(ShooterSubActivity.this) .setAutoDismiss() .setCancelListener(dialog -> { String link = "https://secure.assrt.net/user/logon.xml"; ClipboardManager clipboardManagerMagnet = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData mClipDataMagnet = ClipData.newPlainText("Label", link); if (clipboardManagerMagnet != null) { clipboardManagerMagnet.setPrimaryClip(mClipDataMagnet); ToastUtils.showShort("登录链接已复制"); } }) .build() .show(getResources().getString(R.string.about_download_subtitle), "关于API", "确定", "复制登录链接"); } return super.onOptionsItemSelected(item); }
Example #21
Source File: VideoScanFragment.java From DanDanPlayForAndroid with MIT License | 5 votes |
public void addPath(String path){ for (ScanFolderBean bean : folderList){ if (path.contains(bean.getFolder())){ ToastUtils.showShort("已在扫描范围内"); return; } } presenter.addScanFolder(path, isScanType); }
Example #22
Source File: TorrentService.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null && intent.getAction() != null) { if (Action.ACTION_ADD_TORRENT.equals(intent.getAction())) { Torrent torrent = intent.getParcelableExtra(IntentTag.ADD_TASK_TORRENT); try { TorrentEngine.getInstance().newTask(torrent); } catch (IllegalArgumentException e) { ToastUtils.showShort("添加下载任务失败,参数错误"); } } } return START_NOT_STICKY; }
Example #23
Source File: MainPresenterImpl.java From DanDanPlayForAndroid with MIT License | 5 votes |
private void initAnimeType() { AnimeTypeBean.getAnimeType(new CommOtherDataObserver<AnimeTypeBean>(getLifecycle()) { @Override public void onSuccess(AnimeTypeBean animeTypeBean) { if (animeTypeBean != null && animeTypeBean.getTypes() != null && animeTypeBean.getTypes().size() > 0) { DataBaseManager.getInstance() .selectTable("anime_type") .delete() .postExecute(); DataBaseManager.getInstance() .selectTable("anime_type") .insert() .param("type_id", -1) .param("type_name", "全部") .postExecute(); for (AnimeTypeBean.TypesBean typesBean : animeTypeBean.getTypes()) { DataBaseManager.getInstance() .selectTable("anime_type") .insert() .param("type_id", typesBean.getId()) .param("type_name", typesBean.getName()) .postExecute(); } } } @Override public void onError(int errorCode, String message) { LogUtils.e(message); ToastUtils.showShort(message); } }, new NetworkConsumer()); }
Example #24
Source File: PlayFragment.java From DanDanPlayForAndroid with MIT License | 5 votes |
/** * 刷新文件列表 * * @param reScan 是否重新扫描文件目录 */ @SuppressLint("CheckResult") private void refreshVideo(boolean reScan) { new RxPermissions(this). request(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE) .subscribe(new Observer<Boolean>() { @Override public void onSubscribe(Disposable d) { permissionDis = d; } @Override public void onNext(Boolean granted) { if (granted) { presenter.refreshVideo(getContext(), reScan); } else { ToastUtils.showLong("未授予文件管理权限,无法扫描视频"); refresh.setRefreshing(false); } } @Override public void onError(Throwable e) { e.printStackTrace(); } @Override public void onComplete() { } }); }
Example #25
Source File: FolderActivity.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.item_video_edit) { if (videoList != null && videoList.size() > 0) { showVideoEditDialog(); } else { ToastUtils.showShort("视频列表为空"); } } return super.onOptionsItemSelected(item); }
Example #26
Source File: LocalMusicFragment.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
private void initRecyclerView() { recyclerView.setLayoutManager(new LinearLayoutManager(activity)); adapter = new LocalMusicAdapter(activity); recyclerView.setAdapter(adapter); recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { if(NetworkUtils.isConnected()){ onLazyLoad(); }else { com.pedaily.yc.ycdialoglib.toast.ToastUtils.showRoundRectToast("没有网络"); } } }); }
Example #27
Source File: MainActivity.java From DanDanPlayForAndroid with MIT License | 5 votes |
private void initPermission() { new RxPermissions(this). request(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE) .subscribe(new Observer<Boolean>() { @Override public void onSubscribe(Disposable d) { } @Override public void onNext(Boolean granted) { if (granted) { presenter.initScanFolder(); presenter.initTracker(); if (playFragment != null) { playFragment.initVideoData(); } } else { ToastUtils.showLong("未授予文件管理权限,无法扫描视频"); } } @Override public void onError(Throwable e) { e.printStackTrace(); } @Override public void onComplete() { } }); }
Example #28
Source File: MainActivity.java From V2EX with GNU General Public License v3.0 | 5 votes |
private void feedBack(){ DialogUtil.showInputDialog(this, getString(R.string.feed_back), getString(R.string.summary_feed_back), "", value -> { if ((null != value) && value.isEmpty()) return; CrashReport.postCatchedException(new Throwable("Feed back. " + value)); ToastUtils.showShort(getString(R.string.thanks)); }); }
Example #29
Source File: LocalMusicFragment.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
/** * 设置为铃声 */ private void requestSetRingtone(AudioBean localMusic) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.System.canWrite(getContext())) { ToastUtils.showShort(R.string.no_permission_setting); Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS); intent.setData(Uri.parse("package:" + getContext().getPackageName())); startActivityForResult(intent, 0); } else { setRingtone(localMusic); } }
Example #30
Source File: SmbDeviceActivity.java From DanDanPlayForAndroid with MIT License | 5 votes |
private void onItemClick(int position) { if (isEdit) { for (int i = 0; i < smbList.size(); i++) { smbList.get(i).setEditStatus(i == position); } adapter.notifyDataSetChanged(); return; } SmbDeviceBean smbDeviceBean = smbList.get(position); switch (smbDeviceBean.getSmbType()) { case Constants.SmbSourceType.LAN_DEVICE: case Constants.SmbSourceType.SQL_DEVICE: //未输入账号名 && 不是匿名登录 if (StringUtils.isEmpty(smbDeviceBean.getAccount()) && !smbDeviceBean.isAnonymous()) { new SmbDeviceDialog(this, smbType, smbDeviceBean, SmbDeviceAction.ACTION_DEVICE_INIT, deviceBean -> { smbList.remove(position); presenter.addSqlDevice(deviceBean); smbList.add(0, deviceBean); adapter.notifyDataSetChanged(); presenter.loginSmbDevice(deviceBean, smbType); }).show(); } else if (smbType == SmbType.SMBJ && TextUtils.isEmpty(smbDeviceBean.getRootFolder())) { ToastUtils.showLong("请输入需要连接的共享目录"); new SmbDeviceDialog(this, smbType, smbDeviceBean, SmbDeviceAction.ACTION_DEVICE_EDIT, deviceBean -> { smbList.remove(position); presenter.addSqlDevice(deviceBean); smbList.add(0, deviceBean); adapter.notifyDataSetChanged(); presenter.loginSmbDevice(deviceBean, smbType); }).show(); } else { presenter.loginSmbDevice(smbDeviceBean, smbType); } break; } }