Example usage for android.view ViewGroup setOnClickListener

List of usage examples for android.view ViewGroup setOnClickListener

Introduction

In this page you can find the example usage for android.view ViewGroup setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.google.android.apps.iosched.ui.SessionDetailFragment.java

private void updateLinksTab(Cursor cursor) {
    ViewGroup container = (ViewGroup) mRootView.findViewById(R.id.links_container);

    // Remove all views but the 'empty' view
    int childCount = container.getChildCount();
    if (childCount > 1) {
        container.removeViews(1, childCount - 1);
    }//from  www.ja  va  2  s  . c o  m

    LayoutInflater inflater = getLayoutInflater(null);

    boolean hasLinks = false;
    for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) {
        final String url = cursor.getString(SessionsQuery.LINKS_INDICES[i]);
        if (!TextUtils.isEmpty(url)) {
            hasLinks = true;
            ViewGroup linkContainer = (ViewGroup) inflater.inflate(R.layout.list_item_session_link, container,
                    false);
            ((TextView) linkContainer.findViewById(R.id.link_text)).setText(SessionsQuery.LINKS_TITLES[i]);
            final int linkTitleIndex = i;
            linkContainer.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    fireLinkEvent(SessionsQuery.LINKS_TITLES[linkTitleIndex]);
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    startActivity(intent);

                }
            });

            container.addView(linkContainer);

            // Create separator
            View separatorView = new ImageView(getActivity());
            separatorView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));
            separatorView.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            container.addView(separatorView);
        }
    }

    container.findViewById(R.id.empty_links).setVisibility(hasLinks ? View.GONE : View.VISIBLE);
}

From source file:com.kaku.weac.activities.MainActivity.java

/**
 * ?//from   www .j av  a 2 s  . com
 */
private void initViews() {
    // ?Tab
    // Tab?
    ViewGroup tab_alarm_clock = (ViewGroup) findViewById(R.id.tab_alarm_clock);
    // Tab?
    ViewGroup tab_wea = (ViewGroup) findViewById(R.id.tab_wea);
    // Tab?
    ViewGroup tab_time = (ViewGroup) findViewById(R.id.tab_time);
    // Tab?
    ViewGroup tab_more = (ViewGroup) findViewById(R.id.tab_more);

    // ?Tab
    tv_alarm_clock = (TextView) findViewById(R.id.tv_alarm_clock);
    tv_wea = (TextView) findViewById(R.id.tv_wea);
    tv_time = (TextView) findViewById(R.id.tv_time);
    tv_more = (TextView) findViewById(R.id.tv_more);

    // Tab
    tab_alarm_clock.setOnClickListener(this);
    tab_wea.setOnClickListener(this);
    tab_time.setOnClickListener(this);
    tab_more.setOnClickListener(this);

    // Tab??
    mFragmentList = new ArrayList<>();
    // Fragment
    AlarmClockFragment mAlarmClockFragment = new AlarmClockFragment();
    // Fragment
    mWeaFragment = new WeaFragment();
    // Fragment
    TimeFragment mTimeFragment = new TimeFragment();
    // Fragment
    MoreFragment mMoreFragment = new MoreFragment();
    mFragmentList.add(mAlarmClockFragment);
    mFragmentList.add(mWeaFragment);
    mFragmentList.add(mTimeFragment);
    mFragmentList.add(mMoreFragment);

    // ViewPager
    mViewPager = (ViewPager) findViewById(R.id.fragment_container);
    mViewPager.setAdapter(new MyFragmentPagerAdapter(mFm));
    // page
    mViewPager.setOffscreenPageLimit(3);
    // TODO???
    mViewPager.addOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int index) {
            setTabSelection(index);

        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }
    });

}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

private void setDaysInCalendar() {
    Calendar auxCalendar = Calendar.getInstance(locale);
    auxCalendar.setTime(currentCalendar.getTime());
    auxCalendar.set(Calendar.DAY_OF_MONTH, 1);
    int firstDayOfMonth = auxCalendar.get(Calendar.DAY_OF_WEEK);
    TextView dayOfMonthText;/*w w  w . j  a va2s . com*/
    ViewGroup dayOfMonthContainer;

    // Calculate dayOfMonthIndex
    int dayOfMonthIndex = getWeekIndex(firstDayOfMonth, auxCalendar);

    for (int i = 1; i <= auxCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); i++, dayOfMonthIndex++) {
        dayOfMonthContainer = (ViewGroup) view.findViewWithTag(DAY_OF_MONTH_CONTAINER + dayOfMonthIndex);
        dayOfMonthText = (TextView) view.findViewWithTag(DAY_OF_MONTH_TEXT + dayOfMonthIndex);
        if (dayOfMonthText == null) {
            break;
        }
        dayOfMonthContainer.setOnClickListener(onDayOfMonthClickListener);
        dayOfMonthText.setVisibility(View.VISIBLE);
        dayOfMonthText.setText(String.valueOf(i));
        dayOfMonthText.setTextColor(ContextCompat.getColor(getContext(), R.color.roboto_calendar_day_of_month));
        dayOfMonthContainer.setBackgroundResource(0);
    }

    // If the last week row has no visible days, hide it or show it in case
    ViewGroup weekRow = (ViewGroup) view.findViewWithTag("weekRow6");
    dayOfMonthText = (TextView) view.findViewWithTag("dayOfMonthText36");
    if (dayOfMonthText.getVisibility() == INVISIBLE) {
        weekRow.setVisibility(GONE);
    } else {
        weekRow.setVisibility(VISIBLE);
    }
    updateBackgroundSelectDays();
}

From source file:org.rm3l.ddwrt.fragments.status.StatusWirelessFragment.java

/**
 * Called when a previously created loader has finished its load.  Note
 * that normally an application is <em>not</em> allowed to commit fragment
 * transactions while in this call, since it can happen after an
 * activity's state is saved.  See {@link android.support.v4.app.FragmentManager#beginTransaction()
 * FragmentManager.openTransaction()} for further discussion on this.
 * <p/>//from  www  .ja v  a2 s.  c o  m
 * <p>This function is guaranteed to be called prior to the release of
 * the last data that was supplied for this Loader.  At this point
 * you should remove all use of the old data (since it will be released
 * soon), but should not do your own release of the data since its Loader
 * owns it and will take care of that.  The Loader will take care of
 * management of its data so you don't have to.  In particular:
 * <p/>
 * <ul>
 * <li> <p>The Loader will monitor for changes to the data, and report
 * them to you through new calls here.  You should not monitor the
 * data yourself.  For example, if the data is a {@link android.database.Cursor}
 * and you place it in a {@link android.widget.CursorAdapter}, use
 * the {@link android.widget.CursorAdapter#CursorAdapter(android.content.Context,
 * android.database.Cursor, int)} constructor <em>without</em> passing
 * in either {@link android.widget.CursorAdapter#FLAG_AUTO_REQUERY}
 * or {@link android.widget.CursorAdapter#FLAG_REGISTER_CONTENT_OBSERVER}
 * (that is, use 0 for the flags argument).  This prevents the CursorAdapter
 * from doing its own observing of the Cursor, which is not needed since
 * when a change happens you will get a new Cursor throw another call
 * here.
 * <li> The Loader will release the data once it knows the application
 * is no longer using it.  For example, if the data is
 * a {@link android.database.Cursor} from a {@link android.content.CursorLoader},
 * you should not call close() on it yourself.  If the Cursor is being placed in a
 * {@link android.widget.CursorAdapter}, you should use the
 * {@link android.widget.CursorAdapter#swapCursor(android.database.Cursor)}
 * method so that the old Cursor is not closed.
 * </ul>
 *
 * @param loader The Loader that has finished.
 * @param tiles  The data generated by the Loader.
 */
@Override
public void onLoadFinished(final Loader<Collection<DDWRTTile>> loader,
        @Nullable final Collection<DDWRTTile> tiles) {
    Log.d(LOG_TAG, "Done loading background task for " + StatusWirelessFragment.class.getCanonicalName());
    this.mIfaceTiles = tiles;

    if (viewGroup == null || tiles == null || tiles.isEmpty()) {
        return;
    }

    final SherlockFragmentActivity sherlockActivity = getSherlockActivity();

    final int themeBackgroundColor = getThemeBackgroundColor(sherlockActivity, router.getUuid());
    final boolean isThemeLight = isThemeLight(sherlockActivity, themeBackgroundColor);

    final LinearLayout dynamicTilessViewGroup = (LinearLayout) viewGroup
            .findViewById(R.id.tiles_container_scrollview_layout_dynamic_items);

    //Remove everything first
    dynamicTilessViewGroup.removeAllViews();

    for (@NotNull
    final DDWRTTile tile : tiles) {
        @Nullable
        final ViewGroup tileViewGroupLayout = tile.getViewGroupLayout();
        if (tileViewGroupLayout == null) {
            continue;
        }

        if (isThemeLight) {
            final View titleView = tileViewGroupLayout.findViewById(tile.getTileTitleViewId());
            if (titleView instanceof TextView) {
                ((TextView) titleView).setTextColor(getResources().getColor(android.R.color.holo_blue_dark));
            }
        }

        tileViewGroupLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));

        //Init loaders for these tiles
        getSherlockActivity().getSupportLoaderManager()
                .initLoader(Long.valueOf(Utils.getNextLoaderId()).intValue(), null, tile);

        //Add row for this iface
        final CardView cardView = new CardView(sherlockActivity);
        cardView.setCardBackgroundColor(themeBackgroundColor);

        cardView.setOnClickListener(tile);
        tileViewGroupLayout.setOnClickListener(tile);

        cardView.addView(tileViewGroupLayout);

        //Remove view prior to adding it again to parent
        dynamicTilessViewGroup.addView(cardView);
    }

    //Make it visible now
    dynamicTilessViewGroup.setVisibility(View.VISIBLE);

}

From source file:com.samsistemas.calendarview.widget.CalendarView.java

/**
 * This method prepare and populate the days in the CalendarView
 *///from   ww  w . j a  v a2 s.c  o m
private void setDaysInCalendar() {
    Calendar calendar = Calendar.getInstance(getLocale());
    calendar.setTime(mCalendar.getTime());
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.setFirstDayOfWeek(mFirstDayOfWeek);
    int firstDayOfMonth = calendar.get(Calendar.DAY_OF_WEEK);

    // Calculate dayOfMonthIndex
    int dayOfMonthIndex = CalendarUtility.getWeekIndex(firstDayOfMonth, calendar);
    int actualMaximum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

    final Calendar startCalendar = (Calendar) calendar.clone();
    //Add required number of days
    startCalendar.add(Calendar.DATE, -(dayOfMonthIndex - 1));
    int monthEndIndex = 42 - (actualMaximum + dayOfMonthIndex - 1);

    DayView dayView;
    ViewGroup dayOfMonthContainer;
    for (int i = 1; i < 43; i++) {
        dayOfMonthContainer = (ViewGroup) mView
                .findViewWithTag(mContext.getString(R.string.day_of_month_container) + i);
        dayView = (DayView) mView.findViewWithTag(mContext.getString(R.string.day_of_month_text) + i);
        if (dayView == null)
            continue;

        //Apply the default styles
        dayOfMonthContainer.setOnClickListener(null);
        dayView.bind(startCalendar.getTime(), getDecoratorsList());
        dayView.setVisibility(View.VISIBLE);

        if (null != getTypeface()) {
            dayView.setTypeface(getTypeface());
        }

        if (CalendarUtility.isSameMonth(calendar, startCalendar)) {
            dayOfMonthContainer.setOnClickListener(onDayOfMonthClickListener);
            dayOfMonthContainer.setOnLongClickListener(onDayOfMonthLongClickListener);
            dayView.setBackgroundColor(mCalendarBackgroundColor);
            mIsCommonDay = true;
            if (totalDayOfWeekend().length != 0) {
                for (int weekend : totalDayOfWeekend()) {
                    if (startCalendar.get(Calendar.DAY_OF_WEEK) == weekend) {
                        dayView.setTextColor(mWeekendColor);
                        mIsCommonDay = false;
                    }
                }
            }

            if (mIsCommonDay) {
                dayView.setTextColor(mDayOfWeekTextColor);
            }
        } else {
            dayView.setBackgroundColor(mDisabledDayBackgroundColor);
            dayView.setTextColor(mDisabledDayTextColor);

            if (!isOverflowDateVisible())
                dayView.setVisibility(View.GONE);
            else if (i >= 36 && ((float) monthEndIndex / 7.0f) >= 1) {
                dayView.setVisibility(View.GONE);
            }
        }
        dayView.decorate();

        //Set the current day color
        if (mCalendar.get(Calendar.MONTH) == startCalendar.get(Calendar.MONTH))
            setCurrentDay(mCalendar.getTime());

        startCalendar.add(Calendar.DATE, 1);
        dayOfMonthIndex++;
    }

    // If the last week row has no visible days, hide it or show it in case
    ViewGroup weekRow = (ViewGroup) mView.findViewWithTag("weekRow6");
    dayView = (DayView) mView.findViewWithTag("dayOfMonthText36");
    if (dayView.getVisibility() != VISIBLE) {
        weekRow.setVisibility(GONE);
    } else {
        weekRow.setVisibility(VISIBLE);
    }
}

From source file:com.app.blockydemo.ui.adapter.BrickAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (draggedBrick != null && dragTargetPosition == position) {
        return insertionView;
    }//  w  w  w  . j  a v a 2 s .  co m
    listItemCount = position + 1;

    Object item = getItem(position);

    if (item instanceof ScriptBrick && (!initInsertedBrick || position != positionOfInsertedBrick)) {
        View scriptBrickView = ((Brick) item).getView(context, position, this);
        if (draggedBrick == null) {
            scriptBrickView.setOnClickListener(this);
        }
        return scriptBrickView;
    }

    View currentBrickView;
    // dirty HACK
    // without the footer, position can be 0, and list.get(-1) caused an Indexoutofboundsexception
    // no clean solution was found
    if (position == 0) {
        if (item instanceof AllowedAfterDeadEndBrick && brickList.get(position) instanceof DeadEndBrick) {
            currentBrickView = ((AllowedAfterDeadEndBrick) item).getNoPuzzleView(context, position, this);
        } else {
            currentBrickView = ((Brick) item).getView(context, position, this);
        }
    } else {
        if (item instanceof AllowedAfterDeadEndBrick && brickList.get(position - 1) instanceof DeadEndBrick) {
            currentBrickView = ((AllowedAfterDeadEndBrick) item).getNoPuzzleView(context, position, this);
        } else {
            currentBrickView = ((Brick) item).getView(context, position, this);
        }
    }

    // this one is working but causes null pointer exceptions on movement and control bricks?!
    //      currentBrickView.setOnLongClickListener(longClickListener);

    // Hack!!!
    // if wrapper isn't used the longClick event won't be triggered
    ViewGroup wrapper = (ViewGroup) View.inflate(context, R.layout.brick_wrapper, null);
    if (currentBrickView.getParent() != null) {
        ((ViewGroup) currentBrickView.getParent()).removeView(currentBrickView);
    }

    wrapper.addView(currentBrickView);
    if (draggedBrick == null) {
        if ((selectMode == ListView.CHOICE_MODE_NONE)) {
            wrapper.setOnClickListener(this);
            if (!(item instanceof DeadEndBrick)) {
                wrapper.setOnLongClickListener(dragAndDropListView);
            }
        }
    }

    if (position == positionOfInsertedBrick && initInsertedBrick && (selectMode == ListView.CHOICE_MODE_NONE)) {
        initInsertedBrick = false;
        addingNewBrick = true;
        dragAndDropListView.setInsertedBrick(position);

        dragAndDropListView.setDraggingNewBrick();
        dragAndDropListView.onLongClick(currentBrickView);

        return insertionView;
    }

    if (animatedBricks.contains(brickList.get(position))) {
        Animation animation = AnimationUtils.loadAnimation(context, R.anim.blink);
        wrapper.startAnimation(animation);
        animatedBricks.remove(brickList.get(position));
    }
    return wrapper;
}

From source file:com.marcohc.robotocalendar.RobotoCalendarView.java

private void initializeDaysOfMonthLayout() {

    TextView dayOfMonthText;//from w w w.j  a v a2s.c  om
    //        View firstUnderline;
    //        View secondUnderline;
    ViewGroup dayOfMonthContainer;
    ViewGroup dayOfMonthBackground;

    for (int i = 1; i < 43; i++) {

        dayOfMonthContainer = (ViewGroup) view.findViewWithTag(DAY_OF_MONTH_CONTAINER + i);
        dayOfMonthBackground = (ViewGroup) view.findViewWithTag(DAY_OF_MONTH_BACKGROUND + i);
        dayOfMonthText = (TextView) view.findViewWithTag(DAY_OF_MONTH_TEXT + i);
        //            firstUnderline = view.findViewWithTag(FIRST_UNDERLINE + i);
        //            secondUnderline = view.findViewWithTag(SECOND_UNDERLINE + i);

        dayOfMonthText.setVisibility(View.INVISIBLE);
        //            firstUnderline.setVisibility(View.INVISIBLE);
        //            secondUnderline.setVisibility(View.INVISIBLE);

        // Apply styles
        dayOfMonthText.setBackgroundResource(android.R.color.transparent);
        dayOfMonthContainer.setBackgroundResource(android.R.color.transparent);
        dayOfMonthContainer.setOnClickListener(null);
        dayOfMonthBackground.setBackgroundResource(android.R.color.transparent);
    }
}

From source file:com.willowtreeapps.spurceexampleapp.fragments.ControlsFragment.java

@Nullable
@Override/*from w  w  w . j a  v  a  2 s  .  c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.controls_fragment, container, false);

    parent = (GridLayout) ((SpruceActivity) getActivity()).parent;
    children = ((SpruceActivity) getActivity()).children;
    sortDropDown = ((SpruceActivity) getActivity()).sortDropDown;

    linearRadioGroup = (RadioGroup) rootView.findViewById(R.id.directional_radio_group);
    corneredRadioGroup = (RadioGroup) rootView.findViewById(R.id.cornered_radio_group);
    positionalRadioGroup = (RadioGroupGridLayout) rootView.findViewById(R.id.positional_radio_group);
    RadioGroup verticalWeightedRadioGroup = (RadioGroup) rootView
            .findViewById(R.id.vertical_weighted_radio_group);
    RadioGroup horizontalWeightedRadioGroup = (RadioGroup) rootView
            .findViewById(R.id.horizontal_weighted_radio_group);
    verticalWeightLayout = (LinearLayout) rootView.findViewById(R.id.vertical_weight);
    horizontalWeightLayout = (LinearLayout) rootView.findViewById(R.id.horizontal_weight);
    linearReversed = (CheckBox) rootView.findViewById(R.id.linear_reversed);
    seekBar = (SeekBar) rootView.findViewById(R.id.animation_seek);
    animationEndText = (TextView) rootView.findViewById(R.id.animation_end);
    seekBarTitle = (TextView) rootView.findViewById(R.id.seek_bar_title);
    codeSample = (EditText) rootView.findViewById(R.id.code_sample);

    animators = new Animator[] { DefaultAnimations.shrinkAnimator(parent, /*duration=*/800),
            DefaultAnimations.fadeInAnimator(parent, /*duration=*/800) };

    View.OnClickListener click = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            resetChildViewsAndStartSort();
        }
    };
    container.setOnClickListener(click);
    parent.setOnClickListener(click);

    sortDropDown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case CORNERED_SORT:
            case INLINE_SORT:
                linearRadioGroup.setVisibility(View.GONE);
                linearReversed.setVisibility(View.VISIBLE);
                positionalRadioGroup.setVisibility(View.GONE);
                verticalWeightLayout.setVisibility(View.GONE);
                horizontalWeightLayout.setVisibility(View.GONE);
                corneredRadioGroup.setVisibility(View.VISIBLE);
                break;
            case LINEAR_SORT:
                linearRadioGroup.setVisibility(View.VISIBLE);
                linearReversed.setVisibility(View.VISIBLE);
                positionalRadioGroup.setVisibility(View.GONE);
                verticalWeightLayout.setVisibility(View.GONE);
                horizontalWeightLayout.setVisibility(View.GONE);
                corneredRadioGroup.setVisibility(View.GONE);
                break;
            case CONTINUOUS_SORT:
            case RADIAL_SORT:
                positionalRadioGroup.setVisibility(View.VISIBLE);
                verticalWeightLayout.setVisibility(View.GONE);
                horizontalWeightLayout.setVisibility(View.GONE);
                linearReversed.setVisibility(View.VISIBLE);
                linearRadioGroup.setVisibility(View.GONE);
                corneredRadioGroup.setVisibility(View.GONE);
                break;
            case CONTINUOUS_WEIGHTED_SORT:
                positionalRadioGroup.setVisibility(View.VISIBLE);
                verticalWeightLayout.setVisibility(View.VISIBLE);
                horizontalWeightLayout.setVisibility(View.VISIBLE);
                linearReversed.setVisibility(View.VISIBLE);
                linearRadioGroup.setVisibility(View.GONE);
                corneredRadioGroup.setVisibility(View.GONE);
                break;
            default:
                linearReversed.setVisibility(View.GONE);
                positionalRadioGroup.setVisibility(View.GONE);
                verticalWeightLayout.setVisibility(View.GONE);
                horizontalWeightLayout.setVisibility(View.GONE);
                linearRadioGroup.setVisibility(View.GONE);
                corneredRadioGroup.setVisibility(View.GONE);
                break;
            }
            resetChildViewsAndStartSort();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    // set default vertical weight
    verticalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT;
    verticalWeightedRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
            switch (checkedId) {
            case R.id.vertical_light:
                verticalWeight = ContinuousWeightedSort.LIGHT_WEIGHT;
                break;
            case R.id.vertical_medium:
                verticalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT;
                break;
            case R.id.vertical_heavy:
                verticalWeight = ContinuousWeightedSort.HEAVY_WEIGHT;
                break;
            }
            resetChildViewsAndStartSort();
        }
    });

    // set default horizontal weight
    horizontalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT;
    horizontalWeightedRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
            switch (checkedId) {
            case R.id.horizontal_light:
                horizontalWeight = ContinuousWeightedSort.LIGHT_WEIGHT;
                break;
            case R.id.horizontal_medium:
                horizontalWeight = ContinuousWeightedSort.MEDIUM_WEIGHT;
                break;
            case R.id.horizontal_heavy:
                horizontalWeight = ContinuousWeightedSort.HEAVY_WEIGHT;
                break;
            }
            resetChildViewsAndStartSort();
        }
    });

    // set default direction
    direction = LinearSort.Direction.BOTTOM_TO_TOP;
    linearRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
            switch (checkedId) {
            case R.id.bottom_to_top:
                direction = LinearSort.Direction.BOTTOM_TO_TOP;
                break;
            case R.id.top_to_bottom:
                direction = LinearSort.Direction.TOP_TO_BOTTOM;
                break;
            case R.id.left_to_right:
                direction = LinearSort.Direction.LEFT_TO_RIGHT;
                break;
            case R.id.right_to_left:
                direction = LinearSort.Direction.RIGHT_TO_LEFT;
                break;
            }
            resetChildViewsAndStartSort();
        }
    });

    // set default corner
    corner = CorneredSort.Corner.TOP_LEFT;
    corneredRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
            switch (checkedId) {
            case R.id.top_left:
                corner = CorneredSort.Corner.TOP_LEFT;
                break;
            case R.id.top_right:
                corner = CorneredSort.Corner.TOP_RIGHT;
                break;
            case R.id.bottom_left:
                corner = CorneredSort.Corner.BOTTOM_LEFT;
                break;
            case R.id.bottom_right:
                corner = CorneredSort.Corner.BOTTOM_RIGHT;
                break;
            }
            resetChildViewsAndStartSort();
        }
    });

    linearReversed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            resetChildViewsAndStartSort();
        }
    });

    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            resetChildViewsAndStartSort();
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    positionalRadioGroup.setGroupChildChangedListener(this);
    resetChildViewsAndStartSort();

    return rootView;
}

From source file:com.vuze.android.remote.fragment.TorrentListFragment.java

private void setupExpando(View view, int id_header, int id_body) {
    ViewGroup vgHeader = (ViewGroup) view.findViewById(id_header);
    final ViewGroup vgBody = (ViewGroup) view.findViewById(id_body);
    if (vgBody == null || vgHeader == null) {
        return;/*from w  w  w  . j  a  v  a2s .  co  m*/
    }
    listHeaderViewGroups.add(vgHeader);
    vgHeader.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            sidelistInFocus = true;
            // Consume touch event if user clicked the active sidelist view to
            // expand it
            // Otherwise, the active sidelist content would be collaped
            return expandSideListWidth(true) && sidebarViewActive == vgBody;
        }
    });
    vgHeader.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!sidelistIsExpanded && canSideListExpand()) {
                return;
            }
            boolean same = sidebarViewActive == vgBody;
            if (sidebarViewActive != null) {
                sidebarViewActive.setVisibility(View.GONE);
            }
            if (same) {
                sidebarViewActive = null;
                if (hideUnselectedSideHeaders) {
                    for (ViewGroup vgHeader : listHeaderViewGroups) {
                        vgHeader.setVisibility(View.VISIBLE);
                    }
                }
            } else {
                vgBody.setVisibility(View.VISIBLE);
                sidebarViewActive = vgBody;

                if (hideUnselectedSideHeaders) {
                    for (ViewGroup vgHeader : listHeaderViewGroups) {
                        vgHeader.setVisibility(vgHeader == v ? View.VISIBLE : View.GONE);
                    }
                }
            }

            if (tvSideFilterText != null && listSideFilter != null) {
                tvSideFilterText.setVisibility(tvSideFilterText.getText().length() == 0
                        && ((View) listSideFilter).getVisibility() == View.GONE ? View.GONE : View.VISIBLE);
            }

        }
    });
}

From source file:jp.co.rediscovery.firstflight.BaseAutoPilotFragment.java

@Override
protected View internalCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState, final int layout_id) {
    Bundle args = savedInstanceState;//from w  w w  .  j a  va2  s . com
    if (args == null) {
        args = getArguments();
    }
    mPrefName = args.getString(KEY_PREF_NAME_AUTOPILOT, mPrefName);
    mMode = args.getInt(KEY_AUTOPILOT_MODE, mMode);
    mPref = getActivity().getSharedPreferences(mPrefName, 0);
    // ???
    mCameraAutoWhiteBlance = getInt(mPref, KEY_CAMERA_WHITE_BLANCE, DEFAULT_CAMERA_WHITE_BLANCE);
    mCameraExposure = mPref.getFloat(KEY_CAMERA_EXPOSURE, DEFAULT_CAMERA_EXPOSURE);
    mCameraSaturation = mPref.getFloat(KEY_CAMERA_SATURATION, DEFAULT_CAMERA_SATURATION);
    mCameraPan = getInt(mPref, KEY_CAMERA_PAN, DEFAULT_CAMERA_PAN);
    mCameraTilt = getInt(mPref, KEY_CAMERA_TILT, DEFAULT_CAMERA_TILT);
    //
    mExposure = mPref.getFloat(KEY_EXPOSURE, DEFAULT_EXPOSURE);
    mSaturation = mPref.getFloat(KEY_SATURATION, DEFAULT_SATURATION);
    mBrightness = mPref.getFloat(KEY_BRIGHTNESS, DEFAULT_BRIGHTNESS);
    mBinarizeThreshold = mPref.getFloat(KEY_BINARIZE_THRESHOLD, DEFAULT_BINARIZE_THRESHOLD);
    //
    mExtractH = mPref.getFloat(KEY_EXTRACT_H, DEFAULT_EXTRACT_H);
    mExtractRangeH = mPref.getFloat(KEY_EXTRACT_RANGE_H, DEFAULT_EXTRACT_RANGE_H);
    mExtractS = mPref.getFloat(KEY_EXTRACT_S, DEFAULT_EXTRACT_S);
    mExtractRangeS = mPref.getFloat(KEY_EXTRACT_RANGE_S, DEFAULT_EXTRACT_RANGE_S);
    mExtractV = mPref.getFloat(KEY_EXTRACT_V, DEFAULT_EXTRACT_V);
    mExtractRangeV = mPref.getFloat(KEY_EXTRACT_RANGE_V, DEFAULT_EXTRACT_RANGE_V);
    //
    mEnableGLESExtraction = mPref.getBoolean(KEY_ENABLE_EXTRACTION, DEFAULT_ENABLE_EXTRACTION);
    //
    mAreaLimitMin = mPref.getFloat(KEY_AREA_LIMIT_MIN, DEFAULT_AREA_LIMIT_MIN);
    mAspectLimitMin = mPref.getFloat(KEY_ASPECT_LIMIT_MIN, DEFAULT_ASPECT_LIMIT_MIN);
    mAreaErrLimit1 = mPref.getFloat(KEY_AREA_ERR_LIMIT1, DEFAULT_AREA_ERR_LIMIT1);
    mAreaErrLimit2 = mPref.getFloat(KEY_AREA_ERR_LIMIT2, DEFAULT_AREA_ERR_LIMIT2);
    //
    mTraceAttitudeYaw = mPref.getFloat(KEY_TRACE_ATTITUDE_YAW, DEFAULT_TRACE_ATTITUDE_YAW);
    mTraceSpeed = mPref.getFloat(KEY_TRACE_SPEED, DEFAULT_TRACE_SPEED);
    mTraceAltitudeEnabled = mPref.getBoolean(KEY_TRACE_ALTITUDE_ENABLED, DEFAULT_TRACE_ALTITUDE_ENABLED);
    mTraceAltitude = Math.min(mPref.getFloat(KEY_TRACE_ALTITUDE, DEFAULT_TRACE_ALTITUDE),
            mFlightController.getMaxAltitude().current());
    mTraceDirectionalReverseBias = mPref.getFloat(KEY_TRACE_DIR_REVERSE_BIAS, DEFAULT_TRACE_DIR_REVERSE_BIAS);
    mTraceMovingAveTap = mPref.getInt(KEY_TRACE_MOVING_AVE_TAP, DEFAULT_TRACE_MOVING_AVE_TAP);
    mTraceDecayRate = mPref.getFloat(KEY_TRACE_DECAY_RATE, DEFAULT_TRACE_DECAY_RATE);
    mTraceSensitivity = mPref.getFloat(KEY_TRACE_SENSITIVITY, DEFAULT_TRACE_SENSITIVITY);

    // View???
    mActionViews.clear();

    final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_pilot_auto, container, false);

    final ViewGroup controllerFrame = (ViewGroup) rootView.findViewById(R.id.controller_frame);
    controllerFrame.setOnClickListener(mOnClickListener);

    // ?
    mTopPanel = rootView.findViewById(R.id.top_panel);
    mTopPanel.setOnClickListener(mOnClickListener);
    mTopPanel.setOnLongClickListener(mOnLongClickListener);
    mActionViews.add(mTopPanel);
    // 
    mFlatTrimBtn = (ImageButton) rootView.findViewById(R.id.flat_trim_btn);
    mFlatTrimBtn.setOnClickListener(mOnClickListener);
    mFlatTrimBtn.setOnLongClickListener(mOnLongClickListener);
    mActionViews.add(mFlatTrimBtn);
    // 
    mConfigShowBtn = (ImageButton) rootView.findViewById(R.id.config_show_btn);
    mConfigShowBtn.setOnClickListener(mOnClickListener);
    //
    mBatteryLabel = (TextView) rootView.findViewById(R.id.batteryLabel);
    mAlertMessage = (TextView) rootView.findViewById(R.id.alert_message);
    mAlertMessage.setVisibility(View.INVISIBLE);

    // ?
    // ??
    //      mBottomPanel = rootView.findViewById(R.id.bottom_panel);
    mEmergencyBtn = (ImageButton) rootView.findViewById(R.id.emergency_btn);
    mEmergencyBtn.setOnClickListener(mOnClickListener);
    // ?
    mTakeOnOffBtn = (ImageButton) rootView.findViewById(R.id.take_onoff_btn);
    mTakeOnOffBtn.setOnClickListener(mOnClickListener);
    mTakeOnOffBtn.setOnLongClickListener(mOnLongClickListener);
    mActionViews.add(mTakeOnOffBtn);

    // ??
    mRightSidePanel = rootView.findViewById(R.id.right_side_panel);
    mActionViews.add(mRightSidePanel);

    // 
    mCopilotBtn = (ImageButton) rootView.findViewById(R.id.copilot_btn);
    mCopilotBtn.setOnClickListener(mOnClickListener);
    mCopilotBtn.setVisibility(mController instanceof ISkyController ? View.VISIBLE : View.GONE);

    // ?
    mStillCaptureBtn = (ImageButton) rootView.findViewById(R.id.still_capture_btn);
    mStillCaptureBtn.setOnClickListener(mOnClickListener);

    // 
    mVideoRecordingBtn = (ImageButton) rootView.findViewById(R.id.video_capture_btn);
    mVideoRecordingBtn.setOnClickListener(mOnClickListener);

    // 
    mTraceButton = (ImageButton) rootView.findViewById(R.id.trace_btn);
    mTraceButton.setOnClickListener(mOnClickListener);
    mTraceButton.setOnLongClickListener(mOnLongClickListener);

    if (mController instanceof ICameraController) {
        ((ICameraController) mController).setCameraControllerListener(null);
        ((ICameraController) mController).sendCameraOrientation(0, 0);
    }

    mVideoView = (VideoView) rootView.findViewById(R.id.drone_view);
    mVideoView.setOnClickListener(mOnClickListener);

    mDetectView = (SurfaceView) rootView.findViewById(R.id.detect_view);
    mDetectView.setVisibility(View.VISIBLE);
    //--------------------------------------------------------------------------------
    final ConfigPagerAdapter adapter = new ConfigPagerAdapter(inflater);
    final ViewPager pager = (ViewPager) rootView.findViewById(R.id.pager);
    pager.setAdapter(adapter);
    //
    mTraceTv1 = (TextView) rootView.findViewById(R.id.trace1_tv);
    mTraceTv2 = (TextView) rootView.findViewById(R.id.trace2_tv);
    mTraceTv3 = (TextView) rootView.findViewById(R.id.trace3_tv);
    //
    mCpuLoadTv = (TextView) rootView.findViewById(R.id.cpu_load_textview);
    //
    mFpsSrcTv = (TextView) rootView.findViewById(R.id.fps_src_textview);
    mFpsSrcTv.setText(null);
    mFpsResultTv = (TextView) rootView.findViewById(R.id.fps_result_textview);
    mFpsResultTv.setText(null);

    return rootView;
}