This file contains hidden or 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 byte[] readInputStream(InputStream inputStream) throws IOException { | |
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | |
byte[] buffer = new byte[1024]; | |
int len = 0; | |
while ((len = inputStream.read(buffer)) != -1) { | |
outputStream.write(buffer, 0 ,len); | |
} | |
inputStream.close(); | |
return outputStream.toByteArray(); |
This file contains hidden or 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 FinalVariateChangeByReflection { | |
public static final String HOST_NAME; | |
public static final String HOST_NAME_CHANGE = "http://www.apple.com"; | |
static { | |
HOST_NAME = "http://www.google.com"; | |
} |
This file contains hidden or 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 FinalVariateChangeByReflection { | |
public static final String HOST_NAME; | |
public static final String HOST_NAME_CHANGE = "http://www.apple.com"; | |
private static final String MODIFY_PERMISSION_FIELD = "modifiers"; | |
static { | |
HOST_NAME = "http://www.google.com"; |
This file contains hidden or 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 final static String PICTRUE_SAVE_PATH = Environment.getExternalStorageDirectory() + "/jet/.photo/"; | |
public static String compressImage(String url) { | |
String path = PICTRUE_SAVE_PATH + String.valueOf(UUID.randomUUID()) + ".jpg"; | |
try { | |
BitmapFactory.Options newOpts = new BitmapFactory.Options(); | |
newOpts.inJustDecodeBounds = true; | |
Bitmap image = BitmapFactory.decodeFile(url, newOpts);//此时返回bm为空 |
This file contains hidden or 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
MediaRecorder recorder = new MediaRecorder(); | |
recorder.setAudioSource(MediaRecorder.AudioSource.MIC); | |
if (Build.VERSION.SDK_INT >= 10) { | |
recorder.setAudioSamplingRate(44100); | |
recorder.setAudioEncodingBitRate(96000); | |
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); | |
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); | |
} else { | |
// older version of Android, use crappy sounding voice codec | |
recorder.setAudioSamplingRate(8000); |
This file contains hidden or 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
getSupportFragmentManager().beginTransaction().replace(R.id.container, new BackListenerFragment()).addToBackStack("callback").commit(); | |
//inside BackListenerFragment | |
@Override | |
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
super.onViewCreated(view, savedInstanceState); | |
view.setOnKeyListener(new View.OnKeyListener() { | |
@Override | |
public boolean onKey(View v, int keyCode, KeyEvent event) { | |
if (keyCode == KeyEvent.KEYCODE_BACK) { |
This file contains hidden or 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
package com.gitcafe.android.base.fragment; | |
import android.util.Log; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.GregorianCalendar; | |
import java.util.Hashtable; | |
import java.util.regex.Matcher; |
This file contains hidden or 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
protected final void initStatusBar(int resId) { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | |
SystemBarTintManager tintManager = new SystemBarTintManager(this); | |
tintManager.setStatusBarTintEnabled(true); | |
tintManager.setTintResource(R.color.your_color); | |
SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); | |
findViewById(resId).setPadding(0, config.getPixelInsetTop(true), 0, config.getPixelInsetBottom()); | |
} | |
} |
This file contains hidden or 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 int getActionBarHeight() { | |
int actionBarHeight = getSupportActionBar().getHeight(); | |
if (actionBarHeight != 0) { | |
return actionBarHeight; | |
} | |
final TypedValue typedValue = new TypedValue(); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | |
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) { | |
actionBarHeight = TypedValue.complexToDimensionPixelSize( |
This file contains hidden or 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
this.getWindow().requestFeature(Window.FEATURE_PROGRESS); | |
setContentView(R.layout.main ); | |
final Activity MyActivity = this; | |
// Makes Progress bar Visible | |
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); | |
webview = (WebView) findViewById(R.id.webview); | |
webview.setWebChromeClient(new WebChromeClient() { | |
public void onProgressChanged(WebView view, int progress) | |
{ |
NewerOlder