Android Open Source - ShareSDK-for-Android Platform List Fake Activity






From Project

Back to project page ShareSDK-for-Android.

License

The source code is released under:

MIT License

If you think the Android project ShareSDK-for-Android 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

package cn.sharesdk.onekeyshare;
/*from  www  .  j a v  a  2 s  .  com*/
import android.content.Context;
import android.content.Intent;
import android.view.KeyEvent;
import android.view.View;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import cn.sharesdk.framework.FakeActivity;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.ShareSDK;

public class PlatformListFakeActivity extends FakeActivity {
  protected HashMap<String, Object> shareParamsMap;
  protected boolean silent;
  protected ArrayList<CustomerLogo> customerLogos;
  protected HashMap<String, String> hiddenPlatforms;
  private boolean canceled = false;
  protected View backgroundView;

  protected OnShareButtonClickListener onShareButtonClickListener;
  protected boolean dialogMode = false;
  protected ThemeShareCallback themeShareCallback;

  public static interface OnShareButtonClickListener {
    void onClick(View v, List<Object> checkPlatforms);
  }

  public void onCreate() {
    super.onCreate();

    canceled = false;

    if(themeShareCallback == null) {
      finish();
    }
  }

  public boolean onKeyEvent(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      canceled = true;
    }
    return super.onKeyEvent(keyCode, event);
  }

  protected void setCanceled(boolean canceled) {
    this.canceled = canceled;
  }

  public boolean onFinish() {

    // a statistics of cancel sharing
    if (canceled) {
      ShareSDK.logDemoEvent(2, null);
    }

    return super.onFinish();
  }

  @Override
  public void show(Context context, Intent i) {
    super.show(context, i);
  }

  public HashMap<String, Object> getShareParamsMap() {
    return shareParamsMap;
  }

  public void setShareParamsMap(HashMap<String, Object> shareParamsMap) {
    this.shareParamsMap = shareParamsMap;
  }

  public boolean isSilent() {
    return silent;
  }

  public void setSilent(boolean silent) {
    this.silent = silent;
  }

  public ArrayList<CustomerLogo> getCustomerLogos() {
    return customerLogos;
  }

  public void setCustomerLogos(ArrayList<CustomerLogo> customerLogos) {
    this.customerLogos = customerLogos;
  }

  public HashMap<String, String> getHiddenPlatforms() {
    return hiddenPlatforms;
  }

  public void setHiddenPlatforms(HashMap<String, String> hiddenPlatforms) {
    this.hiddenPlatforms = hiddenPlatforms;
  }

  public View getBackgroundView() {
    return backgroundView;
  }

  public void setBackgroundView(View backgroundView) {
    this.backgroundView = backgroundView;
  }

  public OnShareButtonClickListener getOnShareButtonClickListener() {
    return onShareButtonClickListener;
  }

  public void setOnShareButtonClickListener(OnShareButtonClickListener onShareButtonClickListener) {
    this.onShareButtonClickListener = onShareButtonClickListener;
  }

  public boolean isDialogMode() {
    return dialogMode;
  }

  public void setDialogMode(boolean dialogMode) {
    this.dialogMode = dialogMode;
  }

  public ThemeShareCallback getThemeShareCallback() {
    return themeShareCallback;
  }

  public void setThemeShareCallback(ThemeShareCallback themeShareCallback) {
    this.themeShareCallback = themeShareCallback;
  }

  protected void onShareButtonClick(View v, List<Object> checkedPlatforms) {

    if(onShareButtonClickListener != null) {
      onShareButtonClickListener.onClick(v, checkedPlatforms);
    }

    HashMap<Platform, HashMap<String, Object>> silentShareData = new HashMap<Platform, HashMap<String,Object>>();
    final List<Platform> supportEditPagePlatforms = new ArrayList<Platform>();

    Platform plat;
    HashMap<String, Object> shareParam;
    for(Object item : checkedPlatforms) {
      if(item instanceof CustomerLogo){
        CustomerLogo customerLogo = (CustomerLogo)item;
        customerLogo.listener.onClick(v);
        continue;
      }

      plat = (Platform)item;
      String name = plat.getName();

      // EditPage don't support Wechat, google+, QQ, pinterest, short message and email,
      // these performs always share directly
      if(silent || ShareCore.isDirectShare(plat)) {
        shareParam = new HashMap<String, Object>(shareParamsMap);
        shareParam.put("platform", name);
        silentShareData.put(plat, shareParam);
      } else {
        supportEditPagePlatforms.add(plat);
      }
    }
    if (silentShareData.size() > 0) {
      themeShareCallback.doShare(silentShareData);
    }

    // jump in editpage to share
    if(supportEditPagePlatforms.size() > 0) {
      showEditPage(supportEditPagePlatforms);
    }

    finish();
  }

  protected void showEditPage(List<Platform> platforms) {
    showEditPage(getContext(), platforms);
  }

  public void showEditPage(Context context, Platform platform) {
    ArrayList<Platform> platforms = new ArrayList<Platform>(1);
    platforms.add(platform);
    showEditPage(context, platforms);
  }

  protected void showEditPage(Context context, List<Platform> platforms) {
    EditPageFakeActivity editPageFakeActivity;
    String editPageClass = ((Object)this).getClass().getPackage().getName()+".EditPage";
    try {
      editPageFakeActivity = (EditPageFakeActivity) Class.forName(editPageClass).newInstance();
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    editPageFakeActivity.setBackgroundView(backgroundView);
    editPageFakeActivity.setShareData(shareParamsMap);
    editPageFakeActivity.setPlatforms(platforms);
    if (dialogMode) {
      editPageFakeActivity.setDialogMode();
    }
    editPageFakeActivity.showForResult(context, null, new FakeActivity() {
      public void onResult(HashMap<String, Object> data) {
        if(data == null)
          return;
        if (data.containsKey("editRes")) {
          @SuppressWarnings("unchecked")
          HashMap<Platform, HashMap<String, Object>> editRes
              = (HashMap<Platform, HashMap<String, Object>>) data.get("editRes");
          themeShareCallback.doShare(editRes);
        }
      }
    });
  }
}




Java Source Code List

cn.sharesdk.demo.AuthPage.java
cn.sharesdk.demo.CustomShareFieldsPage.java
cn.sharesdk.demo.CustomerPage.java
cn.sharesdk.demo.DemoPage.java
cn.sharesdk.demo.GetInforPage.java
cn.sharesdk.demo.GetTokenPage.java
cn.sharesdk.demo.JsonPage.java
cn.sharesdk.demo.Laiwang.java
cn.sharesdk.demo.MainActivity.java
cn.sharesdk.demo.MainAdapter.java
cn.sharesdk.demo.MyAdapter.java
cn.sharesdk.demo.MyQZoneWebShareAdapter.java
cn.sharesdk.demo.OneKeyShareCallback.java
cn.sharesdk.demo.ShareContentCustomizeDemo.java
cn.sharesdk.demo.SlidingMenuPage.java
cn.sharesdk.demo.WechatPage.java
cn.sharesdk.demo.YixinPage.java
cn.sharesdk.demo.wxapi.WXEntryActivity.java
cn.sharesdk.demo.yxapi.YXEntryActivity.java
cn.sharesdk.onekeyshare.CustomerLogo.java
cn.sharesdk.onekeyshare.CustomerLogo.java
cn.sharesdk.onekeyshare.EditPageFakeActivity.java
cn.sharesdk.onekeyshare.EditPageFakeActivity.java
cn.sharesdk.onekeyshare.FollowerListFakeActivity.java
cn.sharesdk.onekeyshare.FollowerListFakeActivity.java
cn.sharesdk.onekeyshare.OnekeyShareTheme.java
cn.sharesdk.onekeyshare.OnekeyShareTheme.java
cn.sharesdk.onekeyshare.OnekeyShare.java
cn.sharesdk.onekeyshare.OnekeyShare.java
cn.sharesdk.onekeyshare.PicViewer.java
cn.sharesdk.onekeyshare.PicViewer.java
cn.sharesdk.onekeyshare.PlatformListFakeActivity.java
cn.sharesdk.onekeyshare.PlatformListFakeActivity.java
cn.sharesdk.onekeyshare.Shake2Share.java
cn.sharesdk.onekeyshare.Shake2Share.java
cn.sharesdk.onekeyshare.ShareContentCustomizeCallback.java
cn.sharesdk.onekeyshare.ShareContentCustomizeCallback.java
cn.sharesdk.onekeyshare.ShareCore.java
cn.sharesdk.onekeyshare.ShareCore.java
cn.sharesdk.onekeyshare.ThemeShareCallback.java
cn.sharesdk.onekeyshare.ThemeShareCallback.java
cn.sharesdk.onekeyshare.theme.classic.EditPage.java
cn.sharesdk.onekeyshare.theme.classic.EditPage.java
cn.sharesdk.onekeyshare.theme.classic.FollowListPage.java
cn.sharesdk.onekeyshare.theme.classic.FollowListPage.java
cn.sharesdk.onekeyshare.theme.classic.PlatformGridView.java
cn.sharesdk.onekeyshare.theme.classic.PlatformGridView.java
cn.sharesdk.onekeyshare.theme.classic.PlatformListPage.java
cn.sharesdk.onekeyshare.theme.classic.PlatformListPage.java
cn.sharesdk.onekeyshare.theme.skyblue.EditPage.java
cn.sharesdk.onekeyshare.theme.skyblue.EditPage.java
cn.sharesdk.onekeyshare.theme.skyblue.FollowListPage.java
cn.sharesdk.onekeyshare.theme.skyblue.FollowListPage.java
cn.sharesdk.onekeyshare.theme.skyblue.PlatformGridViewAdapter.java
cn.sharesdk.onekeyshare.theme.skyblue.PlatformGridViewAdapter.java
cn.sharesdk.onekeyshare.theme.skyblue.PlatformListPage.java
cn.sharesdk.onekeyshare.theme.skyblue.PlatformListPage.java
cn.sharesdk.socialization.sample.MainActivity.java
cn.sharesdk.socialization.sample.MyPlatform.java
cn.sharesdk.socialization.sample.wxapi.WXEntryActivity.java
cn.sharesdk.socialization.sample.yxapi.YXEntryActivity.java