List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:org.ednovo.goorusearchwidget.ResourcePlayer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); dialog = new ProgressDialog(this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentViewLayout = new RelativeLayout(ResourcePlayer.this); prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE); token = prefsPrivate.getString("token", ""); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); Bundle extra = getIntent().getExtras(); if (extra != null) { value = extra.getInt("key"); gooruOID1 = extra.getStringArrayList("goor"); searchkeyword = extra.getString("searchkey"); limit = gooruOID1.size();//from w w w . j ava 2s .c o m gooruOID = gooruOID1.get(value); resourceGooruId = gooruOID; if (!gooruOID.isEmpty() || !gooruOID.equalsIgnoreCase("") || gooruOID != null) { if (checkInternetConnection()) { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("Please wait while loading..."); dialog.setCancelable(false); dialog.show(); new getResourcesInfo().execute(); } else { dialog = new ProgressDialog(ResourcePlayer.this); dialog.setTitle("gooru"); dialog.setMessage("No internet connection"); dialog.show(); } } } Editor prefsPrivateEditor = prefsPrivate.edit(); // Authentication details prefsPrivateEditor.putString("searchkeyword", searchkeyword); prefsPrivateEditor.commit(); wvPlayer = new WebView(ResourcePlayer.this); wvPlayer.resumeTimers(); wvPlayer.getSettings().setJavaScriptEnabled(true); wvPlayer.getSettings().setPluginState(PluginState.ON); wvPlayer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); wvPlayer.setWebViewClient(new HelloWebViewClient()); wvPlayer.setWebChromeClient(new MyWebChromeClient() { }); wvPlayer.getSettings().setPluginsEnabled(true); new getResourcesInfo().execute(); RelativeLayout temp = new RelativeLayout(ResourcePlayer.this); temp.setId(668); temp.setBackgroundColor(getResources().getColor(android.R.color.transparent)); header = new RelativeLayout(ResourcePlayer.this); header.setId(1); header.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams headerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, 53); headerParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); headerParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, -1); ivCloseIcon = new ImageView(ResourcePlayer.this); ivCloseIcon.setId(130); ivCloseIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivCloseIconIconParams = new RelativeLayout.LayoutParams(50, 50); ivCloseIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivCloseIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); ivCloseIcon.setPadding(0, 0, 0, 0); ivCloseIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); ivCloseIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.close_corner)); header.addView(ivCloseIcon, ivCloseIconIconParams); ivmoveforward = new ImageView(ResourcePlayer.this); ivmoveforward.setId(222); if (value == limit - 1) { ivmoveforward.setVisibility(View.GONE); } ivmoveforward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmoveforwardIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmoveforwardIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); ivmoveforwardIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmoveforwardIconIconParams.setMargins(0, 0, 30, 0); imageshare = new ImageView(ResourcePlayer.this); imageshare.setId(440); imageshare.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams imageshareIconParams = new RelativeLayout.LayoutParams(50, 50); imageshareIconParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); imageshareIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); imageshareIconParams.setMargins(0, 10, 100, 0); tvDescriptionn = new TextView(ResourcePlayer.this); tvDescriptionn1 = new TextView(ResourcePlayer.this); edittext_copyurl = new EditText(ResourcePlayer.this); imageshare.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (desc == 0) { new getShortUrl().execute(); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_selected)); subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); tvDescriptionn.setVisibility(View.VISIBLE); tvDescriptionn1.setVisibility(View.VISIBLE); edittext_copyurl.setVisibility(View.VISIBLE); tvDescriptionn.setText("Share this with other by copying and pasting these links"); tvDescriptionn.setId(221); tvDescriptionn.setTextSize(18); tvDescriptionn.setTypeface(null, Typeface.BOLD); tvDescriptionn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); subheader.addView(tvDescriptionn, tvDescriptionParams); tvDescriptionn1.setText("Collections"); tvDescriptionn1.setId(226); tvDescriptionn1.setTextSize(18); tvDescriptionn1.setTypeface(null, Typeface.BOLD); tvDescriptionn1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams1 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams1.setMargins(20, 42, 0, 20); subheader.addView(tvDescriptionn1, tvDescriptionParams1); edittext_copyurl.setId(266); edittext_copyurl.setTextSize(18); edittext_copyurl.setTypeface(null, Typeface.BOLD); edittext_copyurl.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams11 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams11.setMargins(130, 35, 0, 20); subheader.addView(edittext_copyurl, tvDescriptionParams11); desc = 1; flag = 0; } else { imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); subheader.removeAllViews(); subheader.setVisibility(View.GONE); desc = 0; } } }); imageshare.setBackgroundDrawable(getResources().getDrawable(R.drawable.share_normal)); ivmoveforward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (value < limit - 1) { Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); // extras.putString("gooruOId",s); extras.putStringArrayList("goor", gooruOID1); value++; extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveforward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrowright)); ivmoveback = new ImageView(ResourcePlayer.this); ivmoveback.setId(220); if (value == 0) { ivmoveback.setVisibility(View.GONE); } ivmoveback.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivmovebackIconIconParams = new RelativeLayout.LayoutParams(21, 38); ivmovebackIconIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); ivmovebackIconIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivmovebackIconIconParams.setMargins(55, 0, 0, 0); ivmoveback.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!(value <= 0)) { value--; Intent intentResPlayer = new Intent(getBaseContext(), ResourcePlayer.class); Bundle extras = new Bundle(); extras.putStringArrayList("goor", gooruOID1); extras.putInt("key", value); intentResPlayer.putExtras(extras); urlcheck = 0; finish(); startActivity(intentResPlayer); } } }); ivmoveback.setBackgroundDrawable(getResources().getDrawable(R.drawable.left)); webViewBack = new ImageView(ResourcePlayer.this); webViewBack.setId(323); webViewBack.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewBackIconParams = new RelativeLayout.LayoutParams(25, 26); webViewBackIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewBackIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewBackIconParams.setMargins(175, 0, 0, 0); webViewBack.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_leftactive)); webViewBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoBack()) { wvPlayer.goBack(); } } }); webViewRefresh = new ImageView(ResourcePlayer.this); webViewRefresh.setId(322); webViewRefresh.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewRefreshIconParams = new RelativeLayout.LayoutParams(30, 30); webViewRefreshIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewRefreshIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewRefreshIconParams.setMargins(305, 0, 0, 0); webViewRefresh.setBackgroundDrawable(getResources().getDrawable(R.drawable.refresh)); webViewRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { wvPlayer.reload(); } }); webViewForward = new ImageView(ResourcePlayer.this); webViewForward.setId(321); webViewForward.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParams = new RelativeLayout.LayoutParams(25, 26); webViewForwardIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1); webViewForwardIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParams.setMargins(245, 0, 0, 0); webViewForward.setBackgroundDrawable(getResources().getDrawable(R.drawable.arrow_rightactive)); webViewForward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (wvPlayer.canGoForward()) { wvPlayer.goForward(); } } }); ivResourceIcon = new ImageView(ResourcePlayer.this); ivResourceIcon.setId(30); ivResourceIcon.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams ivResourceIconParams = new RelativeLayout.LayoutParams(50, 25); ivResourceIconParams.addRule(RelativeLayout.CENTER_VERTICAL, -1); ivResourceIconParams.addRule(RelativeLayout.LEFT_OF, 130); ivResourceIcon.setPadding(50, 0, 0, 0); ivResourceIcon.setBackgroundDrawable(getResources().getDrawable(R.drawable.handouts)); header.addView(ivResourceIcon, ivResourceIconParams); tvLearn = new TextView(this); tvLearn.setText("Learn More"); tvLearn.setId(20); tvLearn.setPadding(100, 0, 0, 0); tvLearn.setTextSize(20); tvLearn.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvLearnParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvLearnParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvLearnParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); tvAbout = new ImageView(ResourcePlayer.this); tvAbout.setId(21); tvAbout.setScaleType(ImageView.ScaleType.FIT_XY); RelativeLayout.LayoutParams webViewForwardIconParamsa = new RelativeLayout.LayoutParams(32, 32); webViewForwardIconParamsa.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1); webViewForwardIconParamsa.addRule(RelativeLayout.CENTER_VERTICAL, -1); webViewForwardIconParamsa.setMargins(0, 0, 200, 0); tvAbout.setBackgroundDrawable(getResources().getDrawable(R.drawable.info)); header.addView(tvAbout, webViewForwardIconParamsa); RelativeLayout fortvtitle = new RelativeLayout(this); RelativeLayout.LayoutParams tvTitleParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParams.addRule(RelativeLayout.CENTER_VERTICAL, 1); tvTitleParams.addRule(RelativeLayout.RIGHT_OF, 322); tvTitleParams.addRule(RelativeLayout.LEFT_OF, 21); header.addView(fortvtitle, tvTitleParams); tvTitle = new TextView(this); tvTitle.setText(""); tvTitle.setId(22); tvTitle.setPadding(0, 0, 0, 0); tvTitle.setTextSize(25); tvTitle.setSingleLine(true); tvTitle.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvTitleParamstv = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvTitleParamstv.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); tvTitleParamstv.addRule(RelativeLayout.CENTER_VERTICAL, 1); fortvtitle.addView(tvTitle, tvTitleParamstv); tvViewsNLikes = new TextView(this); tvViewsNLikes.setText(""); tvViewsNLikes.setId(23); tvViewsNLikes.setPadding(0, 0, 5, 5); tvViewsNLikes.setTextSize(18); tvViewsNLikes.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvViewsNLikesParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); tvViewsNLikesParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); subheader = new RelativeLayout(ResourcePlayer.this); subheader.setId(100); subheader.setVisibility(View.GONE); subheader.setBackgroundDrawable(getResources().getDrawable(R.drawable.navbar)); RelativeLayout.LayoutParams subheaderParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, 100); subheaderParams.addRule(RelativeLayout.BELOW, 1); subheaderParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); RelativeLayout.LayoutParams wvPlayerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); wvPlayerParams.addRule(RelativeLayout.BELOW, 100); wvPlayerParams.addRule(RelativeLayout.CENTER_IN_PARENT, 100); LinearLayout videoLayout = new LinearLayout(this); videoLayout.setVisibility(View.GONE); header.addView(webViewBack, webViewBackIconParams); header.addView(webViewRefresh, webViewRefreshIconParams); header.addView(webViewForward, webViewForwardIconParams); header.addView(ivmoveforward, ivmoveforwardIconIconParams); header.addView(imageshare, imageshareIconParams); header.addView(ivmoveback, ivmovebackIconIconParams); temp.addView(header, headerParams); temp.addView(subheader, subheaderParams); temp.addView(wvPlayer, wvPlayerParams); temp.addView(videoLayout, wvPlayerParams); setContentViewLayout.addView(temp, layoutParams); setContentView(setContentViewLayout); tvDescription = new TextView(ResourcePlayer.this); tvDescription1 = new TextView(ResourcePlayer.this); tvAbout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (flag == 0) { subheader.setVisibility(View.VISIBLE); subheader.removeAllViews(); // tvDescriptionn.setVisibility(View.INVISIBLE); tvDescription1.setVisibility(View.VISIBLE); tvDescription.setVisibility(View.VISIBLE); tvDescription.setText("Description"); tvDescription.setId(221); tvDescription.setTextSize(18); tvDescription.setTypeface(null, Typeface.BOLD); tvDescription.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescriptionParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tvDescriptionParams.setMargins(20, 10, 0, 20); tvDescriptionParams.addRule(RelativeLayout.BELOW, 220); tvDescription1.setText(description); tvDescription1.setLines(3); tvDescription1.setId(321); tvDescription1.setTextSize(15); tvDescription1.setTextColor(getResources().getColor(android.R.color.white)); RelativeLayout.LayoutParams tvDescription1Params = new RelativeLayout.LayoutParams(1100, 100); tvDescription1Params.addRule(RelativeLayout.CENTER_IN_PARENT, -1); tvDescription1.setPadding(100, 20, 100, 0); subheader.addView(tvDescription1, tvDescription1Params); desc = 0; flag = 1; flag1 = 0; } else { subheader.removeAllViews(); subheader.setVisibility(View.GONE); flag = 0; } } }); }
From source file:eu.pellerito.popularmoviesproject2.fragment.DetailFragment.java
private void viewTrailer(@NonNull List<MovieTrailer> trailer) { if ((mContext != null) && (trailerArrayList != null)) { LayoutInflater layoutInflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final String[] strKey = new String[1]; for (int i = 0; i < trailer.size(); i++) { strKey[0] = trailer.get(i).getKey(); View view = layoutInflater.inflate(R.layout.layout_trailer, layoutWrapper, false); LinearLayout linearLayoutWrapper = ButterKnife.findById(view, R.id.trailer_wrapper); LinearLayout.LayoutParams layoutParamsImage = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParamsImage.setMargins(8, 8, 8, 8); if (trailerTitle != null) { separatorTrailer.setVisibility(View.VISIBLE); trailerTitle.setVisibility(View.VISIBLE); }//from ww w . ja v a 2 s. c om final ImageView image = new ImageView(mContext); image.setTag(trailer.get(i).getName()); image.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.youtube)); image.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { playTrailer(strKey[0]); } }); LinearLayout.LayoutParams layoutParamsTextView = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); layoutParamsTextView.setMargins(8, 8, 8, 8); TextView textView = new TextView(mContext); textView.setText(trailer.get(i).getName()); textView.setGravity(Gravity.CENTER_VERTICAL); textView.setLines(2); linearLayoutWrapper.addView(image, layoutParamsImage); linearLayoutWrapper.addView(textView, layoutParamsTextView); if (layoutBaseTrailer != null) { layoutBaseTrailer.addView(linearLayoutWrapper); } } } }
From source file:com.fivetrue.workout.timer.view.PagerSlidingTabStrip.java
private void addIconTab(final int position, Drawable drawable) { ImageView tab = new ImageView(getContext()); tab.setFocusable(true);//from w w w .j a va 2 s. co m tab.setImageDrawable(drawable); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tab.setSelected(currentPosition == position); LinearLayout.LayoutParams params = defaultTabLayoutParams; if (shouldExpand) { params = expandedTabLayoutParams; } tabsContainer.addView(tab, params); }
From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java
/** * Places a marker on the bodyLayout in the given location. * * @param x x location to place the marker. * @param y y location to place the marker. *///from w w w.j a v a 2s.com private void placePointer(int x, int y) { y -= getYOffset(); //Log.d("PLACE_POINTER", "Placing pointer at: " + x + ", " + y); Drawable pointer_im = getResources().getDrawable(R.drawable.pointer_3x); pointer_im.setBounds(0, 0, 44, 65); ImageView new_pointer = new ImageView(getActivity()); new_pointer.setImageDrawable(pointer_im); new_pointer.setLayoutParams(setLayoutParams(x, y)); bodyLayout.addView(new_pointer); pointers.add(new_pointer); }
From source file:com.tsoliveira.android.listeners.DragDropTouchListener.java
private ImageView copyViewAsImageView(View v) { ImageView imageView = new ImageView(activity); imageView.setImageBitmap(copyViewAsBitmap(v)); return imageView; }
From source file:com.androprogrammer.tutorials.customviews.SlidingTabLayout.java
protected ImageView createDefaultIconTabView(Context context) { ImageView tabIconImageView = new ImageView(context); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); tabIconImageView.setBackgroundResource(outValue.resourceId); }//from w w w. j av a 2 s . c om int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); tabIconImageView.setPadding(padding, padding, padding, padding); return tabIconImageView; }
From source file:com.hichinaschool.flashcards.anki.multimediacard.activity.MultimediaCardEditorActivity.java
private void createNewViewer(LinearLayout linearLayout, final IField field, final int index) { final MultimediaCardEditorActivity context = this; switch (field.getType()) { case TEXT:/*w ww . j a v a 2 s . c o m*/ // Create a text field and an edit button, opening editing for // the // text field TextView textView = new TextView(this); textView.setText(field.getText()); linearLayout.addView(textView, LinearLayout.LayoutParams.MATCH_PARENT); break; case IMAGE: ImageView imgView = new ImageView(this); // // BitmapFactory.Options options = new BitmapFactory.Options(); // options.inSampleSize = 2; // Bitmap bm = BitmapFactory.decodeFile(myJpgPath, options); // jpgView.setImageBitmap(bm); LinearLayout.LayoutParams p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); File f = new File(field.getImagePath()); Bitmap b = BitmapUtil.decodeFile(f, getMaxImageSize()); int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= android.os.Build.VERSION_CODES.ECLAIR) { b = ExifUtil.rotateFromCamera(f, b); } imgView.setImageBitmap(b); imgView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imgView.setAdjustViewBounds(true); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int height = metrics.heightPixels; int width = metrics.widthPixels; imgView.setMaxHeight((int) Math.round(height * 0.6)); imgView.setMaxWidth((int) Math.round(width * 0.7)); linearLayout.addView(imgView, p); break; case AUDIO: AudioView audioView = AudioView.createPlayerInstance(this, R.drawable.av_play, R.drawable.av_pause, R.drawable.av_stop, field.getAudioPath()); linearLayout.addView(audioView); break; default: Log.e("multimedia editor", "Unsupported field type found"); break; } Button editButtonText = new Button(this); editButtonText.setText(gtxt(R.string.multimedia_editor_activity_edit_button)); linearLayout.addView(editButtonText, LinearLayout.LayoutParams.MATCH_PARENT); editButtonText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(context, EditFieldActivity.class); putExtrasAndStartEditActivity(field, index, i); } }); }
From source file:com.sinelead.car.club.map.AMapEx.java
@Override public View makeView() { ImageView iv = new ImageView(context); iv.setScaleType(ImageView.ScaleType.CENTER); iv.setLayoutParams(new ImageSwitcher.LayoutParams(ImageSwitcher.LayoutParams.MATCH_PARENT, ImageSwitcher.LayoutParams.MATCH_PARENT)); return iv;/*from w w w . j a va 2 s . c o m*/ }
From source file:com.rnd.snapsplit.view.OwedFragment.java
@Nullable @Override/*from w w w .ja va2 s . c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //super.onCreate(savedInstanceState); view = inflater.inflate(R.layout.activity_owed, container, false); activity = getActivity(); profile = new Profile(getContext()); ((Toolbar) getActivity().findViewById(R.id.tool_bar_hamburger)).setVisibility(View.VISIBLE); mProgressBar = (ProgressBar) view.findViewById(R.id.progressBar); mMessageRecyclerView = (RecyclerView) view.findViewById(R.id.messageRecyclerView); mLinearLayoutManager = new LinearLayoutManager(getContext()); //mLinearLayoutManager.setStackFromEnd(true); mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference().child("requests"); mFirebaseAdapter = new FirebaseRecyclerAdapter<PaymentRequest, MessageViewHolder>(PaymentRequest.class, R.layout.list_owed, MessageViewHolder.class, mFirebaseDatabaseReference.orderByChild("requestEpochDate")) { @Override protected PaymentRequest parseSnapshot(DataSnapshot snapshot) { PaymentRequest pr = super.parseSnapshot(snapshot); if (pr != null) { pr.setId(snapshot.getKey()); return pr; } return null; } @Override protected void populateViewHolder(final MessageViewHolder viewHolder, PaymentRequest pr, int position) { mProgressBar.setVisibility(ProgressBar.INVISIBLE); if (pr != null && pr.getReceipientPhoneNo().equals(profile.getPhoneNumber())) { if (pr.getStrReceiptPic() != null && !pr.getStrReceiptPic().equals("")) { String encodedReceipt = pr.getStrReceiptPic(); byte[] encodeByte = Base64.decode(encodedReceipt, Base64.DEFAULT); Bitmap bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length); viewHolder.receiptIcon.setImageBitmap(bitmap); } viewHolder.pr = pr; viewHolder.id = pr.getId(); viewHolder.description.setText(pr.getDescription()); viewHolder.from.setText( "Request sent by: " + pr.getRequestorName() + " - " + pr.getRequestorPhoneNumber()); viewHolder.share.setText("Your Share: HKD" + String.format("%.2f", pr.getShareAmount())); viewHolder.splitAmount .setText("Total Amount: HKD" + String.format("%.2f", pr.getTotalAmount())); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy' 'HH:mm:ss"); String date = null; Date temp = new Date(Long.parseLong(pr.getRequestEpochDate()) * (-1)); date = simpleDateFormat.format(temp); viewHolder.date.setText(date); } else { ViewGroup.LayoutParams params = viewHolder.item.getLayoutParams(); params.height = 0; viewHolder.item.setLayoutParams(params); } // log a view action on it //FirebaseUserActions.getInstance().end(getMessageViewAction(fd)); } @Override public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { MessageViewHolder viewHolder = super.onCreateViewHolder(parent, viewType); viewHolder.setOnLongClickListener(new MessageViewHolder.LongClickListener() { @Override public void onLongClick(View view, int position, String id, PaymentRequest pr) { AlertDialog.Builder ImageDialog = new AlertDialog.Builder(getActivity()); ImageDialog.setTitle("Receipt Preview - " + pr.getDescription()); ImageView showImage = new ImageView(getActivity()); Bitmap bitmap = null; if (pr.getStrReceiptPic() != null && !pr.getStrReceiptPic().equals("")) { String encodedReceipt = pr.getStrReceiptPic(); byte[] encodeByte = Base64.decode(encodedReceipt, Base64.DEFAULT); bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length); } if (bitmap != null) { showImage.setImageBitmap(bitmap); } ImageDialog.setView(showImage); ImageDialog.setNegativeButton("Close Preview", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); ImageDialog.show(); } }); viewHolder.setOnClickListener(new MessageViewHolder.ClickListener() { @Override public void onItemClick(View view, int position, String id, PaymentRequest pr) { //Toast.makeText(getActivity(), "Item clicked at " + position, Toast.LENGTH_SHORT).show(); Bundle bundle = new Bundle(); bundle.putSerializable("pr", pr); if (initCipher(mCipher, DEFAULT_KEY_NAME)) { // Show the fingerprint dialog. The user has the option to use the fingerprint with // crypto, or you can fall back to using a server-side verified password. DialogFragmentFingerprintAuthentication fragment = new DialogFragmentFingerprintAuthentication(); fragment.setCryptoObject(new FingerprintManager.CryptoObject(mCipher)); boolean useFingerprintPreference = mSharedPreferences .getBoolean(getString(R.string.use_fingerprint_to_authenticate_key), true); if (useFingerprintPreference) { fragment.setStage(DialogFragmentFingerprintAuthentication.Stage.FINGERPRINT); } else { fragment.setStage(DialogFragmentFingerprintAuthentication.Stage.PASSWORD); } fragment.setArguments(bundle); fragment.setTargetFragment(mFragment, 0); fragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG); } else { // This happens if the lock screen has been disabled or or a fingerprint got // enrolled. Thus show the dialog to authenticate with their password first // and ask the user if they want to authenticate with fingerprints in the // future DialogFragmentFingerprintAuthentication fragment = new DialogFragmentFingerprintAuthentication(); fragment.setCryptoObject(new FingerprintManager.CryptoObject(mCipher)); fragment.setStage( DialogFragmentFingerprintAuthentication.Stage.NEW_FINGERPRINT_ENROLLED); fragment.setArguments(bundle); fragment.setTargetFragment(mFragment, 0); fragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG); } } }); return viewHolder; } }; mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeInserted(int positionStart, int itemCount) { super.onItemRangeInserted(positionStart, itemCount); int friendlyMessageCount = mFirebaseAdapter.getItemCount(); int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition(); // If the recycler view is initially being loaded or the user is at the bottom of the list, scroll // to the bottom of the list to show the newly added message. if (lastVisiblePosition == -1 || (positionStart >= (friendlyMessageCount - 1) && lastVisiblePosition == (positionStart - 1))) { mMessageRecyclerView.scrollToPosition(positionStart); } } }); mMessageRecyclerView.setLayoutManager(mLinearLayoutManager); mMessageRecyclerView.setAdapter(mFirebaseAdapter); try { mKeyStore = KeyStore.getInstance("AndroidKeyStore"); } catch (KeyStoreException e) { throw new RuntimeException("Failed to get an instance of KeyStore", e); } try { mKeyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore"); } catch (NoSuchAlgorithmException | NoSuchProviderException e) { throw new RuntimeException("Failed to get an instance of KeyGenerator", e); } //Cipher defaultCipher; Cipher cipherNotInvalidated; try { mCipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); cipherNotInvalidated = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { throw new RuntimeException("Failed to get an instance of Cipher", e); } mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext()); KeyguardManager keyguardManager = getActivity().getSystemService(KeyguardManager.class); FingerprintManager fingerprintManager = getActivity().getSystemService(FingerprintManager.class); if (!keyguardManager.isKeyguardSecure()) { // Show a message that the user hasn't set up a fingerprint or lock screen. Toast.makeText(getActivity(), "Secure lock screen hasn't set up.\n" + "Go to 'Settings -> Security -> Fingerprint' to set up a fingerprint", Toast.LENGTH_LONG).show(); //return; } // Now the protection level of USE_FINGERPRINT permission is normal instead of dangerous. // See http://developer.android.com/reference/android/Manifest.permission.html#USE_FINGERPRINT // The line below prevents the false positive inspection from Android Studio // noinspection ResourceType if (!fingerprintManager.hasEnrolledFingerprints()) { // This happens when no fingerprints are registered. Toast.makeText(getActivity(), "Go to 'Settings -> Security -> Fingerprint' and register at least one fingerprint", Toast.LENGTH_LONG).show(); //return; } createKey(DEFAULT_KEY_NAME, true); createKey(KEY_NAME_NOT_INVALIDATED, false); return view; }
From source file:org.catnut.plugin.zhihu.ZhihuItemFragment.java
private ImageView getImageView() { ImageView image = new ImageView(getActivity()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); lp.setMargins(0, 10, 0, 10);/*from w w w . ja va 2 s .com*/ image.setLayoutParams(lp); image.setAdjustViewBounds(true); image.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return CatnutUtils.imageOverlay(v, event); } }); image.setOnClickListener(this); return image; }