Search in sources :

Example 6 with ABaseFragment

use of org.aisen.android.ui.fragment.ABaseFragment in project AisenWeiBo by wangdan.

the class TopicsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ui_fragment_container);
    if (savedInstanceState == null) {
        if (getIntent() != null && "Previous".equals(getIntent().getAction())) {
            ABaseFragment fragment = TimelineTopicsFragment.newInstance(getIntent().getStringExtra("q"));
            getFragmentManager().beginTransaction().replace(org.aisen.android.R.id.fragmentContainer, fragment, "TopicsTimelint").commit();
        } else {
            Uri data = getIntent().getData();
            if (data != null) {
                String d = data.toString();
                int index = d.lastIndexOf("/");
                String topicsName = d.substring(index + 1);
                topicsName = topicsName.substring(1, topicsName.length() - 1);
                ABaseFragment fragment = TimelineTopicsFragment.newInstance(topicsName);
                getFragmentManager().beginTransaction().replace(org.aisen.android.R.id.fragmentContainer, fragment, "TopicsTimelint").commit();
            } else {
                finish();
                return;
            }
        }
    }
}
Also used : ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) Uri(android.net.Uri)

Example 7 with ABaseFragment

use of org.aisen.android.ui.fragment.ABaseFragment in project AisenWeiBo by wangdan.

the class TimelinePicActivity method loadPicture.

private void loadPicture(String pic) {
    PicUrls picUrls = new PicUrls();
    picUrls.setThumbnail_pic(pic.replace("large", "bmiddle").replace("small", "bmiddle"));
    ABaseFragment pictureFragment = PictureFragment.newInstance(picUrls);
    getFragmentManager().beginTransaction().replace(R.id.layContainer, pictureFragment, "PicFragment").commit();
}
Also used : ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) PicUrls(org.aisen.weibo.sina.sinasdk.bean.PicUrls)

Example 8 with ABaseFragment

use of org.aisen.android.ui.fragment.ABaseFragment in project AisenWeiBo by wangdan.

the class SinaCommonActivity method onCreate.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void onCreate(Bundle savedInstanceState) {
    contentId = savedInstanceState == null ? R.layout.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 9 with ABaseFragment

use of org.aisen.android.ui.fragment.ABaseFragment in project AisenWeiBo by wangdan.

the class FriendsFragment method newInstance.

public static ABaseFragment newInstance(WeiBoUser user) {
    ABaseFragment fragment = new FriendsFragment();
    Bundle args = new Bundle();
    args.putSerializable("user", user);
    args.putBoolean("launch", false);
    fragment.setArguments(args);
    return fragment;
}
Also used : ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) Bundle(android.os.Bundle)

Example 10 with ABaseFragment

use of org.aisen.android.ui.fragment.ABaseFragment in project AisenWeiBo by wangdan.

the class AisenUtils method setTabsText.

public static void setTabsText(Fragment fragment, int index, String text) {
    if (fragment.getActivity() == null)
        return;
    ABaseFragment aFragment = null;
    if (fragment.getActivity() instanceof SinaCommonActivity) {
        aFragment = (ABaseFragment) fragment.getActivity().getFragmentManager().findFragmentByTag(SinaCommonActivity.FRAGMENT_TAG);
    } else if (fragment.getActivity() instanceof MainActivity) {
        aFragment = (ABaseFragment) fragment.getActivity().getFragmentManager().findFragmentByTag("MainFragment");
    }
    if (aFragment != null && aFragment instanceof ATabsTabLayoutFragment) {
        ATabsTabLayoutFragment tabsFragment = (ATabsTabLayoutFragment) aFragment;
        tabsFragment.getTablayout().getTabAt(index).setText(text);
    }
}
Also used : ABaseFragment(org.aisen.android.ui.fragment.ABaseFragment) ATabsTabLayoutFragment(org.aisen.android.ui.fragment.ATabsTabLayoutFragment) MainActivity(org.aisen.weibo.sina.ui.activity.base.MainActivity) SinaCommonActivity(org.aisen.weibo.sina.ui.activity.base.SinaCommonActivity)

Aggregations

ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)13 Bundle (android.os.Bundle)4 BizFragment (org.aisen.weibo.sina.ui.fragment.base.BizFragment)2 Fragment (android.app.Fragment)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Method (java.lang.reflect.Method)1 IAction (org.aisen.android.support.action.IAction)1 FragmentArgs (org.aisen.android.ui.activity.container.FragmentArgs)1 ATabsTabLayoutFragment (org.aisen.android.ui.fragment.ATabsTabLayoutFragment)1 AsToolbar (org.aisen.android.ui.widget.AsToolbar)1 PicUrls (org.aisen.weibo.sina.sinasdk.bean.PicUrls)1 WebLoginAction (org.aisen.weibo.sina.support.action.WebLoginAction)1 PublishBean (org.aisen.weibo.sina.support.bean.PublishBean)1 PublishType (org.aisen.weibo.sina.support.bean.PublishType)1 SdcardPermissionAction (org.aisen.weibo.sina.support.permissions.SdcardPermissionAction)1 MainActivity (org.aisen.weibo.sina.ui.activity.base.MainActivity)1 SinaCommonActivity (org.aisen.weibo.sina.ui.activity.base.SinaCommonActivity)1