This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |