Example usage for android.widget FrameLayout setVisibility

List of usage examples for android.widget FrameLayout setVisibility

Introduction

In this page you can find the example usage for android.widget FrameLayout setVisibility.

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:com.asksven.commandcenter.BasicMasterFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    boolean bUpdateCache = preferences.getBoolean("autoRunStatus", true);
    boolean bForceDualPane = preferences.getBoolean("dualPaneOnSmallScreens", false);

    // detect free/full version and enable/disable ads
    if (!Configuration.isFullVersion(getActivity())) {
        AdView adView = (AdView) getActivity().findViewById(R.id.adView);
        // if ads are part of the view 
        if (adView != null) {
            adView.loadAd(new AdRequest());
        }//from  w ww  .j a  v  a  2s  .co m
    }

    Bundle args = getArguments();
    if (args != null) {
        m_strCollectionName = args.getString("collection");
        m_iContextMenuId = args.getInt("id");
    } else {
        m_strCollectionName = "commands.json";
    }

    CommandCollection myCollection = CollectionManager.getInstance(getActivity())
            .getCollectionByName(m_strCollectionName, false);

    m_bEditable = myCollection.isEditable();

    m_myItems = myCollection.getEntries();

    m_myAdapter = new CommandListAdapter(getActivity(), m_myItems);
    setListAdapter(m_myAdapter);

    registerForContextMenu(getListView());

    // Check to see if we have a frame in which to embed the details
    // fragment directly in the containing UI.
    View detailsFrame = getActivity().findViewById(R.id.details);
    boolean bPortrait = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;
    if (bPortrait) {
        if ((Devices.isTablet(getActivity())) || bForceDualPane) {
            mDualPane = true;
            FrameLayout details = (FrameLayout) getActivity().findViewById(R.id.details);
            details.setVisibility(View.VISIBLE);

        } else {
            mDualPane = false;
            FrameLayout details = (FrameLayout) getActivity().findViewById(R.id.details);
            details.setVisibility(View.GONE);
        }
    }

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        mCurCheckPosition = savedInstanceState.getInt(m_strCollectionName + "_curChoice", 0);
    }

    if (mDualPane) {
        // In dual-pane mode, the list view highlights the selected item.
        getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        // Make sure our UI is in the correct state.
        showDetails(mCurCheckPosition);
    }
}

From source file:com.google.samples.apps.topeka.view.quiz.QuizActivity.java

private void revealFragmentContainer(final View clickedView, final FrameLayout fragmentContainer,
        int themeAccentColor) {
    if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
        revealFragmentContainerLollipop(clickedView, fragmentContainer, themeAccentColor);
    } else {/*  w  w  w  . jav  a 2 s  .com*/
        fragmentContainer.setVisibility(View.VISIBLE);
        clickedView.setVisibility(View.GONE);
        mIcon.setVisibility(View.GONE);
    }
}

From source file:de.incoherent.suseconferenceclient.activities.HomeActivity.java

private void setView(boolean loadSocial) {
    Log.d("SUSEConferences", "setView");

    if (mDialog != null)
        mDialog.dismiss();/*w ww .j  a  v a 2  s.c om*/

    showChangeLog();
    Database db = SUSEConferences.getDatabase();
    mConference = db.getConference(mConferenceId);
    mVenueId = db.getConferenceVenue(mConferenceId);
    getSupportActionBar().setTitle(mConference.getName());
    Log.d("SUSEConferences", "Conference ID is " + mConferenceId);

    mPhonePager = (ViewPager) findViewById(R.id.phonePager);
    if (mPhonePager != null) { // Phone layout
        ActionBar bar = getSupportActionBar();
        bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        Bundle args = new Bundle();
        args.putLong("conferenceId", this.mConferenceId);
        args.putString("socialTag", mConference.getSocialTag());
        args.putString("conferenceName", mConference.getName());

        // If the user has switched the conference after another conference
        // was loaded, we'll just reset everything
        if (mTabsAdapter == null) {
            mTabsAdapter = new TabAdapter(this, mPhonePager);
            Tab myScheduleTab = bar.newTab();

            myScheduleTab.setText(getString(R.string.mySchedule));
            myScheduleTab.setTag(MY_SCHEDULE_TAG);
            mTabsAdapter.addTab(myScheduleTab, MyScheduleFragment.class, args);

            Tab scheduleTab = bar.newTab();
            scheduleTab.setText(getString(R.string.fullSchedule));
            scheduleTab.setTag(SCHEDULE_TAG);
            mTabsAdapter.addTab(scheduleTab, ScheduleFragment.class, args);

            if (hasInternet()) {
                mTabsAdapter.addTab(bar.newTab().setText(getString(R.string.newsFeed)), NewsFeedFragment.class,
                        args);
                //mTabsAdapter.addTab(
                //      bar.newTab().setText(getString(R.string.rssFeed)),
                //      RssFeedFragment.class,args);
            }
        }
    } else { // Tablet layout
        FragmentManager fm = getSupportFragmentManager();
        Bundle args = new Bundle();
        args.putLong("conferenceId", this.mConferenceId);
        args.putString("socialTag", mConference.getSocialTag());
        args.putString("conferenceName", mConference.getName());
        MyScheduleFragment mySched = new MyScheduleFragment();
        mySched.setArguments(args);
        fm.beginTransaction().add(R.id.myScheduleFragmentLayout, mySched, MY_SCHEDULE_TAG).commit();

        ScheduleFragment sched = new ScheduleFragment();
        sched.setArguments(args);
        fm.beginTransaction().add(R.id.scheduleFragmentLayout, sched, SCHEDULE_TAG).commit();

        if (hasInternet() && loadSocial) {
            NewsFeedFragment newsFeed = new NewsFeedFragment();
            newsFeed.setArguments(args);
            fm.beginTransaction().add(R.id.socialLayout, newsFeed, NEWSFEED_TAG).commit();
        }

        if (!hasInternet()) {
            RelativeLayout horizontal = (RelativeLayout) findViewById(R.id.newsFeedHorizontalLayout);
            if (horizontal != null)
                horizontal.setVisibility(View.GONE);
            FrameLayout socialLayout = (FrameLayout) findViewById(R.id.socialLayout);
            socialLayout.setVisibility(View.GONE);
            TextView labelView = (TextView) findViewById(R.id.newsFeedTextView);
            labelView.setVisibility(View.GONE);
        }
    }
}

From source file:de.grobox.liberario.TripsActivity.java

private void addTrips(final TableLayout main, List<Trip> trip_list, boolean append) {
    if (trip_list != null) {
        // reverse order of trips if they should be prepended
        if (!append) {
            ArrayList<Trip> tempResults = new ArrayList<Trip>(trip_list);
            Collections.reverse(tempResults);
            trip_list = tempResults;/*from  www.j  a  v a  2 s  . c o m*/
        }

        for (final Trip trip : trip_list) {
            final LinearLayout trip_layout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.trip,
                    null);
            TableRow row = (TableRow) trip_layout.findViewById(R.id.tripTableRow);

            // Locations
            TextView fromView = (TextView) row.findViewById(R.id.fromView);
            fromView.setText(trip.from.uniqueShortName());
            TextView toView = ((TextView) row.findViewById(R.id.toView));
            toView.setText(trip.to.uniqueShortName());

            // Departure Time and Delay
            TextView departureTimeView = (TextView) row.findViewById(R.id.departureTimeView);
            TextView departureDelayView = (TextView) row.findViewById(R.id.departureDelayView);
            if (trip.getFirstPublicLeg() != null) {
                LiberarioUtils.setDepartureTimes(this, departureTimeView, departureDelayView,
                        trip.getFirstPublicLeg().departureStop);
            } else {
                departureTimeView.setText(DateUtils.getTime(this, trip.getFirstDepartureTime()));
            }

            // Arrival Time and Delay
            TextView arrivalTimeView = (TextView) row.findViewById(R.id.arrivalTimeView);
            TextView arrivalDelayView = (TextView) row.findViewById(R.id.arrivalDelayView);
            if (trip.getLastPublicLeg() != null) {
                LiberarioUtils.setArrivalTimes(this, arrivalTimeView, arrivalDelayView,
                        trip.getLastPublicLeg().arrivalStop);
            } else {
                arrivalTimeView.setText(DateUtils.getTime(this, trip.getLastArrivalTime()));
            }

            // Duration
            TextView durationView = (TextView) trip_layout.findViewById(R.id.durationView);
            durationView
                    .setText(DateUtils.getDuration(trip.getFirstDepartureTime(), trip.getLastArrivalTime()));

            // Transports
            FlowLayout lineLayout = (FlowLayout) trip_layout.findViewById(R.id.lineLayout);

            // for each leg
            for (final Leg leg : trip.legs) {
                if (leg instanceof Trip.Public) {
                    LiberarioUtils.addLineBox(this, lineLayout, ((Public) leg).line);
                } else if (leg instanceof Trip.Individual) {
                    LiberarioUtils.addWalkingBox(this, lineLayout);
                }
            }

            // remember trip in view for onClick event
            trip_layout.setTag(trip);

            // make trip details fold out and in on click
            trip_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    View v = main.getChildAt(main.indexOfChild(view) + 1);

                    if (v != null) {
                        if (v.getVisibility() == View.GONE) {
                            v.setVisibility(View.VISIBLE);
                        } else if (v.getVisibility() == View.VISIBLE) {
                            v.setVisibility(View.GONE);
                        }
                    }
                }

            });
            trip_layout.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View view) {
                    selectTrip(view, trip_layout);
                    return true;
                }
            });

            // show more button for trip details
            final ImageView showMoreView = (ImageView) trip_layout.findViewById(R.id.showMoreView);
            showMoreView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    selectTrip(view, trip_layout);
                }
            });

            // Create container for trip details fragment
            FrameLayout fragmentContainer = new FrameLayout(this);
            fragmentContainer.setId(mContainerId);
            fragmentContainer.setVisibility(View.GONE);

            // Create a new Fragment to be placed in the activity layout
            TripDetailFragment tripDetailFragment = new TripDetailFragment();

            // In case this activity was started with special instructions from an
            // Intent, pass the Intent's extras to the fragment as arguments
            Bundle bundle = new Bundle();
            bundle.putSerializable("de.schildbach.pte.dto.Trip", trip);
            bundle.putSerializable("de.schildbach.pte.dto.Trip.from", from);
            bundle.putSerializable("de.schildbach.pte.dto.Trip.to", to);
            tripDetailFragment.setArguments(bundle);

            // Add the fragment to the 'fragment_container' FrameLayout
            getSupportFragmentManager().beginTransaction().add(mContainerId, tripDetailFragment).commit();

            mContainerId++;

            if (append) {
                trip_layout.addView(LiberarioUtils.getDivider(this));
                main.addView(trip_layout);
                main.addView(fragmentContainer);
            } else {
                trip_layout.addView(LiberarioUtils.getDivider(this), 0);
                main.addView(trip_layout, 0);
                main.addView(fragmentContainer, 1);
            }
        } // end foreach trip

    } else {
        // TODO offer option to query again for trips
    }
}

From source file:com.launcher.silverfish.launcher.homescreen.HomeScreenFragment.java

public void setWidgetVisibility(boolean visible) {
    final FrameLayout widgetArea = (FrameLayout) rootView.findViewById(R.id.widget_area);
    widgetArea.setVisibility(visible ? View.VISIBLE : View.GONE);
}

From source file:com.launcher.silverfish.HomeScreenFragment.java

private void setOnDragListener() {
    rootView.setOnDragListener(new View.OnDragListener() {
        @Override//from   w w w.  j  a  va2 s .c  om
        public boolean onDrag(View view, DragEvent dragEvent) {
            switch (dragEvent.getAction()) {
            case DragEvent.ACTION_DRAG_STARTED:
                // Check that it is a shortcut removal gesture
                ClipDescription cd = dragEvent.getClipDescription();
                if (!cd.getLabel().toString().equals(Constants.DRAG_SHORTCUT_REMOVAL)) {
                    return false;
                }
                break;
            case DragEvent.ACTION_DRAG_ENTERED:
                // Don't do anything
                break;
            case DragEvent.ACTION_DRAG_LOCATION:
                //Don't do anything
                break;
            case DragEvent.ACTION_DROP:

                // If outside of bound, remove the app
                if (Utils.onBottomCenterScreenEdge(getActivity(), dragEvent.getX(), dragEvent.getY())) {
                    String appId = dragEvent.getClipData().getItemAt(0).getText().toString();
                    String appIndex = dragEvent.getClipData().getItemAt(1).getText().toString();
                    removeApp(Integer.parseInt(appIndex), Long.parseLong(appId));
                    updateShortcuts();
                }

                break;
            case DragEvent.ACTION_DRAG_ENDED:
                // Hide the remove-indicator
                FrameLayout rem_ind = (FrameLayout) rootView.findViewById(R.id.remove_indicator);
                rem_ind.setVisibility(View.INVISIBLE);
                break;

            }
            return true;
        }
    });
}

From source file:com.launcher.silverfish.HomeScreenFragment.java

@SuppressWarnings("deprecation")
private void updateShortcuts() {
    int count = appsList.size();
    int size = (int) Math.ceil(Math.sqrt(count));
    shortcutLayout.removeAllViews();/*from  w w w .ja v a2s . c om*/

    if (size == 0) {
        size = 1;
    }

    // Redraw the layout
    shortcutLayout.setSize(size);
    shortcutLayout.requestLayout();
    shortcutLayout.invalidate();

    for (int i = 0; i < appsList.size(); i++) {
        final AppDetail app = appsList.get(i);
        View convertView = getActivity().getLayoutInflater().inflate(R.layout.shortcut_item, null);

        // load the app icon in an async task
        ImageView im = (ImageView) convertView.findViewById(R.id.item_app_icon);
        Utils.loadAppIconAsync(mPacMan, app.name.toString(), im);

        TextView tv = (TextView) convertView.findViewById(R.id.item_app_label);
        tv.setText(app.label);
        shortcutLayout.addView(convertView);

        convertView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent event) {
                switch (MotionEventCompat.getActionMasked(event)) {
                case MotionEvent.ACTION_DOWN:
                    updateTouchDown(event);
                    break;

                case MotionEvent.ACTION_MOVE:
                    tryConsumeSwipe(event);
                    break;

                case MotionEvent.ACTION_UP:
                    // We only want to launch the activity if the touch was not consumed yet!
                    if (!touchConsumed) {
                        Intent i = mPacMan.getLaunchIntentForPackage(app.name.toString());
                        startActivity(i);
                    }
                    break;
                }

                return touchConsumed;
            }
        });

        // start a drag when an app has been long clicked
        final long appId = app.id;
        final int appIndex = i;
        convertView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                String[] mime_types = { ClipDescription.MIMETYPE_TEXT_PLAIN };
                ClipData data = new ClipData(Constants.DRAG_SHORTCUT_REMOVAL, mime_types,
                        new ClipData.Item(Long.toString(appId)));

                data.addItem(new ClipData.Item(Integer.toString(appIndex)));

                View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(
                        view.findViewById(R.id.item_app_icon));

                // "This method was deprecated in API level 24. Use startDragAndDrop()
                // for newer platform versions."
                if (Build.VERSION.SDK_INT < 24) {
                    view.startDrag(data, shadowBuilder, view, 0);
                } else {
                    view.startDragAndDrop(data, shadowBuilder, view, 0);
                }

                // Show removal indicator
                FrameLayout rem_ind = (FrameLayout) rootView.findViewById(R.id.remove_indicator);
                rem_ind.setVisibility(View.VISIBLE);
                AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
                animation.setDuration(500);
                rem_ind.startAnimation(animation);
                return true;

            }
        });
    }
}

From source file:eu.inmite.apps.smsjizdenka.framework.about.BaseAboutFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    FrameLayout vCustomPart = (FrameLayout) view.findViewById(R.id.part_custom);
    ImageView vAppIcon = (ImageView) view.findViewById(R.id.part_app_icon);
    TextView vVersion = (TextView) view.findViewById(R.id.part_version);
    TextView vOpensource = (TextView) view.findViewById(R.id.part_opensource);
    TextView vAppName = (TextView) view.findViewById(R.id.part_app_name);

    if (isVisible(PART_CUSTOM)) {
        View customView = getCustomPart();
        if (customView != null) {
            vCustomPart.setVisibility(View.VISIBLE);
            vCustomPart.addView(customView);
        }//  w  w w .  j av a2 s  .  c o m
    } else {
        vCustomPart.setVisibility(View.GONE);
    }

    if (isVisible(PART_APP_NAME)) {
        vAppName.setText(
                getActivity().getApplicationInfo().loadLabel(getActivity().getPackageManager()).toString());
    } else {
        vAppName.setVisibility(View.GONE);
    }

    if (isVisible(PART_APP_ICON)) {
        if (getAppIcon() != 0) {
            vAppIcon.setImageResource(getAppIcon());
        }
        vAppIcon.setVisibility(View.VISIBLE);
        vAppIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                IntentUtils.openBrowser(getActivity(), "http://www.avast.com");
            }
        });
    } else {
        vAppIcon.setVisibility(View.GONE);
    }

    if (isVisible(PART_VERSION)) {
        vVersion.setVisibility(View.VISIBLE);
        setupVersion(vVersion);
    } else {
        vVersion.setVisibility(View.GONE);
    }

    if (isVisible(PART_OPENSOURCE)) {
        vOpensource.setVisibility(View.VISIBLE);
        setupLink(vOpensource, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                openOpenSourceDialog();
            }
        });
    } else {
        vOpensource.setVisibility(View.GONE);
    }

}

From source file:sg.fxl.topekaport.QuizActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void revealFragmentContainerLollipop(final View clickedView, final FrameLayout fragmentContainer) {
    prepareCircularReveal(clickedView, fragmentContainer);

    ViewCompat.animate(clickedView).scaleX(0).scaleY(0).alpha(0).setInterpolator(interpolator)
            .setListener(new ViewPropertyAnimatorListenerAdapter() {
                @Override/*  w w w.java  2 s.c o  m*/
                public void onAnimationEnd(View view) {
                    fragmentContainer.setVisibility(View.VISIBLE);
                    clickedView.setVisibility(View.GONE);
                }
            }).start();

    fragmentContainer.setVisibility(View.VISIBLE);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(circularReveal).with(colorChange);
    animatorSet.start();
}

From source file:com.google.samples.apps.topeka.activity.QuizActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void revealFragmentContainerLollipop(final View clickedView, final FrameLayout fragmentContainer) {
    prepareCircularReveal(clickedView, fragmentContainer);

    ViewCompat.animate(clickedView).scaleX(0).scaleY(0).alpha(0).setInterpolator(mInterpolator)
            .setListener(new ViewPropertyAnimatorListenerAdapter() {
                @Override//from  w w w  .  j  a va  2s .c o  m
                public void onAnimationEnd(View view) {
                    fragmentContainer.setVisibility(View.VISIBLE);
                    clickedView.setVisibility(View.GONE);
                }
            }).start();

    fragmentContainer.setVisibility(View.VISIBLE);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(mCircularReveal).with(mColorChange);
    animatorSet.start();
}