下面列出了android.util.Log#i ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* This ensures the capacity of the float arrays that hold the information bound to the Vertex
* Attributes needed to render the line with the Vertex and Fragment shader.
*
* @param numPoints int denoting number of points
*/
private void ensureCapacity(int numPoints) {
int count = 1024;
if (mSide != null) {
count = mSide.length;
}
while (count < numPoints) {
count += 1024;
}
if (mSide == null || mSide.length < count) {
Log.i(TAG, "alloc " + count);
mPositions = new float[count * 3];
mNext = new float[count * 3];
mPrevious = new float[count * 3];
mCounters = new float[count];
mSide = new float[count];
mWidth = new float[count];
}
}
/**
* select color format available on specific codec and we can use.
*
* @return 0 if no colorFormat is matched
*/
private static int selectColorFormat(final MediaCodecInfo codecInfo, final String mimeType) {
Log.i(TAG, "selectColorFormat: ");
int result = 0;
final MediaCodecInfo.CodecCapabilities caps;
try {
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
caps = codecInfo.getCapabilitiesForType(mimeType);
} finally {
Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
}
int colorFormat;
for (int i = 0; i < caps.colorFormats.length; i++) {
colorFormat = caps.colorFormats[i];
if (isRecognizedViewoFormat(colorFormat)) {
if (result == 0)
result = colorFormat;
break;
}
}
if (result == 0)
Log.e(TAG, "couldn't find a good color format for " + codecInfo.getName() + " / " + mimeType);
return result;
}
public void querySkuDetails(final String[] skus)
{
IABLogger.logEntering(getClass().getSimpleName(), "querySkuDetails", skus);
if (mHelper == null)
{
Log.i(TAG, BILLING_NOT_RUNNING_ERROR);
return;
}
runSafelyOnUiThread(new Runnable()
{
public void run()
{
mHelper.querySkuDetailsAsync(Arrays.asList(skus), BazaarIABPlugin.this);
}
}, "querySkuDetailsFailed");
}
@Override
public void onActivityResumed(Activity activity) {
paused = false;
boolean wasBackground = !foreground;
foreground = true;
if (check != null)
handler.removeCallbacks(check);
if (wasBackground){
Log.i(TAG, "went foreground");
for (Listener l : listeners) {
try {
l.onBecameForeground();
} catch (Exception exc) {
Log.e(TAG, "Listener threw exception!", exc);
}
}
} else {
Log.i(TAG, "still foreground");
}
}
/**
* Writes the current display, context, and surface to the log.
*/
public static void logCurrent(String msg) {
EGLDisplay display;
EGLContext context;
EGLSurface surface;
display = EGL14.eglGetCurrentDisplay();
context = EGL14.eglGetCurrentContext();
surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
", surface=" + surface);
}
/**
* Posts a file attachment in a draft message by message Id
*
* @param messageId String. The id of the draft message to add an attachment to
* @param picture Byte[]. The picture in bytes
* @param sharingLink String. The sharing link to the uploaded picture
* @param callback
*/
public void addPictureToDraftMessage(String messageId,
byte[] picture,
String sharingLink,
ICallback<Attachment> callback) {
try {
byte[] attachementBytes = new byte[picture.length];
if (picture.length > 0) {
attachementBytes = picture;
} else {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
attachementBytes = getDefaultPicture();
}
else {
attachementBytes = getTestPicture();
}
}
FileAttachment fileAttachment = new FileAttachment();
fileAttachment.oDataType = "#microsoft.graph.fileAttachment";
fileAttachment.contentBytes = attachementBytes;
//fileAttachment.contentType = "image/png";
fileAttachment.name = "me.png";
fileAttachment.size = attachementBytes.length;
fileAttachment.isInline = false;
fileAttachment.id = "blabla";
Log.i("connect sample","attachement id " + fileAttachment.id);
mGraphServiceClient
.me()
.messages(messageId)
.attachments()
.buildRequest()
.post(fileAttachment, callback);
} catch (Exception ex) {
showException(ex, "exception on add picture to draft message","Draft attachment failed", "The post file attachment method failed");
}
}
public static boolean haveRoot() {
if (!sHaveRoot) {
int ret = execRootCmdSilent("echo test"); // 通过执行测试命令来检测
if (ret != -1) {
Log.i(TAG, "have root!");
sHaveRoot = true;
} else {
Log.i(TAG, "not root!");
sHaveRoot = false;
}
} else {
Log.i(TAG, "sHaveRoot = true, have root!");
}
return sHaveRoot;
}
@Override
protected String doInBackground(Void... arg0) {
Log.i(TAG, "Authenticating");
// Get and return the authtoken
return new OAuth2Helper().getRefreshedAuthToken(activity, GV_SERVICE);
}
public static void setBestPreviewFPS(Camera.Parameters parameters, int minFPS, int maxFPS) {
List<int[]> supportedPreviewFpsRanges = parameters.getSupportedPreviewFpsRange();
Log.i(TAG, "Supported FPS ranges: " + toString(supportedPreviewFpsRanges));
if (supportedPreviewFpsRanges != null && !supportedPreviewFpsRanges.isEmpty()) {
int[] suitableFPSRange = null;
for (int[] fpsRange : supportedPreviewFpsRanges) {
int thisMin = fpsRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
int thisMax = fpsRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
if (thisMin >= minFPS * 1000 && thisMax <= maxFPS * 1000) {
suitableFPSRange = fpsRange;
break;
}
}
if (suitableFPSRange == null) {
Log.i(TAG, "No suitable FPS range?");
} else {
int[] currentFpsRange = new int[2];
parameters.getPreviewFpsRange(currentFpsRange);
if (Arrays.equals(currentFpsRange, suitableFPSRange)) {
Log.i(TAG, "FPS range already set to " + Arrays.toString(suitableFPSRange));
} else {
Log.i(TAG, "Setting FPS range to " + Arrays.toString(suitableFPSRange));
parameters.setPreviewFpsRange(suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
suitableFPSRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
}
}
}
}
public static void startFullscreen(Context context, Class _class, String url, Object... objects) {
Log.i(TAG, "startFullscreen: ===manual fullscreen===");
hideSupportActionBar(context);
MxUtils.getAppComptActivity(context).setRequestedOrientation(FULLSCREEN_ORIENTATION);
ViewGroup vp = (ViewGroup) (scanForActivity(context))
.findViewById(Window.ID_ANDROID_CONTENT);
View old = vp.findViewById(R.id.mx_fullscreen_id);
if (old != null) {
vp.removeView(old);
}
try {
Constructor<MxVideoPlayer> constructor = _class.getConstructor(Context.class);
MxVideoPlayer mxVideoPlayer = constructor.newInstance(context);
mxVideoPlayer.setId(R.id.mx_fullscreen_id);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
vp.addView(mxVideoPlayer, lp);
mxVideoPlayer.startPlay(url, SCREEN_WINDOW_FULLSCREEN, objects);
mxVideoPlayer.addTextureView();
mxVideoPlayer.mPlayControllerButton.performClick();
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean init(Context appCtx, Config config) {
if (config.inputShape.length != 4) {
Log.i(TAG, "size of input shape should be: 4");
return false;
}
if (config.inputShape[0] != 1) {
Log.i(TAG, "only one batch is supported in the image classification demo, you can use any batch size in " +
"your Apps!");
return false;
}
if (config.inputShape[1] != 1 && config.inputShape[1] != 3) {
Log.i(TAG, "only one/three channels are supported in the image classification demo, you can use any " +
"channel size in your Apps!");
return false;
}
if (!config.inputColorFormat.equalsIgnoreCase("RGB") && !config.inputColorFormat.equalsIgnoreCase("BGR")) {
Log.i(TAG, "only RGB and BGR color format is supported.");
return false;
}
init(appCtx, config.modelPath, config.cpuThreadNum, config.cpuPowerMode);
if (!isLoaded()) {
return false;
}
this.config = config;
return isLoaded;
}
private String userAuthRequest(String query) {
queryResultStr = "";
// Get a fresh access token
OAuth2Helper oauthHelper = new OAuth2Helper();
String authToken = oauthHelper.getRefreshedAuthToken(activity, authTokenType);
// Make the fusiontables query
if (authToken != null) {
// We handle CREATE TABLE as a special case
if (query.toLowerCase().contains("create table")) {
queryResultStr = doPostRequest(parseSqlCreateQueryToJson(query), authToken);
return queryResultStr;
} else {
// Execute all other queries
com.google.api.client.http.HttpResponse response = sendQuery(query, authToken);
// Process the response
if (response != null) {
queryResultStr = httpResponseToString(response);
Log.i(TAG, "Query = " + query + "\nResultStr = " + queryResultStr);
} else {
queryResultStr = errorMessage;
Log.i(TAG, "Error: " + errorMessage);
}
return queryResultStr;
}
} else {
return OAuth2Helper.getErrorMessage();
}
}
@Override
public void onViewRestored() {
Log.i(TAG, "View restored in [" + TAG + "]");
}
@Override
public void onCreate(SQLiteDatabase db) {
Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
createAllTables(db, false);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
Log.i(TAG, "onLayout: ");
super.onLayout(changed, l, t, r, b);
}
void init(int top){
int len = 4;
int line = 1;
int spaceWidth = Ui.cd.getHt(15);
int paddingWidth = Ui.cd.getHt(15);
int itemWidth = (int)(((float)Menu.width - Ui.cd.getHt(15 * (len + 1))) / len);
int itemHeight = (int)(itemWidth * 1.5f);
int iconSize = (int)(itemWidth * 0.7f);
for(int i = 0;i < len;i++){
for(int j = 0;j < line;j++){
if((j*len) + i < 2){
final Item item = new Item(getContext(),itemWidth,itemHeight);
item.onClick(new call(){
@Override
public void onCall(boolean bl) {
onBtn(item.name.Text);
}
});
//item.setBackgroundColor(0xFFCCCCCC);
item.setX((i * itemWidth) + (i * spaceWidth) + spaceWidth);
item.setY(top + (j * itemHeight) + (spaceWidth * (j + 1)));
Menu.addView(item);
Log.i("My","(i*len) + j = " + ((i*len) + j));
switch ((j*len) + i){
case 0:
item.setData("PLAY", new com.shape.Library.Icon.playAllIcon(iconSize,iconSize,0,0));
break;
case 9:
item.setData("SHOW FILE",new folderIcon(iconSize,iconSize,0,0));
break;
case 10:
item.setData("REMOVE",new deleteIcon(iconSize,iconSize,0,0));
break;
case 1:
item.setData("SHARE",new shareFileIcon(iconSize,iconSize,0,0));
break;
case 4:
item.setData("RINGTONE",new ringToneIcon(iconSize,iconSize,0,0));
break;
case 5:
item.setData("INFO",new fileInfoIcon(iconSize,iconSize,0,0));
break;
}
}
}
}
}
@Override
public void i(final String msg) {
Log.i(TAG, msg);
}
public static void i(String mess) {
if (DEBUG) {
Log.i(getTag(), mess);
}
}
@Deprecated
@Override
public float getX() {
Log.i("DEPRECATED", "Pie entries do not have x values");
return super.getX();
}
@Override
public void initialView() {
tvTongyi.setOnClickListener(this);
ll_Back.setOnClickListener(this);
tvJujue.setOnClickListener(this);
rlMsg.setOnClickListener(this);
Intent intent = getIntent();
message = (XmppMessage) intent.getSerializableExtra("xmpp_user");
Log.i("message", message.toString());
//String str[] = message.getUser().getName().split(";");
User users = new Gson().fromJson(message.getUser().getName(), User.class);
tv_Name.setText(users.getNickname());
tv_Shenqing.setText("申请时间:" + message.getTime());
if (message.getType().equals("add")) {
if (message.getResult() == 1) {
llBtn.setVisibility(View.VISIBLE);
tvTishi.setVisibility(View.GONE);
} else {
llBtn.setVisibility(View.GONE);
if (message.getResult() == 0) {
tvTishi.setText("已同意" + "该申请");
} else if (message.getResult() == -1) {
tvTishi.setText("已拒绝" + "该申请");
}
tvTishi.setVisibility(View.VISIBLE);
}
} else if (message.getType().equals("tongyi") || message.getType().equals("jujue")) {
llBtn.setVisibility(View.GONE);
tvTishi.setVisibility(View.VISIBLE);
tvTishi.setText(message.getContent());
if (message.getResult() == 1) {
ContentValues values = new ContentValues();
values.put("result", 0);
XmppService.resolver.update(XmppContentProvider.CONTENT_MESSAGES_URI, values, "id=?", new String[]{message.getId() + ""});
SharedPreferencesUtil.setFriendMessageNumber_subone(this, message.getTo());
Intent intents = new Intent("xmpp_receiver");
intents.putExtra("type", message.getType());
sendBroadcast(intents);
}
}
Drawable nav_up = null;
if (users.getSex().equals("男")) {
tv_Sex.setText("男");
nav_up = getResources().getDrawable(R.mipmap.man);
nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
tv_Sex.setCompoundDrawables(null, null, nav_up, null);
} else {
tv_Sex.setText("女");
nav_up = getResources().getDrawable(R.mipmap.woman);
nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
tv_Sex.setCompoundDrawables(null, null, nav_up, null);
}
if (users.getIcon().equals("")) {
if (users.getSex().equals("男")) {
iv_Icon.setImageResource(R.mipmap.me_icon_man);
tv_Sex.setText("男");
} else {
tv_Sex.setText("女");
iv_Icon.setImageResource(R.mipmap.me_icon_woman);
}
} else {
if (users.getIcon().substring(0, 4).equals("http")) {
Picasso.with(this).load(users.getIcon()).resize(200, 200).placeholder(R.mipmap.qq_addfriend_search_friend).error(R.mipmap.qq_addfriend_search_friend).centerInside().into(iv_Icon);
} else {
Picasso.with(this).load(url_icon + users.getIcon()).resize(200, 200).placeholder(R.mipmap.qq_addfriend_search_friend).error(R.mipmap.qq_addfriend_search_friend).centerInside().into(iv_Icon);
}
}
}