2013年1月19日 星期六

[Android] RemoteView & AppWidget機制介紹

@ What is Widget
AppWidget framework通過broadcast intents和你的widget溝通,例如當需要更新Widget的時候。透過使用RemoteViews構建和發送。RemoteViews將Widget的layout和特定内容包裝後,藉由IPC傳送到Launcher,最後顯示到桌面上。

@ What is RemoteViews
RemoteViews並不是一個真正的View,而只是一個用於整合Widget裡layout呈現與view元件行為的一個Wrapper class(也就是appWidget所要長得樣子),透過RemoteView把建立該Widget需要的resource ID和各個元件的事件封裝起來。 RemoteViews會通過進程間通信機制傳遞給AppWidgetHost。

2013年1月5日 星期六

[Tool] Tmux(在家工作的好工具)

工作上有時需要假日連回公司,sync最新的code base或是build code的動作,可以節省隔天上班時等build code的時間,一開始都是直接用pietty或是ssh連回去,缺點就是當在build code時,家裡電腦上的console視窗不能關閉,這樣就中斷build code的工作了,所以就找尋看看有沒有可以關閉後還能夠繼續工作的tool。

2012年12月1日 星期六

[C++] A *a 和 A *aa = new A 的差別

在寫C++過程中,指標的使用與操作是最頻繁被使用的,有些難解的bug,通常point佔絕大多數,這裡複習一個很基本的概念。

如下面的例子,個別使用兩個a指標,也各自呼叫他們的member function test(),發覺都可以印出test的字串,但為什麼第一個指標明明是指向undefine的空間,為什麼不會出現問題呢,不是應該要出現Segmentation Fault嗎?

這裡隱藏一個很重要,也很容易被誤解的觀念,通常使用null point或不知指向何處的point時,操作member function是不會發生Segmentation Fault的,會產生Segmentation Fault是在操作它的member時,如果下面的程式碼多加上一段a->value的話,當程式運行到這一行就會發生crash了。

2012年11月11日 星期日

[Aadroid] Android版本控制工具---Repo(轉)

Android 原始碼下載及版本控制 - 使用git與repo

要取得Android的原始碼,會需要用到GitRepo還有Gerrit。 以下解釋一些工具,太冗長,可直接拉到最下方看如何取得Android原始碼。

什麼是Git?

Git is an open-source version-control system designed to handle very large projects that are distributed over multiple repositories.

那Git for Android是?

In the context of Android, we use Git for local operations such as local branching, commits, diffs, and edits. One of the challenges in setting up the Android project was figuring out how to best support the outside community–from the hobbiest community to large OEMs building mass-market consumer devices. We wanted components to be replaceable, and we wanted interesting components to be able to grow a life of their own outside of Android. We first chose a distributed revision control system, then further narrowed it down to Git.

2012年11月1日 星期四

[Tool] Source Insight常用的快捷鍵

@Source Insight常用的快捷鍵:

  • Ctrl+= :Jump to definition
  • Alt+/ :Look up reference
  • Alt+分頁標題首字字母 : 切換至該標題的頁面
  • F3 : search backward
  • F4 : search forward
  • F5: go to Line
  • F7 :Look up symbols
  • F8 :Look up local symbols
  • F9 :Ident left
  • F10 :Ident right
  • Alt+, :Jump backword
  • Alt+. : Jump forward
  • Shift+F3 : search the word under cusor backward
  • Shift+F4 : search the word under cusor forward
  • F12 : incremental search
  • Shift+Ctrl+f: search in project
  • shift+F8 : hilight word

2012年10月27日 星期六

[Vim]常用的技巧記錄

@VIM外掛安裝方式

透過github
(1)使用git submodule add  "要安裝plugin的路徑"   bundle/plugin-name
frank@frank:~/.vim$ git submodule add https://github.com/vim-scripts/taglist.vim.git bundle/Taglist  ./bundle/Taglist

(2)輸入指令初始化外掛
frank@frank:~/.vim$ git submodule init

2012年10月13日 星期六

[C++]必須傳回物件時,別妄想傳回其reference

函數的回傳值使用上要非常的小心,雖然程式寫久了,這算是比較基礎的概念,但有時一疏忽,往往就會造成系統Crash,簡單來說,函式產生新物件的路徑有二,在Stack空間或是在Heap空間裡,以底下例子來說。

const Rational& operator* (const Rational& lhs,
                                        const Rational& lhs)
{
    Rational result(lhs.n * rhs.n, lhs.d* rhs.d)
    return result;
}