Java Code Examples for com.socks.jiandan.utils.ShareUtil

The following examples show how to use com.socks.jiandan.utils.ShareUtil. These examples are extracted from open source projects. 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
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.action_comment:
            Intent intent = new Intent(getActivity(), CommentListActivity.class);
            intent.putExtra(DATA_THREAD_ID, freshNews.getId());
            intent.putExtra(DATA_IS_FROM_FRESH_NEWS, true);
            startActivity(intent);
            return true;
        case R.id.action_share:
            ShareUtil.shareText(getActivity(), freshNews.getTitle() + " " + freshNews.getUrl());
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 2
Source Project: JianDan   Source File: FreshNewsDetailFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.action_comment:
            Intent intent = new Intent(getActivity(), CommentListActivity.class);
            intent.putExtra(DATA_THREAD_ID, freshNews.getId());
            intent.putExtra(DATA_IS_FROM_FRESH_NEWS, true);
            startActivity(intent);
            return true;
        case R.id.action_share:
            ShareUtil.shareText(getActivity(), freshNews.getTitle() + " " + freshNews.getUrl());
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 3
Source Project: JianDanRxJava   Source File: ImageDetailActivity.java    License: Apache License 2.0 6 votes vote down vote up
@OnClick({R.id.img_back, R.id.img_share, R.id.tv_unlike, R.id.tv_like, R.id.img_comment, R.id.img_download})
void click(View v) {

    switch (v.getId()) {
        case R.id.img_back:
            finish();
            break;
        case R.id.img_share:
            ShareUtil.sharePicture(this, img_urls[0]);
            break;
        case R.id.tv_like:
            ToastHelper.Short(UN_CLICK);
            break;
        case R.id.tv_unlike:
            ToastHelper.Short(UN_CLICK);
            break;
        case R.id.img_comment:
            Intent intent = new Intent(this, CommentListActivity.class);
            intent.putExtra(DATA_THREAD_KEY, threadKey);
            startActivity(intent);
            break;
        case R.id.img_download:
            FileUtil.savePicture(img_urls[0], this);
            break;
    }
}
 
Example 4
Source Project: JianDan_OkHttp   Source File: FreshNewsDetailFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.action_comment:
            Intent intent = new Intent(getActivity(), CommentListActivity.class);
            intent.putExtra(DATA_THREAD_ID, freshNews.getId());
            intent.putExtra(DATA_IS_FROM_FRESH_NEWS, true);
            startActivity(intent);
            return true;
        case R.id.action_share:
            ShareUtil.shareText(getActivity(), freshNews.getTitle() + " " + freshNews.getUrl());
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 5
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        case R.id.action_more:
            new MaterialDialog.Builder(this)
                    .items(R.array.video_more)
                    .backgroundColor(getResources().getColor(JDApplication.COLOR_OF_DIALOG))
                    .contentColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                    .itemsCallback(new MaterialDialog.ListCallback() {
                        @Override
                        public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                            switch (which) {
                                //分享
                                case 0:
                                    ShareUtil.shareText(VideoDetailActivity.this, mToolbar.getTitle() + " " + url);
                                    break;
                                //复制
                                case 1:
                                    TextUtil.copy(VideoDetailActivity.this, url);
                                    break;
                                //浏览器打开
                                case 2:
                                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                                    break;
                            }
                        }
                    }).show();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 6
@OnClick({R.id.img_back, R.id.img_share, R.id.tv_unlike, R.id.tv_like, R.id.img_comment, R.id.img_download})
@Override
public void onClick(View v) {

    switch (v.getId()) {
        case R.id.img_back:
            finish();
            break;
        case R.id.img_share:
            ShareUtil.sharePicture(this, img_urls[0]);
            break;
        case R.id.tv_like:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.tv_unlike:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.img_comment:
            Intent intent = new Intent(this, CommentListActivity.class);
            intent.putExtra(DATA_THREAD_KEY, threadKey);
            startActivity(intent);
            break;
        case R.id.img_download:
            FileUtil.savePicture(this, img_urls[0], this);
            break;
    }
}
 
Example 7
Source Project: JianDan   Source File: VideoDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        case R.id.action_more:
            new MaterialDialog.Builder(this)
                    .items(R.array.video_more)
                    .backgroundColor(getResources().getColor(JDApplication.COLOR_OF_DIALOG))
                    .contentColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                    .itemsCallback(new MaterialDialog.ListCallback() {
                        @Override
                        public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                            switch (which) {
                                //分享
                                case 0:
                                    ShareUtil.shareText(VideoDetailActivity.this, mToolbar.getTitle() + " " + url);
                                    break;
                                //复制
                                case 1:
                                    TextUtil.copy(VideoDetailActivity.this, url);
                                    break;
                                //浏览器打开
                                case 2:
                                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                                    break;
                            }
                        }
                    }).show();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 8
Source Project: JianDan   Source File: ImageDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
@OnClick({R.id.img_back, R.id.img_share, R.id.tv_unlike, R.id.tv_like, R.id.img_comment, R.id.img_download})
@Override
public void onClick(View v) {

    switch (v.getId()) {
        case R.id.img_back:
            finish();
            break;
        case R.id.img_share:
            ShareUtil.sharePicture(this, img_urls[0]);
            break;
        case R.id.tv_like:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.tv_unlike:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.img_comment:
            Intent intent = new Intent(this, CommentListActivity.class);
            intent.putExtra(DATA_THREAD_KEY, threadKey);
            startActivity(intent);
            break;
        case R.id.img_download:
            FileUtil.savePicture(this, img_urls[0], this);
            break;
    }
}
 
Example 9
Source Project: JianDanRxJava   Source File: JokeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(final JokeViewHolder holder, final int position) {

    final Joke joke = mJokes.get(position);
    holder.tv_content.setText(joke.getComment_content());
    holder.tv_author.setText(joke.getComment_author());
    holder.tv_time.setText(String2TimeUtil.dateString2GoodExperienceFormat(joke.getComment_date()));
    holder.tv_like.setText(joke.getVote_positive());
    holder.tv_comment_count.setText(joke.getComment_counts());
    holder.tv_unlike.setText(joke.getVote_negative());

    holder.img_share.setOnClickListener(v -> new MaterialDialog.Builder(mActivity)
            .items(R.array.joke_dialog)
            .backgroundColor(mActivity.getResources().getColor(JDApplication.COLOR_OF_DIALOG))
            .contentColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
            .itemsCallback((dialog, view, which, text) -> {
                switch (which) {
                    case 0:
                        ShareUtil.shareText(mActivity, joke.getComment_content().trim());
                        break;
                    case 1:
                        TextUtil.copy(mActivity, joke.getComment_content());
                        break;
                }
            }).show());

    holder.ll_comment.setOnClickListener(v -> {
        Intent intent = new Intent(mActivity, CommentListActivity.class);
        intent.putExtra("thread_key", "comment-" + joke.getComment_ID());
        mActivity.startActivity(intent);
    });

    setAnimation(holder.card, position);

}
 
Example 10
Source Project: JianDanRxJava   Source File: FreshNewsDetailFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_comment:
            IntentHelper.toCommentListActivity(mContext, freshNews.id);
            return true;
        case R.id.action_share:
            ShareUtil.shareText(getActivity(), freshNews.title + " " + freshNews.url);
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 11
Source Project: JianDanRxJava   Source File: VideoDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        case R.id.action_more:
            new MaterialDialog.Builder(this)
                    .items(R.array.video_more)
                    .backgroundColor(getResources().getColor(JDApplication.COLOR_OF_DIALOG))
                    .contentColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                    .itemsCallback((dialog, view, which, text) -> {
                        switch (which) {
                            //分享
                            case 0:
                                ShareUtil.shareText(VideoDetailActivity.this, mToolbar.getTitle() + " " + url);
                                break;
                            //复制
                            case 1:
                                TextUtil.copy(VideoDetailActivity.this, url);
                                break;
                            //浏览器打开
                            case 2:
                                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                                break;
                        }
                    }).show();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 12
Source Project: JianDan_OkHttp   Source File: VideoDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        case R.id.action_more:
            new MaterialDialog.Builder(this)
                    .items(R.array.video_more)
                    .backgroundColor(getResources().getColor(JDApplication.COLOR_OF_DIALOG))
                    .contentColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
                    .itemsCallback(new MaterialDialog.ListCallback() {
                        @Override
                        public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                            switch (which) {
                                //分享
                                case 0:
                                    ShareUtil.shareText(VideoDetailActivity.this, mToolbar.getTitle() + " " + url);
                                    break;
                                //复制
                                case 1:
                                    TextUtil.copy(VideoDetailActivity.this, url);
                                    break;
                                //浏览器打开
                                case 2:
                                    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                                    break;
                            }
                        }
                    }).show();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 13
Source Project: JianDan_OkHttp   Source File: ImageDetailActivity.java    License: Apache License 2.0 5 votes vote down vote up
@OnClick({R.id.img_back, R.id.img_share, R.id.tv_unlike, R.id.tv_like, R.id.img_comment, R.id.img_download})
@Override
public void onClick(View v) {

    switch (v.getId()) {
        case R.id.img_back:
            finish();
            break;
        case R.id.img_share:
            ShareUtil.sharePicture(this, img_urls[0]);
            break;
        case R.id.tv_like:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.tv_unlike:
            ShowToast.Short("别点了,这玩意不能用");
            break;
        case R.id.img_comment:
            Intent intent = new Intent(this, CommentListActivity.class);
            intent.putExtra(DATA_THREAD_KEY, threadKey);
            startActivity(intent);
            break;
        case R.id.img_download:
            FileUtil.savePicture(this, img_urls[0], this);
            break;
    }
}
 
Example 14
Source Project: JianDanRxJava   Source File: PictureAdapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(final PictureViewHolder holder, final int position) {

    final Picture picture = mPictures.get(position);
    String picUrl = picture.getPics()[0];

    if (picUrl.endsWith(".gif")) {
        holder.img_gif.setVisibility(View.VISIBLE);
        //非WIFI网络情况下,GIF图只加载缩略图,详情页才加载真实图片
        if (!isWifiConnected) {
            picUrl = picUrl.replace("mw600", "small").replace("mw1200", "small").replace
                    ("large", "small");
        }
    } else {
        holder.img_gif.setVisibility(View.GONE);
    }

    holder.progress.setProgress(0);
    holder.progress.setVisibility(View.VISIBLE);

    ImageLoadProxy.displayImageList(picUrl, holder.img, R.drawable.ic_loading_large, new
                    SimpleImageLoadingListener() {
                        @Override
                        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                            super.onLoadingComplete(imageUri, view, loadedImage);
                            holder.progress.setVisibility(View.GONE);
                        }
                    },
            (imageUri, view, current, total) -> holder.progress.setProgress((int) (current * 100f / total)));

    if (TextUtil.isNull(picture.getText_content().trim())) {
        holder.tv_content.setVisibility(View.GONE);
    } else {
        holder.tv_content.setVisibility(View.VISIBLE);
        holder.tv_content.setText(picture.getText_content().trim());
    }

    holder.img.setOnClickListener(v -> IntentHelper.toImageDetailActivity(mActivity, picture));

    holder.tv_author.setText(picture.getComment_author());
    holder.tv_time.setText(String2TimeUtil.dateString2GoodExperienceFormat(picture.getComment_date()));
    holder.tv_like.setText(picture.getVote_positive());
    holder.tv_comment_count.setText(picture.getComment_counts());

    //用于恢复默认的文字
    holder.tv_like.setTypeface(Typeface.DEFAULT);
    holder.tv_like.setTextColor(mActivity.getResources().getColor(
            secondary_text_default_material_light));
    holder.tv_support_des.setTextColor(mActivity.getResources().getColor(
            secondary_text_default_material_light));

    holder.tv_unlike.setText(picture.getVote_negative());
    holder.tv_unlike.setTypeface(Typeface.DEFAULT);
    holder.tv_unlike.setTextColor(mActivity.getResources().getColor(
            secondary_text_default_material_light));
    holder.tv_un_support_des.setTextColor(mActivity.getResources().getColor(
            secondary_text_default_material_light));

    holder.img_share.setOnClickListener(v -> new MaterialDialog.Builder(mActivity)
            .items(R.array.picture_dialog)
            .backgroundColor(mActivity.getResources().getColor(JDApplication.COLOR_OF_DIALOG))
            .contentColor(JDApplication.COLOR_OF_DIALOG_CONTENT)
            .itemsCallback((dialog, view, which, text) -> {

                switch (which) {
                    case 0:
                        ShareUtil.sharePicture(mActivity, picture
                                .getPics()[0]);
                        break;
                    case 1:
                        FileUtil.savePicture(picture
                                .getPics()[0], mSaveFileCallBack);
                        break;
                }
            })
            .show());

    holder.ll_comment.setOnClickListener(v -> {
        Intent intent = new Intent(mActivity, CommentListActivity.class);
        intent.putExtra(BaseActivity.DATA_THREAD_KEY, "comment-" + picture.getComment_ID());
        mActivity.startActivity(intent);
    });

    setAnimation(holder.card, position);

}