Skip to content

Instantly share code, notes, and snippets.

View defHLT's full-sized avatar
🐔

Artem Kholodnyi defHLT

🐔
View GitHub Profile
package com.mlatu.tv.ui.views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import android.widget.FrameLayout;
public class ClipRevealFrame extends FrameLayout {
mRatingView = view.findViewById(R.id.rating_view);
mRatingClip = (ClipDrawable) mRatingView.getBackground();
BitmapDrawable star = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_fab_star);
Bitmap bitmap = star.getBitmap();
int side = bitmap.getHeight();
ViewGroup.LayoutParams lp = mRatingView.getLayoutParams();
lp.width = side * 10;
lp.height = side;
if (mServiceConn != null) {
if (mContext != null) mContext.unbindService(mServiceConn);
}
<uses-feature android:required="true" android:name="android.hardware.sensor.accelerometer" />
<uses-feature android:required="false" android:name="android.hardware.sensor.gyroscope" />
private Sensor getDefaultSensor() {
Sensor gravitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
Sensor accelSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (gravitySensor != null)
return gravitySensor;
else if (accelSensor != null)
return accelSensor;
else {
throw new RuntimeException("It seems device has neither gravity nor accelerometer sensor");
}
public void invokePicker(Integer requestCode) {
Intent intentGetContent = new Intent(Intent.ACTION_GET_CONTENT,
MediaStore.Images.Media.INTERNAL_CONTENT_URI);
intentGetContent.setType("image/*");
final PackageManager pm = getPackageManager();
final Intent i = new Intent(intentGetContent);
final List list = pm.queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
startActivityForResult(intentGetContent, requestCode);
} else {
(on-ui
(set-content-view! this
[:linear-layout {}
[:button {:id ::mybtn
:text "A button"
:on-click (fn [w]
(let [edit (find-view this ::myedit)]
(config edit :text "Clicked!")))}]
[:edit-text {:id ::myedit}]]))
PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped, either by a job control signal or because it is being traced
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by its parent
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
float scale = getMeasuredWidth() / mMaxImageWidth;
int width = Math.round(getMeasuredWidth() * scale);
int height = Math.round(getMeasuredHeight() * scale);
setMeasuredDimension(width, height);
}
private void init() {
paint = new Paint();
paint.setColor(Color.BLUE);
paint.setAntiAlias(true);
paint.setStrokeWidth(50);
paint.setStyle(Paint.Style.STROKE);
paintFill = new Paint();
paintFill.setColor(Color.RED);
paint.setAntiAlias(true);