当前位置: 首页>>代码示例>>Java>>正文


Java ToastUtils类代码示例

本文整理汇总了Java中com.blankj.utilcode.util.ToastUtils的典型用法代码示例。如果您正苦于以下问题:Java ToastUtils类的具体用法?Java ToastUtils怎么用?Java ToastUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ToastUtils类属于com.blankj.utilcode.util包,在下文中一共展示了ToastUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onWidgetClick

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:CleanActivity.java

示例2: onCreate

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setToolBarTitle("问答详情");
   // relay.setFocusable(false);
    QAid= getIntent().getStringExtra("id");
    replyRecyclerview.setLayoutManager(new LinearLayoutManager(TakeMedicinApplication.getContext()));
    commonAdapter = new CommonAdapter<Reply>(getApplicationContext(),R.layout.reply_item,replyList){

        @Override
        public void convert(ViewHolder holder, final Reply reply, int position) {
            LinearLayout replyItemLayout= holder.getView(R.id.replyItemLayout);
            holder.setText(R.id.content,reply.getContent());
            holder.setText(R.id.created_at,reply.getCreated_at());
            replyItemLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ToastUtils.showShortToast(reply.getId());
                }
            });

        }
    };
      httpGetMainContet();
    //setIption();
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:27,代码来源:CreateQuestionAanswerActivity.java

示例3: importAddress

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@Event(R.id.importAddress)
private void importAddress(View view) {


    if (Build.VERSION.SDK_INT >= 23) {
        //获取权限

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
            startActivityForResult(new Intent(
                    Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI), 0);
        } else {
            ToastUtils.showLongToast("您已拒绝读取联系人权限,请前往设置开通或者重新安装!");
        }
    } else {
        startActivityForResult(new Intent(
                Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI), 0);
    }


}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:21,代码来源:AddContactActivity.java

示例4: popBackStackFinish

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
/**
 * fragment回退栈管理(返回时优先处理回退栈推出)
 */
public void popBackStackFinish() {
    //设置返回键监听,返回标识是否中断其他操作
    if (onBackListener()) {
        return;
    }
    //按2次才能退出的相关代码
    if (exitToast != null && System.currentTimeMillis() - exitMillis > 2000) {
        ToastUtils.showShort(exitToast);
        exitMillis = System.currentTimeMillis();
        return;
    }
    //当回退栈中有数据时,进行fragment的回退
    if (mFragmentManager.getBackStackEntryCount() > 0) {
        mFragmentManager.popBackStack();
        return;
    }
    //否则直接finish
    finish();
}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:23,代码来源:BaseActivity.java

示例5: lazyLoad

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
/**
 * 懒加载
 */
protected void lazyLoad() {
    if (!NetworkUtils.isConnected()) {
        ToastUtils.showShort(R.string.no_internet);
        return;
    }

    if (!isPrepared || isLoadData) {
        return;
    }

    if (Key.getSetting().PREF_PRELOAD || !(getActivity() instanceof MainActivity)) {
        isLoadData = true;
        initData();
        return;
    }

    if (!isVisible) {
        return;
    }

    isLoadData = true;
    initData();

}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:28,代码来源:BaseFragment.java

示例6: onGranted

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@Override
public void onGranted() {
    Glide.with(context).load(url).into(new SimpleTarget<Drawable>() {
        @Override
        public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
            String path = String.format("%s/Android/data/%s/",
                    Environment.getExternalStorageDirectory(), AppUtils.getAppPackageName());
            String filename = TimeUtils.getNowString() + ".png";
            boolean ok = ImageUtils.save(ImageUtils.drawable2Bitmap(resource),
                    path + filename, Bitmap.CompressFormat.PNG);
            if (ok) {
                ToastUtils.showShort(R.string.success);
            } else {
                ToastUtils.showShort(R.string.error);
            }
        }
    });
}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:19,代码来源:ImageViewActivity.java

示例7: openGallery

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
private void openGallery() {
    requestRuntimePermission(Manifest.permission.READ_EXTERNAL_STORAGE,
            new onRequestPermissionCallback() {
                @Override
                public void onGranted() {
                    Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                    startActivityForResult(i, Gallery);
                }

                @Override
                public void onDenied() {
                    ToastUtils.showShort(R.string.permissionDenied);
                }
            });

}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:17,代码来源:ImagesGalleryActivity.java

示例8: getData

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@Override
    public void getData() {
        if (type == Key.GENE) {
            new TopicActivityPresenter<>(this, TopicGene.class);
        } else if (type == Key.QA) {
            //TODO
            ToastUtils.showShort(R.string.not_support);
            finish();
            return;
//            new TopicActivityPresenter<>(this, TopicQA.class);
        } else {
            new TopicActivityPresenter<>(this, Topic.class);
        }
        presenter.start();
        fab.setVisibility(UserState.isLogin() ? View.VISIBLE : View.INVISIBLE);
    }
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:17,代码来源:TopicActivity.java

示例9: sendFeedback

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@Override
public void sendFeedback(final String content, final String contact) {

    if(TextUtils.isEmpty(content)){
        ToastUtils.showShort("请至少填写反馈内容");
        return;
    }
    if(content.equals(mLastContent) && contact.equals(mLastContact)){
        ToastUtils.showShort("请不要重复提交");
        return;
    }

    Feedback feedback=getFeedback(content,contact);
    mView.showLoading();
    feedback.save(new SaveListener<String>() {
        @Override
        public void done(String s, BmobException e) {
           sendBack(e,content,contact);
        }
    });
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:22,代码来源:FeedbackPresenter.java

示例10: toCamera

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@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("打开相机失败");
    }
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:20,代码来源:EditNotePresenter.java

示例11: copyFileInOtherThread

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
private void copyFileInOtherThread(String imagePath) {
    final String imagePaths = imagePath;
    new AsyncTask<String, Integer, Boolean>() {

        @Override
        protected void onPreExecute() {
            mView.showLoading("加载中...");
        }

        @Override
        protected Boolean doInBackground(String... params) {
            return FileUtils.copyFile(new File(imagePaths), mImageFile);
        }

        @Override
        protected void onPostExecute(Boolean aBoolean) {
            mView.unShowLoading();
            if (aBoolean) {
                displayImage();
            } else {
                ToastUtils.showShort("图片读取失败");
            }
        }
    }.execute();
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:26,代码来源:EditNotePresenter.java

示例12: copyFile

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
private void copyFile( final Activity activity){
    new AsyncTask<String,Integer,Boolean>(){

        @Override
        protected void onPreExecute() {
            mView.showLoading("保存中...");
        }

        @Override
        protected Boolean doInBackground(String... params) {
            return  FileUtils.copyFile(getImageFile(activity),
                    new File(Constans.imageSaveFolder+mImageName));
        }

        @Override
        protected void onPostExecute(Boolean aBoolean) {
            mView.unShowLoading();
            if(aBoolean){
                ToastUtils.showLong("已保存至/SuperNote/image/中");
            } else {
                ToastUtils.showLong("保存失败,请查看图片是否已存在");
            }
        }
    }.execute();
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:26,代码来源:ImagePresenter.java

示例13: deleteFile

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
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();
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:25,代码来源:ImagePresenter.java

示例14: onCreate

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    PermissionHelper.requestLocation(new PermissionHelper.OnPermissionGrantedListener() {
        @Override
        public void onPermissionGranted() {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Looper.prepare();
                    isSuccess = LocationUtils.register(0, 0, mOnLocationChangeListener);
                    if (isSuccess) ToastUtils.showShort("init success");
                    Looper.loop();
                }
            }).start();
        }
    });
}
 
开发者ID:Blankj,项目名称:AndroidUtilCode,代码行数:19,代码来源:LocationService.java

示例15: onCreate

import com.blankj.utilcode.util.ToastUtils; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    new Thread(new Runnable() {
        @Override
        public void run() {
            Looper.prepare();
            isSuccess = LocationUtils.register(0, 0, mOnLocationChangeListener);
            if (isSuccess) ToastUtils.showShort("init success");
            Looper.loop();
        }
    }).start();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:LocationService.java


注:本文中的com.blankj.utilcode.util.ToastUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。