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 your.awesome.app; | |
import android.graphics.Bitmap; | |
import android.support.v4.util.LruCache; | |
import com.android.volley.toolbox.ImageLoader.ImageCache; | |
public class LruBitmapCache extends LruCache<String, Bitmap> implements ImageCache { | |
public LruBitmapCache(int maxSize) { | |
super(maxSize); |
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 your.awesome.app; | |
import android.graphics.Bitmap; | |
import android.support.v4.util.LruCache; | |
import com.android.volley.toolbox.ImageLoader.ImageCache; | |
public class LruBitmapCache extends LruCache<String, Bitmap> implements ImageCache { | |
public LruBitmapCache(int maxSize) { | |
super(maxSize); |
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
第一种: | |
Map map = new HashMap(); | |
Iterator iter = map.entrySet().iterator(); | |
while (iter.hasNext()) { | |
Map.Entry entry = (Map.Entry) iter.next(); | |
Object key = entry.getKey(); | |
Object val = entry.getValue(); | |
} | |
效率高,以后一定要使用此种方式! | |
第二种: |
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 void makePointCloud(float innerRadius, float outerRadius) { | |
if (innerRadius == 0) { | |
Log.w(TAG, "Must specify an inner radius"); | |
return; | |
} | |
mOuterRadius = outerRadius; | |
mPointCloud.clear(); | |
final float pointAreaRadius = (outerRadius - innerRadius); | |
final float ds = (2.0f * PI * innerRadius / INNER_POINTS); | |
final int bands = (int) Math.round(pointAreaRadius / ds); |
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 void setBrightness( int barValue) { | |
int birghtness = barValue + MIN_BRIGHTNESS; | |
LayoutParams lp = getWindow().getAttributes(); | |
lp. screenBrightness = (birghtness / 255.0F); // 预览亮度, 一个浮点数0-1 | |
getWindow().setAttributes(lp); | |
Settings.System. putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS , birghtness);// brightness设置屏幕亮度,值为30-255 | |
} | |
// <uses-permission android:name="android.permission.WRITE_SETTINGS" /> |
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
String status = Environment.getExternalStorageState(); | |
if(status.equals(Environment.MEDIA_MOUNTED)) | |
{ | |
filePath = sdcardDir + "/" + filename + ".jpg"; | |
Intent getImageByCamera = new Intent("android.media.action.IMAGE_CAPTURE"); | |
//得到的filePath这个路径的文件图片没有被压缩,使用是直接根据路径filePath获得这个文件 | |
getImageByCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(filePath))); | |
startActivityForResult(getImageByCamera,RESULT_OK_CAMERA); | |
} | |
else |
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
//把图片文件按比例生产高度为240的btimap | |
BitmapFactory.Options options = new BitmapFactory.Options(); | |
options.inJustDecodeBounds =true; | |
bmp = BitmapFactory.decodeFile(filePath, options ); | |
options.inJustDecodeBounds =false; | |
int be = (int)(options.outHeight/ (float)240); | |
if(be <= 0) | |
be = 1; | |
options.inSampleSize = be; | |
bmp=BitmapFactory.decodeFile(filePath,options); |
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 void choosePic() | |
{ | |
final CharSequence[] items = {"拍照上传", "从相册上传", "取消"}; | |
AlertDialog dialog = new AlertDialog.Builder(this) | |
.setTitle("添加相片") | |
.setItems(items, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int item) { |
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
/* user-defined TabHost,remenber in you layout use full-name for you tabhost such as com.gng.view.MyTabHost, | |
you need to write you class extends TabHost, | |
and override the method setCurrentTab() , | |
in this method you can use you own animation to change activity | |
*/ | |
//this is my setCurrentTab | |
@Override | |
public void setCurrentTab(int index) |
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
NotificationManager notificationManager = | |
(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); | |
Notification notification = new Notification(icon,title,when); | |
Intent openIntent = new Intent(this, MyNotificationActivity); | |
PendingIntent pIntent = PendingIntent.getActivity(this,0,openIntent,0); | |
notification.setLatesEventInfo(this, "标题", "内容", pIntent); | |
notificationManager.notify(0,notification); |
NewerOlder