Skip to content

Instantly share code, notes, and snippets.

:bowtie:
Coding

书虫 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 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 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 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;
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;
@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 / 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 / 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();
View AndroidStudio使用教程(第七弹).md

AndroidStudio使用教程(第七弹)

本文讲解一下Gradle的应用,大家都知道Gradle使用起来非常方便,那他究竟方便在哪里?                          

  • 很多时候我们在打印Log日志的时候都是需要在Debug版本中进行打印,而在正式版本中关闭。 通常我们都是用一个Config文件来配置,不知道大家有没有遇到过正式版中忘记关闭Log日志的情况。
  • 多渠道包非常让人头疼。现在国内市场这么多。一个个的打多麻烦,虽然我们会用友盟打包工具等。 怎么破?
You can’t perform that action at this time.