List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:com.variable.demo.api.fragment.BarCodeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.barcode, null, false); final Context thiscontext = container.getContext(); //Create a Listener for recieving barcodes and update the edit text box. final EditText barCodeEditText = (EditText) root.findViewById(R.id.editBarCode); listener = new BarCodeScanner.BarCodeScannerListener() { @Override//w ww . ja v a 2 s . c o m public void onBarCodeTransmitted(BarCodeScanner barCodeScanner, final SensorReading<String> barCodeReading) { // convert the UTF final String serialnumOne = barCodeScanner.getSerialNumber(); final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", ""); final String scann = barCodeReading.getValue(); final String scan = scann.replaceAll("[\u0000-\u001f]", ""); String json = "barcode;" + serialnum + ";" + scan; // POST to variable dashboard Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false); Ion.with(thiscontext).load( "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]=" + json) .setLogging("MyLogs", Log.DEBUG).asString().withResponse() .setCallback(new FutureCallback<Response<String>>() { @Override public void onCompleted(Exception e, Response<String> result) { if (e == null) { Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString()); } else { Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION"); e.printStackTrace(); } } }); getActivity().runOnUiThread(new Runnable() { @Override public void run() { barCodeEditText.setText(barCodeReading.getValue()); } }); } }; return root; }
From source file:com.ameron32.apps.tapnotes._trial._demo.fragment.FlippableStackViewTestFragment.java
private void initAdapter() { mAdapter = new PagerAdapter() { @Override//www . j a v a2 s . co m public int getCount() { return colors.length; } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } @Override public Object instantiateItem(ViewGroup container, int position) { // Object o = super.instantiateItem(container, position); final FrameLayout l = new FrameLayout(container.getContext()); l.setBackgroundColor(getColorFrom(position)); container.addView(l); return l; } private int getColorFrom(int position) { return colors[(getCount() - 1) - position]; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View) object); } }; }
From source file:com.gbozza.android.popularmovies.adapters.MoviesAdapter.java
@Override public MoviesAdapterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.popular_movies_card; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); return new MoviesAdapterViewHolder(view, ((FragmentActivity) context).getSupportFragmentManager()); }
From source file:com.readystatesoftware.chuck.internal.ui.TransactionAdapter.java
TransactionAdapter(Context context, OnListFragmentInteractionListener listener) { this.listener = listener; this.context = context; colorDefault = ContextCompat.getColor(context, R.color.chuck_status_default); colorRequested = ContextCompat.getColor(context, R.color.chuck_status_requested); colorError = ContextCompat.getColor(context, R.color.chuck_status_error); color500 = ContextCompat.getColor(context, R.color.chuck_status_500); color400 = ContextCompat.getColor(context, R.color.chuck_status_400); color300 = ContextCompat.getColor(context, R.color.chuck_status_300); cursorAdapter = new CursorAdapter(TransactionAdapter.this.context, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) { @Override// w ww .j av a2 s .co m public View newView(Context context, Cursor cursor, ViewGroup parent) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.chuck_list_item_transaction, parent, false); ViewHolder holder = new ViewHolder(itemView); itemView.setTag(holder); return itemView; } @Override public void bindView(View view, final Context context, Cursor cursor) { final HttpTransaction transaction = LocalCupboard.getInstance().withCursor(cursor) .get(HttpTransaction.class); final ViewHolder holder = (ViewHolder) view.getTag(); holder.path.setText(transaction.getMethod() + " " + transaction.getPath()); holder.host.setText(transaction.getHost()); holder.start.setText(transaction.getRequestStartTimeString()); holder.ssl.setVisibility(transaction.isSsl() ? View.VISIBLE : View.GONE); if (transaction.getStatus() == HttpTransaction.Status.Complete) { holder.code.setText(String.valueOf(transaction.getResponseCode())); holder.duration.setText(transaction.getDurationString()); holder.size.setText(transaction.getTotalSizeString()); } else { holder.code.setText(null); holder.duration.setText(null); holder.size.setText(null); } if (transaction.getStatus() == HttpTransaction.Status.Failed) { holder.code.setText("!!!"); } setStatusColor(holder, transaction); holder.transaction = transaction; holder.view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (null != TransactionAdapter.this.listener) { TransactionAdapter.this.listener.onListFragmentInteraction(holder.transaction); } } }); } private void setStatusColor(ViewHolder holder, HttpTransaction transaction) { int color; if (transaction.getStatus() == HttpTransaction.Status.Failed) { color = colorError; } else if (transaction.getStatus() == HttpTransaction.Status.Requested) { color = colorRequested; } else if (transaction.getResponseCode() >= 500) { color = color500; } else if (transaction.getResponseCode() >= 400) { color = color400; } else if (transaction.getResponseCode() >= 300) { color = color300; } else { color = colorDefault; } holder.code.setTextColor(color); holder.path.setTextColor(color); } }; }
From source file:com.g_node.gca.abstracts.AbstractCursorAdapter.java
@Override public View newView(Context context, Cursor cursor, ViewGroup viewgroup) { // TODO Auto-generated method stub LayoutInflater inflater = LayoutInflater.from(viewgroup.getContext()); View returnView = inflater.inflate(R.layout.abstract_content, viewgroup, false); return returnView; }
From source file:com.potato.sticker.camera.ui.fragment.CameraAblumFragment.java
@Nullable @Override/*from w w w . j a va 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mList = getArguments().getParcelableArrayList(EXTRARS_LIST); mBinding = DataBindingUtil.inflate(LayoutInflater.from(container.getContext()), R.layout.fragment_ablum_camara, container, false); mAdapter = new CameraAblumAdapter(getActivity()); mAdapter.setDataList(mList); mBinding.list.setAdapter(mAdapter); mBinding.swipeContainer.setColorSchemeResources(R.color.google_blue, R.color.google_green, R.color.google_red, R.color.google_yellow); mBinding.swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { sendRequest2RefreshList(); } }); mBinding.swipeContainer.setEmptyView(mBinding.emptyView); mBinding.emptyView.setOnClickListener(this); mBinding.swipeContainer.showProgress(); sendRequest2RefreshList(); return mBinding.getRoot(); }
From source file:com.embeddedlapps.primeraversion.ListAdapterHolder.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final LayoutInflater mInflater = LayoutInflater.from(parent.getContext()); final View sView = mInflater.inflate(R.layout.single_list_item, parent, false); return new ViewHolder(sView); }
From source file:com.rks.musicx.ui.adapters.QueueAdapter.java
@Override public QueueViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()).inflate(mLayoutId, parent, false); return new QueueViewHolder(itemView); }
From source file:com.simplechatclient.android.ProfileAddFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.profile_add_fragment, container, false); context = container.getContext(); myStart();//from www .j a v a 2 s . c om return view; }
From source file:com.near.chimerarevo.adapters.PostsRecyclerAdapter.java
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext()); if (hasHeader) { if (viewType == 0) return new HeaderViewHolder(inflater.inflate(R.layout.posts_header_overlay, viewGroup, false), ctx); else/*from ww w .j a va 2 s.co m*/ return new PostViewHolder(inflater.inflate(R.layout.posts_card_layout, viewGroup, false), ctx); } else return new PostViewHolder(inflater.inflate(R.layout.posts_card_layout, viewGroup, false), ctx); }