Android Open Source - AURHelperDroid Activity Host Fragment






From Project

Back to project page AURHelperDroid.

License

The source code is released under:

Apache License

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

/*
 * Copyright (C) 2011 Ievgenii Nazaruk//from  w  ww.  ja v  a  2 s.  co m
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.stomachion.aurhelperdroid.fallbacksupport;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.*;

/**
 * This is a fragment that will be used during transition from activities to fragments.
 */
public abstract class ActivityHostFragment extends LocalActivityManagerFragment {

    protected abstract Class<? extends Activity> getActivityClass();

    private final static String ACTIVITY_TAG = "hosted";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        final Class<? extends Activity> activityClass = getActivityClass();
        if (activityClass == null)
            return super.onCreateView(inflater, container, savedInstanceState);

        final Intent intent = new Intent(getActivity(), getActivityClass());

        @SuppressWarnings("deprecation")
        final Window w = getLocalActivityManager().startActivity(ACTIVITY_TAG, intent);
        final View wd = w != null ? w.getDecorView() : null;

        if (wd != null) {
            ViewParent parent = wd.getParent();
            if (parent != null) {
                ViewGroup v = (ViewGroup) parent;
                v.removeView(wd);
            }

            wd.setVisibility(View.VISIBLE);
            wd.setFocusableInTouchMode(true);
            if (wd instanceof ViewGroup) {
                ((ViewGroup) wd).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
            }
        }
        return wd;
    }
}




Java Source Code List

com.stomachion.aurhelperdroid.activities.MainActivity.java
com.stomachion.aurhelperdroid.activities.PreferencesActivity.java
com.stomachion.aurhelperdroid.adapters.NewsAdapter.java
com.stomachion.aurhelperdroid.fallbacksupport.ActivityHostFragment.java
com.stomachion.aurhelperdroid.fallbacksupport.LocalActivityManagerFragment.java
com.stomachion.aurhelperdroid.fragments.AboutFrag.java
com.stomachion.aurhelperdroid.fragments.NewsRSSFrag.java
com.stomachion.aurhelperdroid.fragments.PreferencesFrag.java
com.stomachion.aurhelperdroid.fragments.SearchFrag.java
com.stomachion.aurhelperdroid.logic.NewsItem.java
com.stomachion.aurhelperdroid.network.InternetState.java
com.stomachion.aurhelperdroid.parser.MainRssParser.java
com.stomachion.aurhelperdroid.parser.RssNewsHandler.java
com.stomachion.aurhelperdroid.utils.CommonUtils.java
com.stomachion.aurhelperdroid.utils.Constants.java
com.stomachion.aurhelperdroid.utils.Prefs.java