com.pedaily.yc.ycdialoglib.toast.ToastUtils Java Examples

The following examples show how to use com.pedaily.yc.ycdialoglib.toast.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: ShareGoodsPolicy.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
@Override
void shareSaveImg(ShareTypeBean shareTypeBean, final Context context) {
    super.shareSaveImg(shareTypeBean, context);
    GoodShareBitmap goodShareBitmap = new GoodShareBitmap(context);
    goodShareBitmap.setData(shareTypeBean,new GoodShareBitmap.onLoadFinishListener() {
        @Override
        public void listener(Bitmap bmp, boolean isSuccess) {
            if (bmp!=null && isSuccess){
                String s = FileSaveUtils.saveBitmap(context, bmp, null, true);
                if (s!=null && s.length()>0){
                    ToastUtils.showRoundRectToast("保存成功");
                }else {
                    ToastUtils.showRoundRectToast("保存失败");
                }
            }
        }
    });
}
 
Example #2
Source File: ShareGoodsPolicy.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
@Override
void shareCreatePoster(ShareTypeBean shareTypeBean, final Context context) {
    super.shareCreatePoster(shareTypeBean, context);
    GoodShareBitmap goodShareBitmap = new GoodShareBitmap(context);
    goodShareBitmap.setData(shareTypeBean,new GoodShareBitmap.onLoadFinishListener() {
        @Override
        public void listener(Bitmap bmp, boolean isSuccess) {
            if (bmp!=null && isSuccess){
                String s = FileSaveUtils.saveBitmap(context, bmp, null, true);
                if (s!=null && s.length()>0){
                    ToastUtils.showRoundRectToast("保存成功");
                }else {
                    ToastUtils.showRoundRectToast("保存失败");
                }
            }
        }
    });
}
 
Example #3
Source File: OnLineMusicFragment.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void initRecyclerView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    final RecycleViewItemLine line = new RecycleViewItemLine(activity, LinearLayout.HORIZONTAL,
            SizeUtils.dp2px(1), Color.parseColor("#f5f5f7"));
    recyclerView.addItemDecoration(line);
    adapter = new OnLineMusicAdapter(activity);
    recyclerView.setAdapter(adapter);
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            if(NetworkUtils.isConnected()){
                onLazyLoad();
            }else {
                ToastUtils.showRoundRectToast("没有网络");
            }
        }
    });
}
 
Example #4
Source File: OnlineMusicActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 播放音乐
 * @param onlineMusic                       onlineMusic
 */
private void playMusic(OnlineMusicList.SongListBean onlineMusic) {
    new AbsPlayOnlineMusic(this, onlineMusic) {
        @Override
        public void onPrepare() {

        }

        @Override
        public void onExecuteSuccess(AudioBean music) {
            getPlayService().play(music);
            showPlayingFragment();
            ToastUtils.showRoundRectToast("正在播放" + music.getTitle());
        }

        @Override
        public void onExecuteFail(Exception e) {
            ToastUtils.showRoundRectToast(Utils.getApp().getResources().getString(R.string.unable_to_play));
        }
    }.execute();
}
 
Example #5
Source File: OnlineMusicActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 下载音乐
 *
 * @param onlineMusic 实体类
 */
private void download(final OnlineMusicList.SongListBean onlineMusic) {
    new AbsDownloadOnlineMusic(this, onlineMusic) {
        @Override
        public void onPrepare() {
            LoadDialog.show(OnlineMusicActivity.this, "下载中……");
        }

        @Override
        public void onExecuteSuccess(Void aVoid) {
            LoadDialog.dismiss(OnlineMusicActivity.this);
            ToastUtils.showRoundRectToast("下载成功" + onlineMusic.getTitle());
        }

        @Override
        public void onExecuteFail(Exception e) {
            LoadDialog.dismiss(OnlineMusicActivity.this);
            ToastUtils.showRoundRectToast("下载失败");
        }
    }.execute();
}
 
Example #6
Source File: MainActivity.java    From YCDialog with Apache License 2.0 6 votes vote down vote up
/**
 * 处理弹出显示内容、点击事件等逻辑
 * @param contentView           view
 */
private void handleLogic(View contentView){
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(popWindow!=null){
                popWindow.dismiss();
            }
            String showContent = "";
            switch (v.getId()){
                case R.id.menu1:
                    showContent = "点击 Item菜单1";
                    break;
                case R.id.menu2:
                    showContent = "点击 Item菜单2";
                    break;
                default:
                    break;
            }
            ToastUtils.showRoundRectToast(showContent);
        }
    };
    contentView.findViewById(R.id.menu1).setOnClickListener(listener);
    contentView.findViewById(R.id.menu2).setOnClickListener(listener);
}
 
Example #7
Source File: WebViewActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 显示加载失败时自定义的网页
 */
protected void initErrorPage() {
    if (mErrorView == null) {
        mErrorView = View.inflate(this, R.layout.view_custom_data_error, null);
        LinearLayout ll_error_view = (LinearLayout) mErrorView.findViewById(R.id.ll_error_view);
        ll_error_view.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (NetworkUtils.isConnected()) {
                    //如果有网络,则刷新页面
                    mWebView.reload();
                    recreate();
                } else {
                    //没有网络,不处理
                    ToastUtils.showRoundRectToast("请检查是否连上网络");
                }
            }
        });
        mErrorView.setOnClickListener(null);
    }
}
 
Example #8
Source File: ClassDlCacheActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
private void showDialogAnim(final int index) {
    List<String> names = new ArrayList<>();
    names.add("下载");
    names.add("分享");
    names.add("取消收藏");
    DialogUtils.showDialog(this, new CustomSelectDialog.SelectDialogListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
                case 0:
                    ToastUtils.showRoundRectToast("下载" + index);
                    break;
                case 1:
                    ToastUtils.showRoundRectToast("分享" + index);
                    break;
                case 2:
                    ToastUtils.showRoundRectToast("取消收藏" + index);
                    break;
                default:
                    break;
            }
        }
    }, names);
}
 
Example #9
Source File: MainActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 是当某个按键被按下是触发。所以也有人在点击返回键的时候去执行该方法来做判断
 */
@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 #10
Source File: SearchMusicActivity.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * 下载音乐
 * @param song           实体类
 */
private void download(final SearchMusic.Song song) {
    new AbsDownloadSearchMusic(this, song) {
        @Override
        public void onPrepare() {
            LoadDialog.show(SearchMusicActivity.this,"下载中……");
        }

        @Override
        public void onExecuteSuccess(Void aVoid) {
            LoadDialog.dismiss(SearchMusicActivity.this);
            ToastUtils.showRoundRectToast("下载成功"+song.getSongname());
        }

        @Override
        public void onExecuteFail(Exception e) {
            LoadDialog.dismiss(SearchMusicActivity.this);
            ToastUtils.showRoundRectToast("下载失败");
        }
    }.execute();
}
 
Example #11
Source File: ViewBase.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
protected void showError(final String errorMsg) {
	post(new Runnable() {
		@Override
		public void run() {
			ToastUtils.showRoundRectToast(errorMsg);
		}
	});
}
 
Example #12
Source File: MainActivity.java    From YCCustomText with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    init();
    HyperLogUtils.setIsLog(true);
    ToastUtils.init(getApplication());
}
 
Example #13
Source File: TestActivity.java    From YCDialog with Apache License 2.0 5 votes vote down vote up
private void showToast() {
    ToastUtils.showRoundRectToast("潇湘剑雨-杨充");
    try {
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

}
 
Example #14
Source File: CustomPop.java    From YCDialog with Apache License 2.0 5 votes vote down vote up
@Override
public void initData(View contentView) {
    TextView tv_pop = (TextView) contentView.findViewById(R.id.tv_pop);
    tv_pop.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ToastUtils.showRoundRectToast("滚犊子吧");
        }
    });
}
 
Example #15
Source File: AbsDownloadOnlineMusic.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@Override
protected void download() {
    final String artist = mOnlineMusic.getArtist_name();
    final String title = mOnlineMusic.getTitle();

    // 下载歌词
    String lrcFileName = FileMusicUtils.getLrcFileName(artist, title);
    File lrcFile = new File(FileMusicUtils.getLrcDir() + lrcFileName);
    if (!TextUtils.isEmpty(mOnlineMusic.getLrclink()) && !lrcFile.exists()) {
        downloadLrc(mOnlineMusic.getLrclink(), FileMusicUtils.getLrcDir(), lrcFileName);
    }else {
        ToastUtils.showToast("无法下载歌词");
    }

    // 下载封面
    String albumFileName = FileMusicUtils.getAlbumFileName(artist, title);
    final File albumFile = new File(FileMusicUtils.getAlbumDir(), albumFileName);
    String picUrl = mOnlineMusic.getPic_big();
    if (TextUtils.isEmpty(picUrl)) {
        picUrl = mOnlineMusic.getPic_small();
    }
    if (!albumFile.exists() && !TextUtils.isEmpty(picUrl)) {
        downloadFile(picUrl, FileMusicUtils.getAlbumDir(), albumFileName);
    }else {
        ToastUtils.showRoundRectToast("无法下载封面");
    }

    // 获取歌曲下载链接
    getMusicDownloadInfo(mOnlineMusic.getSong_id(),artist,title,albumFile);
}
 
Example #16
Source File: MainActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.fl_search:
            ActivityUtils.startActivity(SearchMusicActivity.class);
            break;
        case R.id.fl_play_bar:
            showPlayingFragment();
            break;
        case R.id.iv_play_bar_list:
            showListDialog();
            break;
        case R.id.iv_play_bar_play:
            if(getPlayService().isDefault()){
                if(BaseAppHelper.get().getMusicList().size()>0){
                    int mPlayPosition;
                    if (getPlayService().getPlayingMusic() != null &&
                            getPlayService().getPlayingMusic().getType() == AudioBean.Type.LOCAL) {
                        mPlayPosition = getPlayService().getPlayingPosition();
                    } else {
                        mPlayPosition = 0;
                    }
                    getPlayService().play(BaseAppHelper.get().getMusicList().get(mPlayPosition));
                }else {
                    ToastUtils.showToast("请检查是否有音乐");
                }
            }else {
                getPlayService().playPause();
            }
            break;
        case R.id.iv_play_bar_next:
            getPlayService().next();
            break;
        default:
            break;
    }
}
 
Example #17
Source File: WebViewActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    super.onReceivedError(view, errorCode, description, failingUrl);
    LogUtils.e("WebViewActivity-----onReceivedError-------" + failingUrl);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        LogUtils.e("服务器异常" + "----");
    }
    ToastUtils.showRoundRectToast("服务器异常6.0之前");
    //当加载错误时,就让它加载本地错误网页文件
    //mWebView.loadUrl("file:///android_asset/errorpage/error.html");

    showErrorPage();//显示错误页面
}
 
Example #18
Source File: WebViewActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
    super.onReceivedError(view, request, error);
    LogUtils.e("WebViewActivity-----onReceivedError-------" + error.toString());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        LogUtils.e("服务器异常" + error.getDescription().toString());
    }
    ToastUtils.showRoundRectToast("服务器异常6.0之后");
    //当加载错误时,就让它加载本地错误网页文件
    //mWebView.loadUrl("file:///android_asset/errorpage/error.html");

    showErrorPage();//显示错误页面
}
 
Example #19
Source File: MusicInfoActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();
        return true;
    } else if (item.getItemId() == R.id.action_save) {
        ToastUtils.showRoundRectToast("保存信息功能");
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example #20
Source File: OnlineMusicActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void getData(final int offset) {
    OnLineMusicModel model = OnLineMusicModel.getInstance();
    model.getSongListInfo(OnLineMusicModel.METHOD_GET_MUSIC_LIST,
            type, MUSIC_LIST_SIZE, String.valueOf(offset))
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Consumer<OnlineMusicList>() {
                @Override
                public void accept(OnlineMusicList onlineMusicList) throws Exception {
                    if (onlineMusicList == null || onlineMusicList.getSong_list() == null || onlineMusicList.getSong_list().size() == 0) {
                        return;
                    }
                    addHeader(onlineMusicList);
                    adapter.addAll(onlineMusicList.getSong_list());
                    recyclerView.showRecycler();
                    setOnLineMusic(onlineMusicList);
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    if (throwable instanceof RuntimeException) {
                        // 歌曲全部加载完成
                        recyclerView.showError();
                        return;
                    }
                    if (offset == 0) {
                        recyclerView.showError();
                    } else {
                        ToastUtils.showRoundRectToast(Utils.getApp().getResources().getString(R.string.load_fail));
                    }
                }
            }, new Action() {
                @Override
                public void run() throws Exception {

                }
            });
}
 
Example #21
Source File: BaseApplication.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 程序启动的时候执行
 */
@Override
public void onCreate() {
    Log.d("Application", "onCreate");
    super.onCreate();
    instance = this;
    Utils.init(this);
    ToastUtils.init(this);
    BaseLifecycleCallback.getInstance().init(this);
    BaseAppHelper.get().init(this);
    initAutoSizeConfig();
    initThreadPool();
    InitializeService.start(this);
}
 
Example #22
Source File: StudyFragment.java    From YCAudioPlayer with Apache License 2.0 4 votes vote down vote up
private void initHorizontalView() {
    adapter.addFooter(new RecyclerArrayAdapter.ItemView() {
        @Override
        public View onCreateView(ViewGroup parent) {
            RecyclerView recyclerView = new RecyclerView(parent.getContext()){
                //为了不打扰RecyclerView的滑动操作,可以这样处理
                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouchEvent(MotionEvent event) {
                    super.onTouchEvent(event);
                    return true;
                }
            };
            RecyclerView.LayoutParams layoutParams = new RecyclerView.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            layoutParams.setMargins(SizeUtils.dp2px(10),SizeUtils.dp2px(5),
                    SizeUtils.dp2px(10),SizeUtils.dp2px(10));
            recyclerView.setLayoutParams(layoutParams);
            final NarrowImageAdapter narrowAdapter;
            recyclerView.setAdapter(narrowAdapter = new NarrowImageAdapter(parent.getContext()));
            recyclerView.setLayoutManager(new LinearLayoutManager(parent.getContext(), LinearLayoutManager.HORIZONTAL,false));
            recyclerView.addItemDecoration(new SpaceViewItemLine(SizeUtils.dp2px(8)));

            narrowAdapter.setMore(R.layout.view_more_horizontal, new RecyclerArrayAdapter.OnLoadMoreListener() {
                @Override
                public void onLoadMore() {
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            ToastUtils.showRoundRectToast("没有更多呢!");
                        }
                    },1000);
                }
            });
            List<VideoPlayerFavorite> favoriteList = new ArrayList<>();
            for(int a=0 ; a<10 ; a++){
                VideoPlayerFavorite videoPlayerFavorite = new VideoPlayerFavorite(
                        "这个是猜你喜欢的标题",R.drawable.bg_small_tree_min,"");
                favoriteList.add(videoPlayerFavorite);

            }
            narrowAdapter.addAll(favoriteList);
            return recyclerView;
        }

        @Override
        public void onBindView(View headerView) {
            //这里的处理别忘了
            ((ViewGroup)headerView).requestDisallowInterceptTouchEvent(true);
        }
    });
}
 
Example #23
Source File: StudyFragment.java    From YCAudioPlayer with Apache License 2.0 4 votes vote down vote up
@Override
public void initData() {
    List<String> data = new ArrayList<>();
    for(int a=0 ; a<10 ; a++){
        data.add("吴文杰是个大神级别的人物"+a);
    }
    adapter.addAll(data);
    adapter.notifyDataSetChanged();
    adapter.setOnLongClickListener(new StudyAdapter.OnLongClickListener() {
        @Override
        public boolean onLongClick(final View view, int position) {
            //设置点击是view置灰色
            view.setBackgroundColor(activity.getResources().getColor(R.color.alpha_20_black));
            int measuredHeight = view.getMeasuredHeight();
            int measuredWidth = view.getMeasuredWidth();
            View contentView = LayoutInflater.from(activity)
                    .inflate(R.layout.pop_layout_copy,null);
            TextView tv_copy = contentView.findViewById(R.id.tv_copy);
            final CustomPopupWindow popWindow = new CustomPopupWindow.PopupWindowBuilder(activity)
                    //.setView(R.layout.pop_layout)
                    .setView(contentView)
                    .setFocusable(true)
                    //弹出popWindow时,背景是否变暗
                    .enableBackgroundDark(false)
                    //控制亮度
                    .setBgDarkAlpha(0.0f)
                    .setOutsideTouchable(true)
                    //.setAnimationStyle(R.style.popWindowStyle)
                    .setOnDissmissListener(new PopupWindow.OnDismissListener() {
                        @Override
                        public void onDismiss() {
                            //对话框销毁时,设置view恢复为白色
                            view.setBackgroundColor(activity.getResources().getColor(R.color.white));
                        }
                    })
                    .create()
                    .showAsDropDown(view, measuredWidth/2, - (int) (2.5*measuredHeight));
            tv_copy.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    popWindow.dismiss();
                    ToastUtils.showRoundRectToast("复制内容");
                }
            });
            return true;
        }
    });
}
 
Example #24
Source File: LocalVideoFragment.java    From YCAudioPlayer with Apache License 2.0 4 votes vote down vote up
private void initVideoPlayer(VideoBean videoBean) {
    String path = videoBean.getPath();
    String title = videoBean.getTitle();
    if(path==null ||path.length()==0){
        ToastUtils.showRoundRectToast("视频地址不能为空");
        return;
    }
    //设置播放类型
    videoPlayer.setPlayerType(VideoPlayer.TYPE_IJK);
    //是否从上一次的位置继续播放
    videoPlayer.continueFromLastPosition(true);
    //设置播放速度
    videoPlayer.setSpeed(1.0f);
    //网络视频地址
    videoPlayer.setUp(path, null);
    //设置视频地址和请求头部
    //创建视频控制器
    VideoPlayerController controller = new VideoPlayerController(activity);
    //设置标题
    controller.setTitle(title);
    //隐藏top
    controller.setTopVisibility(false);
    //设置loading类型【共两种】
    controller.setLoadingType(1);
    //设置背景
    controller.imageView().setBackgroundResource(R.color.blackText);
    //设置10秒不操作隐藏top和bottom
    controller.setHideTime(10000);
    //播放完成监听
    controller.setOnCompletedListener(new OnCompletedListener() {
        @Override
        public void onCompleted() {

        }
    });
    controller.setOnVideoBackListener(new OnVideoBackListener() {
        @Override
        public void onBackClick() {

        }
    });
    //设置视频控制器
    videoPlayer.setController(controller);
}
 
Example #25
Source File: DetailVideoActivity.java    From YCAudioPlayer with Apache License 2.0 4 votes vote down vote up
private void initVideoPlayer() {
    videoPlayer.release();
    //设置播放类型
    videoPlayer.setPlayerType(VideoPlayer.TYPE_IJK);
    //是否从上一次的位置继续播放
    videoPlayer.continueFromLastPosition(true);
    //设置播放速度
    videoPlayer.setSpeed(1.0f);
    //网络视频地址
    videoPlayer.setUp(Constant.DEVIE_URL, null);
    //设置视频地址和请求头部
    //创建视频控制器
    VideoPlayerController controller = new VideoPlayerController(this);
    controller.setTopVisibility(true);
    controller.setOnVideoBackListener(new OnVideoBackListener() {
        @Override
        public void onBackClick() {
            onBackPressed();
        }
    });
    controller.setOnPlayOrPauseListener(new OnPlayOrPauseListener() {
        @Override
        public void onPlayOrPauseClick(boolean isPlaying) {
            if (isPlaying) {
                ToastUtils.showRoundRectToast( "暂停视频");
            } else {
                ToastUtils.showRoundRectToast("开始播放");
                if (getPlayService().isPlaying() || getPlayService().isPreparing()) {
                    getPlayService().pause();
                    videoPlayer.seekTo(BaseConfig.INSTANCE.getPosition());
                }
            }
        }
    });
    controller.setOnVideoControlListener(new OnVideoControlListener() {
        @Override
        public void onVideoControlClick(int type) {
            switch (type) {
                case ConstantKeys.VideoControl.DOWNLOAD:
                    showDownloadDialog();
                    break;
                case ConstantKeys.VideoControl.AUDIO:
                    showPlayingFragment();
                    break;
                case ConstantKeys.VideoControl.SHARE:
                    ToastUtils.showRoundRectToast("分享内容");
                    break;
                default:
                    break;
            }
        }
    });
    //设置视频控制器
    videoPlayer.setController(controller);
}
 
Example #26
Source File: CustomDialogFragment.java    From YCDialog with Apache License 2.0 4 votes vote down vote up
@Override
public void bindView(View v) {
    TextView mTvTitle = (TextView) v.findViewById(R.id.tv_title);
    TextView mTvContent = (TextView) v.findViewById(R.id.tv_content);
    TextView mTvCancel = (TextView) v.findViewById(R.id.tv_cancel);
    TextView mTvOk = (TextView) v.findViewById(R.id.tv_ok);
    TextView mTvOther = (TextView) v.findViewById(R.id.tv_other);
    View mViewLineLeft = v.findViewById(R.id.view_line_left);
    View mViewLineRight = v.findViewById(R.id.view_line_right);


    if (title!=null && title.length()>0){
        mTvTitle.setVisibility(View.VISIBLE);
        mTvTitle.setText(title);
    }else {
        mTvTitle.setVisibility(View.GONE);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.topMargin = DialogUtils.dip2px(ToastUtils.getApp(),20.0f);
        params.leftMargin = DialogUtils.dip2px(ToastUtils.getApp(),20.0f);
        params.rightMargin = DialogUtils.dip2px(ToastUtils.getApp(),20.0f);
        mTvContent.setLayoutParams(params);
    }

    if (content!=null && content.length()>0){
        mTvContent.setVisibility(View.VISIBLE);
        mTvContent.setText(content);
    }else {
        mTvContent.setVisibility(View.GONE);
    }

    if(cancelColor!=0){
        mTvCancel.setTextColor(cancelColor);
    }else {
        mTvCancel.setTextColor(Color.parseColor("#333333"));
    }

    if(okColor!=0){
        mTvOk.setTextColor(okColor);
    }else {
        mTvOk.setTextColor(Color.parseColor("#ff666666"));
    }

    if(cancelContent!=null && cancelContent.length()>0){
        mTvCancel.setText(cancelContent);
        mTvCancel.setVisibility(View.VISIBLE);
        mViewLineLeft.setVisibility(View.VISIBLE);
    }else {
        mTvCancel.setVisibility(View.GONE);
        mViewLineLeft.setVisibility(View.GONE);
    }

    if (okContent!=null && okContent.length()>0){
        mTvOk.setText(okContent);
    }else {
        mTvOk.setText("确定");
    }

    if(cancelListener!=null){
        mTvCancel.setOnClickListener(cancelListener);
    }
    if(okListener!=null){
        mTvOk.setOnClickListener(okListener);
    }

    if(otherContent!=null && otherContent.length()>0 && otherListener!=null){
        mViewLineRight.setVisibility(View.VISIBLE);
        mTvOther.setVisibility(View.VISIBLE);
        mTvOther.setOnClickListener(otherListener);
        dismissDialogFragment();
    }else {
        mViewLineRight.setVisibility(View.GONE);
        mTvOther.setVisibility(View.GONE);
    }
}
 
Example #27
Source File: App.java    From YCDialog with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    ToastUtils.init(this);
}