Skip to content

Instantly share code, notes, and snippets.

relex ongakuer

Block or report user

Report or block ongakuer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ongakuer
ongakuer / MainActivity.java
Created Sep 12, 2016
Show PopupWindow in Immersive Sticky mode
View MainActivity.java
public class MainActivity extends AppCompatActivity {
private PopupWindow mPopupWindow;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int windowWidth = 480;
int windowHeight = 120;
@ongakuer
ongakuer / MathUtil.java
Last active Jan 16, 2019
Smooth LinearGradient
View MathUtil.java
public class MathUtil {
public static float constrain(float min, float max, float v) {
return Math.max(min, Math.min(max, v));
}
public static float interpolate(float x1, float x2, float f) {
return x1 + (x2 - x1) * f;
}
public static float uninterpolate(float x1, float x2, float v) {
@ongakuer
ongakuer / NetworkRoundedImageView.java
Last active Aug 29, 2015
NetworkRoundedImageView
View NetworkRoundedImageView.java
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.ImageLoader.ImageContainer;
import com.makeramen.RoundedImageView;
public class NetworkRoundedImageView extends RoundedImageView {
@ongakuer
ongakuer / gist:add32475478360251809
Created Jul 7, 2014
SquareFrameLayout (这个版本的测量考虑更全面)
View gist:add32475478360251809
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ongakuer
ongakuer / gist:b531b3de0d389463e1fe
Last active Aug 29, 2015
proguard混淆后导致json解析出错
View gist:b531b3de0d389463e1fe
private void parseJson() {
String json = "{\"school\":{\"classes\": [{\"name\":\"one\",\"count\":1},{\"name\":\"two\",\"count\":2}],\"headMaster\" : \"Einstein\"}}";
ObjectMapper mapper = new ObjectMapper();
try {
ResponseModle response = mapper.readValue(json, ResponseModle.class);
Log.e(this.getClass().getName(), "headMaster : " + response.getSchool().getHeadMaster());
@ongakuer
ongakuer / gist:0ef96ebc7e89288590fd
Last active Mar 14, 2018
Android 测量字符宽度的几种方法和场景
View gist:0ef96ebc7e89288590fd
mTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
TextPaint textPaint = mTextView.getPaint();
String source = "Lorem ipsum dolor sit amet";
// mTextView的宽度作为参考值
mTextView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int textViewWidth = mTextView.getMeasuredWidth();
You can’t perform that action at this time.