package com.smartalk.gank.utils;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.smartalk.gank.R;
import com.smartalk.gank.model.entity.Gank;
/**
* 分享相关工具类
* Created by panl on 16/1/8.
*/
public class ShareUtil {
public static void shareImage(Context context, Uri uri, String title) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/jpeg");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(shareIntent, title));
}
public static void shareApp(Context context) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.share_app));
shareIntent.setType("text/plain");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(shareIntent, context.getString(R.string.share_app_to_friend)));
}
public static void shareGank(Context context, Gank gank) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, gank.desc + gank.url + context.getString(R.string.download_gank));
intent.setType("text/plain");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_gank_to)));
}
public static void shareVideo(Context context, Gank gank) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, gank.desc + gank.url + context.getString(R.string.download_gank));
intent.setType("text/plain");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_video_to)));
}
}