android.view.View

Here are the examples of the java api class android.view.View taken from open source projects.

1. MainActivity#onCreate()

Project: android-player
Source File: MainActivity.java
View license
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final View toolbar = findViewById(R.id.toolbar);
    final View activityMainMessageIcon = findViewById(R.id.activityMainMessageIcon);
    final View activityMainMobile = findViewById(R.id.activityMainMobile);
    final View activityMainMobileNumber = findViewById(R.id.activityMainMobileNumber);
    final View activityMainCallIcon = findViewById(R.id.activityMainCallIcon);
    final View activityMainMobileNumberLayout = findViewById(R.id.activityMainMobileNumberLayout);
    final View activityMainPinkFab = findViewById(R.id.activityMainPinkFab);
    final View activityMainProfileName = findViewById(R.id.activityMainProfileName);
    final View activityMainDrawerLayout = findViewById(R.id.activityMainDrawerLayout);
    final View activityMainheaderLayout = findViewById(R.id.activityMainheaderLayout);
    initDrawerLayout();
    animateSampleOne(toolbar, activityMainMobileNumberLayout, activityMainPinkFab, activityMainheaderLayout);
//        animateSampleTwo(toolbar, activityMainMobileNumberLayout, activityMainPinkFab, activityMainheaderLayout);
//        animateSampleThree(toolbar, activityMainMobileNumberLayout, activityMainPinkFab, activityMainheaderLayout, activityMainMessageIcon);
//        animateSampleFour(toolbar, activityMainMessageIcon, activityMainMobile, activityMainMobileNumber, activityMainCallIcon, activityMainPinkFab, activityMainheaderLayout);
//animateSampleFive(activityMainProfileName);
}

2. SeekBarIncrementHandler#init()

View license
public void init(IViewContainer parent, SeekBar seekBar, int minusViewId, int plusViewId) {
    this.seekBar = seekBar;
    View minus = parent.findViewById(minusViewId);
    minus.setTag(Integer.valueOf(-1));
    minus.setOnTouchListener(this);
    minus.setOnClickListener(this);
    minus.setOnLongClickListener(this);
    View plus = parent.findViewById(plusViewId);
    plus.setTag(Integer.valueOf(+1));
    plus.setOnTouchListener(this);
    plus.setOnClickListener(this);
    plus.setOnLongClickListener(this);
}

3. MainActivity#initUI()

Project: NavigationTabBar
Source File: MainActivity.java
View license
private void initUI() {
    final View btnHorizontalNtb = findViewById(R.id.btn_horizontal_ntb);
    btnHorizontalNtb.setOnClickListener(this);
    final View btnHorizontalCoordinatorNtb = findViewById(R.id.btn_horizontal_coordinator_ntb);
    btnHorizontalCoordinatorNtb.setOnClickListener(this);
    final View btnTopHorizontalNtb = findViewById(R.id.btn_horizontal_top_ntb);
    btnTopHorizontalNtb.setOnClickListener(this);
    final View btnVerticalNtb = findViewById(R.id.btn_vertical_ntb);
    btnVerticalNtb.setOnClickListener(this);
    final View btnSamplesNtb = findViewById(R.id.btn_samples_ntb);
    btnSamplesNtb.setOnClickListener(this);
}

4. ListViewTest#addHeaderView_ShouldRecordHeaders()

Project: robolectric
Source File: ListViewTest.java
View license
@Test
public void addHeaderView_ShouldRecordHeaders() throws Exception {
    View view0 = new View(null);
    view0.setId(0);
    View view1 = new View(null);
    view1.setId(1);
    View view2 = new View(null);
    view2.setId(2);
    View view3 = new View(null);
    view3.setId(3);
    listView.addHeaderView(view0);
    listView.addHeaderView(view1);
    listView.addHeaderView(view2, null, false);
    listView.addHeaderView(view3, null, false);
    assertThat(listView.getHeaderViewsCount(), equalTo(4));
    assertThat(shadowOf(listView).getHeaderViews().get(0), sameInstance(view0));
    assertThat(shadowOf(listView).getHeaderViews().get(1), sameInstance(view1));
    assertThat(shadowOf(listView).getHeaderViews().get(2), sameInstance(view2));
    assertThat(shadowOf(listView).getHeaderViews().get(3), sameInstance(view3));
    assertThat(listView.findViewById(0), notNullValue());
    assertThat(listView.findViewById(1), notNullValue());
    assertThat(listView.findViewById(2), notNullValue());
    assertThat(listView.findViewById(3), notNullValue());
}

5. YoukuPlayerView#addLeftAndRight()

Project: SimplifyReader
Source File: YoukuPlayerView.java
View license
/**
	 * ??????4.4??????????????????surfaceview????view
	 */
private void addLeftAndRight() {
    View viewLeft = new View(mContext);
    viewLeft.setId(1999);
    viewLeft.setVisibility(View.INVISIBLE);
    RelativeLayout.LayoutParams leftLayoutParams = new RelativeLayout.LayoutParams(0, 0);
    leftLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    viewLeft.setLayoutParams(leftLayoutParams);
    spaceMiddle.addView(viewLeft);
    View viewRight = new View(mContext);
    viewRight.setId(1998);
    viewRight.setVisibility(View.INVISIBLE);
    RelativeLayout.LayoutParams rightLayoutParams = new RelativeLayout.LayoutParams(0, 0);
    rightLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    viewRight.setLayoutParams(rightLayoutParams);
    spaceMiddle.addView(viewRight);
    RelativeLayout.LayoutParams surfaceLayoutParams = (RelativeLayout.LayoutParams) surfaceView.getLayoutParams();
    surfaceLayoutParams.addRule(RelativeLayout.RIGHT_OF, viewLeft.getId());
    surfaceLayoutParams.addRule(RelativeLayout.LEFT_OF, viewRight.getId());
}

6. MainActivity#buildCounterDrawable()

Project: TLint
Source File: MainActivity.java
View license
private Drawable buildCounterDrawable(int count, int backgroundImageId) {
    LayoutInflater inflater = LayoutInflater.from(this);
    View view = inflater.inflate(R.layout.notification_count_layout, null);
    view.setBackgroundResource(backgroundImageId);
    TextView tvCount = (TextView) view.findViewById(R.id.tvCount);
    if (count == 0) {
        tvCount.setVisibility(View.GONE);
    } else {
        tvCount.setVisibility(View.VISIBLE);
        tvCount.setText(String.valueOf(count));
    }
    view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
    view.setDrawingCacheEnabled(true);
    view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
    view.setDrawingCacheEnabled(false);
    return new BitmapDrawable(getResources(), bitmap);
}

7. EpisodePosterOnItemSelectedListener#createVideoMetaData()

View license
@Override
protected void createVideoMetaData(ImageView v) {
    super.createVideoMetaData(v);
    View categoryFilter = context.findViewById(R.id.categoryFilter);
    categoryFilter.setVisibility(View.GONE);
    View categoryFilter2 = context.findViewById(R.id.categoryFilter2);
    categoryFilter2.setVisibility(View.GONE);
    View categoryName = context.findViewById(R.id.movieCategoryName);
    categoryName.setVisibility(View.GONE);
    TextView subt = (TextView) context.findViewById(R.id.subtitleFilter);
    subt.setVisibility(View.GONE);
    Spinner subtitleSpinner = (Spinner) context.findViewById(R.id.videoSubtitle);
    subtitleSpinner.setVisibility(View.GONE);
}

8. TableFixHeaders#makeView()

View license
private View makeView(int row, int column, int w, int h) {
    final int itemViewType = adapter.getItemViewType(row, column);
    final View recycledView;
    if (itemViewType == TableAdapter.IGNORE_ITEM_VIEW_TYPE) {
        recycledView = null;
    } else {
        recycledView = recycler.getRecycledView(itemViewType);
    }
    final View view = adapter.getView(row, column, recycledView, this);
    view.setTag(R.id.tag_type_view, itemViewType);
    view.setTag(R.id.tag_row, row);
    view.setTag(R.id.tag_column, column);
    view.measure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY));
    addTableView(view, row, column);
    return view;
}

9. EditPageLand#initShadow()

Project: zhsz
Source File: EditPageLand.java
View license
private void initShadow(LinearLayout llShadow, float ratio) {
    int px_1 = ratio > 1 ? ((int) ratio) : 1;
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
    View v = new View(activity);
    v.setBackgroundColor(0x29000000);
    llShadow.addView(v, lp);
    v = new View(activity);
    v.setBackgroundColor(0x14000000);
    llShadow.addView(v, lp);
    v = new View(activity);
    v.setBackgroundColor(0x07000000);
    llShadow.addView(v, lp);
}

10. EditPagePort#initShadow()

Project: zhsz
Source File: EditPagePort.java
View license
private void initShadow(LinearLayout llShadow, float ratio) {
    int px_1 = ratio > 1 ? ((int) ratio) : 1;
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
    View v = new View(activity);
    v.setBackgroundColor(0x29000000);
    llShadow.addView(v, lp);
    v = new View(activity);
    v.setBackgroundColor(0x14000000);
    llShadow.addView(v, lp);
    v = new View(activity);
    v.setBackgroundColor(0x07000000);
    llShadow.addView(v, lp);
}

11. CallLogDetailsFragment#configureCallButton()

View license
/** Configures the call button area using the given entry. */
private void configureCallButton(String callText, CharSequence nbrLabel, CharSequence number) {
    View convertView = getView().findViewById(R.id.call_and_sms);
    convertView.setVisibility(TextUtils.isEmpty(number) ? View.GONE : View.VISIBLE);
    TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text);
    View mainAction = convertView.findViewById(R.id.call_and_sms_main_action);
    mainAction.setOnClickListener(mPrimaryActionListener);
    mainAction.setContentDescription(callText);
    if (TextUtils.isEmpty(number)) {
        number = "";
    }
    mainAction.setTag(SipUri.getCanonicalSipContact(number.toString(), false));
    text.setText(callText);
    TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label);
    if (TextUtils.isEmpty(nbrLabel)) {
        label.setVisibility(View.GONE);
    } else {
        label.setText(nbrLabel);
        label.setVisibility(View.VISIBLE);
    }
}

12. TransactionsFragment#onTransactionClicked()

View license
@Override
public void onTransactionClicked(View view, Transaction transaction) {
    app.setTransactionDetail(transaction);
    // startActivity( new Intent( getContext(), DetailActivity.class ));
    View smallDateHolder = view.findViewById(R.id.tr_wrapperDate);
    smallDateHolder.setTransitionName("transition_date");
    View smallDateDay = smallDateHolder.findViewById(R.id.tr_day);
    smallDateDay.setTransitionName("transition_date_day");
    View smallDateMonth = smallDateHolder.findViewById(R.id.tr_month);
    smallDateMonth.setTransitionName("transition_date_month");
    Pair<View, String> holder = Pair.create(smallDateHolder, "transition_date");
    Pair<View, String> day = Pair.create(smallDateDay, "transition_date_day");
    Pair<View, String> month = Pair.create(smallDateMonth, "transition_date_month");
    Intent intent = new Intent(getContext(), DetailActivity.class);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(main, holder, day, month);
    main.startActivity(intent, options.toBundle());
//main.overridePendingTransition( R.anim.pull_up, R.anim.push_out );
}

13. UIManagerModuleTest#testTagsAssignment()

View license
@Test
public void testTagsAssignment() {
    UIManagerModule uiManager = getUIManagerModule();
    TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManager);
    View view0 = hierarchy.nativeRootView.getChildAt(0);
    assertThat(view0.getId()).isEqualTo(hierarchy.view0);
    View viewWithChildren1 = hierarchy.nativeRootView.getChildAt(1);
    assertThat(viewWithChildren1.getId()).isEqualTo(hierarchy.viewWithChildren1);
    View childView0 = ((ViewGroup) viewWithChildren1).getChildAt(0);
    assertThat(childView0.getId()).isEqualTo(hierarchy.childView0);
    View childView1 = ((ViewGroup) viewWithChildren1).getChildAt(1);
    assertThat(childView1.getId()).isEqualTo(hierarchy.childView1);
    View view2 = hierarchy.nativeRootView.getChildAt(2);
    assertThat(view2.getId()).isEqualTo(hierarchy.view2);
    View view3 = hierarchy.nativeRootView.getChildAt(3);
    assertThat(view3.getId()).isEqualTo(hierarchy.view3);
}

14. CardStackAdapter#addView()

Project: CardStackUI
Source File: CardStackAdapter.java
View license
void addView(final int position) {
    View root = createView(position, mParent);
    root.setOnTouchListener(this);
    root.setTag(R.id.cardstack_internal_position_tag, position);
    root.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    mCardPaddingInternal = root.getPaddingTop();
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullCardHeight);
    root.setLayoutParams(lp);
    if (mShowInitAnimation) {
        root.setY(getCardFinalY(position));
        setScreenTouchable(false);
    } else {
        root.setY(getCardOriginalY(position) - mParentPaddingTop);
        setScreenTouchable(true);
    }
    mCardViews[position] = root;
    mParent.addView(root);
}

15. Fab#setOverlay()

Project: Omni-Notes
Source File: Fab.java
View license
public void setOverlay(int colorResurce) {
    View overlayView = new View(OmniNotes.getAppContext());
    overlayView.setBackgroundResource(colorResurce);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
    overlayView.setLayoutParams(params);
    overlayView.setVisibility(View.GONE);
    overlayView.setOnClickListener( v -> performToggle());
    ViewGroup parent = ((ViewGroup) fab.getParent());
    parent.addView(overlayView, parent.indexOfChild(fab));
    this.overlay = overlayView;
}

16. ViewUtils#snapShotWithoutStatusBar()

Project: PracticeDemo
Source File: ViewUtils.java
View license
/**
     * ???????????????
     * @param activity
     * @return
     * by Hankkin at:2015-10-07 21:16:43
     */
public static Bitmap snapShotWithoutStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    Rect frame = new Rect();
    view.getWindowVisibleDisplayFrame(frame);
    int statusBarHeight = frame.top;
    int width = getScreenWidth(activity);
    int height = getScreenHeight(activity);
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height - statusBarHeight);
    view.destroyDrawingCache();
    return bp;
}

17. ExportFragment#onCreateView()

Project: Silence
Source File: ExportFragment.java
View license
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
    View layout = inflater.inflate(R.layout.export_fragment, container, false);
    View exportEncryptedView = layout.findViewById(R.id.export_encrypted_backup);
    View exportPlaintextView = layout.findViewById(R.id.export_plaintext_backup);
    exportEncryptedView.setOnClickListener(new View.OnClickListener() {

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

        @Override
        public void onClick(View v) {
            handleExportPlaintextBackup();
        }
    });
    return layout;
}

18. SpringFloatingActionMenu#generateRevealCircle()

View license
private View generateRevealCircle() {
    int diameter = mFAB.getType() == FloatingActionButton.TYPE_NORMAL ? Utils.getDimension(mContext, R.dimen.fab_size_normal) : Utils.getDimension(mContext, R.dimen.fab_size_mini);
    View view = new View(mContext);
    OvalShape ovalShape = new OvalShape();
    ShapeDrawable shapeDrawable = new ShapeDrawable(ovalShape);
    shapeDrawable.getPaint().setColor(ContextCompat.getColor(mContext, mRevealColor));
    view.setBackgroundDrawable(shapeDrawable);
    LayoutParams lp = new LayoutParams(diameter, diameter);
    view.setLayoutParams(lp);
    // Make view clickable to avoid clicks on any view located behind the menu
    view.setClickable(true);
    // note it is invisible, but will be visible while  animating
    view.setVisibility(View.INVISIBLE);
    return view;
}

19. ChatAvatarsAnimator#initializeAnimator()

View license
private void initializeAnimator() {
    final View avatar1 = rootView.findViewById(R.id.avatar1_page2);
    final View card1 = rootView.findViewById(R.id.card1_page2);
    final View avatar2 = rootView.findViewById(R.id.avatar2_page2);
    final View card2 = rootView.findViewById(R.id.card2_page2);
    final View star = rootView.findViewById(R.id.star);
    Animator avatar1Animator = getScaleAnimator(avatar1);
    Animator card1Animator = getFlightFromLeft(card1);
    Animator avatar2Animator = getScaleAnimator(avatar2);
    Animator card2Animator = getFlightFromRight(card2);
    Animator starAnimator = getScaleAndVisibilityAnimator(star);
    animator = new AnimatorSet();
    animator.play(starAnimator).after(card2Animator);
    animator.play(card2Animator).after(avatar2Animator);
    animator.play(avatar2Animator).after(card1Animator);
    animator.play(card1Animator).after(avatar1Animator);
}

20. RocketAvatarsAnimator#initializeAnimator()

View license
private void initializeAnimator() {
    final View rocketFlame = rootView.findViewById(R.id.rocket_flame);
    final View avatar1 = rootView.findViewById(R.id.avatar1);
    final View avatar2 = rootView.findViewById(R.id.avatar2);
    final View avatar3 = rootView.findViewById(R.id.avatar3);
    final View avatar4 = rootView.findViewById(R.id.avatar4);
    Animator avatar1Animator = getAnimator(avatar1);
    Animator avatar2Animator = getAnimator(avatar2);
    Animator avatar3Animator = getAnimator(avatar3);
    Animator avatar4Animator = getAnimator(avatar4);
    rocketFlameAnimator = getFlameAnimator(rocketFlame);
    animator = new AnimatorSet();
    animator.setStartDelay(500);
    animator.play(avatar3Animator).after(avatar4Animator);
    animator.play(avatar2Animator).after(avatar3Animator);
    animator.play(avatar1Animator).after(avatar2Animator);
}

21. ViewGroupTest#setUp()

Project: robolectric
Source File: ViewGroupTest.java
View license
@Before
public void setUp() throws Exception {
    Application context = new Application();
    ShadowApplication.bind(context, new ResourceLoader(10, R.class, null, null));
    root = new FrameLayout(context);
    child1 = new View(context);
    child2 = new View(context);
    child3 = new FrameLayout(context);
    child3a = new View(context);
    child3b = new View(context);
    root.addView(child1);
    root.addView(child2);
    root.addView(child3);
    child3.addView(child3a);
    child3.addView(child3b);
    defaultLineSeparator = System.getProperty("line.separator");
    System.setProperty("line.separator", "\n");
}

22. MainActivity#showNoShadersAvailable()

Project: ShaderEditor
Source File: MainActivity.java
View license
private void showNoShadersAvailable() {
    View progressView;
    View textView;
    if ((progressView = findViewById(R.id.progress_bar)) == null || (textView = findViewById(R.id.no_shaders_message)) == null)
        return;
    progressView.setVisibility(View.GONE);
    textView.setVisibility(View.VISIBLE);
    if (shaderAdapter != null)
        shaderAdapter.changeCursor(null);
}

23. SlideLayout#setDim()

Project: SlideLayout
Source File: SlideLayout.java
View license
/**
     * 
     * @param progress 1f: no Dim, 0f: maximum Dim
     * @param maxDim maximum Dim value
     */
private void setDim(float progress, float maxDim) {
    View v = getOverlayView();
    if (v == null)
        return;
    v.clearAnimation();
    ChangeAlphaAnimation anim = new ChangeAlphaAnimation((1f - Math.max(0f, Math.min(1f, progress))) * maxDim);
    v.startAnimation(anim);
    v.setVisibility(progress == 1f ? View.GONE : View.VISIBLE);
}

24. SwipeableLayout#generateCache()

View license
private Bitmap generateCache(ViewGroup aContainer) {
    View view = aContainer.getChildAt(0);
    int width = 0;
    if (view.getMeasuredWidth() <= 0 || view.getMeasuredHeight() <= 0) {
        int parentSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
        aContainer.measure(parentSpec, parentSpec);
    }
    width = view.getMeasuredWidth();
    int spec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    int widthspec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
    view.measure(widthspec, spec);
    view.layout(0, 0, width, view.getMeasuredHeight());
    Bitmap b = Bitmap.createBitmap(width, view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(b);
    view.draw(canvas);
    return b;
}

25. OrderedTraversalControllerTest#testMultipleReorderingKeepReorderingChainCase1()

View license
@MediumTest
public void testMultipleReorderingKeepReorderingChainCase1() {
    if (!checkApiLevelSuffice()) {
        return;
    }
    View view3 = getActivity().findViewById(R.id.node3);
    View view7 = getActivity().findViewById(R.id.node7);
    view3.setAccessibilityTraversalBefore(R.id.node7);
    view7.setAccessibilityTraversalAfter(R.id.node2);
    initController();
    assertForwardOrder(mNode1, mNode2, mNode4, mNode3, mNode7, mNode5, mNode6);
    assertBackwardOrder(mNode6, mNode5, mNode7, mNode3, mNode4, mNode2, mNode1);
}

26. OrderedTraversalControllerTest#testMultipleReorderingKeepReorderingChainCase2()

View license
@MediumTest
public void testMultipleReorderingKeepReorderingChainCase2() {
    if (!checkApiLevelSuffice()) {
        return;
    }
    View view2 = getActivity().findViewById(R.id.node2);
    View view7 = getActivity().findViewById(R.id.node7);
    view2.setAccessibilityTraversalAfter(R.id.node7);
    view7.setAccessibilityTraversalAfter(R.id.node1);
    initController();
    assertForwardOrder(mNode1, mNode5, mNode6, mNode7, mNode2, mNode3, mNode4);
    assertBackwardOrder(mNode4, mNode3, mNode2, mNode7, mNode6, mNode5, mNode1);
}

27. TintLayout#getChildBitmap()

Project: TintLayout
Source File: TintLayout.java
View license
private void getChildBitmap() {
    final View child = getChildAt(0);
    ((LayoutParams) child.getLayoutParams()).gravity = Gravity.CENTER;
    this.childLeft = child.getLeft();
    this.childTop = child.getTop();
    this.childWidth = child.getRight() - this.childLeft;
    this.childHeight = child.getBottom() - this.childTop;
    child.setDrawingCacheEnabled(true);
    child.buildDrawingCache();
    this.childBitmap = Bitmap.createBitmap(child.getDrawingCache());
    child.setDrawingCacheEnabled(false);
    this.isChildGet = true;
}

28. ProgressFragment#onCreateView()

Project: TLint
Source File: ProgressFragment.java
View license
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup main = (ViewGroup) inflater.inflate(R.layout.epf_layout, container, false);
    View content = onCreateContentView(inflater);
    View error = onCreateContentErrorView(inflater);
    View empty = onCreateContentEmptyView(inflater);
    View progress = onCreateProgressView(inflater);
    replaceViewById(main, R.id.epf_content, content);
    replaceViewById(main, R.id.epf_error, error);
    replaceViewById(main, R.id.epf_empty, empty);
    replaceViewById(main, R.id.epf_progress, progress);
    mContentView = main;
    mAnimIn = onCreateAnimationIn();
    mAnimOut = onCreateAnimationOut();
    initStates();
    isPrepare = true;
    return main;
}

29. AnimatorProxy#invalidateAfterUpdate()

Project: todo.txt-android
Source File: AnimatorProxy.java
View license
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View) view.getParent();
    if (parent == null) {
        return;
    }
    view.setAnimation(this);
    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);
    parent.invalidate((int) FloatMath.floor(after.left), (int) FloatMath.floor(after.top), (int) FloatMath.ceil(after.right), (int) FloatMath.ceil(after.bottom));
}

30. MaterialMenuBase#setupActionBar()

View license
private void setupActionBar(Activity activity) {
    final View iconView = getActionBarHomeView(activity);
    final View upView = getActionBarUpView(activity);
    if (iconView == null || upView == null) {
        throw new IllegalStateException("Could not find ActionBar views");
    }
    // need no margins so that clicked state would work nicely
    ViewGroup.MarginLayoutParams iconParams = (ViewGroup.MarginLayoutParams) iconView.getLayoutParams();
    iconParams.bottomMargin = 0;
    iconParams.topMargin = 0;
    iconParams.leftMargin = 0;
    iconView.setLayoutParams(iconParams);
    // remove up arrow margins
    ViewGroup.MarginLayoutParams upParams = (ViewGroup.MarginLayoutParams) upView.getLayoutParams();
    upParams.leftMargin = activity.getResources().getDimensionPixelSize(R.dimen.mm_up_arrow_margin);
    upParams.rightMargin = 0;
    upView.setLayoutParams(upParams);
}

31. MaterialMenuBase#setupActionBar()

View license
private void setupActionBar(Activity activity) {
    final View iconView = getActionBarHomeView(activity);
    final View upView = getActionBarUpView(activity);
    if (iconView == null || upView == null) {
        throw new IllegalStateException("Could not find ActionBar views");
    }
    // need no margins so that clicked state would work nicely
    ViewGroup.MarginLayoutParams iconParams = (ViewGroup.MarginLayoutParams) iconView.getLayoutParams();
    iconParams.bottomMargin = 0;
    iconParams.topMargin = 0;
    iconParams.leftMargin = 0;
    iconView.setLayoutParams(iconParams);
    // remove up arrow margins
    ViewGroup.MarginLayoutParams upParams = (ViewGroup.MarginLayoutParams) upView.getLayoutParams();
    upParams.leftMargin = activity.getResources().getDimensionPixelSize(R.dimen.mm_up_arrow_margin);
    upParams.rightMargin = 0;
    upView.setLayoutParams(upParams);
}

32. AnimatorProxy#invalidateAfterUpdate()

Project: Ushahidi_Android
Source File: AnimatorProxy.java
View license
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View) view.getParent();
    if (parent == null) {
        return;
    }
    view.setAnimation(this);
    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);
    parent.invalidate((int) FloatMath.floor(after.left), (int) FloatMath.floor(after.top), (int) FloatMath.ceil(after.right), (int) FloatMath.ceil(after.bottom));
}

33. PlaybackActivity#bindControlButtons()

Project: vanilla
Source File: PlaybackActivity.java
View license
/**
	 * Sets up onClick listeners for our common control buttons bar
	 */
protected void bindControlButtons() {
    View previousButton = findViewById(R.id.previous);
    previousButton.setOnClickListener(this);
    mPlayPauseButton = (ImageButton) findViewById(R.id.play_pause);
    mPlayPauseButton.setOnClickListener(this);
    View nextButton = findViewById(R.id.next);
    nextButton.setOnClickListener(this);
    mShuffleButton = (ImageButton) findViewById(R.id.shuffle);
    mShuffleButton.setOnClickListener(this);
    registerForContextMenu(mShuffleButton);
    mEndButton = (ImageButton) findViewById(R.id.end_action);
    mEndButton.setOnClickListener(this);
    registerForContextMenu(mEndButton);
}

34. PlaylistAdapter#onCreateViewHolder()

Project: VCL-Android
Source File: PlaylistAdapter.java
View license
@Override
public PlaylistAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_activated_2, parent, false);
    v.setClickable(true);
    v.setFocusable(true);
    v.setFocusableInTouchMode(true);
    ViewHolder vh = new ViewHolder(v);
    return vh;
}

35. MoreChangeListener#updateHeader()

Project: YiBo
Source File: MoreChangeListener.java
View license
private void updateHeader(ViewChangeEvent changeEvent) {
    View llHeaderBase = ((Activity) context).findViewById(R.id.llHeaderBase);
    llHeaderBase.setVisibility(View.VISIBLE);
    View llHeaderMessage = ((Activity) context).findViewById(R.id.llHeaderMessage);
    llHeaderMessage.setVisibility(View.GONE);
    TextView tvTitle = (TextView) context.findViewById(R.id.tvTitle);
    tvTitle.setText(R.string.title_tab_more);
    ImageButton ibProfileImage = (ImageButton) context.findViewById(R.id.ibProfileImage);
    ibProfileImage.setVisibility(View.VISIBLE);
    ImageButton ibGroup = (ImageButton) context.findViewById(R.id.ibGroup);
    ibGroup.setVisibility(View.GONE);
    ImageButton ibEdit = (ImageButton) context.findViewById(R.id.ibEdit);
    ibEdit.setVisibility(View.VISIBLE);
    ibEdit.setOnClickListener(new HomePageEditStatusClickListener(context));
}

36. ProfileChangeListener#updateHeader()

Project: YiBo
Source File: ProfileChangeListener.java
View license
private void updateHeader() {
    View llHeaderBase = ((Activity) context).findViewById(R.id.llHeaderBase);
    llHeaderBase.setVisibility(View.VISIBLE);
    View llHeaderMessage = ((Activity) context).findViewById(R.id.llHeaderMessage);
    llHeaderMessage.setVisibility(View.GONE);
    TextView tvTitle = (TextView) context.findViewById(R.id.tvTitle);
    tvTitle.setText(R.string.title_tab_profile);
    ImageButton ibProfileImage = (ImageButton) context.findViewById(R.id.ibProfileImage);
    ibProfileImage.setVisibility(View.VISIBLE);
    ImageButton ibGroup = (ImageButton) context.findViewById(R.id.ibGroup);
    ibGroup.setVisibility(View.GONE);
    ImageButton ibEdit = (ImageButton) context.findViewById(R.id.ibEdit);
    ibEdit.setVisibility(View.VISIBLE);
    ibEdit.setOnClickListener(new HomePageEditStatusClickListener(context));
}

37. AnimatorProxy#invalidateAfterUpdate()

View license
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View) view.getParent();
    if (parent == null) {
        return;
    }
    view.setAnimation(this);
    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);
    parent.invalidate((int) FloatMath.floor(after.left), (int) FloatMath.floor(after.top), (int) FloatMath.ceil(after.right), (int) FloatMath.ceil(after.bottom));
}

38. QuickAction#showArrow()

Project: android
Source File: QuickAction.java
View license
/**
     * Show arrow
     * 
     * @param whichArrow arrow type resource id
     * @param requestedX distance from left screen
     */
private void showArrow(int whichArrow, int requestedX) {
    final View showArrow = (whichArrow == R.id.arrow_up) ? mArrowUp : mArrowDown;
    final View hideArrow = (whichArrow == R.id.arrow_up) ? mArrowDown : mArrowUp;
    final int arrowWidth = mArrowUp.getMeasuredWidth();
    showArrow.setVisibility(View.VISIBLE);
    ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) showArrow.getLayoutParams();
    param.leftMargin = requestedX - arrowWidth / 2;
    hideArrow.setVisibility(View.INVISIBLE);
}

39. OptionsDisplay#createView()

Project: android-demos
Source File: OptionsDisplay.java
View license
private void createView(ViewGroup parent, TypedArray attributes) {
    mView = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.leftnav_bar_options, parent, false);
    View menuOption = mView.findViewById(R.id.menu);
    configureOption(menuOption, mContext.getResources().getString(R.string.lib_leftnav_bar_option_label), true);
    menuOption.setClickable(true);
    menuOption.setFocusable(true);
    menuOption.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            if (mContext instanceof Activity) {
                ((Activity) mContext).openOptionsMenu();
            }
        }
    });
    setDuplicateParentState(getOptionIcon(menuOption));
    setDuplicateParentState(getOptionTitle(menuOption));
}

40. BaseDialogFragment#modifyButtonsBasedOnScrollableContent()

View license
/**
     * Button divider should be shown only if the content is scrollable.
     */
private void modifyButtonsBasedOnScrollableContent(boolean scrollable) {
    if (getView() == null) {
        return;
    }
    View vButtonDivider = getView().findViewById(R.id.sdl_button_divider);
    View vButtonsBottomSpace = getView().findViewById(R.id.sdl_buttons_bottom_space);
    View vDefaultButtons = getView().findViewById(R.id.sdl_buttons_default);
    View vStackedButtons = getView().findViewById(R.id.sdl_buttons_stacked);
    if (vDefaultButtons.getVisibility() == View.GONE && vStackedButtons.getVisibility() == View.GONE) {
        // no buttons
        vButtonDivider.setVisibility(View.GONE);
        vButtonsBottomSpace.setVisibility(View.GONE);
    } else if (scrollable) {
        vButtonDivider.setVisibility(View.VISIBLE);
        vButtonsBottomSpace.setVisibility(View.GONE);
    } else {
        vButtonDivider.setVisibility(View.GONE);
        vButtonsBottomSpace.setVisibility(View.VISIBLE);
    }
}

41. DisplayUtil#snapShotWithStatusBar()

Project: AndroidStudyDemo
Source File: DisplayUtil.java
View license
/**
     * ??????????????
     *
     * @param activity
     * @return
     */
public static Bitmap snapShotWithStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    int width = getScreenW(activity);
    int height = getScreenH(activity);
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
    view.destroyDrawingCache();
    return bp;
}

42. DisplayUtil#snapShotWithoutStatusBar()

Project: AndroidStudyDemo
Source File: DisplayUtil.java
View license
/**
     * ???????????????
     *
     * @param activity
     * @return
     */
public static Bitmap snapShotWithoutStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    Rect frame = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    int statusBarHeight = frame.top;
    int width = getScreenW(activity);
    int height = getScreenH(activity);
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height - statusBarHeight);
    view.destroyDrawingCache();
    return bp;
}

43. LeftDrawerLayout#onLayout()

View license
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    View menuView = mLeftMenuView;
    View contentView = mContentView;
    MarginLayoutParams lp = (MarginLayoutParams) contentView.getLayoutParams();
    contentView.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + contentView.getMeasuredWidth(), lp.topMargin + contentView.getMeasuredHeight());
    lp = (MarginLayoutParams) menuView.getLayoutParams();
    final int menuWidth = menuView.getMeasuredWidth();
    int childLeft = -menuWidth + (int) (menuWidth * mLeftMenuOnScrren);
    menuView.layout(childLeft, lp.topMargin, childLeft + menuWidth, lp.topMargin + menuView.getMeasuredHeight());
}

44. SwipeableBottomDialog#makeDummyView()

View license
private View makeDummyView(int width, int height) {
    View view = new View(getContext());
    view.setLayoutParams(new ListView.LayoutParams(width, height));
    view.setClickable(true);
    view.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                dismiss();
            }
            return true;
        }
    });
    return view;
}

45. AnimatorProxy#invalidateAfterUpdate()

Project: astrid
Source File: AnimatorProxy.java
View license
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View) view.getParent();
    if (parent == null) {
        return;
    }
    view.setAnimation(this);
    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);
    parent.invalidate((int) FloatMath.floor(after.left), (int) FloatMath.floor(after.top), (int) FloatMath.ceil(after.right), (int) FloatMath.ceil(after.bottom));
}

46. ActFmLoginActivity#initializeUI()

Project: astrid
Source File: ActFmLoginActivity.java
View license
@SuppressWarnings("nls")
protected void initializeUI() {
    errors = (TextView) findViewById(R.id.error);
    LoginButton loginButton = (LoginButton) findViewById(R.id.fb_login);
    if (loginButton == null)
        return;
    loginButton.setReadPermissions(Arrays.asList("email", "offline_access"));
    View googleLogin = findViewById(R.id.gg_login);
    if (AmazonMarketStrategy.isKindleFire())
        googleLogin.setVisibility(View.GONE);
    googleLogin.setOnClickListener(googleListener);
    View fbLogin = findViewById(R.id.fb_login_dummy);
    fbLogin.setOnClickListener(facebookListener);
    TextView signUp = (TextView) findViewById(R.id.pw_signup);
    signUp.setOnClickListener(signUpListener);
    TextView signIn = (TextView) findViewById(R.id.pw_login);
    signIn.setOnClickListener(signInListener);
    setupTermsOfService((TextView) findViewById(R.id.tos));
}

47. AACRecordingActivity#setupUi()

Project: astrid
Source File: AACRecordingActivity.java
View license
private void setupUi() {
    View stopRecording = findViewById(R.id.stop_recording);
    stopRecording.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            stopRecording();
        }
    });
    View dismiss = findViewById(R.id.dismiss);
    dismiss.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            recorder.setListener(null);
            recorder.stopRecording();
            finish();
        }
    });
    timer = (Chronometer) findViewById(R.id.timer);
}

48. QuickActionWidget#showArrow()

Project: astrid
Source File: QuickActionWidget.java
View license
private void showArrow() {
    final View contentView = getContentView();
    final int arrowId = mIsOnTop ? R.id.gdi_arrow_down : R.id.gdi_arrow_up;
    final View arrow = contentView.findViewById(arrowId);
    final View arrowUp = contentView.findViewById(R.id.gdi_arrow_up);
    final View arrowDown = contentView.findViewById(R.id.gdi_arrow_down);
    if (arrowId == R.id.gdi_arrow_up) {
        arrowUp.setVisibility(View.VISIBLE);
        arrowDown.setVisibility(View.INVISIBLE);
    } else if (arrowId == R.id.gdi_arrow_down) {
        arrowUp.setVisibility(View.INVISIBLE);
        arrowDown.setVisibility(View.VISIBLE);
    }
    ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams();
    param.leftMargin = getArrowLeftMargin(arrow);
}

49. ButterKnifeTest#propertyAppliedToEveryViewInArray()

Project: butterknife
Source File: ButterKnifeTest.java
View license
@Test
public void propertyAppliedToEveryViewInArray() {
    View view1 = new View(RuntimeEnvironment.application);
    View view2 = new View(RuntimeEnvironment.application);
    View view3 = new View(RuntimeEnvironment.application);
    assertThat(view1.isEnabled()).isTrue();
    assertThat(view2.isEnabled()).isTrue();
    assertThat(view3.isEnabled()).isTrue();
    View[] views = new View[] { view1, view2, view3 };
    ButterKnife.apply(views, PROPERTY_ENABLED, false);
    assertThat(view1.isEnabled()).isFalse();
    assertThat(view2.isEnabled()).isFalse();
    assertThat(view3.isEnabled()).isFalse();
}

50. ButterKnifeTest#actionAppliedToEveryViewInArray()

Project: butterknife
Source File: ButterKnifeTest.java
View license
@Test
public void actionAppliedToEveryViewInArray() {
    View view1 = new View(RuntimeEnvironment.application);
    View view2 = new View(RuntimeEnvironment.application);
    View view3 = new View(RuntimeEnvironment.application);
    assertThat(view1.isEnabled()).isTrue();
    assertThat(view2.isEnabled()).isTrue();
    assertThat(view3.isEnabled()).isTrue();
    View[] views = new View[] { view1, view2, view3 };
    ButterKnife.apply(views, ACTION_DISABLE);
    assertThat(view1.isEnabled()).isFalse();
    assertThat(view2.isEnabled()).isFalse();
    assertThat(view3.isEnabled()).isFalse();
}

51. ButterKnifeTest#actionsAppliedToEveryViewInArray()

Project: butterknife
Source File: ButterKnifeTest.java
View license
@Test
public void actionsAppliedToEveryViewInArray() {
    View view1 = new View(RuntimeEnvironment.application);
    View view2 = new View(RuntimeEnvironment.application);
    View view3 = new View(RuntimeEnvironment.application);
    assertThat(view1.isEnabled()).isTrue();
    assertThat(view2.isEnabled()).isTrue();
    assertThat(view3.isEnabled()).isTrue();
    assertThat(view1.getAlpha()).isEqualTo(1f);
    assertThat(view2.getAlpha()).isEqualTo(1f);
    assertThat(view3.getAlpha()).isEqualTo(1f);
    View[] views = new View[] { view1, view2, view3 };
    ButterKnife.apply(views, ACTION_DISABLE, ACTION_ZERO_ALPHA);
    assertThat(view1.isEnabled()).isFalse();
    assertThat(view2.isEnabled()).isFalse();
    assertThat(view3.isEnabled()).isFalse();
    assertThat(view1.getAlpha()).isEqualTo(0f);
    assertThat(view2.getAlpha()).isEqualTo(0f);
    assertThat(view3.getAlpha()).isEqualTo(0f);
}

52. ButterKnifeTest#setterAppliedToEveryViewInArray()

Project: butterknife
Source File: ButterKnifeTest.java
View license
@Test
public void setterAppliedToEveryViewInArray() {
    View view1 = new View(RuntimeEnvironment.application);
    View view2 = new View(RuntimeEnvironment.application);
    View view3 = new View(RuntimeEnvironment.application);
    assertThat(view1.isEnabled()).isTrue();
    assertThat(view2.isEnabled()).isTrue();
    assertThat(view3.isEnabled()).isTrue();
    View[] views = new View[] { view1, view2, view3 };
    ButterKnife.apply(views, SETTER_ENABLED, false);
    assertThat(view1.isEnabled()).isFalse();
    assertThat(view2.isEnabled()).isFalse();
    assertThat(view3.isEnabled()).isFalse();
}

53. ColorPickerDialog#showAdvancedView()

View license
/**
     * Hides the simple view (the default) and shows the advanced one instead, hiding the
     * "More" button at the same time.
     */
private void showAdvancedView() {
    // Only need to hide the borders, not the Views themselves, since the Views are
    // contained within the borders.
    View buttonBorder = findViewById(R.id.more_colors_button_border);
    buttonBorder.setVisibility(View.GONE);
    View simpleView = findViewById(R.id.color_picker_simple);
    simpleView.setVisibility(View.GONE);
    mAdvancedColorPicker.setVisibility(View.VISIBLE);
    mAdvancedColorPicker.setListener(this);
    mAdvancedColorPicker.setColor(mCurrentColor);
}

54. MaterialMenuBase#setupActionBar()

Project: Conquer
Source File: MaterialMenuBase.java
View license
private void setupActionBar(Activity activity) {
    final View iconView = getActionBarHomeView(activity);
    final View upView = getActionBarUpView(activity);
    if (iconView == null || upView == null) {
        throw new IllegalStateException("Could not find ActionBar views");
    }
    // need no margins so that clicked state would work nicely
    ViewGroup.MarginLayoutParams iconParams = (ViewGroup.MarginLayoutParams) iconView.getLayoutParams();
    iconParams.bottomMargin = 0;
    iconParams.topMargin = 0;
    iconParams.leftMargin = 0;
    iconView.setLayoutParams(iconParams);
    // remove up arrow margins
    ViewGroup.MarginLayoutParams upParams = (ViewGroup.MarginLayoutParams) upView.getLayoutParams();
    upParams.leftMargin = activity.getResources().getDimensionPixelSize(R.dimen.mm_up_arrow_margin);
    upParams.rightMargin = 0;
    upView.setLayoutParams(upParams);
}

55. Utils#getDivider()

Project: Context-Menu.Android
Source File: Utils.java
View license
public static View getDivider(Context context, MenuObject menuItem) {
    View dividerView = new View(context);
    RelativeLayout.LayoutParams viewLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) context.getResources().getDimension(R.dimen.divider_height));
    viewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    dividerView.setLayoutParams(viewLayoutParams);
    dividerView.setClickable(true);
    int dividerColor = menuItem.getDividerColor() == Integer.MAX_VALUE ? R.color.divider_color : menuItem.getDividerColor();
    dividerView.setBackgroundColor(ContextCompat.getColor(context, dividerColor));
    return dividerView;
}

56. PassFailButtons#setInfo()

Project: CtsVerifier
Source File: PassFailButtons.java
View license
private static void setInfo(final android.app.Activity activity, final int titleId, final int messageId, final int viewId) {
    // Show the middle "info" button and make it show the info dialog when clicked.
    View infoButton = activity.findViewById(R.id.info_button);
    infoButton.setVisibility(View.VISIBLE);
    infoButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            showInfoDialog(activity, titleId, messageId, viewId);
        }
    });
    infoButton.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View view) {
            Toast.makeText(activity, R.string.info_button_text, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    // Show the info dialog if the user has never seen it before.
    if (!hasSeenInfoDialog(activity)) {
        showInfoDialog(activity, titleId, messageId, viewId);
    }
}

57. ViewMatchersTest#testIsVisible()

View license
public void testIsVisible() {
    View visible = new View(getInstrumentation().getTargetContext());
    visible.setVisibility(View.VISIBLE);
    View invisible = new View(getInstrumentation().getTargetContext());
    invisible.setVisibility(View.INVISIBLE);
    assertTrue(withEffectiveVisibility(Visibility.VISIBLE).matches(visible));
    assertFalse(withEffectiveVisibility(Visibility.VISIBLE).matches(invisible));
    // Make the visible view invisible by giving it an invisible parent.
    ViewGroup parent = new RelativeLayout(getInstrumentation().getTargetContext());
    parent.addView(visible);
    parent.setVisibility(View.INVISIBLE);
    assertFalse(withEffectiveVisibility(Visibility.VISIBLE).matches(visible));
}

58. ViewMatchersTest#testIsInvisible()

View license
public void testIsInvisible() {
    View visible = new View(getInstrumentation().getTargetContext());
    visible.setVisibility(View.VISIBLE);
    View invisible = new View(getInstrumentation().getTargetContext());
    invisible.setVisibility(View.INVISIBLE);
    assertFalse(withEffectiveVisibility(Visibility.INVISIBLE).matches(visible));
    assertTrue(withEffectiveVisibility(Visibility.INVISIBLE).matches(invisible));
    // Make the visible view invisible by giving it an invisible parent.
    ViewGroup parent = new RelativeLayout(getInstrumentation().getTargetContext());
    parent.addView(visible);
    parent.setVisibility(View.INVISIBLE);
    assertTrue(withEffectiveVisibility(Visibility.INVISIBLE).matches(visible));
}

59. ViewMatchersTest#testIsGone()

View license
public void testIsGone() {
    View gone = new View(getInstrumentation().getTargetContext());
    gone.setVisibility(View.GONE);
    View visible = new View(getInstrumentation().getTargetContext());
    visible.setVisibility(View.VISIBLE);
    assertFalse(withEffectiveVisibility(Visibility.GONE).matches(visible));
    assertTrue(withEffectiveVisibility(Visibility.GONE).matches(gone));
    // Make the gone view gone by giving it a gone parent.
    ViewGroup parent = new RelativeLayout(getInstrumentation().getTargetContext());
    parent.addView(visible);
    parent.setVisibility(View.GONE);
    assertTrue(withEffectiveVisibility(Visibility.GONE).matches(visible));
}

60. HalfHalfModifier#getView()

Project: droidar
Source File: HalfHalfModifier.java
View license
@Override
public View getView(Context context) {
    LinearLayout l = new LinearLayout(context);
    View left = myLeft.getView(context);
    View right = myRight.getView(context);
    LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1);
    left.setLayoutParams(params);
    right.setLayoutParams(params);
    l.addView(left);
    l.addView(right);
    return l;
}

61. QuickAction#showArrow()

View license
/**
     * Show arrow
     * 
     * @param whichArrow
     *            arrow type resource id
     * @param requestedX
     *            distance from left screen
     */
private void showArrow(final int whichArrow, final int requestedX) {
    final View showArrow = (whichArrow == R.id.arrow_up) ? mArrowUp : mArrowDown;
    final View hideArrow = (whichArrow == R.id.arrow_up) ? mArrowDown : mArrowUp;
    final int arrowWidth = mArrowUp.getMeasuredWidth();
    showArrow.setVisibility(View.VISIBLE);
    final ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) showArrow.getLayoutParams();
    param.leftMargin = requestedX - (arrowWidth / 2);
    hideArrow.setVisibility(View.INVISIBLE);
}

62. LeftDrawerLayout#onLayout()

Project: FlowingDrawer
Source File: LeftDrawerLayout.java
View license
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    View menuView = mLeftMenuView;
    View contentView = mContentView;
    MarginLayoutParams lp = (MarginLayoutParams) contentView.getLayoutParams();
    contentView.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + contentView.getMeasuredWidth(), lp.topMargin + contentView.getMeasuredHeight());
    lp = (MarginLayoutParams) menuView.getLayoutParams();
    final int menuWidth = menuView.getMeasuredWidth();
    int childLeft = -menuWidth + (int) (menuWidth * mLeftMenuOnScrren);
    menuView.layout(childLeft, lp.topMargin, childLeft + menuWidth, lp.topMargin + menuView.getMeasuredHeight());
}

63. FoldingCell#setStateToFolded()

View license
/**
     * Instantly change current state of cell to Folded without any animations
     */
protected void setStateToFolded() {
    if (this.mAnimationInProgress || !this.mUnfolded)
        return;
    // get basic views
    final View contentView = getChildAt(0);
    if (contentView == null)
        return;
    final View titleView = getChildAt(1);
    if (titleView == null)
        return;
    contentView.setVisibility(GONE);
    titleView.setVisibility(VISIBLE);
    FoldingCell.this.mUnfolded = false;
    ViewGroup.LayoutParams layoutParams = this.getLayoutParams();
    layoutParams.height = titleView.getHeight();
    this.setLayoutParams(layoutParams);
    this.requestLayout();
}

64. FoldingCell#setStateToUnfolded()

View license
/**
     * Instantly change current state of cell to Unfolded without any animations
     */
protected void setStateToUnfolded() {
    if (this.mAnimationInProgress || this.mUnfolded)
        return;
    // get basic views
    final View contentView = getChildAt(0);
    if (contentView == null)
        return;
    final View titleView = getChildAt(1);
    if (titleView == null)
        return;
    contentView.setVisibility(VISIBLE);
    titleView.setVisibility(GONE);
    FoldingCell.this.mUnfolded = true;
    ViewGroup.LayoutParams layoutParams = this.getLayoutParams();
    layoutParams.height = contentView.getHeight();
    this.setLayoutParams(layoutParams);
    this.requestLayout();
}

65. UiHelper#snapShotWithStatusBar()

Project: GanWuMei
Source File: UiHelper.java
View license
/**
     * ??????????????
     */
public static Bitmap snapShotWithStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    int width = getScreenWidth(activity);
    int height = getScreenHeight(activity);
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
    view.destroyDrawingCache();
    return bp;
}

66. UiHelper#snapShotWithoutStatusBar()

Project: GanWuMei
Source File: UiHelper.java
View license
/**
     * ???????????????
     */
public static Bitmap snapShotWithoutStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    Rect frame = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    int statusBarHeight = frame.top;
    int width = getScreenWidth(activity);
    int height = getScreenHeight(activity);
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height - statusBarHeight);
    view.destroyDrawingCache();
    return bp;
}

67. QuickActionWidget#showArrow()

Project: GreenDroid
Source File: QuickActionWidget.java
View license
private void showArrow() {
    final View contentView = getContentView();
    final int arrowId = mIsOnTop ? R.id.gdi_arrow_down : R.id.gdi_arrow_up;
    final View arrow = contentView.findViewById(arrowId);
    final View arrowUp = contentView.findViewById(R.id.gdi_arrow_up);
    final View arrowDown = contentView.findViewById(R.id.gdi_arrow_down);
    if (arrowId == R.id.gdi_arrow_up) {
        arrowUp.setVisibility(View.VISIBLE);
        arrowDown.setVisibility(View.INVISIBLE);
    } else if (arrowId == R.id.gdi_arrow_down) {
        arrowUp.setVisibility(View.INVISIBLE);
        arrowDown.setVisibility(View.VISIBLE);
    }
    ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams();
    param.leftMargin = mRect.centerX() - (arrow.getMeasuredWidth()) / 2;
}

68. MessageCompose#addAttachmentView()

Project: k-9
Source File: MessageCompose.java
View license
private void addAttachmentView(Attachment attachment) {
    boolean hasMetadata = (attachment.state != Attachment.LoadingState.URI_ONLY);
    boolean isLoadingComplete = (attachment.state == Attachment.LoadingState.COMPLETE);
    View view = getLayoutInflater().inflate(R.layout.message_compose_attachment, mAttachments, false);
    TextView nameView = (TextView) view.findViewById(R.id.attachment_name);
    View progressBar = view.findViewById(R.id.progressBar);
    if (hasMetadata) {
        nameView.setText(attachment.name);
    } else {
        nameView.setText(R.string.loading_attachment);
    }
    progressBar.setVisibility(isLoadingComplete ? View.GONE : View.VISIBLE);
    ImageButton delete = (ImageButton) view.findViewById(R.id.attachment_delete);
    delete.setOnClickListener(MessageCompose.this);
    delete.setTag(view);
    view.setTag(attachment);
    mAttachments.addView(view);
}

69. AnimatorProxy#invalidateAfterUpdate()

View license
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View) view.getParent();
    if (parent == null) {
        return;
    }
    view.setAnimation(this);
    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);
    parent.invalidate((int) FloatMath.floor(after.left), (int) FloatMath.floor(after.top), (int) FloatMath.ceil(after.right), (int) FloatMath.ceil(after.bottom));
}

70. SimpleSwipeUndoAdapter#getView()

View license
@NonNull
@Override
public View getView(final int position, @Nullable final View convertView, @NonNull final ViewGroup parent) {
    SwipeUndoView view = (SwipeUndoView) convertView;
    if (view == null) {
        view = new SwipeUndoView(mContext);
    }
    View primaryView = super.getView(position, view.getPrimaryView(), view);
    view.setPrimaryView(primaryView);
    View undoView = mUndoAdapter.getUndoView(position, view.getUndoView(), view);
    view.setUndoView(undoView);
    mUndoAdapter.getUndoClickView(undoView).setOnClickListener(new UndoClickListener(view, position));
    boolean isInUndoState = mUndoPositions.contains(position);
    primaryView.setVisibility(isInUndoState ? View.GONE : View.VISIBLE);
    undoView.setVisibility(isInUndoState ? View.VISIBLE : View.GONE);
    return view;
}

71. ProgressCheckDialog#onViewCreated()

View license
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    View cancelButton = view.findViewById(android.R.id.button2);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    View confirmButton = view.findViewById(android.R.id.button1);
    confirmButton.setOnClickListener(new View.OnClickListener() {

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

72. ProgressCheckDialog#onViewCreated()

View license
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    View cancelButton = view.findViewById(android.R.id.button2);
    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    View confirmButton = view.findViewById(android.R.id.button1);
    confirmButton.setOnClickListener(new View.OnClickListener() {

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

73. MaterialMenuBase#setupActionBar()

Project: material-menu
Source File: MaterialMenuBase.java
View license
private void setupActionBar(Activity activity) {
    final View iconView = getActionBarHomeView(activity);
    final View upView = getActionBarUpView(activity);
    if (iconView == null || upView == null) {
        throw new IllegalStateException("Could not find ActionBar views");
    }
    // need no margins so that clicked state would work nicely
    ViewGroup.MarginLayoutParams iconParams = (ViewGroup.MarginLayoutParams) iconView.getLayoutParams();
    iconParams.bottomMargin = 0;
    iconParams.topMargin = 0;
    iconParams.leftMargin = 0;
    iconView.setLayoutParams(iconParams);
    // remove up arrow margins
    ViewGroup.MarginLayoutParams upParams = (ViewGroup.MarginLayoutParams) upView.getLayoutParams();
    upParams.leftMargin = activity.getResources().getDimensionPixelSize(R.dimen.mm_up_arrow_margin);
    upParams.rightMargin = 0;
    upView.setLayoutParams(upParams);
}

74. ScreenUtil#snapShotWithStatusBar()

Project: MousePaint
Source File: ScreenUtil.java
View license
/**
     * ??????????????
     * @param activity
     * @return
     */
public static Bitmap snapShotWithStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    int width = getScreenWidth();
    int height = getScreenHeight();
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
    view.destroyDrawingCache();
    return bp;
}

75. ScreenUtil#snapShotWithoutStatusBar()

Project: MousePaint
Source File: ScreenUtil.java
View license
/**
     * ???????????????
     * @param activity
     * @return
     */
public static Bitmap snapShotWithoutStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    Rect frame = new Rect();
    activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
    int statusBarHeight = frame.top;
    int width = getScreenWidth();
    int height = getScreenHeight();
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height - statusBarHeight);
    view.destroyDrawingCache();
    return bp;
}

76. GPXFragment#setButtonsEnabledState()

Project: MozStumbler
Source File: GPXFragment.java
View license
private void setButtonsEnabledState() {
    View buttonLoad = mRootView.findViewById(R.id.buttonLoad);
    View buttonSave = mRootView.findViewById(R.id.buttonSave);
    buttonLoad.setEnabled(!mIsRunning);
    buttonSave.setEnabled(!mIsRunning && !mPointsToWrite.isEmpty());
    if (!mIsRunning) {
        String[] files = getFileList();
        buttonLoad.setEnabled(files != null && files.length > 0);
    }
}

77. KMLFragment#setButtonsEnabledState()

Project: MozStumbler
Source File: KMLFragment.java
View license
private void setButtonsEnabledState() {
    View buttonLoad = mRootView.findViewById(R.id.buttonLoad);
    View buttonSave = mRootView.findViewById(R.id.buttonSave);
    buttonLoad.setEnabled(!mIsRunning);
    buttonSave.setEnabled(!mIsRunning && !mPointsToWrite.isEmpty());
    if (!mIsRunning) {
        String[] files = getFileList();
        buttonLoad.setEnabled(files != null && files.length > 0);
    }
}

78. QuickAction#showArrow()

View license
/**
     * Show arrow
     * 
     * @param whichArrow arrow type resource id
     * @param requestedX distance from left screen
     */
private void showArrow(int whichArrow, int requestedX) {
    final View showArrow = (whichArrow == R.id.arrow_up) ? mArrowUp : mArrowDown;
    final View hideArrow = (whichArrow == R.id.arrow_up) ? mArrowDown : mArrowUp;
    final int arrowWidth = mArrowUp.getMeasuredWidth();
    showArrow.setVisibility(View.VISIBLE);
    ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) showArrow.getLayoutParams();
    param.leftMargin = requestedX - arrowWidth / 2;
    hideArrow.setVisibility(View.INVISIBLE);
}

79. AnimatorProxy#invalidateAfterUpdate()

Project: networklog
Source File: AnimatorProxy.java
View license
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View) view.getParent();
    if (parent == null) {
        return;
    }
    view.setAnimation(this);
    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);
    parent.invalidate((int) FloatMath.floor(after.left), (int) FloatMath.floor(after.top), (int) FloatMath.ceil(after.right), (int) FloatMath.ceil(after.bottom));
}

80. QuickAction#showArrow()

Project: NewQuickAction
Source File: QuickAction.java
View license
/**
	 * Show arrow
	 * 
	 * @param whichArrow arrow type resource id
	 * @param requestedX distance from left screen
	 */
private void showArrow(int whichArrow, int requestedX) {
    final View showArrow = (whichArrow == R.id.arrow_up) ? mArrowUp : mArrowDown;
    final View hideArrow = (whichArrow == R.id.arrow_up) ? mArrowDown : mArrowUp;
    final int arrowWidth = mArrowUp.getMeasuredWidth();
    showArrow.setVisibility(View.VISIBLE);
    ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) showArrow.getLayoutParams();
    param.leftMargin = requestedX - arrowWidth / 2;
    hideArrow.setVisibility(View.INVISIBLE);
}

81. QuickAction#showArrow()

Project: NewQuickAction3D
Source File: QuickAction.java
View license
/**
	 * Show arrow
	 * 
	 * @param whichArrow arrow type resource id
	 * @param requestedX distance from left screen
	 */
private void showArrow(int whichArrow, int requestedX) {
    final View showArrow = (whichArrow == R.id.arrow_up) ? mArrowUp : mArrowDown;
    final View hideArrow = (whichArrow == R.id.arrow_up) ? mArrowDown : mArrowUp;
    final int arrowWidth = mArrowUp.getMeasuredWidth();
    showArrow.setVisibility(View.VISIBLE);
    ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) showArrow.getLayoutParams();
    param.leftMargin = requestedX - arrowWidth / 2;
    hideArrow.setVisibility(View.INVISIBLE);
}

82. QuickAction#showArrow()

Project: ObscuraCam
Source File: QuickAction.java
View license
/**
	 * Show arrow
	 * 
	 * @param whichArrow arrow type resource id
	 * @param requestedX distance from left screen
	 */
private void showArrow(int whichArrow, int requestedX) {
    final View showArrow = (whichArrow == R.id.arrow_up) ? mArrowUp : mArrowDown;
    final View hideArrow = (whichArrow == R.id.arrow_up) ? mArrowDown : mArrowUp;
    final int arrowWidth = mArrowUp.getMeasuredWidth();
    showArrow.setVisibility(View.VISIBLE);
    ViewGroup.MarginLayoutParams param = (ViewGroup.MarginLayoutParams) showArrow.getLayoutParams();
    param.leftMargin = requestedX - arrowWidth / 2;
    hideArrow.setVisibility(View.INVISIBLE);
}

83. ViewUtils#snapShotWithStatusBar()

Project: PracticeDemo
Source File: ViewUtils.java
View license
/**
     * ??????????????
     * @param activity
     */
public static Bitmap snapShotWithStatusBar(Activity activity) {
    View view = activity.getWindow().getDecorView();
    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    Bitmap bmp = view.getDrawingCache();
    int width = getScreenWidth(activity);
    int height = getScreenHeight(activity);
    Bitmap bp = null;
    bp = Bitmap.createBitmap(bmp, 0, 0, width, height);
    view.destroyDrawingCache();
    return bp;
}

84. BaseActivity#lightsOutMode()

Project: Protocoder
Source File: BaseActivity.java
View license
public void lightsOutMode() {
    lightsOutMode = true;
    final View rootView = getWindow().getDecorView();
    rootView.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
    rootView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
    rootView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {

        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            MLog.d(TAG, "" + visibility);
            rootView.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
            rootView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
        }
    });
}

85. ToolbarIndicator#onPageSelected()

Project: QDNews
Source File: ToolbarIndicator.java
View license
@Override
public void onPageSelected(int position) {
    if (mAnimationIn.isRunning())
        mAnimationIn.cancel();
    if (mAnimationOut.isRunning())
        mAnimationOut.cancel();
    View currentIndicator = getChildAt(mCurrentPosition);
    currentIndicator.setBackgroundResource(mIndicatorUnselectedBackground);
    mAnimationIn.setTarget(currentIndicator);
    mAnimationIn.start();
    View selectedIndicaotr = getChildAt(position);
    selectedIndicaotr.setBackgroundResource(mIndicatorBackground);
    mAnimationOut.setTarget(selectedIndicaotr);
    mAnimationOut.start();
    mCurrentPosition = position;
}

86. NativeViewHierarchyManager#measure()

View license
/**
   * Returns true on success, false on failure. If successful, after calling, output buffer will be
   * {x, y, width, height}.
   */
public void measure(int tag, int[] outputBuffer) {
    UiThreadUtil.assertOnUiThread();
    View v = mTagsToViews.get(tag);
    if (v == null) {
        throw new NoSuchNativeViewException("No native view for " + tag + " currently exists");
    }
    View rootView = (View) RootViewUtil.getRootView(v);
    // and has been removed by clipping
    if (rootView == null) {
        throw new NoSuchNativeViewException("Native view " + tag + " is no longer on screen");
    }
    rootView.getLocationInWindow(outputBuffer);
    int rootX = outputBuffer[0];
    int rootY = outputBuffer[1];
    v.getLocationInWindow(outputBuffer);
    outputBuffer[0] = outputBuffer[0] - rootX;
    outputBuffer[1] = outputBuffer[1] - rootY;
    outputBuffer[2] = v.getWidth();
    outputBuffer[3] = v.getHeight();
}

87. DensityActivity#addBitmapDrawable()

View license
private void addBitmapDrawable(LinearLayout layout, int resource, boolean scale) {
    Bitmap bitmap;
    bitmap = loadAndPrintDpi(resource, scale);
    View view = new View(this);
    final BitmapDrawable d = new BitmapDrawable(getResources(), bitmap);
    if (!scale)
        d.setTargetDensity(getResources().getDisplayMetrics());
    view.setBackgroundDrawable(d);
    view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(), d.getIntrinsicHeight()));
    layout.addView(view);
}

88. DensityActivity#addNinePatchResourceDrawable()

View license
private void addNinePatchResourceDrawable(LinearLayout layout, int resource) {
    View view = new View(this);
    final Drawable d = getResources().getDrawable(resource);
    view.setBackgroundDrawable(d);
    Log.i("foo", "9-patch #" + Integer.toHexString(resource) + " w=" + d.getIntrinsicWidth() + " h=" + d.getIntrinsicHeight());
    view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth() * 2, d.getIntrinsicHeight() * 2));
    layout.addView(view);
}

89. UARTButtonAdapter#getView()

View license
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
    View view = convertView;
    if (view == null) {
        final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        view = inflater.inflate(R.layout.feature_uart_button, parent, false);
    }
    view.setEnabled(isEnabled(position));
    view.setActivated(mEditMode);
    // Update image
    final Command command = (Command) getItem(position);
    final ImageView image = (ImageView) view;
    final boolean active = command != null && command.isActive();
    if (active) {
        final int icon = command.getIconIndex();
        image.setImageResource(R.drawable.uart_button);
        image.setImageLevel(icon);
    } else
        image.setImageDrawable(null);
    return view;
}

90. SampleListFragment#onCreateView()

View license
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_list, null);
    mListView = (ListView) v.findViewById(R.id.listView);
    View placeHolderView = inflater.inflate(R.layout.view_header_placeholder, mListView, false);
    placeHolderView.setBackgroundColor(0xFFFFFFFF);
    mListView.addHeaderView(placeHolderView);
    return v;
}

91. DynamicSongQueryAdapter#newView()

View license
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    View convertView = ((Activity) mContext).getLayoutInflater().inflate(R.layout.item_dynamic_song_query, parent, false);
    convertView.setBackgroundResource(R.drawable.selector_white_orange_selected);
    ViewHolder viewHolder = new ViewHolder();
    viewHolder.title = (TextView) convertView.findViewById(R.id.tv_dsq_title);
    viewHolder.subtitle = (TextView) convertView.findViewById(R.id.tv_dsq_subtitle);
    viewHolder.image = (ImageView) convertView.findViewById(R.id.img_dsq_icon);
    convertView.setTag(viewHolder);
    return convertView;
}

92. SpinnerItemAdapter#bindView()

View license
private void bindView(int position, View spinnerItemView, SpinnerItem spinnerItem) {
    // configure spinner name
    TextView nameView = (TextView) spinnerItemView.findViewById(R.id.spinner_name);
    spinnerItem.formatNameView(nameView);
    // configure spinner color
    View colorView = spinnerItemView.findViewById(R.id.spinner_color);
    spinnerItem.formatColorView(colorView);
    // set background for selected item
    View textContainer = spinnerItemView.findViewById(R.id.chip_pacemaker);
    textContainer = textContainer == null ? nameView : textContainer;
    textContainer.setBackgroundResource(position == mSelectedItem ? mSelectedBackgroundId : android.R.color.transparent);
}

93. TransitionHelper#createSafeTransitionParticipants()

View license
/**
     * Create the transition participants required during a activity transition while
     * avoiding glitches with the system UI.
     *
     * @param activity The activity used as start for the transition.
     * @param includeStatusBar If false, the status bar will not be added as the transition
     * participant.
     * @return All transition participants.
     */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Pair<View, String>[] createSafeTransitionParticipants(@NonNull Activity activity, boolean includeStatusBar, @Nullable Pair... otherParticipants) {
    // Avoid system UI glitches as described here:
    // https://plus.google.com/+AlexLockwood/posts/RPtwZ5nNebb
    View decor = activity.getWindow().getDecorView();
    View statusBar = null;
    if (includeStatusBar) {
        statusBar = decor.findViewById(android.R.id.statusBarBackground);
    }
    View navBar = decor.findViewById(android.R.id.navigationBarBackground);
    // Create pair of transition participants.
    List<Pair> participants = new ArrayList<>(3);
    addNonNullViewToTransitionParticipants(statusBar, participants);
    addNonNullViewToTransitionParticipants(navBar, participants);
    // only add transition participants if there's at least one none-null element
    if (otherParticipants != null && !(otherParticipants.length == 1 && otherParticipants[0] == null)) {
        participants.addAll(Arrays.asList(otherParticipants));
    }
    //noinspection unchecked
    return participants.toArray(new Pair[participants.size()]);
}

94. MainActivity#getActivityOptions()

Project: android-unsplash
Source File: MainActivity.java
View license
private ActivityOptions getActivityOptions(PhotoItemBinding binding) {
    Pair authorPair = Pair.create(binding.author, binding.author.getTransitionName());
    Pair photoPair = Pair.create(binding.photo, binding.photo.getTransitionName());
    View decorView = getWindow().getDecorView();
    View statusBackground = decorView.findViewById(android.R.id.statusBarBackground);
    View navBackground = decorView.findViewById(android.R.id.navigationBarBackground);
    Pair statusPair = Pair.create(statusBackground, statusBackground.getTransitionName());
    final ActivityOptions options;
    if (navBackground == null) {
        options = ActivityOptions.makeSceneTransitionAnimation(this, authorPair, photoPair, statusPair);
    } else {
        Pair navPair = Pair.create(navBackground, navBackground.getTransitionName());
        options = ActivityOptions.makeSceneTransitionAnimation(this, authorPair, photoPair, statusPair, navPair);
    }
    return options;
}

95. PermissionsActivity#onCreate()

View license
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getIntent() == null || !getIntent().hasExtra(EXTRA_PERMISSIONS)) {
        throw new RuntimeException("PermissionsActivity??????startActivityForResult????!");
    }
    View view = new View(this);
    view.setBackgroundColor(getResources().getColor(R.color.theme_color_level2));
    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    view.setLayoutParams(lp);
    setContentView(view);
    mChecker = new PermissionsChecker(this);
    isRequireCheck = true;
}

96. AtlasMessageComposer#addAttachmentMenuItem()

View license
private void addAttachmentMenuItem(AttachmentSender sender) {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    LinearLayout menuLayout = (LinearLayout) mAttachmentMenu.getContentView();
    View menuItem = inflater.inflate(R.layout.atlas_message_composer_attachment_menu_item, menuLayout, false);
    ((TextView) menuItem.findViewById(R.id.title)).setText(sender.getTitle());
    menuItem.setTag(sender);
    menuItem.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            mAttachmentMenu.dismiss();
            ((AttachmentSender) v.getTag()).requestSend();
        }
    });
    if (sender.getIcon() != null) {
        ImageView iconView = ((ImageView) menuItem.findViewById(R.id.icon));
        iconView.setImageResource(sender.getIcon());
        iconView.setVisibility(VISIBLE);
        Drawable d = DrawableCompat.wrap(iconView.getDrawable());
        DrawableCompat.setTint(d, getResources().getColor(R.color.atlas_icon_enabled));
    }
    menuLayout.addView(menuItem);
}

97. BeaconEntityAdapter#onCreateViewHolder()

View license
@Override
public BeaconEntityAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.e_list, parent, false);
    ViewHolder vh = new ViewHolder(v);
    v.setOnClickListener(this);
    v.setTag(vh);
    return vh;
}

98. GridMenuFragment#onCreateView()

View license
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    final View view = inflater.inflate(R.layout.fragment_grid_menu, null);
    View backgroundView = view.findViewById(R.id.blurred_view);
    int backgroundResourceID = getArguments().getInt(KEY_BG_RESOURCE_ID, 0);
    backgroundView.setBackgroundResource(backgroundResourceID);
    BlurringView blurringView = (BlurringView) view.findViewById(R.id.blurring_view);
    blurringView.setBlurredView(backgroundView);
    GridView gridView = (GridView) view.findViewById(R.id.menu_grid_view);
    mGridMenuAdapter.addAll(this.mMenus);
    gridView.setAdapter(mGridMenuAdapter);
    gridView.setOnItemClickListener(this);
    return view;
}

99. BrailleIME#onCreateInputView()

Project: brailleback
Source File: BrailleIME.java
View license
@Override
public View onCreateInputView() {
    final LayoutInflater inflater = getLayoutInflater();
    final View inputView = inflater.inflate(R.layout.braille_ime, null);
    inputView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            switchAwayFromThisIme();
        }
    });
    inputView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switchAwayFromThisIme();
            return true;
        }
    });
    return inputView;
}

100. ButterKnifeTest#propertyAppliedToEveryViewInList()

Project: butterknife
Source File: ButterKnifeTest.java
View license
@Test
public void propertyAppliedToEveryViewInList() {
    View view1 = new View(RuntimeEnvironment.application);
    View view2 = new View(RuntimeEnvironment.application);
    View view3 = new View(RuntimeEnvironment.application);
    assertThat(view1.isEnabled()).isTrue();
    assertThat(view2.isEnabled()).isTrue();
    assertThat(view3.isEnabled()).isTrue();
    List<View> views = asList(view1, view2, view3);
    ButterKnife.apply(views, PROPERTY_ENABLED, false);
    assertThat(view1.isEnabled()).isFalse();
    assertThat(view2.isEnabled()).isFalse();
    assertThat(view3.isEnabled()).isFalse();
}