List of usage examples for android.widget RelativeLayout invalidate
public void invalidate()
From source file:com.support.android.designlibdemo.MatchedPetsDetailActivity.java
/**********************************************************************************************/ private AlertDialog createReportDialog(String titulo, String message) { // Instanciamos un nuevo AlertDialog Builder y le asociamos titulo y mensaje AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(titulo); alertDialogBuilder.setMessage(message); RelativeLayout linearLayout = new RelativeLayout(this); final EditText link = new EditText(this); link.setHint("Causa de la denuncia"); link.setWidth(750);/*from w w w . j av a2 s . c o m*/ linearLayout.addView(link); linearLayout.setPadding(70, 0, 0, 0); alertDialogBuilder.setView(linearLayout); link.invalidate(); linearLayout.invalidate(); final String petId = getIntent().getStringExtra("id"); final String reporterId = this.loginUser.getId(); // Creamos un nuevo OnClickListener para el boton OK que realice la conexion DialogInterface.OnClickListener listenerOk = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { reportComplain(petId, reporterId, link.getText().toString()); } }; // Creamos un nuevo OnClickListener para el boton Cancelar DialogInterface.OnClickListener listenerCancelar = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }; // Asignamos los botones positivo y negativo a sus respectivos listeners //OJO: estan al reves para que sea display si - no en vez de no - si alertDialogBuilder.setPositiveButton(R.string.dialogCancel, listenerCancelar); alertDialogBuilder.setNegativeButton(R.string.dialogSend, listenerOk); return alertDialogBuilder.create(); }
From source file:com.cloverstudio.spika.CameraCropActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); String pManufacturer = android.os.Build.MANUFACTURER; String pModel = android.os.Build.MODEL; if ("GT-I9300".equals(pModel) && "samsung".equals(pManufacturer)) { RelativeLayout main = (RelativeLayout) findViewById(R.id.relativeLayout_main); main.invalidate(); setContentView(R.layout.activity_camera_crop); mImageView = (CroppedImageView) findViewById(R.id.ivCameraCropPhoto); mImageView.setDrawingCacheEnabled(true); scaleView();/* w w w.j ava 2 s . c o m*/ // Cancel button findViewById(R.id.btnCameraCancel).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); if (getIntent().getStringExtra("type").equals("gallery")) { Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class); intent.putExtra("type", "gallery"); startActivity(intent); } else { Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class); intent.putExtra("type", "camera"); startActivity(intent); } } }); // Next button findViewById(R.id.btnCameraOk).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Bitmap resizedBitmap = getBitmapFromView(mImageView); ByteArrayOutputStream bs = new ByteArrayOutputStream(); resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bs); if (saveBitmapToFile(resizedBitmap, mFilePath) == true) { if (mForProfile == true) { MyProfileActivity.gProfileImage = getBitmapFromView(mImageView); MyProfileActivity.gProfileImagePath = mFilePath; } else if (mForGroup == true) { CreateGroupActivity.gGroupImage = getBitmapFromView(mImageView); CreateGroupActivity.gGroupImagePath = mFilePath; } else if (mForGroupUpdate == true) { GroupProfileActivity.gGroupImage = getBitmapFromView(mImageView); GroupProfileActivity.gGroupImagePath = mFilePath; } else { fileUploadAsync(mFilePath); // new FileUploadAsync(CameraCropActivity.this) // .execute(mFilePath); // new // SendMessageAsync(getApplicationContext(), // SendMessageAsync.TYPE_PHOTO) // .execute(resizedBitmap); } } else { Toast.makeText(CameraCropActivity.this, "Failed to send photo", Toast.LENGTH_LONG).show(); } } }); File file = new File(_path); boolean exists = file.exists(); if (exists) onPhotoTaken(_path); else Toast.makeText(getBaseContext(), "Something went wrong while taking picture, please try again.", Toast.LENGTH_SHORT).show(); } }
From source file:com.snappy.CameraCropActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); String pManufacturer = android.os.Build.MANUFACTURER; String pModel = android.os.Build.MODEL; if ("GT-I9300".equals(pModel) && "samsung".equals(pManufacturer)) { RelativeLayout main = (RelativeLayout) findViewById(R.id.relativeLayout_main); main.invalidate(); setContentView(R.layout.activity_camera_crop); mImageView = (CroppedImageView) findViewById(R.id.ivCameraCropPhoto); mImageView.setDrawingCacheEnabled(true); scaleView();//from w w w.j av a2 s .com // Cancel button findViewById(R.id.btnCameraCancel).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); if (getIntent().getStringExtra("type").equals("gallery")) { Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class); intent.putExtra("type", "gallery"); startActivity(intent); } else { Intent intent = new Intent(CameraCropActivity.this, CameraCropActivity.class); intent.putExtra("type", "camera"); startActivity(intent); } } }); // Next button findViewById(R.id.btnCameraOk).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Bitmap resizedBitmap = getBitmapFromView(mImageView); ByteArrayOutputStream bs = new ByteArrayOutputStream(); resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bs); if (saveBitmapToFile(resizedBitmap, mFilePath) == true) { if (mForProfile == true) { MyProfileActivity.gProfileImage = getBitmapFromView(mImageView); MyProfileActivity.gProfileImagePath = mFilePath; } else if (mForGroup == true) { CreateGroupActivity.gGroupImage = getBitmapFromView(mImageView); CreateGroupActivity.gGroupImagePath = mFilePath; } else if (mForGroupUpdate == true) { GroupProfileActivity.gGroupImage = getBitmapFromView(mImageView); GroupProfileActivity.gGroupImagePath = mFilePath; } else { fileUploadAsync(mFilePath); // new FileUploadAsync(CameraCropActivity.this) // .execute(mFilePath); // new // SendMessageAsync(getApplicationContext(), // SendMessageAsync.TYPE_PHOTO) // .execute(resizedBitmap); } } else { Toast.makeText(CameraCropActivity.this, R.string.cameracrop_imagesend_failed, Toast.LENGTH_LONG).show(); } } }); File file = new File(_path); boolean exists = file.exists(); if (exists) onPhotoTaken(_path); else Toast.makeText(getBaseContext(), R.string.cameracrop_image_fatalerror, Toast.LENGTH_SHORT).show(); } }
From source file:com.support.android.designlibdemo.PetsDetailActivity.java
/**********************************************************************************************/ private AlertDialog createReportDialog(String titulo, String message) { // Instanciamos un nuevo AlertDialog Builder y le asociamos titulo y mensaje AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(titulo); alertDialogBuilder.setMessage(message); RelativeLayout linearLayout = new RelativeLayout(this); final EditText link = new EditText(this); link.setHint("Causa de la denuncia"); link.setWidth(750);//from w ww . ja v a2 s . co m linearLayout.addView(link); linearLayout.setPadding(70, 0, 0, 0); alertDialogBuilder.setView(linearLayout); link.invalidate(); linearLayout.invalidate(); final String petId = getIntent().getStringExtra("id"); // Creamos un nuevo OnClickListener para el boton OK que realice la conexion DialogInterface.OnClickListener listenerOk = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { reportComplain(petId, loginUser.getId(), link.getText().toString()); } }; // Creamos un nuevo OnClickListener para el boton Cancelar DialogInterface.OnClickListener listenerCancelar = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }; // Asignamos los botones positivo y negativo a sus respectivos listeners //OJO: estan al reves para que sea display si - no en vez de no - si alertDialogBuilder.setPositiveButton(R.string.dialogCancel, listenerCancelar); alertDialogBuilder.setNegativeButton(R.string.dialogSend, listenerOk); return alertDialogBuilder.create(); }
From source file:com.support.android.designlibdemo.PetsDetailActivity.java
/**********************************************************************************************/ private AlertDialog createPublicationDialog(String titulo, String message) { // Instanciamos un nuevo AlertDialog Builder y le asociamos titulo y mensaje AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(titulo); alertDialogBuilder.setMessage(message); RelativeLayout linearLayout = new RelativeLayout(this); final EditText link = new EditText(this); link.setText(buildDescription());// w w w .j a v a 2 s . c om link.setTextSize(12); link.setWidth(750); linearLayout.addView(link); linearLayout.setPadding(70, 0, 0, 0); alertDialogBuilder.setView(linearLayout); link.invalidate(); linearLayout.invalidate(); // final String petId = getIntent().getStringExtra("id"); // Creamos un nuevo OnClickListener para el boton OK que realice la conexion DialogInterface.OnClickListener listenerOk = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String texto = link.getText().toString(); shareOnFacebook(texto); Toast.makeText(getApplicationContext(), "Publicacin compartida correctamente", Toast.LENGTH_SHORT) .show(); } }; // Creamos un nuevo OnClickListener para el boton Cancelar DialogInterface.OnClickListener listenerCancelar = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }; // Asignamos los botones positivo y negativo a sus respectivos listeners //OJO: estan al reves para que sea display si - no en vez de no - si alertDialogBuilder.setPositiveButton(R.string.dialogCancel, listenerCancelar); alertDialogBuilder.setNegativeButton(R.string.dialogPublish, listenerOk); return alertDialogBuilder.create(); }
From source file:com.nextgis.forestinspector.fragment.MapFragment.java
protected void showMapButtons(boolean show, RelativeLayout rl) { if (null == rl) { return;/*w w w . j a va 2 s .c om*/ } View v = rl.findViewById(R.id.action_zoom_out); if (null != v) { if (show) { v.setVisibility(View.VISIBLE); } else { v.setVisibility(View.GONE); } } v = rl.findViewById(R.id.action_zoom_in); if (null != v) { if (show) { v.setVisibility(View.VISIBLE); } else { v.setVisibility(View.GONE); } } rl.invalidate(); }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Show the alert/* w w w. j a v a 2 s . c o m*/ * * @param context application-specific resources * @param configuration describes all device configuration information * @param text message to be displayed * @param forceClearPreviousAlert true will clear previous alert else keep it */ @SuppressLint("NewApi") private static void showAlertOnScreen(final Activity context, final Configuration configuration, final String text, boolean forceClearPreviousAlert) { final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content)); boolean currentlyDisplayed = false; int viewId = R.id.alert_view_top; final TextView textView; boolean alertAlreadyExists = false; if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) { viewId = R.id.alert_view_bottom; } // Retrieving the view RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId); if (forceClearPreviousAlert) { mainView.removeView(relativeLayout); relativeLayout = null; } // Creating the view if (relativeLayout == null) { // Main layout relativeLayout = new RelativeLayout(context); relativeLayout.setId(viewId); relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight())); relativeLayout.setGravity(Gravity.CENTER); // Textview textView = new TextView(context); textView.setId(R.id.alert_view_text); textView.setGravity(Gravity.CENTER); textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); relativeLayout.addView(textView); setIcon(context, configuration, relativeLayout, textView); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { relativeLayout.setY(-configuration.getHeight()); } else { relativeLayout.setY(mainView.getHeight()); } // Adding the view to the global layout mainView.addView(relativeLayout, 0); relativeLayout.bringToFront(); relativeLayout.requestLayout(); relativeLayout.invalidate(); } // View already exists else { alertAlreadyExists = true; textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { if (relativeLayout.getY() == 0) { currentlyDisplayed = true; } } else { if (relativeLayout.getY() < mainView.getHeight()) { currentlyDisplayed = true; } } // The view is currently shown to the user if (currentlyDisplayed) { // If the message is not the same, we hide the current message and display the new one if (!StringUtils.equals(text, textView.getText())) { // Anim out the current message ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout); final RelativeLayout relativeLayoutFinal = relativeLayout; if (viewPropertyAnimator != null) { // Anim in the new message after the animation out has finished if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { viewPropertyAnimator.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } else { viewPropertyAnimator.withEndAction(new Runnable() { @Override public void run() { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } } else { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } } } } final RelativeLayout relativeLayoutFinal = relativeLayout; // Close the alert by clicking the layout if (configuration.isCloseable()) { relativeLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { animOut(configuration, mainView, relativeLayoutFinal); v.performClick(); return true; } }); } if (!currentlyDisplayed) { // Set the icon in case the alert already exists but it's not currently displayed if (alertAlreadyExists) { setIcon(context, configuration, relativeLayoutFinal, textView); } // We anim in the alert animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }
From source file:ac.robinson.paperchains.PaperChainsActivity.java
private void animateRecordingInterface(int direction, View keyView) { mPlayButton.setVisibility(View.VISIBLE); mDeleteButton.setVisibility(View.VISIBLE); mSaveButton.setVisibility(View.VISIBLE); // animate the control buttons out to be equally spaced around the record button float buttonOffset = -mPlayButton.getWidth(); PointF centre = new PointF(0, 0); PointF startingPoint = new PointF(0, buttonOffset); double radRot = Math.toRadians(-120); double cosRot = Math.cos(radRot); double sinRot = Math.sin(radRot); QRImageParser.rotatePoint(startingPoint, centre, cosRot, sinRot); float leftX = startingPoint.x; float leftY = startingPoint.y; QRImageParser.rotatePoint(startingPoint, centre, cosRot, sinRot); float rightX = startingPoint.x; float rightY = startingPoint.y; RelativeLayout parent; AnimatorSet buttonAnimator = new AnimatorSet(); switch (direction) { case 1: // out // on an outward animation, we want the three minor buttons to have priority so the record button's // larger click area doesn't capture their clicks mPlayButton.bringToFront();//from w w w. j a v a 2 s .c o m mDeleteButton.bringToFront(); mSaveButton.bringToFront(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { // need to manually re-layout before KitKat parent = (RelativeLayout) mPlayButton.getParent(); parent.requestLayout(); parent.invalidate(); } buttonAnimator.playTogether(ObjectAnimator.ofFloat(mDeleteButton, "translationX", 0, leftX), ObjectAnimator.ofFloat(mDeleteButton, "translationY", 0, leftY), ObjectAnimator.ofFloat(mSaveButton, "translationX", 0, rightX), ObjectAnimator.ofFloat(mSaveButton, "translationY", 0, rightY), ObjectAnimator.ofFloat(mPlayButton, "translationY", 0, buttonOffset)); buttonAnimator.setInterpolator(new OvershootInterpolator()); break; case -1: // in // keyView is the view we want to be at the front after an inward animation if (keyView != null) { keyView.bringToFront(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { // need to manually re-layout before KitKat parent = (RelativeLayout) keyView.getParent(); parent.requestLayout(); parent.invalidate(); } } buttonAnimator.playTogether(ObjectAnimator.ofFloat(mDeleteButton, "translationX", leftX, 0), ObjectAnimator.ofFloat(mDeleteButton, "translationY", leftY, 0), ObjectAnimator.ofFloat(mSaveButton, "translationX", rightX, 0), ObjectAnimator.ofFloat(mSaveButton, "translationY", rightY, 0), ObjectAnimator.ofFloat(mPlayButton, "translationY", buttonOffset, 0)); buttonAnimator.setInterpolator(new AnticipateInterpolator()); break; } buttonAnimator.setDuration(BUTTON_ANIMATION_DURATION); buttonAnimator.start(); }
From source file:com.acceleratedio.pac_n_zoom.AnimActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_anm); orgnlImageView = (ImageView) findViewById(R.id.imageView); orgnlImageView.setMaxHeight(800);/*from w w w . ja v a 2 s. c o m*/ orgnlImageView.setMaxWidth(600); crt_ctx = this; BitmapFactory.Options bmp_opt = new BitmapFactory.Options(); bmp_opt.inTargetDensity = DisplayMetrics.DENSITY_DEFAULT; // - Now we need to set the GUI ImageView data with data read from the picked file. DcodRszdBmpFil dcodRszdBmpFil = new DcodRszdBmpFil(); Bitmap bmp = dcodRszdBmpFil.DcodRszdBmpFil(SelectImageActivity.orgFil, bmp_opt); // Now we need to set the GUI ImageView data with the orginal file selection. orgnlImageView.setImageBitmap(bmp); orgnl_iv_wdth = bmp.getWidth(); orgnl_iv_hght = bmp.getHeight(); final RelativeLayout rel_anm_lo = (RelativeLayout) findViewById(R.id.activity_anm_lo); scaleGestureDetector = new ScaleGestureDetector(this, new simpleOnScaleGestureListener()); orgnlImageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getPointerCount() > 1 || flgInScale) { scaleGestureDetector.onTouchEvent(event); return true; } int end_hrz; int end_vrt; final int pointerIndex; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: pointerIndex = MotionEventCompat.getActionIndex(event); bgn_hrz = (int) MotionEventCompat.getX(event, pointerIndex); bgn_vrt = (int) MotionEventCompat.getY(event, pointerIndex); String log_str = "Beginning coordinates: Horz = " + String.valueOf(bgn_hrz) + "; Vert = " + String.valueOf(bgn_vrt); Log.d("OnTouchListener", log_str); orlp = (RelativeLayout.LayoutParams) orgnlImageView.getLayoutParams(); bgn_top = (int) orlp.topMargin; bgn_lft = (int) orlp.leftMargin; // To prevent an initial jump of the magnifier, aposX and aPosY must // have the values from the magnifier frame if (aPosX == 0) aPosX = orgnlImageView.getX(); if (aPosY == 0) aPosY = orgnlImageView.getY(); break; case MotionEvent.ACTION_MOVE: pointerIndex = MotionEventCompat.getActionIndex(event); float crt_hrz = MotionEventCompat.getX(event, pointerIndex); float crt_vrt = MotionEventCompat.getY(event, pointerIndex); final float dx = crt_hrz - bgn_hrz; final float dy = crt_vrt - bgn_vrt; aPosX += dx; aPosY += dy; orgnlImageView.setX(aPosX); orgnlImageView.setY(aPosY); log_str = "Current Position: Horz = " + String.valueOf(crt_hrz) + "; Vert = " + String.valueOf(crt_vrt); Log.d("OnTouchListener", log_str); break; case MotionEvent.ACTION_UP: pointerIndex = MotionEventCompat.getActionIndex(event); end_hrz = (int) MotionEventCompat.getX(event, pointerIndex); end_vrt = (int) MotionEventCompat.getY(event, pointerIndex); } rel_anm_lo.invalidate(); return true; } }); sav_anm_btn = (Button) findViewById(R.id.sav_btn); sav_anm_btn.setOnClickListener(new View.OnClickListener() { public void onClick(View vw) { onClickFlg = 1; RelativeLayout rel_anm_lo = (RelativeLayout) findViewById(R.id.activity_anm_lo); rel_anm_lo.removeView(vw); Bitmap tnBmp = getWrtBmp("thumbnail", rel_anm_lo, 40); tnBmp.recycle(); int vw_nmbr = anmViews.size(); for (int vw_mbr = 1; vw_mbr < vw_nmbr; vw_mbr += 1) { anim_view = anmViews.get(vw_mbr); if (anim_view != null) { Animation crt_anm = anim_view.getAnimation(); if (crt_anm != null) crt_anm.cancel(); anim_view.setAnimation(null); rel_anm_lo.removeView(anim_view); // Garbage collect the bitmap Drawable drawable = anim_view.getDrawable(); if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; Bitmap anim_bmp = bitmapDrawable.getBitmap(); anim_bmp.recycle(); } } } Bitmap orgnlImageBmp = getWrtBmp("bgimg", rel_anm_lo, 90); orgnlImageWdth = Integer.toString(orgnlImageBmp.getWidth()); orgnlImageHght = Integer.toString(orgnlImageBmp.getHeight()); anmViews.clear(); unbindDrawables(rel_anm_lo); ((RelativeLayout) rel_anm_lo).removeAllViews(); orgnlImageBmp.recycle(); crt_ctx = null; orgnlImageView = null; Intent intent = new Intent(AnimActivity.this, com.acceleratedio.pac_n_zoom.SaveAnmActivity.class); startActivity(intent); } }); progress = ProgressDialog.show(crt_ctx, "Loading the animation", "dialog message", true); GetRequest get_svg_img = new GetRequest(); get_svg_img.execute(""); }