Search in sources :

Example 1 with PublishType

use of org.aisen.weibo.sina.support.bean.PublishType in project AisenWeiBo by wangdan.

the class PublishActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ui_fragment_container);
    getSupportActionBar().setDisplayShowHomeEnabled(false);
    // 接收分享
    if (savedInstanceState == null) {
        Intent intent = getIntent();
        String action = intent.getAction();
        String type = intent.getType();
        if (!TextUtils.isEmpty(action)) {
            if (action.equals(Intent.ACTION_SEND) && !TextUtils.isEmpty(type)) {
                if (!AppContext.isLoggedIn()) {
                    // AccountFragment.launch(this);
                    showMessage(R.string.publish_please_login);
                    finish();
                    return;
                }
                if ("text/plain".equals(type)) {
                    handleSendText(intent);
                } else if (type.startsWith("image/")) {
                    handleSendImage(intent);
                } else {
                    finish();
                }
                return;
            }
        }
    }
    typeStr = savedInstanceState == null ? getIntent().getStringExtra("type") : savedInstanceState.getString("type");
    bean = savedInstanceState == null ? (PublishBean) getIntent().getSerializableExtra("bean") : (PublishBean) savedInstanceState.getSerializable("bean");
    if (savedInstanceState == null) {
        if (TextUtils.isEmpty(typeStr)) {
            finish();
            return;
        }
        PublishType type = PublishType.valueOf(typeStr);
        ABaseFragment fragment = null;
        switch(type) {
            case status:
                fragment = PublishStatusFragment.newInstance(bean);
                break;
            case commentReply:
                fragment = PublishCommentReplyFragment.newInstance(bean);
                break;
            case commentCreate:
                fragment = PublishStatusCommentFragment.newInstance(bean);
                break;
            case statusRepost:
                fragment = PublishStatusRepostFragment.newInstance(bean);
                break;
            default:
                break;
        }
        if (fragment != null)
            getFragmentManager().beginTransaction().add(R.id.fragmentContainer, fragment, "PublishFragment").commit();
    }
}
Also used : PublishBean(org.aisen.weibo.sina.support.bean.PublishBean) ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) Intent(android.content.Intent) PublishType(org.aisen.weibo.sina.support.bean.PublishType)

Aggregations

Intent (android.content.Intent)1 ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)1 PublishBean (org.aisen.weibo.sina.support.bean.PublishBean)1 PublishType (org.aisen.weibo.sina.support.bean.PublishType)1