androidx.constraintlayout.widget.ConstraintLayout Java Examples

The following examples show how to use androidx.constraintlayout.widget.ConstraintLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SingleCGroupAdapter.java    From call_manage with MIT License 6 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
@Override
public void onBindViewHolder(@NonNull ContactHolder holder, int position) {
    Contact contact = mData.get(position);

    holder.name.setText(contact.getName());
    holder.number.setText(contact.getMainPhoneNumber());

    holder.dragHandle.setOnTouchListener((v, event) -> {
        if (event.getActionMasked() ==
                MotionEvent.ACTION_DOWN) {
            mItemTouchHelperListener.onStartDrag(holder);
        }
        return false;
    });

    holder.removeItem.setOnClickListener(v -> onItemDismiss(holder.getAdapterPosition()));

    ConstraintLayout itemRoot = (ConstraintLayout) holder.itemView;
    ConstraintSet set = new ConstraintSet();
    int layoutId = mEditModeEnabled ? R.layout.item_contact_editable_modified : R.layout.item_contact_editable;
    set.load(mContext, layoutId);
    set.applyTo(itemRoot);
}
 
Example #2
Source File: WebViewDialog.java    From cloudflare-scrape-Android with MIT License 6 votes vote down vote up
private void initWebView(){
    mWebView = new WebView(mContext);
    ConstraintLayout.LayoutParams layoutParams =
            new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
    mWebView.setLayoutParams(layoutParams);
    mWebView.setId(R.id.webview);
    mWebView.setVisibility(View.INVISIBLE);
    mLayout.addView(mWebView,-1);
    mAdvanceWebClient = new AdvanceWebClient(getContext(), mWebView,mUser_agent);
    mAdvanceWebClient.setListener(mLoginSuccessListener);
    mAdvanceWebClient.initWebView("https://" + mUrl.getHost());
}
 
Example #3
Source File: TemplateView.java    From googleads-mobile-android-native-templates with Apache License 2.0 6 votes vote down vote up
@Override
public void onFinishInflate() {
  super.onFinishInflate();
  nativeAdView = (UnifiedNativeAdView) findViewById(R.id.native_ad_view);
  primaryView = (TextView) findViewById(R.id.primary);
  secondaryView = (TextView) findViewById(R.id.secondary);
  tertiaryView = (TextView) findViewById(R.id.body);

  ratingBar = (RatingBar) findViewById(R.id.rating_bar);
  ratingBar.setEnabled(false);

  callToActionView = (Button) findViewById(R.id.cta);
  iconView = (ImageView) findViewById(R.id.icon);
  mediaView = (MediaView) findViewById(R.id.media_view);
  background = (ConstraintLayout) findViewById(R.id.background);
}
 
Example #4
Source File: ToolbarHelper.java    From CloudReader with Apache License 2.0 6 votes vote down vote up
/**
 * 将View的top margin 向下偏移一个状态栏的高度
 */
public static void initMarginTopDiffBar(View view) {
    ViewGroup.LayoutParams params = view.getLayoutParams();
    if (params instanceof LinearLayout.LayoutParams) {
        LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) params;
        linearParams.topMargin += DensityUtil.getStatusHeight(view.getContext());
    } else if (params instanceof FrameLayout.LayoutParams) {
        FrameLayout.LayoutParams frameParams = (FrameLayout.LayoutParams) params;
        frameParams.topMargin += DensityUtil.getStatusHeight(view.getContext());
    } else if (params instanceof RelativeLayout.LayoutParams) {
        RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) params;
        relativeParams.topMargin += DensityUtil.getStatusHeight(view.getContext());
    } else if (params instanceof ConstraintLayout.LayoutParams) {
        ConstraintLayout.LayoutParams constraintParams = (ConstraintLayout.LayoutParams) params;
        constraintParams.topMargin += DensityUtil.getStatusHeight(view.getContext());
    }
    view.setLayoutParams(params);
}
 
Example #5
Source File: StreamFragment.java    From Twire with GNU General Public License v3.0 6 votes vote down vote up
private void setVideoViewLayout() {
    ViewGroup.LayoutParams layoutParams = rootView.getLayoutParams();
    layoutParams.height = isLandscape ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;

    ConstraintLayout.LayoutParams layoutWrapper = (ConstraintLayout.LayoutParams) mVideoWrapper.getLayoutParams();
    if (isLandscape && !pictureInPictureEnabled) {
        layoutWrapper.width = mShowChatButton.getRotation() == 0 ? ConstraintLayout.LayoutParams.MATCH_PARENT : getScreenRect(getActivity()).height() - getLandscapeChatTargetWidth();
    } else {
        layoutWrapper.width = ConstraintLayout.LayoutParams.MATCH_PARENT;
    }
    mVideoWrapper.setLayoutParams(layoutWrapper);

    AspectRatioFrameLayout contentFrame = mVideoWrapper.findViewById(R.id.exo_content_frame);
    if (isLandscape) {
        contentFrame.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
    } else {
        contentFrame.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH);
    }
}
 
Example #6
Source File: LessonC.java    From SchoolQuest with GNU General Public License v3.0 6 votes vote down vote up
private void generatePoint() {
    int r = (int) (Math.random() * points.size());

    while (r == oldIndex) { r = (int) (Math.random() * points.size()); }

    int r0 = (int) (Math.random() * points.get(r).size());

    oldIndex = r;
    currentPoint = points.get(r).remove(r0);

    ImageView mapPoint = GameActivity.getInstance().findViewById(R.id.lesson_c_map_menu_point);

    ConstraintLayout.LayoutParams layoutParams =
            (ConstraintLayout.LayoutParams) mapPoint.getLayoutParams();
    layoutParams.topMargin =
            Math.round((currentPoint.y - PE_MAP_TOP_MARGIN) * 8 * SCREEN_DENSITY);
    layoutParams.leftMargin =
            Math.round((currentPoint.x - PE_MAP_LEFT_MARGIN) * 8 * SCREEN_DENSITY);
    mapPoint.setLayoutParams(layoutParams);
}
 
Example #7
Source File: RecyclerViewAdapter.java    From ExoPlayer-Wrapper with Apache License 2.0 6 votes vote down vote up
public void changeToNormalScreen() {
    ((Activity) mTextView.getContext()).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    mLayouManager.enableScroll();

    RecyclerView.LayoutParams layoutParamsItem = (RecyclerView.LayoutParams) mView.getLayoutParams();
    layoutParamsItem.height = mItemHeight;
    layoutParamsItem.width = mItemWidth;
    layoutParamsItem.topMargin = mItemTopMargin;
    layoutParamsItem.bottomMargin = mItemBottomMargin;
    layoutParamsItem.leftMargin = mItemLeftMargin;
    layoutParamsItem.rightMargin = mItemRightMargin;
    mView.setLayoutParams(layoutParamsItem);

    ConstraintLayout.LayoutParams videoParams = (ConstraintLayout.LayoutParams) mExoPlayerView.getLayoutParams();
    videoParams.height = mVideoHeight;
    videoParams.width = mVideoWidth;
    //videoParams.bottomToBottom = 0;
    mExoPlayerView.setLayoutParams(videoParams);

    mTextView.setVisibility(View.VISIBLE);
}
 
Example #8
Source File: GameActivity.java    From SchoolQuest with GNU General Public License v3.0 6 votes vote down vote up
public boolean isGamePause() {
    ConstraintLayout statusMenu = findViewById(R.id.status_menu);
    ConstraintLayout mapMenu = findViewById(R.id.map_menu);
    ConstraintLayout inventory = findViewById(R.id.inventory_menu);
    ConstraintLayout textBox = findViewById(R.id.textbox);
    ConstraintLayout studyMenu = findViewById(R.id.study_menu);
    ConstraintLayout buyMenu = findViewById(R.id.buy_menu);

    boolean lessonCHelp = false;
    MiniGame miniGame = GAME.getMiniGame();
    if (miniGame != null) {
        if (miniGame instanceof LessonC) {
            lessonCHelp = ((LessonC) miniGame).isHelp();
        }
    }

    return statusMenu.getVisibility() == View.VISIBLE || mapMenu.getVisibility() == View.VISIBLE
            || inventory.getVisibility() == View.VISIBLE
            || textBox.getVisibility() == View.VISIBLE
            || studyMenu.getVisibility() == View.VISIBLE
            || buyMenu.getVisibility() == View.VISIBLE
            || lessonCHelp;
}
 
Example #9
Source File: ConstraintSetExampleActivity.java    From android-ConstraintLayoutExamples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.constraintset_example_main);

    mRootLayout = (ConstraintLayout) findViewById(R.id.activity_constraintset_example);
    // Note that this can also be achieved by calling
    // `mConstraintSetNormal.load(this, R.layout.constraintset_example_main);`
    // Since we already have an inflated ConstraintLayout in `mRootLayout`, clone() is
    // faster and considered the best practice.
    mConstraintSetNormal.clone(mRootLayout);
    // Load the constraints from the layout where ImageView is enlarged.
    mConstraintSetBig.load(this, R.layout.constraintset_example_big);

    if (savedInstanceState != null) {
        boolean previous = savedInstanceState.getBoolean(SHOW_BIG_IMAGE);
        if (previous != mShowBigImage) {
            mShowBigImage = previous;
            applyConfig();
        }
    }
}
 
Example #10
Source File: ConstraintSetExampleActivity.java    From views-widgets-samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.constraintset_example_main);

    mRootLayout = (ConstraintLayout) findViewById(R.id.activity_constraintset_example);
    // Note that this can also be achieved by calling
    // `mConstraintSetNormal.load(this, R.layout.constraintset_example_main);`
    // Since we already have an inflated ConstraintLayout in `mRootLayout`, clone() is
    // faster and considered the best practice.
    mConstraintSetNormal.clone(mRootLayout);
    // Load the constraints from the layout where ImageView is enlarged.
    mConstraintSetBig.load(this, R.layout.constraintset_example_big);

    if (savedInstanceState != null) {
        boolean previous = savedInstanceState.getBoolean(SHOW_BIG_IMAGE);
        if (previous != mShowBigImage) {
            mShowBigImage = previous;
            applyConfig();
        }
    }
}
 
Example #11
Source File: RecyclerViewAdapter.java    From tap-android-sdk with Apache License 2.0 6 votes vote down vote up
public ViewHolder(ConstraintLayout itemView) {
    super(itemView);
    this.itemView = itemView;

    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });

    tapName = itemView.findViewById(R.id.tapName);
    tapIdentifier = itemView.findViewById(R.id.tapAddress);
    tapInputInt = itemView.findViewById(R.id.tapInputInt);
    finger1 = itemView.findViewById(R.id.finger1);
    finger2 = itemView.findViewById(R.id.finger2);
    finger3 = itemView.findViewById(R.id.finger3);
    finger4 = itemView.findViewById(R.id.finger4);
    finger5 = itemView.findViewById(R.id.finger5);
    mode = itemView.findViewById(R.id.tapMode);
    fwVer = itemView.findViewById(R.id.tapFwVer);
}
 
Example #12
Source File: BaldKeyboard.java    From BaldPhone with Apache License 2.0 6 votes vote down vote up
@Keep
public BaldKeyboard(final Context context, final View.OnClickListener onClickListener, final Runnable backspaceRunnable, final int imeOptions) {
    super(context);
    vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    this.backspaceRunnable = backspaceRunnable;
    final ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, S.getTheme(context));
    keyboard = (ConstraintLayout) LayoutInflater.from(contextThemeWrapper).inflate(layout(), this, false);
    children = new View[keyboard.getChildCount()];
    final char[] codes = codes();
    for (int i = 0; i < children.length - 1/*cause of space view...*/; i++) {
        final View view = keyboard.getChildAt(i + 1/*cause of space view...*/);
        view.setOnClickListener(onClickListener);
        view.setTag(codes[i]);
        children[i] = view;
    }
    backspace = keyboard.findViewById(R.id.backspace);
    backspace.setOnTouchListener(getBackSpaceListener());
    enter = keyboard.findViewById(R.id.enter);
    tv_enter = keyboard.findViewById(R.id.tv_enter);
    iv_enter = keyboard.findViewById(R.id.iv_enter);
    imeOptionsChanged(imeOptions);
    addView(keyboard);
}
 
Example #13
Source File: FileViewFragment.java    From lbry-android with MIT License 6 votes vote down vote up
@SuppressLint("SourceLockedOrientationActivity")
private void enableFullScreenMode() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        View root = getView();
        ConstraintLayout globalLayout = root.findViewById(R.id.file_view_global_layout);
        View exoplayerContainer = root.findViewById(R.id.file_view_exoplayer_container);
        ((ViewGroup) exoplayerContainer.getParent()).removeView(exoplayerContainer);
        globalLayout.addView(exoplayerContainer);

        View playerView = root.findViewById(R.id.file_view_exoplayer_view);
        ((ImageView) playerView.findViewById(R.id.player_image_full_screen_toggle)).setImageResource(R.drawable.ic_fullscreen_exit);

        MainActivity activity = (MainActivity) context;
        activity.enterFullScreenMode();

        int statusBarHeight = activity.getStatusBarHeight();
        exoplayerContainer.setPadding(0, 0, 0, statusBarHeight);

        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    }
}
 
Example #14
Source File: GameActivity.java    From SchoolQuest with GNU General Public License v3.0 6 votes vote down vote up
public void showButtons() {
    ConstraintLayout topMenu = findViewById(R.id.top_menu);

    ImageView statusButton = findViewById(R.id.status_button);
    ImageView mapButton = findViewById(R.id.map_button);
    ImageView inventoryButton = findViewById(R.id.inventory_button);
    ImageView runButton = findViewById(R.id.run_button);
    ImageView heistButton = findViewById(R.id.heist_button);
    ImageView cancelButton = findViewById(R.id.cancel_button);
    ImageView quitButton = findViewById(R.id.quit_button);

    topMenu.setVisibility(View.VISIBLE);

    statusButton.setVisibility(View.VISIBLE);
    mapButton.setVisibility(View.VISIBLE);
    inventoryButton.setVisibility(View.VISIBLE);
    cancelButton.setVisibility(View.VISIBLE);
    if (GAME.hasItem(Item.getItem(KEY2_INDEX))) { runButton.setVisibility(View.VISIBLE); }
    if (GAME.getProgressDataStructure().hasHeistPlan()) {
        heistButton.setVisibility(View.VISIBLE);
        setUpHeistMenu();
    }
    quitButton.setVisibility(View.VISIBLE);
}
 
Example #15
Source File: GameActivity.java    From SchoolQuest with GNU General Public License v3.0 6 votes vote down vote up
public void hideButtons() {
    ConstraintLayout topMenu = findViewById(R.id.top_menu);

    ImageView statusButton = findViewById(R.id.status_button);
    ImageView mapButton = findViewById(R.id.map_button);
    ImageView inventoryButton = findViewById(R.id.inventory_button);
    ImageView runButton = findViewById(R.id.run_button);
    ImageView heistButton = findViewById(R.id.heist_button);
    ImageView cancelButton = findViewById(R.id.cancel_button);
    ImageView quitButton = findViewById(R.id.quit_button);

    topMenu.setVisibility(View.GONE);

    statusButton.setVisibility(View.GONE);
    mapButton.setVisibility(View.GONE);
    inventoryButton.setVisibility(View.GONE);
    cancelButton.setVisibility(View.GONE);
    runButton.setVisibility(View.GONE);
    heistButton.setVisibility(View.GONE);
    quitButton.setVisibility(View.GONE);
}
 
Example #16
Source File: GameActivity.java    From SchoolQuest with GNU General Public License v3.0 6 votes vote down vote up
public void refreshBuyMenu() {
    final ConstraintLayout shopBuyMenu = findViewById(R.id.shop_menu_buy);

    for (int i = 0; i < shopBuyMenu.getChildCount(); i ++) {
        View view = shopBuyMenu.getChildAt(i);
        if (view instanceof ItemImageView) {
            if ((GAME.isSheetItem(((ItemImageView) view).getItem())
                    && GAME.hasBook(((ItemImageView) view).getItem()))
                    ||
                    (GAME.isBookItem(((ItemImageView) view).getItem())
                            && GAME.hasItem(((ItemImageView) view).getItem()))) {
                view.setEnabled(false);
                view.setAlpha(0.5f);
            } else {
                view.setEnabled(true);
                view.setAlpha(1f);
            }
        }

    }
}
 
Example #17
Source File: ExampleFlyinBounceHelper.java    From views-widgets-samples with Apache License 2.0 5 votes vote down vote up
/**
 * @param container
 * @hide
 */
@Override
public void updatePreLayout(ConstraintLayout container) {
    if (mContainer!=container) {
        View[] views = getViews(container);
        for (int i = 0; i < mCount; i++) {
            View view = views[i];
            ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationX", - 2000, 0).setDuration(1000);
            animator.setInterpolator(new BounceInterpolator());
            animator.start();
        }
    }
    mContainer = container;
}
 
Example #18
Source File: GroupModelAdapter.java    From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void updateGroupItemViewHolder(final ViewHolder holder, final Element element) {
    holder.elementTitle.setText(MeshAddress.formatAddress(element.getElementAddress(), true));
    holder.mModelContainer.removeAllViews();
    for (Map.Entry<Integer, MeshModel> modelEntry : element.getMeshModels().entrySet()) {
        final MeshModel model = modelEntry.getValue();
        for (Integer address : model.getSubscribedAddresses()) {
            if (mGroup.getAddress() == address) {
                final View view = LayoutInflater.from(mContext).inflate(R.layout.group_model_item, holder.mModelContainer, false);
                final ConstraintLayout container = view.findViewById(R.id.container);
                final ImageView modelIcon = view.findViewById(R.id.icon);
                final TextView modelTitle = view.findViewById(R.id.model_title);
                modelTitle.setText(model.getModelName());
                if(MeshParserUtils.isVendorModel(model.getModelId())){
                    modelIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_domain_nordic_medium_gray));
                } else {
                    switch (model.getModelId()) {
                        case SigModelParser.GENERIC_ON_OFF_SERVER:
                            modelIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_lightbulb_outline_24dp));
                            break;
                        case SigModelParser.GENERIC_ON_OFF_CLIENT:
                            modelIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_light_switch_24dp));
                            break;
                        case SigModelParser.GENERIC_LEVEL_SERVER:
                            modelIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_lightbulb_level_24dp));
                            break;
                        default:
                            modelIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_help_outline_24dp));
                            break;
                    }
                }
                container.setOnClickListener(v -> mOnItemClickListener.onModelItemClick(element, model));
                holder.mModelContainer.addView(view);
            }
        }
    }
}
 
Example #19
Source File: SingleCGroupAdapter.java    From call_manage with MIT License 5 votes vote down vote up
/**
 * Animates the ContactHolder
 */
public void animate() {
    ConstraintLayout itemRoot = (ConstraintLayout) itemView;
    ConstraintSet set = new ConstraintSet();
    set.clone(itemRoot);

    Transition transition = new AutoTransition();
    transition.setInterpolator(new OvershootInterpolator());
    TransitionManager.beginDelayedTransition(itemRoot, transition);
    int layoutId = mEditModeEnabled ? R.layout.item_contact_editable_modified : R.layout.item_contact_editable;
    set.load(mContext, layoutId);
    set.applyTo(itemRoot);
}
 
Example #20
Source File: GuidanceNextManeuverViewTest.java    From msdkui-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testIconEndMargin() {
    mGuidanceNextManeuverView.setIconEndMargin(10);
    final ImageView iconView = mGuidanceNextManeuverView.findViewById(R.id.nextManeuverIconView);
    final ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams)
            iconView.getLayoutParams();
    assertThat(layoutParams.getMarginEnd(), equalTo(10));
}
 
Example #21
Source File: OngoingCallActivity.java    From call_manage with MIT License 5 votes vote down vote up
/**
 * Moves the reject button to the middle
 */
private void moveRejectButtonToMiddle() {
    ConstraintSet ongoingSet = new ConstraintSet();

    ongoingSet.clone(mOngoingCallLayout);
    ongoingSet.connect(R.id.reject_btn, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.END);
    ongoingSet.connect(R.id.reject_btn, ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.START);
    ongoingSet.setHorizontalBias(R.id.reject_btn, 0.5f);
    ongoingSet.setMargin(R.id.reject_btn, ConstraintSet.END, 0);

    ConstraintSet overlaySet = new ConstraintSet();
    overlaySet.clone(this, R.layout.correction_overlay_reject_call_options);

    if (!mIsCreatingUI) { //Don't animate if the activity is just being created
        Transition transition = new ChangeBounds();
        transition.setInterpolator(new AccelerateDecelerateInterpolator());
        transition.addTarget(mRejectCallOverlay);
        transition.addTarget(mRejectButton);
        TransitionManager.beginDelayedTransition(mOngoingCallLayout, transition);
    }

    ongoingSet.applyTo(mOngoingCallLayout);
    overlaySet.applyTo((ConstraintLayout) mRejectCallOverlay);

    mFloatingRejectCallTimerButton.hide();
    mFloatingCancelOverlayButton.hide();
    mFloatingSendSMSButton.hide();

    mRootView.removeView(mAnswerCallOverlay);
}
 
Example #22
Source File: PlacePickerActivity.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void customizeViews() {
  ConstraintLayout toolbar = findViewById(R.id.place_picker_toolbar);
  if (options != null && options.toolbarColor() != null) {
    toolbar.setBackgroundColor(options.toolbarColor());
  } else {
    int color = ColorUtils.getMaterialColor(this, R.attr.colorPrimary);
    toolbar.setBackgroundColor(color);
  }
}
 
Example #23
Source File: RecyclerViewAdapter.java    From tap-android-sdk with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

    ConstraintLayout v = (ConstraintLayout) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.list_row, parent, false);

    return new ViewHolder(v);
}
 
Example #24
Source File: ConfigWizardBaseActivity.java    From bitmask_android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Restores the default size of the white content area in tablet layouts
 */
private void showStandardTabletContentArea() {
    if (isPhoneLayout()) {
        return;
    }
    ConstraintLayout.LayoutParams guideLineTopParams = (ConstraintLayout.LayoutParams) guideline_top.getLayoutParams();
    guideLineTopParams.guidePercent = defaultGuidelineTopPercentage;
    guideline_top.setLayoutParams(guideLineTopParams);

    ConstraintLayout.LayoutParams guideLineBottomParams = (ConstraintLayout.LayoutParams) guideline_bottom.getLayoutParams();
    guideLineBottomParams.guidePercent = defaultGuidelineBottomPercentage;
    guideline_bottom.setLayoutParams(guideLineBottomParams);
}
 
Example #25
Source File: ConfigWizardBaseActivity.java    From bitmask_android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Increases the white content area in tablet layouts
 */
private void showIncreasedTabletContentArea() {
    if (isPhoneLayout()) {
        return;
    }
    ConstraintLayout.LayoutParams guideLineTopParams = (ConstraintLayout.LayoutParams) guideline_top.getLayoutParams();
    float increasedTopPercentage = defaultGuidelineTopPercentage - GUIDE_LINE_COMPACT_DELTA;
    guideLineTopParams.guidePercent = increasedTopPercentage > 0f ? increasedTopPercentage : 0f;
    guideline_top.setLayoutParams(guideLineTopParams);

    ConstraintLayout.LayoutParams guideLineBottomParams = (ConstraintLayout.LayoutParams) guideline_bottom.getLayoutParams();
    float increasedBottomPercentage = defaultGuidelineBottomPercentage + GUIDE_LINE_COMPACT_DELTA;
    guideLineBottomParams.guidePercent = increasedBottomPercentage < 1f ? increasedBottomPercentage : 1f;
    guideline_bottom.setLayoutParams(guideLineBottomParams);
}
 
Example #26
Source File: BaseActivity.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
protected void addToolbarView(View v) {
    ConstraintLayout toolbar = findViewById(R.id.myToolBar);
    if (toolbar != null) {
        ConstraintLayout.LayoutParams pls = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
        v.setLayoutParams(pls);
        int padding = DimenUtils.dip2px(this, 12);
        v.setPadding(padding, padding, padding, padding);
        pls.setMarginEnd(padding);
        pls.bottomToBottom = ConstraintSet.PARENT_ID;
        pls.topToTop = ConstraintSet.PARENT_ID;
        pls.endToEnd = ConstraintSet.PARENT_ID;
        //pls.gravity = Gravity.END;
        toolbar.addView(v);
    }
}
 
Example #27
Source File: CustomNotificationSettingsActivity.java    From an2linuxclient with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_notification_settings);

    final CustomProgressDialog progressDialog = new CustomProgressDialog();
    progressDialog.setCancelable(false);
    progressDialog.show(getSupportFragmentManager(), "progressDialog");

    final RecyclerView recyclerView = findViewById(R.id.recyclerView);
    final ConstraintLayout emptyView = findViewById(R.id.emptyView);
    emptyView.setOnClickListener(view -> {
        Intent intent = new Intent(CustomNotificationSettingsActivity.this, EnabledApplicationsActivity.class);
        startActivityForResult(intent, RETURNED_FROM_ENABLED_APPS_SETTINGS_REQUEST);
    });

    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    final CustomNotificationSettingsAdapter adapter = new CustomNotificationSettingsAdapter(this);
    recyclerView.setAdapter(adapter);

    recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL));

    viewModel = ViewModelProviders.of(this).get(CustomNotificationSettingsViewModel.class);
    viewModel.getAppsDataList().observe(this, customSettingsAppData -> {
        adapter.setAppDataList(customSettingsAppData);
        progressDialog.dismiss();
        if (customSettingsAppData.size() == 0) {
            emptyView.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        } else {
            emptyView.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        }
    });
}
 
Example #28
Source File: RecyclerViewAdapter.java    From ExoPlayer-Wrapper with Apache License 2.0 5 votes vote down vote up
public void changeToFullScreen() {
    mLayouManager.disableScroll();
    RecyclerView.LayoutParams layoutParamsItem = (RecyclerView.LayoutParams) mView.getLayoutParams();
    mItemHeight = layoutParamsItem.height;
    mItemWidth = layoutParamsItem.width;
    mItemTopMargin = layoutParamsItem.topMargin;
    mItemBottomMargin = layoutParamsItem.bottomMargin;
    mItemLeftMargin = layoutParamsItem.leftMargin;
    mItemRightMargin = layoutParamsItem.rightMargin;

    layoutParamsItem.height = ViewGroup.LayoutParams.MATCH_PARENT;
    layoutParamsItem.width = ViewGroup.LayoutParams.MATCH_PARENT;
    layoutParamsItem.topMargin = 0;
    layoutParamsItem.bottomMargin = 0;
    layoutParamsItem.leftMargin = 0;
    layoutParamsItem.rightMargin = 0;
    mView.setLayoutParams(layoutParamsItem);

    ConstraintLayout.LayoutParams videoParams = (ConstraintLayout.LayoutParams) mExoPlayerView.getLayoutParams();
    mVideoHeight = videoParams.height;
    mVideoWidth = videoParams.width;
    videoParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
    videoParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
    //videoParams.bottomToBottom = R.id.parent;
    mExoPlayerView.setLayoutParams(videoParams);

    mExoPlayerView.post(new Runnable() {
        @Override
        public void run() {
            mLayouManager.scrollToPosition(getAdapterPosition());
        }
    });

    mTextView.setVisibility(View.GONE);

    ((Activity) mTextView.getContext()).setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);

}
 
Example #29
Source File: ExampleFlyinBounceHelper.java    From android-ConstraintLayoutExamples with Apache License 2.0 5 votes vote down vote up
/**
 * @param container
 * @hide
 */
@Override
public void updatePreLayout(ConstraintLayout container) {
    if (mContainer!=container) {
        View[] views = getViews(container);
        for (int i = 0; i < mCount; i++) {
            View view = views[i];
            ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationX", - 2000, 0).setDuration(1000);
            animator.setInterpolator(new BounceInterpolator());
            animator.start();
        }
    }
    mContainer = container;
}
 
Example #30
Source File: MainActivity.java    From opentok-android-sdk-samples with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mContainer = (ConstraintLayout) findViewById(R.id.main_container);

    requestPermissions();
}