Search in sources :

Example 6 with FragmentArgs

use of org.aisen.android.ui.activity.container.FragmentArgs in project AisenWeiBo by wangdan.

the class SinaCommonActivity method onCreate.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void onCreate(Bundle savedInstanceState) {
    contentId = savedInstanceState == null ? org.aisen.android.R.layout.comm_ui_fragment_container : savedInstanceState.getInt("contentId");
    overrideTheme = savedInstanceState == null ? -1 : savedInstanceState.getInt("overrideTheme");
    Fragment fragment = null;
    if (savedInstanceState == null) {
        try {
            String className = getIntent().getStringExtra("className");
            if (TextUtils.isEmpty(className)) {
                super.onCreate(savedInstanceState);
                finish();
                return;
            }
            FragmentArgs values = (FragmentArgs) getIntent().getSerializableExtra("args");
            Class clazz = Class.forName(className);
            fragment = (Fragment) clazz.newInstance();
            // 设置参数给Fragment
            if (values != null) {
                try {
                    Method method = clazz.getMethod("setArguments", new Class[] { Bundle.class });
                    method.invoke(fragment, FragmentArgs.transToBundle(values));
                } catch (Exception e) {
                }
            }
            // 重写Activity的主题
            try {
                Method method = clazz.getMethod("setActivityTheme");
                if (method != null) {
                    int theme = Integer.parseInt(method.invoke(fragment).toString());
                    if (theme > 0) {
                        overrideTheme = theme;
                    }
                }
            } catch (Exception e) {
            }
            // 重写Activity的contentView
            try {
                Method method = clazz.getMethod("inflateActivityContentView");
                if (method != null) {
                    int fragmentConfigId = Integer.parseInt(method.invoke(fragment).toString());
                    if (fragmentConfigId > 0) {
                        contentId = fragmentConfigId;
                    }
                }
            } catch (Exception e) {
            }
        } catch (Exception e) {
            e.printStackTrace();
            super.onCreate(savedInstanceState);
            finish();
            return;
        }
    }
    super.onCreate(savedInstanceState);
    setContentView(contentId);
    if (fragment != null) {
        if (!(fragment instanceof ABaseFragment) || ((ABaseFragment) fragment).inflateContentView() > 0) {
            getFragmentManager().beginTransaction().add(org.aisen.android.R.id.fragmentContainer, fragment, FRAGMENT_TAG).commit();
        } else {
            getFragmentManager().beginTransaction().add(fragment, FRAGMENT_TAG).commit();
        }
    }
    if (getSupportActionBar() != null)
        getSupportActionBar().setDisplayShowHomeEnabled(false);
    BizFragment.createBizFragment(this);
}
Also used : ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) Method(java.lang.reflect.Method) Fragment(android.app.Fragment) ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) BizFragment(org.aisen.weibo.sina.ui.fragment.base.BizFragment) FragmentArgs(org.aisen.android.ui.activity.container.FragmentArgs)

Example 7 with FragmentArgs

use of org.aisen.android.ui.activity.container.FragmentArgs in project AisenWeiBo by wangdan.

the class WebLoginFragment method launch.

public static void launch(Fragment from, Client client, String account, String password, int requestCode) {
    FragmentArgs args = new FragmentArgs();
    args.add("client", client.toString());
    if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(password)) {
        args.add("account", account);
        args.add("password", password);
    }
    SinaCommonActivity.launchForResult(from, WebLoginFragment.class, args, requestCode);
}
Also used : FragmentArgs(org.aisen.android.ui.activity.container.FragmentArgs)

Example 8 with FragmentArgs

use of org.aisen.android.ui.activity.container.FragmentArgs in project AisenWeiBo by wangdan.

the class WebLoginFragment method launch.

public static void launch(Activity from, Client client, String account, String password, int requestCode) {
    FragmentArgs args = new FragmentArgs();
    args.add("client", client.toString());
    if (!TextUtils.isEmpty(account) && !TextUtils.isEmpty(password)) {
        args.add("account", account);
        args.add("password", password);
    }
    SinaCommonActivity.launchForResult(from, WebLoginFragment.class, args, requestCode);
}
Also used : FragmentArgs(org.aisen.android.ui.activity.container.FragmentArgs)

Example 9 with FragmentArgs

use of org.aisen.android.ui.activity.container.FragmentArgs in project AisenWeiBo by wangdan.

the class ProfilePagerFragment method launch.

public static void launch(Activity from, WeiBoUser user) {
    FragmentArgs args = new FragmentArgs();
    args.add("mUser", user);
    args.add(SET_INDEX, String.valueOf(1));
    SinaCommonActivity.launch(from, ProfilePagerFragment.class, args);
}
Also used : FragmentArgs(org.aisen.android.ui.activity.container.FragmentArgs)

Example 10 with FragmentArgs

use of org.aisen.android.ui.activity.container.FragmentArgs in project AisenWeiBo by wangdan.

the class TimelineDetailPagerFragment method launch.

public static void launch(Activity from, StatusContent status) {
    FragmentArgs args = new FragmentArgs();
    args.add("status", status);
    SinaCommonActivity.launch(from, TimelineDetailPagerFragment.class, args);
}
Also used : FragmentArgs(org.aisen.android.ui.activity.container.FragmentArgs)

Aggregations

FragmentArgs (org.aisen.android.ui.activity.container.FragmentArgs)11 Fragment (android.app.Fragment)1 Intent (android.content.Intent)1 Method (java.lang.reflect.Method)1 TabItem (org.aisen.android.support.bean.TabItem)1 ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)1 BizFragment (org.aisen.weibo.sina.ui.fragment.base.BizFragment)1