android.view.View#getContext ( )源码实例Demo

下面列出了android.view.View#getContext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Bailan   文件: ParallaxRecyclerAdapter.java
/**
 * Set the view as header.
 *
 * @param header The inflated header
 * @param view   The RecyclerView to set scroll listeners
 */
public void setParallaxHeader(View header, final RecyclerView view) {
    mRecyclerView = view;
    mHeader = new CustomRelativeWrapper(header.getContext(), mShouldClipView);
    mHeader.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mHeader.addView(header, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    view.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (mHeader != null) {
                translateHeader(mRecyclerView.getLayoutManager().getChildAt(0) == mHeader ?
                        mRecyclerView.computeVerticalScrollOffset() : mHeader.getHeight());

            }
        }
    });
}
 
源代码2 项目: FastAccess   文件: ViewHelper.java
@SuppressWarnings("ConstantConditions,PrivateResource")
public static void showTooltip(@NonNull final View view, @StringRes final int titleResId,
                               int gravity, @Nullable final OnTooltipDismissListener dismissListener) {
    if (view != null && view.getContext() != null) {
        if (!PrefHelper.getBoolean(String.valueOf(titleResId))) {
            new Tooltip.Builder(view)
                    .setText(titleResId)
                    .setTypeface(TypeFaceHelper.getTypeface())
                    .setTextColor(Color.WHITE)
                    .setGravity(gravity)
                    .setPadding(R.dimen.spacing_xs_large)
                    .setBackgroundColor(ContextCompat.getColor(view.getContext(), R.color.primary))
                    .setDismissOnClick(true)
                    .setCancelable(true)
                    .setTextStyle(android.support.v7.appcompat.R.style.TextAppearance_AppCompat_Title_Inverse)
                    .setOnDismissListener(new OnDismissListener() {
                        @Override public void onDismiss() {
                            PrefHelper.set(String.valueOf(titleResId), true);
                            if (dismissListener != null) dismissListener.onDismissed(titleResId);
                        }
                    })
                    .show();
        }
    }
}
 
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);

  // Set the Recycler View adapter
  Context context = view.getContext();
  mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
  mRecyclerView.setAdapter(mEarthquakeAdapter);

  // Setup the Swipe to Refresh view
  mSwipeToRefreshView.setOnRefreshListener(
    new SwipeRefreshLayout.OnRefreshListener() {
      @Override
      public void onRefresh() {
        updateEarthquakes();
      }
    });
}
 
源代码4 项目: deltachat-android   文件: LongClickCopySpan.java
@Override
public void onClick(View widget) {
  String url = getURL();
  if (url.startsWith(PREFIX_MAILTO)) {
    try {
      String addr = prepareUrl(url);
      Activity activity = (Activity) widget.getContext();
      DcContext dcContext = DcHelper.getContext(activity);
      DcContact contact = dcContext.getContact(dcContext.createContact(null, addr));
      if (contact.getId()!=0 && dcContext.getChatIdByContactId(contact.getId())!=0) {
        openChat(activity, contact);
      } else {
        new AlertDialog.Builder(activity)
                .setMessage(activity.getString(R.string.ask_start_chat_with, contact.getNameNAddr()))
                .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                  openChat(activity, contact);
                })
                .setNegativeButton(R.string.cancel, null)
                .show();
      }
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  else {
    super.onClick(widget);
  }
}
 
源代码5 项目: PressureNet   文件: NewWelcomeIntroFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View v = inflater.inflate(R.layout.new_welcome_intro, null);
	context = v.getContext();
	
	SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
	
	nextButton = (Button) v.findViewById(R.id.buttonNewWelcomeNext);
	nextButton.setOnClickListener(this);
	
	checkBarometer();
	
	welcomeNewDescription = (TextView) v.findViewById(R.id.welcome_new_description);
	
	if(!hasBarometer) {
		welcomeNewDescription.setText(getString(R.string.newWelcomeNoBarometerIntro));
	} else {
		welcomeNewDescription.setText(getString(R.string.newWelcomeBarometerIntro));
	}
	
	
	// set default units that are region aware/localized
	Locale current = getResources().getConfiguration().locale;
	if(current.getCountry().equals("US")) {
		// default to 'ft' and 'F'
	      SharedPreferences.Editor editor = settings.edit();
	      editor.putString("distance_units", "Feet (ft)");
	      editor.putString("temperature_units", "Fahrenheit (°F)");
	      editor.commit();
	}
	

	// updateView();
	return v;
}
 
源代码6 项目: ans-android-sdk   文件: EventSender.java
private static String getTargetPage(View view) {
    try {
        Context context = view.getContext();
        if (context instanceof Activity) {
            Activity activity = (Activity) context;
            return activity.getClass().getName();
        }
    } catch (Throwable e) {
        InternalAgent.e(e);
    }
    return "";
}
 
源代码7 项目: nano-wallet-android   文件: CustomUrlSpan.java
@Override
public void onClick(View widget) {
    String url = getURL();
    if (url != null && widget.getContext() instanceof WindowControl) {
        WebViewDialogFragment
                .newInstance(url, "")
                .show(
                        ((WindowControl) widget.getContext()).getFragmentUtility().getFragmentManager(),
                        WebViewDialogFragment.TAG
                );
    } else if (url != null) {
        RxBus.get().post(new OpenWebView(url));
    }
}
 
@Override
public boolean onLongClick(View v) {
    PopupMenu menu = new PopupMenu(v.getContext(), v);
    menu.getMenu().add(0, CONTEXT_MENU_FILTER_ID, 0, R.string.filter_choice);
    menu.getMenu().add(0, CONTEXT_MENU_COPY_ID, 0, R.string.copy_to_clipboard);
    menu.setOnMenuItemClickListener(LogLineViewHolder.this);
    menu.show();
    return true;
}
 
源代码9 项目: emojicon   文件: EmojiconRecentsGridFragment.java
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    EmojiconRecentsManager recents = EmojiconRecentsManager
            .getInstance(view.getContext());

    mAdapter = new EmojiconAdapter(view.getContext(), recents, mUseSystemDefault);
    GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
    gridView.setAdapter(mAdapter);
    gridView.setOnItemClickListener(this);
}
 
源代码10 项目: arcusandroid   文件: LawnAndGardenCardItemView.java
public LawnAndGardenCardItemView(View view) {
    super(view);
    serviceImage = (ImageView) view.findViewById(R.id.service_image);
    serviceName = (Version1TextView) view.findViewById(R.id.service_name);
    this.context = view.getContext();
    zoneCount = view.findViewById(R.id.zonecount);
    zoneCountText = (Version1TextView) view.findViewById(R.id.water_zone_count);
    timeImage = (ImageView) view.findViewById(R.id.time_image);
}
 
源代码11 项目: tenor-android-core   文件: AbstractUIUtils.java
/**
 * @param flags Provides additional operating flags.  Set to 0 if there are no additional flags.
 */
public static void showInputMethod(@Nullable final View view, int flags) {
    if (view == null || view.getContext() == null) {
        return;
    }

    final InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null) {
        return;
    }
    imm.showSoftInput(view, flags);
}
 
源代码12 项目: GoogleVR   文件: VrVideoAdapter.java
@Override
public void onClick(View v) {
	VideoItem item= (VideoItem) v.getTag();
	Intent intent=new Intent(v.getContext(),VideoDetailActivity.class);
	//需要传递的数据:
	intent.putExtra("title",item.title);
	intent.putExtra("img",item.img);
	intent.putExtra("text",item.text);
	intent.putExtra("play",item.play);
	v.getContext().startActivity(intent);
}
 
源代码13 项目: nono-android   文件: ContentFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
						 Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View view= inflater.inflate(R.layout.frament_content, container, false);
	recyclerView=(RecyclerView)view.findViewById(R.id.frg_content_recyclerview);
	LinearLayoutManager linearLayoutManager = new LinearLayoutManager(view.getContext());
	recyclerView.setLayoutManager(linearLayoutManager);
	recyclerView.setHasFixedSize(true);
	recyclerView.setAdapter(searchAdapter);
	return view;
}
 
源代码14 项目: iBeebo   文件: LargePictureFragment.java
public LargeOnTouchListener(final View view) {
    gestureDetector = new GestureDetector(view.getContext(), new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            Utility.playClickSound(view);
            getActivity().onBackPressed();
            return true;
        }
    });
}
 
源代码15 项目: guideshow   文件: ExploreByTouchHelper.java
/**
 * Factory method to create a new {@link ExploreByTouchHelper}.
 *
 * @param forView View whose logical children are exposed by this helper.
 */
public ExploreByTouchHelper(View forView) {
    if (forView == null) {
        throw new IllegalArgumentException("View may not be null");
    }

    mView = forView;
    final Context context = forView.getContext();
    mManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
}
 
源代码16 项目: HAPP   文件: EnterTreatment.java
public void cancel(View view){
    Intent intentHome = new Intent(view.getContext(), MainActivity.class);
    intentHome.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    view.getContext().startActivity(intentHome);
}
 
@SuppressLint("ClickableViewAccessibility")
public static PictureInPictureGestureHelper applyTo(@NonNull View child) {
  TouchInterceptingFrameLayout  parent          = (TouchInterceptingFrameLayout) child.getParent();
  PictureInPictureGestureHelper helper          = new PictureInPictureGestureHelper(parent, child);
  GestureDetectorCompat         gestureDetector = new GestureDetectorCompat(child.getContext(), helper);

  parent.setOnInterceptTouchEventListener((event) -> {
    if (helper.velocityTracker == null) {
      helper.velocityTracker = VelocityTracker.obtain();
    }

    helper.velocityTracker.addMovement(event);

    return false;
  });

  parent.setOnTouchListener((v, event) -> {
    if (helper.velocityTracker != null) {
      helper.velocityTracker.recycle();
      helper.velocityTracker = null;
    }

    return false;
  });

  child.setOnTouchListener((v, event) -> {
    boolean handled = gestureDetector.onTouchEvent(event);

    if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
      if (!handled) {
        handled = helper.onGestureFinished(event);
      }

      if (helper.velocityTracker != null) {
        helper.velocityTracker.recycle();
        helper.velocityTracker = null;
      }
    }

    return handled;
  });

  return helper;
}
 
源代码18 项目: timecat   文件: DragDropHelper.java
public void startDrag(View v) {
    isInit = true;
    mDragView = new DragView(v.getContext(), v);
    mDragView.setImageBitmap(getViewBitmap(v));
    mDragView.dragStart();
}
 
源代码19 项目: FimiX8-RE   文件: X8GimbalItemController.java
public X8GimbalItemController(View rootView) {
    super(rootView);
    this.mContext = rootView.getContext();
}
 
源代码20 项目: android_9.0.0_r45   文件: PopupWindow.java
/**
 * <p>Create a new popup window which can display the <tt>contentView</tt>.
 * The dimension of the window must be passed to this constructor.</p>
 *
 * <p>The popup does not provide any background. This should be handled
 * by the content view.</p>
 *
 * @param contentView the popup's content
 * @param width the popup's width
 * @param height the popup's height
 * @param focusable true if the popup can be focused, false otherwise
 */
public PopupWindow(View contentView, int width, int height, boolean focusable) {
    if (contentView != null) {
        mContext = contentView.getContext();
        mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    }

    setContentView(contentView);
    setWidth(width);
    setHeight(height);
    setFocusable(focusable);
}
 
 方法所在类
 同类方法