List of usage examples for android.view View getBackground
public Drawable getBackground()
From source file:org.appcelerator.titanium.view.TiUIView.java
public void clearOpacity(View view) { Drawable d = view.getBackground(); if (d != null) { d.clearColorFilter(); } }
From source file:com.bigpigs.fragments.SearchFragment.java
private Bitmap getMarkerBitmapFromView(@DrawableRes int resId) { View customMarkerView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.custom_marker, null); ImageView markerImageView = (ImageView) customMarkerView.findViewById(R.id.marker_icon); markerImageView.setImageResource(resId); customMarkerView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); customMarkerView.layout(0, 0, customMarkerView.getMeasuredWidth(), customMarkerView.getMeasuredHeight()); customMarkerView.buildDrawingCache(); Bitmap returnedBitmap = Bitmap.createBitmap(customMarkerView.getMeasuredWidth(), customMarkerView.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(returnedBitmap); canvas.drawColor(Color.WHITE, PorterDuff.Mode.SRC_IN); Drawable drawable = customMarkerView.getBackground(); if (drawable != null) drawable.draw(canvas);/*from w w w . j av a2 s . c om*/ customMarkerView.draw(canvas); return returnedBitmap; }
From source file:com.malin.rxjava.activity.MainActivity.java
/** * ???Activity onDestoryviewrootview/* ww w.j a v a 2s . c o m*/ * ?view?DrawingCache?? * Activity??????? * * @param view:the root view of the layout * @description Unbind the rootView * @author malin.myemail@gmail.com * @link http://stackoverflow.com/questions/9461364/exception-in-unbinddrawables * http://mp.weixin.qq.com/s?__biz=MzAwNDY1ODY2OQ==&mid=400656149&idx=1&sn=122b4f4965fafebf78ec0b4fce2ef62a&3rd=MzA3MDU4NTYzMw==&scene=6#rd * @since 2015.12.16 */ private void unBindDrawables(View view) { if (view != null) { try { Drawable drawable = view.getBackground(); if (drawable != null) { drawable.setCallback(null); } else { } if (view instanceof ViewGroup && !(view instanceof AdapterView)) { ViewGroup viewGroup = (ViewGroup) view; int viewGroupChildCount = viewGroup.getChildCount(); for (int j = 0; j < viewGroupChildCount; j++) { unBindDrawables(viewGroup.getChildAt(j)); } viewGroup.removeAllViews(); } } catch (Exception e) { e.printStackTrace(); } } }
From source file:org.appcelerator.titanium.view.TiUIView.java
/** * Sets the view's opacity.// w w w.ja v a 2 s .co m * @param view the view object. * @param opacity the opacity to set. */ protected void setOpacity(View view, float opacity) { if (view != null) { TiUIHelper.setDrawableOpacity(view.getBackground(), opacity); if (opacity == 1) { clearOpacity(view); } view.invalidate(); } }
From source file:co.taqat.call.CallActivity.java
private void unbindDrawables(View view) { if (view.getBackground() != null) { view.getBackground().setCallback(null); }/*from w ww .j a va 2 s . c o m*/ if (view instanceof ImageView) { view.setOnClickListener(null); } if (view instanceof ViewGroup && !(view instanceof AdapterView)) { for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { unbindDrawables(((ViewGroup) view).getChildAt(i)); } ((ViewGroup) view).removeAllViews(); } }
From source file:co.taqat.call.LinphoneActivity.java
private void unbindDrawables(View view) { if (view != null && view.getBackground() != null) { view.getBackground().setCallback(null); }//from w w w. ja va 2 s .c o m if (view instanceof ViewGroup && !(view instanceof AdapterView)) { for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { unbindDrawables(((ViewGroup) view).getChildAt(i)); } ((ViewGroup) view).removeAllViews(); } }
From source file:org.appcelerator.titanium.view.TiUIView.java
public void release() { Log.d(TAG, "Releasing: " + this, Log.DEBUG_MODE); View nv = getNativeView(); if (nv != null) { if (nv instanceof ViewGroup) { ViewGroup vg = (ViewGroup) nv; Log.d(TAG, "Group has: " + vg.getChildCount(), Log.DEBUG_MODE); if (!(vg instanceof AdapterView<?>)) { vg.removeAllViews();/*www. j a va 2 s .com*/ } } Drawable d = nv.getBackground(); if (d != null) { nv.setBackgroundDrawable(null); d.setCallback(null); if (d instanceof TiBackgroundDrawable) { ((TiBackgroundDrawable) d).releaseDelegate(); } d = null; } nativeView = null; borderView = null; if (proxy != null) { proxy.setModelListener(null); } } }
From source file:org.xingjitong.LinphoneActivity.java
@SuppressLint("NewApi") private void unbindDrawables(View view) { if (view != null && view.getBackground() != null) { view.getBackground().setCallback(null); }// w w w.j av a 2 s . com if (view instanceof ViewGroup && !(view instanceof AdapterView)) { for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) { unbindDrawables(((ViewGroup) view).getChildAt(i)); } ((ViewGroup) view).removeAllViews(); } }
From source file:sysnetlab.android.sdc.ui.CreateExperimentActivity.java
@Override public void onTagClicked_ExperimentRunTaggingFragment(AdapterView<?> gridview, View view, int position) { if (mPreviousTagPosition != position) { // pressed different tags or // first press Log.d("SensorDataCollector", "Tagging: first tag or different tag pressed."); Log.d("SensorDataCollector", "previous tag position = " + mPreviousTagPosition + "\t" + "current tag position = " + position); StateTag stateTag = (StateTag) gridview.getItemAtPosition(position); if (mPreviousTagPosition >= 0) { // pressed different tags switch (mStateTagPrevious.getState()) { case TAG_ON: // turn off previous tag mStateTagPrevious.setState(TaggingState.TAG_OFF); UserInterfaceUtils.setViewBackgroundCompatible(gridview.getChildAt(mPreviousTagPosition), mDrawableBackground); /*/*from w w w.java 2 s . c o m*/ * gridview.getChildAt(mPreviousTagPosition). * setBackgroundColor( * getResources().getColor(android.R. * color.background_light)); */ mExperiment.setLastTagging(new TaggingAction(mStateTagPrevious.getTag(), new ExperimentTime(), TaggingState.TAG_OFF)); break; case TAG_OFF: case TAG_CONTEXT: } } else { mDrawableBackground = view.getBackground(); } // turn on current tag stateTag.setState(TaggingState.TAG_ON); mExperiment.setLastTagging( new TaggingAction(stateTag.getTag(), new ExperimentTime(), TaggingState.TAG_ON)); view.setBackgroundColor(getResources().getColor(android.R.color.darker_gray)); mPreviousTagPosition = position; mStateTagPrevious = stateTag; } else { // pressed the same button Log.d("SensorDataCollector", "Tagging: first tag or different tag pressed."); Log.d("SensorDataCollector", "previous tag position = " + mPreviousTagPosition + "\t" + "current tag position = " + position); StateTag stateTag = (StateTag) gridview.getItemAtPosition(position); switch (stateTag.getState()) { case TAG_ON: // turn it off stateTag.setState(TaggingState.TAG_OFF); UserInterfaceUtils.setViewBackgroundCompatible(view, mDrawableBackground); /* * view.setBackgroundColor(getResources().getColor( * android.R.color.background_light)); */ mExperiment.setLastTagging( new TaggingAction(mStateTagPrevious.getTag(), new ExperimentTime(), TaggingState.TAG_OFF)); break; case TAG_OFF: // turn it on stateTag.setState(TaggingState.TAG_ON); view.setBackgroundColor(getResources().getColor(android.R.color.darker_gray)); mExperiment.setLastTagging( new TaggingAction(stateTag.getTag(), new ExperimentTime(), TaggingState.TAG_ON)); break; case TAG_CONTEXT: } mPreviousTagPosition = position; mStateTagPrevious = stateTag; } }
From source file:com.stikyhive.stikyhive.ChattingActivity.java
public void clickHoldAndTalk(View v) { v.setOnTouchListener(new View.OnTouchListener() { @Override//from ww w .j av a2 s . co m public boolean onTouch(View v, MotionEvent event) { v.setBackgroundResource(R.drawable.spin_animation); // Get the background, which has been compiled to an AnimationDrawable object. AnimationDrawable frameAnimation = (AnimationDrawable) v.getBackground(); if (event.getAction() == event.ACTION_DOWN) { onRecord(true); // Start the animation (looped playback by default). frameAnimation.start(); Toast.makeText(getBaseContext(), "Action Down", Toast.LENGTH_SHORT).show(); } else if (event.getAction() == event.ACTION_UP) { calcualteTodayDate(); adapter.add(new StikyChat("", "<img", false, timeSend, "voiceSend", 0, 0, "", "", audiofile.getAbsolutePath(), null, "")); adapter.notifyDataSetChanged(); lv.smoothScrollToPosition(adapter.getCount() - 1); Toast.makeText(getBaseContext(), "Action Up", Toast.LENGTH_SHORT).show(); onRecord(false); frameAnimation.stop(); v.setBackgroundResource(R.drawable.chat_micro); upLoadServerUri = getApplicationContext().getResources().getString(R.string.url) + "/androidstikyhive/voicetransfer.php?fromStikyBee=" + pref.getString("stkid", "") + "&toStikyBee=" + recipientStkid + "&message=voice" + "&dateTime=" + URLEncoder.encode(timeSendServer) + "&url=" + URLEncoder.encode(getResources().getString(R.string.url)); new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub int serverResponseCode = uploadFile(audiofile); if (serverResponseCode == 200) { Log.i("Success", " is done! "); flagChatting = false; flagTransfer = true; messageServer = "<img"; msg = "Voice Message"; recipientStkidGCM = recipientStkid; new regTask().execute("GCM"); new regTask2().execute("Last Message!"); } } }).start(); } return false; } }); }