Skip to content

Instantly share code, notes, and snippets.

:bowtie:
Coding

Logan Guo Logan676

:bowtie:
Coding
Block or report user

Report or block Logan676

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View wx_pay_useful_methods.java
/** JSAPI支付 */
public JSONObject jsPay() {
JSONObject obj = new JSONObject();
WeixinMpAccount weixinAccount = JSON.parseObject(
ConfigUtil.getValue("account"), WeixinMpAccount.class);
// V3 支付
PayPackage payPackage = new PayPackageV3(weixinAccount, "用户openid",
"商品描述", "系统内部订单号", 1d, "IP地址", TradeType.JSAPI);
// V2 支付
View codeStyleSettings.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
View android_eclipse_formatter.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Android" version="12">
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
View TransferDatabaseUtils.java
package com.seafile.seadroid2.transfer;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.google.common.collect.Lists;
import java.util.List;
View TransferDatabaseHelper.java
package com.seafile.seadroid2.transfer;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.seafile.seadroid2.SeadroidApplication;
import com.seafile.seadroid2.data.DataManager;
import java.io.File;
@Logan676
Logan676 / UpgradeDatabaseWithoutLosingData.java
Created Jun 11, 2015
You should add some code into the onUpgrade method. With that, you can check the oldVersion and the newVersion and do the proper ALTER TABLE statements. As you can see, the current version is 23 and the check code checks what is the old version. If version 22 it does just the v22 statements, but if version 21 it does both v21 AND v22 statements.…
View UpgradeDatabaseWithoutLosingData.java
private static final int VER_LAUNCH = 21;
private static final int VER_SESSION_FEEDBACK_URL = 22;
private static final int VER_SESSION_NOTES_URL_SLUG = 23;
private static final int DATABASE_VERSION = VER_SESSION_NOTES_URL_SLUG;
...
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
@Logan676
Logan676 / DatabaseHelper.java
Last active Aug 29, 2015
upgrade a database without removing the data - code segment one
View DatabaseHelper.java
public class DatabaseHelper extends SQLiteOpenHelper {
//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/test.test/databases/";
private static String DB_NAME = "TestDatabase";
private static final int DB_VERSION = 1;
private SQLiteDatabase myDatabase;
@Logan676
Logan676 / LibraryFragment.java
Created Jun 18, 2015
implement multi-selection and Contextual ActionMode in ActionBarSherlock
View LibraryFragment.java
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ListView;
import com.actionbarsherlock.app.SherlockListFragment;
import com.actionbarsherlock.view.ActionMode;
import com.actionbarsherlock.view.Menu;
View sublime_text_2_useful_shortcuts.md

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
View FileUtils.java
/**
* Attempts to open a file for viewing.
*
* @param fileholder The holder of the file to open.
*/
public static void openFile(FileHolder fileholder, Context c) {
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = FileUtils.getUri(fileholder.getFile());
String type = fileholder.getMimeType();
You can’t perform that action at this time.