Example usage for android.view View getParent

List of usage examples for android.view View getParent

Introduction

In this page you can find the example usage for android.view View getParent.

Prototype

public final ViewParent getParent() 

Source Link

Document

Gets the parent of this view.

Usage

From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java

public void grabsamcounts() {

    int[] samcount = new int[view.maxelcs];
    for (int h = 0; h < samcount.length; h++) {
        samcount[h] = 0;//from   w w  w .j a  v a  2 s  .  c  o  m
    }

    int rownum = 0;

    try {
        View firstview;
        TableRow tablerow;
        TableLayout tablelayout;
        LinearLayout linearlayout;

        firstview = Tabs1.mcrentries[Tabs1.METERINGLIST][rownum][u.cellx("B1")];
        tablerow = ((TableRow) firstview.getParent());
        tablelayout = ((TableLayout) tablerow.getParent());
        linearlayout = (LinearLayout) tablelayout.getParent();

        Log.d("tablelayoutchild count", u.s(linearlayout.getChildCount()));
        for (int k = 0; k < linearlayout.getChildCount(); k++) {

            int elcnum = u.i(Tabs1.mcrentries[Tabs1.METERINGLIST][k][u.cellx("B1")].getText().toString());

            for (int y = 0; y < view.i; y++) {
                if ((view.ITEMtype[y] == view.TYPE_ELC) && view.ELCdisplaynumber[y] == elcnum) {
                    samcount[elcnum]++;
                }
            }
        }
        for (int y = 0; y < view.i; y++) {
            if ((view.ITEMtype[y] == view.TYPE_ELC)) {
                view.ITEMsamscount[y] = samcount[view.ELCdisplaynumber[y]];
            }
        }
    } catch (Throwable e) {

    }
}

From source file:com.anysoftkeyboard.AnySoftKeyboard.java

@Override
public void setCandidatesView(@NonNull View view) {
    super.setCandidatesView(view);
    mCandidatesParent = view.getParent() instanceof View ? (View) view.getParent() : null;

    mCandidateView = (CandidateView) view.findViewById(R.id.candidates);
    mCandidateView.setService(this);
    setCandidatesViewShown(false);/*from   ww  w  . j av a2  s  .co  m*/

    final KeyboardTheme theme = KeyboardThemeFactory.getCurrentKeyboardTheme(getApplicationContext());
    final TypedArray a = theme.getPackageContext().obtainStyledAttributes(null,
            R.styleable.AnyKeyboardViewTheme, 0, theme.getThemeResId());
    int closeTextColor = ContextCompat.getColor(this, R.color.candidate_other);
    float fontSizePixel = getResources().getDimensionPixelSize(R.dimen.candidate_font_height);
    Drawable suggestionCloseDrawable = null;
    try {
        closeTextColor = a.getColor(R.styleable.AnyKeyboardViewTheme_suggestionOthersTextColor, closeTextColor);
        fontSizePixel = a.getDimension(R.styleable.AnyKeyboardViewTheme_suggestionTextSize, fontSizePixel);
        suggestionCloseDrawable = a.getDrawable(R.styleable.AnyKeyboardViewTheme_suggestionCloseImage);
    } catch (Exception e) {
        e.printStackTrace();
    }
    a.recycle();

    mCandidateCloseText = (TextView) view.findViewById(R.id.close_suggestions_strip_text);
    ImageView closeIcon = (ImageView) view.findViewById(R.id.close_suggestions_strip_icon);
    if (suggestionCloseDrawable != null)
        closeIcon.setImageDrawable(suggestionCloseDrawable);

    closeIcon.setOnClickListener(new OnClickListener() {
        // two seconds is enough.
        private static final long DOUBLE_TAP_TIMEOUT = 2 * 1000 - 50;

        public void onClick(View v) {
            mKeyboardHandler.removeMessages(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT);
            mCandidateCloseText.setVisibility(View.VISIBLE);
            mCandidateCloseText.startAnimation(
                    AnimationUtils.loadAnimation(getApplicationContext(), R.anim.close_candidates_hint_in));
            mKeyboardHandler.sendMessageDelayed(
                    mKeyboardHandler.obtainMessage(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT),
                    DOUBLE_TAP_TIMEOUT);
        }
    });

    mCandidateCloseText.setTextColor(closeTextColor);
    mCandidateCloseText.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSizePixel);
    mCandidateCloseText.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mKeyboardHandler.removeMessages(KeyboardUIStateHandler.MSG_REMOVE_CLOSE_SUGGESTIONS_HINT);
            mCandidateCloseText.setVisibility(View.GONE);
            abortCorrectionAndResetPredictionState(true);
        }
    });
}

From source file:com.androidquery.AQuery.java

/**
 * Return a new AQuery object that uses the found parent as a root.
 * If no parent with matching id is found, operating view will be null and isExist() will return false.
 * //from w w w .j a v  a2 s  .c  o  m
 *
 * @param id the parent id
 * @return new AQuery object
 */
public AQuery parent(int id) {

    View node = view;
    View result = null;

    while (node != null) {
        if (node.getId() == id) {
            result = node;
            break;
        }
        ViewParent p = node.getParent();
        if (!(p instanceof View))
            break;
        node = (View) p;
    }

    return create(result);
}

From source file:com.marlonjones.voidlauncher.CellLayout.java

public void markCellsAsOccupiedForView(View view) {
    if (view == null || view.getParent() != mShortcutsAndWidgets)
        return;//from ww  w. j  a va 2s. co  m
    LayoutParams lp = (LayoutParams) view.getLayoutParams();
    mOccupied.markCells(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, true);
}

From source file:com.marlonjones.voidlauncher.CellLayout.java

public void markCellsAsUnoccupiedForView(View view) {
    if (view == null || view.getParent() != mShortcutsAndWidgets)
        return;//from w  ww .  j  ava  2  s.co  m
    LayoutParams lp = (LayoutParams) view.getLayoutParams();
    mOccupied.markCells(lp.cellX, lp.cellY, lp.cellHSpan, lp.cellVSpan, false);
}

From source file:android.support.designox.widget.CoordinatorLayout.java

/**
 * Check whether two views overlap each other. The views need to be descendants of this
 * {@link CoordinatorLayout} in the view hierarchy.
 *
 * @param first first child view to test
 * @param second second child view to test
 * @return true if both views are visible and overlap each other
 *///from ww  w. j a v  a 2 s . c o m
public boolean doViewsOverlap(View first, View second) {
    if (first.getVisibility() == VISIBLE && second.getVisibility() == VISIBLE) {
        final Rect firstRect = mTempRect1;
        getChildRect(first, first.getParent() != this, firstRect);
        final Rect secondRect = mTempRect2;
        getChildRect(second, second.getParent() != this, secondRect);

        return !(firstRect.left > secondRect.right || firstRect.top > secondRect.bottom
                || firstRect.right < secondRect.left || firstRect.bottom < secondRect.top);
    }
    return false;
}

From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java

@Override
public void onGUICreate() {
    this.clearViews();

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());

    // change shutter icon
    isRecording = false;//  w  w w  . ja  v a2s  .  c o  m
    prefs.edit().putBoolean("videorecording", false).commit();

    ApplicationScreen.getGUIManager().setShutterIcon(ShutterButton.RECORDER_START);

    onPreferenceCreate((PreferenceFragment) null);

    setupVideoSize(prefs);

    List<View> specialView = new ArrayList<View>();
    RelativeLayout specialLayout = (RelativeLayout) ApplicationScreen.instance
            .findViewById(R.id.specialPluginsLayout2);
    for (int i = 0; i < specialLayout.getChildCount(); i++)
        specialView.add(specialLayout.getChildAt(i));

    for (int j = 0; j < specialView.size(); j++) {
        View view = specialView.get(j);
        int view_id = view.getId();
        if (view_id == this.mRecordingTimeView.getId() || view_id == this.modeSwitcher.getId()) {
            if (view.getParent() != null)
                ((ViewGroup) view.getParent()).removeView(view);

            specialLayout.removeView(view);
        }
    }

    {
        final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);

        params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

        ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3))
                .removeView(this.modeSwitcher);
        ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout3))
                .addView(this.modeSwitcher, params);

        this.modeSwitcher.setLayoutParams(params);
    }

    // Calculate right sizes for plugin's controls
    DisplayMetrics metrics = new DisplayMetrics();
    ApplicationScreen.instance.getWindowManager().getDefaultDisplay().getMetrics(metrics);
    float fScreenDensity = metrics.density;

    int iIndicatorSize = (int) (ApplicationScreen.getMainContext().getResources()
            .getInteger(R.integer.infoControlHeight) * fScreenDensity);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(iIndicatorSize, iIndicatorSize);
    int topMargin = ApplicationScreen.instance.findViewById(R.id.paramsLayout).getHeight()
            + (int) ApplicationScreen.getAppResources().getDimension(R.dimen.viewfinderViewsMarginTop);
    params.setMargins((int) (2 * ApplicationScreen.getGUIManager().getScreenDensity()), topMargin, 0, 0);

    params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);

    ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout2))
            .addView(this.mRecordingTimeView, params);

    this.mRecordingTimeView.setLayoutParams(params);

    LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater();
    buttonsLayout = inflator.inflate(R.layout.plugin_capture_video_layout, null, false);
    buttonsLayout.setVisibility(View.VISIBLE);

    timeLapseButton = (RotateImageView) buttonsLayout.findViewById(R.id.buttonTimeLapse);
    pauseVideoButton = (RotateImageView) ApplicationScreen.instance.findViewById(R.id.buttonVideoPause);
    stopVideoButton = (RotateImageView) ApplicationScreen.instance.findViewById(R.id.buttonVideoStop);

    snapshotSupported = CameraController.isVideoSnapshotSupported();
    takePictureButton = (RotateImageView) buttonsLayout.findViewById(R.id.buttonCaptureImage);

    timeLapseButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            TimeLapseDialog();
        }
    });

    pauseVideoButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pauseVideoRecording();
        }
    });

    stopVideoButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            onShutterClick();
        }
    });

    if (snapshotSupported) {
        takePictureButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                takePicture();
            }

        });
    }

    for (int j = 0; j < specialView.size(); j++) {
        View view = specialView.get(j);
        int view_id = view.getId();
        if (view_id == this.buttonsLayout.getId()) {
            if (view.getParent() != null)
                ((ViewGroup) view.getParent()).removeView(view);

            specialLayout.removeView(view);
        }
    }

    params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.videobuttons_size);

    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

    ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout2))
            .addView(this.buttonsLayout, params);

    this.buttonsLayout.setLayoutParams(params);

    if (snapshotSupported) {
        takePictureButton.setOrientation(ApplicationScreen.getGUIManager().getLayoutOrientation());
        takePictureButton.invalidate();
        // takePictureButton.requestLayout();
        displayTakePicture = true;
    } else {
        takePictureButton.setVisibility(View.GONE);
        displayTakePicture = false;
    }

    timeLapseButton.setOrientation(ApplicationScreen.getGUIManager().getLayoutOrientation());

    if (this.modeDRO() || CameraController.isRemoteCamera()) {
        takePictureButton.setVisibility(View.GONE);
        timeLapseButton.setVisibility(View.GONE);
    }

    if (prefs.getBoolean("videoStartStandardPref", false)) {
        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    PluginManager.getInstance().onPause(true);
                    Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
                    ApplicationScreen.instance.startActivity(intent);
                    break;

                case DialogInterface.BUTTON_NEGATIVE:
                    // No button clicked
                    break;
                default:
                    break;
                }
            }
        };

        AlertDialog.Builder builder = new AlertDialog.Builder(ApplicationScreen.instance);
        builder.setMessage("You selected to start standard camera. Start camera?")
                .setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener)
                .show();
    }

    rotatorLayout = inflator.inflate(R.layout.plugin_capture_video_lanscaperotate_layout, null, false);
    rotatorLayout.setVisibility(View.VISIBLE);
    initRotateNotification(videoOrientation);

    List<View> specialViewRotator = new ArrayList<View>();
    RelativeLayout specialLayoutRotator = (RelativeLayout) ApplicationScreen.instance
            .findViewById(R.id.specialPluginsLayout);
    for (int i = 0; i < specialLayoutRotator.getChildCount(); i++)
        specialViewRotator.add(specialLayoutRotator.getChildAt(i));

    for (int j = 0; j < specialViewRotator.size(); j++) {
        View view = specialViewRotator.get(j);
        int view_id = view.getId();
        int layout_id = this.rotatorLayout.getId();
        if (view_id == layout_id) {
            if (view.getParent() != null)
                ((ViewGroup) view.getParent()).removeView(view);

            specialLayoutRotator.removeView(view);
        }
    }

    RelativeLayout.LayoutParams paramsRotator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    paramsRotator.height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.gui_element_2size);

    paramsRotator.addRule(RelativeLayout.CENTER_IN_PARENT);

    ((RelativeLayout) ApplicationScreen.instance.findViewById(R.id.specialPluginsLayout))
            .addView(this.rotatorLayout, paramsRotator);
}

From source file:com.android.calendar.event.EditEventView.java

@Override
public void onClick(View view) {
    if (view == mRruleButton) {
        Bundle b = new Bundle();
        b.putLong(RecurrencePickerDialog.BUNDLE_START_TIME_MILLIS, mStartTime.toMillis(false));
        b.putString(RecurrencePickerDialog.BUNDLE_TIME_ZONE, mStartTime.timezone);

        // TODO may be more efficient to serialize and pass in
        // EventRecurrence
        b.putString(RecurrencePickerDialog.BUNDLE_RRULE, mRrule);

        FragmentManager fm = mActivity.getSupportFragmentManager();
        RecurrencePickerDialog rpd = (RecurrencePickerDialog) fm.findFragmentByTag(FRAG_TAG_RECUR_PICKER);
        if (rpd != null) {
            rpd.dismiss();//from   w ww .j  a  v  a  2 s . c  o  m
        }
        rpd = new RecurrencePickerDialog();
        rpd.setArguments(b);
        rpd.setOnRecurrenceSetListener(EditEventView.this);
        rpd.show(fm, FRAG_TAG_RECUR_PICKER);
        return;
    }

    // This must be a click on one of the "remove reminder" buttons
    LinearLayout reminderItem = (LinearLayout) view.getParent();
    LinearLayout parent = (LinearLayout) reminderItem.getParent();
    parent.removeView(reminderItem);
    mReminderItems.remove(reminderItem);
    updateRemindersVisibility(mReminderItems.size());
    EventViewUtils.updateAddReminderButton(mView, mReminderItems, mModel.mCalendarMaxReminders);
}

From source file:cc.flydev.launcher.Page.java

public int getPageForView(View v) {
    int result = -1;
    if (v != null) {
        ViewParent vp = v.getParent();
        int count = getChildCount();
        for (int i = 0; i < count; i++) {
            if (vp == getPageAt(i)) {
                return i;
            }//  w w  w  .  ja va 2 s. c  om
        }
    }
    return result;
}

From source file:com.plusot.senselib.SenseMain.java

private void removeView() {
    if (viewsAdded == 0)
        return;/* w w w.ja v  a 2 s  . c  om*/

    View v = findViewById(VIEW_ID_BASE + --viewsAdded);
    if (v != null) {
        ViewParent vp = v.getParent();
        if (vp instanceof ViewGroup) {
            ((ViewGroup) vp).removeView(v);
            LLog.d(Globals.TAG, CLASSTAG + " View removed from viewgroup.");
            v.setVisibility(View.GONE);
        }
    }

    adjustViews();
}