Java Code Examples for com.blankj.utilcode.util.ToastUtils#showLong()

The following examples show how to use com.blankj.utilcode.util.ToastUtils#showLong() . 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: FolderPresenterImpl.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@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 2
Source File: ImagePreviewActivity.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
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 3
Source File: SmbDeviceActivity.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
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;
    }
}
 
Example 4
Source File: UnexpectedExceptionHandler.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
private boolean handleException(Throwable throwable){
    if (null==throwable){
        return false;
    }
    new Thread(()->{
        Looper.prepare();
        ToastUtils.showLong(throwable.toString());
        Looper.loop();
    });
    return false;
}
 
Example 5
Source File: UnexpectedExceptionHandler.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void uncaughtException(Thread t, Throwable e) {
    if (!handleException(e)){
        if (mDefaultHandler != null){
            System.err.println(e.getLocalizedMessage());
            ToastUtils.showLong(e.toString());
            // handle exception by default handler
            mDefaultHandler.uncaughtException(t, e);
        }
    }else {
        System.err.println("END");
    }
}
 
Example 6
Source File: BaseModel.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
void destroy() {
    onDestroyModel();
    for (ThreadUtils.Task task : mTasks) {
        if (task == null) continue;
        task.cancel();
        ToastUtils.showLong("Mvp Task Canceled.");
    }
}
 
Example 7
Source File: ClearCacheDebug.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
private ThreadUtils.SimpleTask<Long> createClearCacheTask() {
    return new ThreadUtils.SimpleTask<Long>() {
        @Override
        public Long doInBackground() throws Throwable {
            try {
                long len = 0;
                File appDataDir = new File(PathUtils.getInternalAppDataPath());
                if (appDataDir.exists()) {
                    String[] names = appDataDir.list();
                    for (String name : names) {
                        if (!name.equals("lib")) {
                            File file = new File(appDataDir, name);
                            len += FileUtils.getLength(file);
                            FileUtils.delete(file);
                            LogUtils.i("「" + file + "」 was deleted.");
                        }
                    }
                }
                String externalAppCachePath = PathUtils.getExternalAppCachePath();
                len += FileUtils.getLength(externalAppCachePath);
                FileUtils.delete(externalAppCachePath);
                LogUtils.i("「" + externalAppCachePath + "」 was deleted.");
                return len;
            } catch (Exception e) {
                ToastUtils.showLong(e.toString());
                return -1L;
            }
        }

        @Override
        public void onSuccess(Long result) {
            if (result != -1) {
                ToastUtils.showLong("Clear Cache: " + ConvertUtils.byte2FitMemorySize(result));
            }
        }
    };
}
 
Example 8
Source File: SmbDeviceActivity.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
@Override
public void showError(String message) {
    ToastUtils.showLong(message);
}
 
Example 9
Source File: Demo0Fragment.java    From Android-UtilCode with Apache License 2.0 4 votes vote down vote up
@Override
public void onWidgetClick(View view) {
    tvAboutFragment.setText("");
    switch (view.getId()) {
        case R.id.btn_show_about_fragment:
            tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
                    + "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
                    + "\ntopShow: " + (FragmentUtils.getTopShowFragment(getFragmentManager()) != null ? FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName() : "null")
                    + "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
                    + "\n---all of fragments---\n"
                    + FragmentUtils.getAllFragments(getFragmentManager()).toString()
                    + "\n----------------------\n\n"
                    + "---stack top---\n"
                    + FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString()
                    + "\n---stack bottom---\n\n"
            );
            break;
        case R.id.btn_add_hide:
            FragmentUtils.hideAddFragment(getFragmentManager(),
                    demo0Fragment,
                    addSharedElement(Demo1Fragment.newInstance()),
                    R.id.fragment_container,
                    false,
                    true,
                    sharedElement);
            break;
        case R.id.btn_add_show:
            FragmentUtils.addFragment(getFragmentManager(),
                    addSharedElement(Demo1Fragment.newInstance()),
                    R.id.fragment_container,
                    false,
                    false,
                    sharedElement);
            break;
        case R.id.btn_add_child:
            FragmentUtils.addFragment(getChildFragmentManager(),
                    Demo2Fragment.newInstance(),
                    R.id.child_fragment_container,
                    false,
                    true);
            break;
        case R.id.btn_pop_to_root:
            FragmentUtils.popToFragment(getFragmentManager(),
                    Demo1Fragment.class,
                    true);
            break;
        case R.id.btn_pop_add:
            FragmentUtils.popAddFragment(getFragmentManager(),
                    addSharedElement(Demo2Fragment.newInstance()),
                    R.id.fragment_container,
                    true,
                    sharedElement);
            break;
        case R.id.btn_hide_show:
            Fragment fragment1 = FragmentUtils.findFragment(getFragmentManager(), Demo1Fragment.class);
            if (fragment1 != null) {
                FragmentUtils.hideShowFragment(this, fragment1);
            } else {
                ToastUtils.showLong("please add demo1 first!");
            }
            break;
        case R.id.btn_replace:
            ((FragmentActivity) getActivity()).rootFragment = FragmentUtils.replaceFragment(this, addSharedElement(Demo3Fragment.newInstance()), false, sharedElement);
            break;
    }
}
 
Example 10
Source File: Demo3Fragment.java    From Android-UtilCode with Apache License 2.0 4 votes vote down vote up
@Override
public void onWidgetClick(View view) {
    tvAboutFragment.setText("");
    switch (view.getId()) {
        case R.id.btn_show_about_fragment:
            tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName()
                    + "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
                    + "\ntopShow: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName()
                    + "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null")
                    + "\n---all of fragments---\n"
                    + FragmentUtils.getAllFragments(getFragmentManager()).toString()
                    + "\n----------------------\n\n"
                    + "---stack top---\n"
                    + FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString()
                    + "\n---stack bottom---\n\n"
            );
            break;
        case R.id.btn_add_hide:
            FragmentUtils.addFragment(getFragmentManager(), Demo1Fragment.newInstance(), R.id.fragment_container, true, true);
            break;
        case R.id.btn_add_show:
            FragmentUtils.addFragment(getFragmentManager(), Demo1Fragment.newInstance(), R.id.fragment_container, false, true);
            break;
        case R.id.btn_add_child:
            FragmentUtils.addFragment(getChildFragmentManager(), Demo2Fragment.newInstance(), R.id.child_fragment_container, false, true);
            break;
        case R.id.btn_pop_to_root:
            FragmentUtils.popToFragment(getFragmentManager(), Demo1Fragment.class, true);
            break;
        case R.id.btn_pop_add:
            FragmentUtils.popAddFragment(getFragmentManager(), Demo2Fragment.newInstance(), R.id.fragment_container, true, new FragmentUtils.SharedElement(this.btnShowAboutFragment, "btnShowAboutFragment"));
            break;
        case R.id.btn_hide_show:
            Fragment fragment1 = FragmentUtils.findFragment(getFragmentManager(), Demo1Fragment.class);
            if (fragment1 != null) {
                FragmentUtils.hideShowFragment(this, fragment1);
            } else {
                ToastUtils.showLong("please add demo1 first!");
            }
            break;
        case R.id.btn_replace:
            Demo0Fragment demo0Fragment = Demo0Fragment.newInstance();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                demo0Fragment.setSharedElementEnterTransition(new DetailTransition());
                setExitTransition(new Fade());
                demo0Fragment.setEnterTransition(new Fade());
                demo0Fragment.setSharedElementReturnTransition(new DetailTransition());
            }
            ((FragmentActivity) getActivity()).rootFragment = FragmentUtils.replaceFragment(this, demo0Fragment, false, new FragmentUtils.SharedElement(ivSharedElement, getString(R.string.fragment_transition)));
            break;
    }
}
 
Example 11
Source File: SharePresenter.java    From SuperNote with GNU General Public License v3.0 4 votes vote down vote up
private void saveImageToLocation(Bitmap bitmap) {
    File file = new File(Constans.imageSaveFolder + "/" + TimeUtils.getNowMills() + ".jpg");
    ImageUtils.save(bitmap, file, Bitmap.CompressFormat.JPEG);
    ToastUtils.showLong("已保存至" + "/SuperNote/Image/" + "中");
}
 
Example 12
Source File: MvpView.java    From AndroidUtilCode with Apache License 2.0 4 votes vote down vote up
@Override
public void showMsg(CharSequence msg) {
    ToastUtils.showLong(msg);
}