List of usage examples for android.view View getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:com.anysoftkeyboard.ui.settings.AboutAnySoftKeyboardFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); TextView copyright = (TextView) view.findViewById(R.id.about_copyright); copyright.setText(getString(R.string.about_copyright_text, Calendar.getInstance().get(Calendar.YEAR))); String appVersionName = ""; int appVersionNumber = 0; try {//ww w . j a v a 2 s .c o m PackageInfo info = view.getContext().getPackageManager() .getPackageInfo(view.getContext().getPackageName(), 0); appVersionName = info.versionName; appVersionNumber = info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } TextView version = (TextView) view.findViewById(R.id.about_app_version); version.setText(getString(R.string.version_text, appVersionName, appVersionNumber)); view.findViewById(R.id.about_donate_paypal).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9989122 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9989122")); getActivity().startActivity(intent); } }); }
From source file:ab.util.AbDialogUtil.java
/** * ?View./*from ww w . j a v a2s. co m*/ * * @param view * ? */ public static AbAlertDialogFragment showAlertDialog(View view) { FragmentActivity activity = (FragmentActivity) view.getContext(); AbAlertDialogFragment newFragment = AbAlertDialogFragment.newInstance(0, null, null, view, null); FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); newFragment.show(ft, mDialogTag); return newFragment; }
From source file:ab.util.AbDialogUtil.java
/** * ???dialog View.// w w w. j a va2 s . c om * * @param icon * @param title * ? * @param view * ??? */ public static AbAlertDialogFragment showAlertDialog(int icon, String title, View view) { FragmentActivity activity = (FragmentActivity) view.getContext(); AbAlertDialogFragment newFragment = AbAlertDialogFragment.newInstance(icon, title, null, view, null); FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); newFragment.show(ft, mDialogTag); return newFragment; }
From source file:ab.util.AbDialogUtil.java
/** * ???dialog View./*from w ww . j a va2 s. c om*/ * * @param title * ? * @param view * ??? */ public static AbAlertDialogFragment showAlertDialog(String title, View view) { FragmentActivity activity = (FragmentActivity) view.getContext(); AbAlertDialogFragment newFragment = AbAlertDialogFragment.newInstance(0, title, null, view, null); FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); newFragment.show(ft, mDialogTag); return newFragment; }
From source file:ab.util.AbDialogUtil.java
/** * ??//ww w . ja va2 s .co m * * @param view * @return */ public static AbSampleDialogFragment showFullScreenDialog(View view) { FragmentActivity activity = (FragmentActivity) view.getContext(); // Create and show the dialog. AbSampleDialogFragment newFragment = AbSampleDialogFragment.newInstance(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Black_NoTitleBar_Fullscreen); newFragment.setContentView(view); FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); newFragment.show(ft, mDialogTag); return newFragment; }
From source file:com.example.ray.firstapp.bottombar.BottomBar.java
/** * Bind the BottomBar to the specified View's parent, and inflate * your layout there. Useful when the BottomBar overlaps some content * that shouldn't be overlapped./*ww w.j a va 2s . co m*/ * <p/> * Remember to also call {@link #onRestoreInstanceState(Bundle)} inside * of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state. * * @param view a View, which parent we're going to attach to. * @param savedInstanceState a Bundle for restoring the state on configuration change. * @return a BottomBar at the bottom of the screen. */ public static BottomBar attach(View view, Bundle savedInstanceState) { BottomBar bottomBar = new BottomBar(view.getContext()); bottomBar.onRestoreInstanceState(savedInstanceState); ViewGroup contentView = (ViewGroup) view.getParent(); if (contentView != null) { View oldLayout = contentView.getChildAt(0); contentView.removeView(oldLayout); bottomBar.setPendingUserContentView(oldLayout); contentView.addView(bottomBar, 0); } else { bottomBar.setPendingUserContentView(view); } return bottomBar; }
From source file:com.fusionx.lightirc.ui.UserListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mStickyListView = (StickyListHeadersListView) view.findViewById(android.R.id.list); mAdapter = new UserListAdapter(view.getContext(), mWorldUsers); getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL); getListView().getWrappedList().setMultiChoiceModeListener(this); getListView().setOnItemClickListener(this); getListView().setFastScrollEnabled(true); }
From source file:ab.util.AbDialogUtil.java
/** * ?????View/*from w w w . j a va 2 s .co m*/ * * @param view * @return */ public static AbSampleDialogFragment showTipsDialog(View view) { FragmentActivity activity = (FragmentActivity) view.getContext(); // Create and show the dialog. AbSampleDialogFragment newFragment = AbSampleDialogFragment.newInstance(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light); newFragment.setContentView(view); FragmentTransaction ft = activity.getFragmentManager().beginTransaction(); // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); // ?,content?fragment,Activity ft.add(android.R.id.content, newFragment, mDialogTag).addToBackStack(null).commit(); return newFragment; }
From source file:com.ferid.app.classroom.statistics.StatisticsFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.refreshable_list, container, false); context = rootView.getContext(); list = (RecyclerView) rootView.findViewById(R.id.list); classroomAdapter = new OperateClassroomsAdapter(classroomArrayList); list.setAdapter(classroomAdapter);//from www . j a v a2 s .co m list.setLayoutManager(new LinearLayoutManager(context)); list.setHasFixedSize(true); emptyText = (TextView) rootView.findViewById(R.id.emptyText); swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { new SelectClassrooms().execute(); } }); addAdapterClickListener(); new SelectClassrooms().execute(); return rootView; }
From source file:com.fastbootmobile.encore.app.adapters.PlaylistListAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final int itemViewType = getItemViewType(position); if (itemViewType == VIEW_TYPE_HEADER) { SpecialViewHolder specialHolder = (SpecialViewHolder) holder; specialHolder.cardFavorites.setOnClickListener(new View.OnClickListener() { @Override/*from ww w. j av a2s .com*/ public void onClick(View v) { Context ctx = v.getContext(); Intent intent = PlaylistActivity.craftIntent(ctx, AutoPlaylistHelper.REF_SPECIAL_FAVORITES, null); ctx.startActivity(intent); } }); specialHolder.cardMostPlayed.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context ctx = v.getContext(); Intent intent = PlaylistActivity.craftIntent(ctx, AutoPlaylistHelper.REF_SPECIAL_MOST_PLAYED, null); ctx.startActivity(intent); } }); } else if (itemViewType == VIEW_TYPE_REGULAR) { final Playlist item = mPlaylists.get(position - 1); holder.tvPlaylistName.setText(item.getName()); holder.ivCover.loadArtForPlaylist(item); if (item.isLoaded() || item.getSongsCount() > 0) { ProviderConnection provider = PluginsLookup.getDefault().getProvider(item.getProvider()); if (provider != null) { holder.tvPlaylistDesc .setText(String.format("%s / %s", holder.tvPlaylistDesc.getContext().getResources().getQuantityString( R.plurals.xx_songs, item.getSongsCount(), item.getSongsCount()), provider.getProviderName())); } holder.ivOfflineStatus.setVisibility(View.VISIBLE); switch (item.getOfflineStatus()) { case BoundEntity.OFFLINE_STATUS_NO: holder.ivOfflineStatus.setVisibility(View.GONE); break; case BoundEntity.OFFLINE_STATUS_DOWNLOADING: holder.ivOfflineStatus.setImageResource(R.drawable.ic_sync_in_progress); break; case BoundEntity.OFFLINE_STATUS_ERROR: holder.ivOfflineStatus.setImageResource(R.drawable.ic_sync_problem); break; case BoundEntity.OFFLINE_STATUS_PENDING: holder.ivOfflineStatus.setImageResource(R.drawable.ic_track_download_pending); break; case BoundEntity.OFFLINE_STATUS_READY: holder.ivOfflineStatus.setImageResource(R.drawable.ic_track_downloaded); break; } } else { holder.tvPlaylistDesc.setText(null); holder.ivOfflineStatus.setVisibility(View.GONE); } final int dragState = holder.getDragStateFlags(); if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0)) { int bgColor = 0; if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) { bgColor = 0xFFDDDDDD; } else if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) { bgColor = 0xFFAAAAAA; } if (bgColor != 0) { holder.container.setBackgroundColor(bgColor); } else { int[] attrs = new int[] { android.R.attr.selectableItemBackground /* index 0 */ }; TypedArray ta = holder.container.getContext().obtainStyledAttributes(attrs); Drawable drawableFromTheme = ta.getDrawable(0 /* index */); ta.recycle(); holder.container.setBackground(drawableFromTheme); } } holder.container.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context ctx = v.getContext(); Intent intent = PlaylistActivity.craftIntent(ctx, item, ((MaterialTransitionDrawable) holder.ivCover.getDrawable()).getFinalDrawable() .getBitmap()); if (Utils.hasLollipop()) { ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation((Activity) ctx, holder.ivCover, "itemImage"); ctx.startActivity(intent, opt.toBundle()); } else { ctx.startActivity(intent); } } }); } }