Skip to content

Instantly share code, notes, and snippets.

View jiemachina's full-sized avatar
🚛

Jie.Ma jiemachina

🚛
View GitHub Profile
@jiemachina
jiemachina / gist:4631989
Last active December 11, 2015 17:08
zxing 竖屏截图
public synchronized Rect getFramingRectInPreview(){
int tmpRigth = rect.right;
int tmpLeft = rect.left;
int tmpTop = rect.top;
int tmpBottom =rect.bottom;
rect.left = (tmpTop * cameraResolution.x) /screenResolution.y ;
rect.top = cameraResolution.y - tmpRigth *cameraResolution.y/screenResolution.x;
@jiemachina
jiemachina / gist:4465609
Last active December 10, 2015 17:08
channel build
#!/usr/bin/python
import os
# -*- coding: utf-8 -*-
def writeFile(filename, content):
outfile = open(filename, "w")
outfile.write(content)
outfile.close()
def build(versionString):
xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
xmlResH = "<resources>\n\t"
@jiemachina
jiemachina / gist:4092218
Created November 17, 2012 00:41
python nginx
nginx和tornado就像apache和tomcat的功能;
@jiemachina
jiemachina / gist:3910321
Created October 18, 2012 07:44
根据文件路径,使用默认程序打开
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW);
File file = new File(sdcardPath);
String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
myIntent.setDataAndType(Uri.fromFile(file),mimetype);
mContext.startActivity(myIntent);
@jiemachina
jiemachina / gist:3760716
Created September 21, 2012 10:01
webview 数据库基本设置
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDatabaseEnabled(true);
// mWebView.getSettings().setDomStorageEnabled(true);
// mWebView.requestFocus(View.FOCUS_DOWN);
mWebView.requestFocus(View.FOCUS_DOWN);
// mWebView.addJavascriptInterface(new
// JavaScriptInterface(RecommendActivity.this, bookId,bookName),
// "android");
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
@jiemachina
jiemachina / gist:3736413
Created September 17, 2012 09:23
popuWindow 快速点击,背景透明
//背景不透明
mPopupWindow.setBackgroundDrawable(null);
final View contentView = getContentView();
//设置触摸事件 给 PopupWindow的ContentView重新设置触摸事件 解决setOutsideTouchable(true) 失效了,contentView为popuwindow的View
contentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int x = (int) event.getX();
final int y = (int) event.getY();
@jiemachina
jiemachina / 自定义progressBar 使用图片
Created September 17, 2012 03:29
自定义progressBar 使用图片
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" android:drawable="@drawable/progress_bg" />
<item android:id="@android:id/secondaryProgress" android:drawable="@drawable/progress_fg_start" />
<item android:id="@android:id/progress" android:drawable="@drawable/progress_fg_start" />
</layer-list>
@jiemachina
jiemachina / android 自定义progressBar
Created September 17, 2012 03:15
android 自定义progressBar
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape>
<corners android:radius="0dip" />
<gradient
android:angle="270"
android:centerColor="#ff5a5d5a"
@jiemachina
jiemachina / gist:3695896
Created September 11, 2012 04:10
webview中的组件可以编辑,因为mEditText组件已经获得焦点,所以先除去焦点,然后再分配可以有焦点,
mWebView.requestFocus(View.FOCUS_DOWN);
//先是去焦点,然后再给焦点去对焦
mEditText.setFocusable(false);
mEditText.setFocusableInTouchMode(true);
mEditText.setFocusable(true);
@jiemachina
jiemachina / eclispe key
Created August 31, 2012 02:41
search file name eclipse key
ctrl + shift + r