List of usage examples for android.view View getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:com.bitants.wally.fragments.LatestFragment.java
private void setupAdapter() { imagesAdapter.setOnGetViewListener(new RecyclerImagesAdapter.OnGetViewListener() { @Override//from ww w .j ava2 s . com public void onBindView(int position) { getMoreImagesIfNeeded(position, imagesAdapter.getItemCount()); } }); imagesAdapter.setOnItemClickListener(new RecyclerImagesAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { Image image = (Image) imagesAdapter.getItem(position); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(image.imagePageURL()), view.getContext(), ImageDetailsActivity.class); ImageView thumbnailImageView = (ImageView) view.findViewById(R.id.thumb_image_view); Bitmap thumb = null; intent.putExtra(ImageDetailsActivity.INTENT_EXTRA_IMAGE, image); if (thumbnailImageView != null && thumbnailImageView.getDrawable() != null && thumbnailImageView.getDrawable() instanceof GlideBitmapDrawable) { GlideBitmapDrawable glideBitmapDrawable = (GlideBitmapDrawable) thumbnailImageView .getDrawable(); thumb = glideBitmapDrawable.getBitmap(); } else if (thumbnailImageView != null && thumbnailImageView.getDrawable() != null && thumbnailImageView.getDrawable() instanceof TransitionDrawable) { GlideBitmapDrawable squaringDrawable = (GlideBitmapDrawable) ((TransitionDrawable) thumbnailImageView .getDrawable()).getDrawable(1); thumb = squaringDrawable.getBitmap(); } WallyApplication.setBitmapThumb(thumb); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { String transitionNameImage = getString(R.string.transition_image_details); ActivityOptionsCompat options = ActivityOptionsCompat .makeSceneTransitionAnimation(getActivity(), android.support.v4.util.Pair .create(view.findViewById(R.id.thumb_image_view), transitionNameImage)); ActivityCompat.startActivityForResult(getActivity(), intent, ImageDetailsActivity.REQUEST_EXTRA_TAG, options.toBundle()); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.buildDrawingCache(true); Bitmap drawingCache = view.getDrawingCache(true); Bundle bundle = ActivityOptions.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0) .toBundle(); getActivity().startActivityForResult(intent, REQUEST_CODE, bundle); } else { startActivityForResult(intent, REQUEST_CODE); } } }); }
From source file:com.garlicg.screenrecord4cm.SettingsActivity.java
/** * TriggerMessage/*from ww w . ja v a2 s . co m*/ */ private void createTriggerMessage(Bundle savedInstanceState) { final TextView valueView = ViewFinder.byId(this, R.id.triggerMessageValue); String value = mPrefs.getTriggerMessage(); valueView.setText(value); // handle value from dialog callback final ValidateTextDialogBuilder.Callback callback = new ValidateTextDialogBuilder.Callback() { @Override public boolean onValidate(CharSequence value) { return !TextUtils.isEmpty(value); } @Override public void onOk(CharSequence value) { valueView.setText(value); mPrefs.saveTriggerMessage(value.toString()); } }; // show dialog on click valueView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String value = mPrefs.getTriggerMessage(); AlertDialog ad = ValidateTextDialogBuilder.build(v.getContext(), value, null, 100, callback); ad.show(); } }); }
From source file:com.bitants.wally.fragments.ToplistFragment.java
private void setupAdapter() { imagesAdapter.setOnGetViewListener(new RecyclerImagesAdapter.OnGetViewListener() { @Override/*from w ww. j a v a2 s . c om*/ public void onBindView(int position) { getMoreImagesIfNeeded(position, imagesAdapter.getItemCount()); } }); imagesAdapter.setOnItemClickListener(new RecyclerImagesAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { Image image = (Image) imagesAdapter.getItem(position); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(image.imagePageURL()), view.getContext(), ImageDetailsActivity.class); ImageView thumbnailImageView = (ImageView) view.findViewById(R.id.thumb_image_view); Bitmap thumb = null; intent.putExtra(ImageDetailsActivity.INTENT_EXTRA_IMAGE, image); if (thumbnailImageView != null && thumbnailImageView.getDrawable() != null && thumbnailImageView.getDrawable() instanceof GlideBitmapDrawable) { GlideBitmapDrawable glideBitmapDrawable = (GlideBitmapDrawable) thumbnailImageView .getDrawable(); thumb = glideBitmapDrawable.getBitmap(); } else if (thumbnailImageView != null && thumbnailImageView.getDrawable() != null && thumbnailImageView.getDrawable() instanceof TransitionDrawable) { GlideBitmapDrawable squaringDrawable = (GlideBitmapDrawable) ((TransitionDrawable) thumbnailImageView .getDrawable()).getDrawable(1); thumb = squaringDrawable.getBitmap(); } WallyApplication.setBitmapThumb(thumb); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { String transitionNameImage = getString(R.string.transition_image_details); ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), Pair.create(view.findViewById(R.id.thumb_image_view), transitionNameImage)); ActivityCompat.startActivityForResult(getActivity(), intent, ImageDetailsActivity.REQUEST_EXTRA_TAG, options.toBundle()); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.buildDrawingCache(true); Bitmap drawingCache = view.getDrawingCache(true); Bundle bundle = ActivityOptions.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0) .toBundle(); getActivity().startActivityForResult(intent, REQUEST_CODE, bundle); } else { startActivityForResult(intent, REQUEST_CODE); } } }); }
From source file:com.daycle.daycleapp.custom.swipelistview.itemmanipulation.swipedismiss.SwipeDismissTouchListener.java
@Override protected void onCancelSwipe(@NonNull View view, int position) { //super.onCancelSwipe(view, position); if (mRightSwipeBackgroundColorResId > 0) { View childView = ((ViewGroup) view.findViewById(R.id.itemContent)).getChildAt(0); // ? /* w w w . j av a 2 s . com*/ childView .setBackgroundColor(ContextCompat.getColor(view.getContext(), mRightSwipeBackgroundColorResId)); } }
From source file:br.com.frs.foodrestrictions.MessageVegan.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_message_vegan, container, false); String language = getArguments().getString(MessageLanguageSelector.ARG_LANGUAGE); TextView tv = (TextView) v.findViewById(R.id.tvVegegan); /* //TODO - Find a better way of doing it * I don't believe that this is the best approach to handle this problem but it is * the only way I found to do it so far. Do you have any better idea? * please help me here :D//from ww w . j a v a 2 s. c om */ /* Getting the current resource and config info */ Resources rsc = v.getContext().getResources(); Configuration config = rsc.getConfiguration(); /* Saving the original locale before changing to the new one * just to show the texts */ Locale orgLocale = config.locale; if (language != null) { config.locale = new Locale(language); } /* Setting the new locale */ rsc.updateConfiguration(config, rsc.getDisplayMetrics()); /* Updating the layout with the new selected language */ tv.setText(rsc.getString(R.string.msg_vegan)); /* Return to last locale to keep the app as it was before */ config.locale = orgLocale; rsc.updateConfiguration(config, rsc.getDisplayMetrics()); return v; }
From source file:com.android.utils.ExploreByTouchHelper.java
/** * Constructs a new Explore by Touch helper. * * @param host The view whose virtual hierarchy is exposed by this * helper.//from ww w .j a v a 2s. c om */ ExploreByTouchHelper(View host) { mHost = host; mManager = (AccessibilityManager) host.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); }
From source file:com.bilibili.boxing_impl.ui.BoxingViewFragment.java
public void setTitleTxt(TextView titleTxt) { mTitleTxt = titleTxt;/*from w ww . j a v a 2 s. c o m*/ mTitleTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAlbumPopWindow == null) { int height = WindowManagerHelper.getScreenHeight(v.getContext()) - (WindowManagerHelper.getToolbarHeight(v.getContext()) + WindowManagerHelper.getStatusBarHeight(v.getContext())); View windowView = createWindowView(); mAlbumPopWindow = new PopupWindow(windowView, ViewGroup.LayoutParams.MATCH_PARENT, height, true); mAlbumPopWindow.setAnimationStyle(R.style.PopupAnimation); mAlbumPopWindow.setOutsideTouchable(true); mAlbumPopWindow.setBackgroundDrawable( new ColorDrawable(ContextCompat.getColor(v.getContext(), R.color.colorPrimaryAlpha))); mAlbumPopWindow.setContentView(windowView); } mAlbumPopWindow.showAsDropDown(v, 0, 0); } @NonNull private View createWindowView() { View view = LayoutInflater.from(getActivity()).inflate(R.layout.layout_album, null); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.album_recycleview); recyclerView.setLayoutManager( new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false)); recyclerView.addItemDecoration(new SpacesItemDecoration(2, 1)); View albumShadowLayout = view.findViewById(R.id.album_shadow); albumShadowLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissAlbumWindow(); } }); mAlbumWindowAdapter.setAlbumOnClickListener(new OnAlbumItemOnClickListener()); recyclerView.setAdapter(mAlbumWindowAdapter); return view; } }); }
From source file:com.garlicg.screenrecord4cm.SettingsActivity.java
/** * Create auto stop setting view//from w w w . jav a2s . co m */ private void createAutoStop(Bundle savedInstanceState) { // init value setup final TextView valueView = ViewFinder.byId(this, R.id.autoStopValue); int value = mPrefs.getAutoStopMilliSec(); valueView.setText(value == 0 ? getString(R.string.no_seconds_only_manual_stop) : getString(R.string.plus_x_ms_later, value)); // handle value from dialog callback final InputSecondDialogBuilder.Callback callback = new InputSecondDialogBuilder.Callback() { @Override public boolean onValidate(int value) { int msec = value * 100; //noinspection PointlessArithmeticExpression return msec >= 0 && msec <= 1 * 1000 * 1000 - 1; // 999 } @Override public void onOk(int value) { int msec = value * 100; valueView.setText(msec == 0 ? getString(R.string.no_seconds_only_manual_stop) : getString(R.string.plus_x_ms_later, msec)); mPrefs.saveAutoStopMilliSec(msec); } }; // show dialog on click valueView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int value = mPrefs.getAutoStopMilliSec() / 100; AlertDialog ad = InputSecondDialogBuilder.build(v.getContext(), value, getString(R.string.unit_00ms_later), callback); ad.show(); } }); }
From source file:br.com.frs.foodrestrictions.MessageVegetarian.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.activity_message_vegetarian, container, false); String language = getArguments().getString(MessageLanguageSelector.ARG_LANGUAGE); TextView tv = (TextView) v.findViewById(R.id.tvVegetarian); /* //TODO - Find a better way of doing it * I don't believe that this is the best approach to handle this problem but it is * the only way I found to do it so far. Do you have any better idea? * please help me here :D//ww w .java2s .c om */ /* Getting the current resource and config info */ Resources rsc = v.getContext().getResources(); Configuration config = rsc.getConfiguration(); /* Saving the original locale before changing to the new one * just to show the texts */ Locale orgLocale = config.locale; if (language != null) { config.locale = new Locale(language); } /* Setting the new locale */ rsc.updateConfiguration(config, rsc.getDisplayMetrics()); /* Updating the layout with the new selected language */ tv.setText(rsc.getString(R.string.msg_veget)); /* Return to last locale to keep the app as it was before */ config.locale = orgLocale; rsc.updateConfiguration(config, rsc.getDisplayMetrics()); return v; }
From source file:com.fuzz.emptyhusk.prefab.ProportionalImageCellGenerator.java
@Override public void onBindChild(@NonNull View child, @NonNull CutoutViewLayoutParams lp, @Nullable View originator) { child.setBackgroundResource(lp.cellBackgroundId); if (originator != null) { rvChildLength = originator.getHeight(); if (originator.getParent() instanceof ViewGroup) { rvLength = ((ViewGroup) originator.getParent()).getHeight(); }/*from w w w.ja v a 2 s . com*/ } if (child instanceof ImageView) { GradientDrawable elongated = new GradientDrawable(); elongated.setShape(GradientDrawable.RECTANGLE); int accent = ContextCompat.getColor(child.getContext(), R.color.transparentColorAccent); float fractionOfParent = rvLength * 1.0f / rvChildLength; elongated.setColor(accent); float proposedLength = fractionOfParent * lp.perpendicularLength; elongated.setSize(lp.perpendicularLength, (int) proposedLength); ((ImageView) child).setImageDrawable(elongated); } }