Android Open Source - YahooWeather Share Core






From Project

Back to project page YahooWeather.

License

The source code is released under:

GNU General Public License

If you think the Android project YahooWeather listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * ????:http://www.ShareSDK.cn/*from ww  w  .  j  a v  a  2  s. c  om*/
 * ?????QQ: 4006852216
 * ????:ShareSDK   ??????????????????????????????????????????????????????????????????????????????24??????????
 *
 * Copyright (c) 2013? ShareSDK.cn. All rights reserved.
 */

package cn.sharesdk.onekeyshare;

import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.text.TextUtils;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.Platform.ShareParams;
import cn.sharesdk.framework.utils.R;
import cn.sharesdk.framework.ShareSDK;

/**
 * ShareCore?????????????????????????????????????????HashMap?
 *??{@link ShareParams}???????????????????????????????
 */
public class ShareCore {
  private ShareContentCustomizeCallback customizeCallback;

  /** ????????????????????????????????? */
  public void setShareContentCustomizeCallback(ShareContentCustomizeCallback callback) {
    customizeCallback = callback;
  }

  /**
   * ?????????????
   * <p>
   * <b>????</b><br>
   * ????data??????????{@link ShareParams}????????????????????
   *??????????????????????
   */
  public boolean share(Platform plat, HashMap<String, Object> data) {
    if (plat == null || data == null) {
      return false;
    }

    try {
      String imagePath = (String) data.get("imagePath");
      Bitmap viewToShare = (Bitmap) data.get("viewToShare");
      if (TextUtils.isEmpty(imagePath) && viewToShare != null && !viewToShare.isRecycled()) {
        String path = R.getCachePath(plat.getContext(), "screenshot");
        File ss = new File(path, String.valueOf(System.currentTimeMillis()) + ".jpg");
        FileOutputStream fos = new FileOutputStream(ss);
        viewToShare.compress(CompressFormat.JPEG, 100, fos);
        fos.flush();
        fos.close();
        data.put("imagePath", ss.getAbsolutePath());
      }
    } catch (Throwable t) {
      t.printStackTrace();
      return false;
    }

    ShareParams sp = new ShareParams(data);
    if (customizeCallback != null) {
      customizeCallback.onShare(plat, sp);
    }

    String[] flags = new String[] {
        "OnekeyShare",
        plat.getContext().getPackageName(),
        String.valueOf(ShareSDK.getSDKVersionCode())
    };
    sp.setCustomFlag(flags);
    plat.share(sp);
    return true;
  }

  /** ??????????????????? */
  public static boolean isUseClientToShare(String platform) {
    if ("Wechat".equals(platform) || "WechatMoments".equals(platform)
        || "WechatFavorite".equals(platform) || "ShortMessage".equals(platform)
        || "Email".equals(platform) || "GooglePlus".equals(platform)
        || "QQ".equals(platform) || "Pinterest".equals(platform)
        || "Instagram".equals(platform) || "Yixin".equals(platform)
        || "YixinMoments".equals(platform) || "QZone".equals(platform)
        || "Mingdao".equals(platform) || "Line".equals(platform)) {
      return true;
    } else if ("Evernote".equals(platform)) {
      Platform plat = ShareSDK.getPlatform(platform);
      if ("true".equals(plat.getDevinfo("ShareByAppClient"))) {
        return true;
      }
    } else if ("SinaWeibo".equals(platform)) {
      Platform plat = ShareSDK.getPlatform(platform);
      if ("true".equals(plat.getDevinfo("ShareByAppClient"))) {
        Intent test = new Intent(Intent.ACTION_SEND);
        test.setPackage("com.sina.weibo");
        test.setType("image/*");
        ResolveInfo ri = plat.getContext().getPackageManager().resolveActivity(test, 0);
        return (ri != null);
      }
    }

    return false;
  }

  /** ???????????????????????? */
  public static boolean canAuthorize(Context context, String platform) {
    if ("Wechat".equals(platform) || "WechatMoments".equals(platform)
        || "WechatFavorite".equals(platform) || "ShortMessage".equals(platform)
        || "Email".equals(platform) || "GooglePlus".equals(platform)
        || "Pinterest".equals(platform) || "Yixin".equals(platform)
        || "YixinMoments".equals(platform) || "Line".equals(platform)) {
      return false;
    }
    return true;
  }

}




Java Source Code List

cn.sharesdk.demo.wxapi.WXEntryActivity.java
cn.sharesdk.onekeyshare.CustomerLogo.java
cn.sharesdk.onekeyshare.EditPage.java
cn.sharesdk.onekeyshare.FollowList.java
cn.sharesdk.onekeyshare.OnekeyShare.java
cn.sharesdk.onekeyshare.PicViewer.java
cn.sharesdk.onekeyshare.PlatformGridView.java
cn.sharesdk.onekeyshare.Shake2Share.java
cn.sharesdk.onekeyshare.ShareContentCustomizeCallback.java
cn.sharesdk.onekeyshare.ShareCore.java
com.imlongluo.weather.MainActivity.java
com.imlongluo.weather.WeatherApplication.java
com.imlongluo.weather.apis.AsciiUtils.java
com.imlongluo.weather.apis.ImageUtils.java
com.imlongluo.weather.apis.NetworkUtils.java
com.imlongluo.weather.apis.UserLocationUtils.java
com.imlongluo.weather.apis.WOEIDInfo.java
com.imlongluo.weather.apis.WOEIDUtils.java
com.imlongluo.weather.apis.WeatherInfo.java
com.imlongluo.weather.apis.YahooWeatherConsts.java
com.imlongluo.weather.apis.YahooWeatherExceptionListener.java
com.imlongluo.weather.apis.YahooWeatherInfoListener.java
com.imlongluo.weather.apis.YahooWeatherLog.java
com.imlongluo.weather.apis.YahooWeather.java
com.imlongluo.weather.lbs.LocationGetter.java
com.imlongluo.weather.lbs.LocationManagerActivity.java
com.imlongluo.weather.settings.SettingsActivity.java
com.imlongluo.weather.share.ShareActivity.java
com.imlongluo.weather.utils.Constants.java
com.imlongluo.weather.utils.Utils.java