雜項16

SVN
刪除包不方便,在資源管理器 手工刪除 ,但是svn 不能同步了。以後應該謹慎手工刪除文件。但是沒有看到svn控制文件,被隱藏了。
重新檢出


check for upgrade ,全部更新所有eclipse 包。
速度太慢。
應該可以單獨更新,有個管理器,在 about install detail 。
爲什麼一直沒有考慮這個問題。
eclipse 新特性帶來的好處
可以學習到什麼 。多思索。


Android事件處理分析
http://www.cnblogs.com/cnhome/archive/2010/03/24/1629435.html


onInterceptTouchEvent和onTouchEvent調用時序
http://blog.csdn.net/ddna/article/details/5473293


keyevent 監視 軟鍵盤 ? 不應該
keyevent 傳送 到 focus child view ? 




每個Activity 都要出來back 健


思維定勢,一條路走死 用 listView ,注意需求,新的修改
 CameraMediaUtil.onMediaActivityResult(this , requestCode,  resultCode,  intent,true,150,150) ;
怪怪的,把requestCode 界面 加進去了。 方法要簡單。封裝了系統的封裝,過分的重用。






setImage 做了太多的功能。不要考慮性能 ,浪費就浪費點。




一個Activity ,配一個model 。寧願多點類,也要機構清楚。


定義 page 類。


網上也沒有提到的系統問題,是我們自己的問題。


判斷gameinfo 實例 就可以了。思路開放。(系統提供的功能,和自己的管理)


List 中 onTouch 事件處理。利用了onTouchUp() 


public boolean onTouch(View v, MotionEvent event) {
    if(event.getAction() == MotionEvent.ACTION_DOWN || 
        event.getAction() == MotionEvent.ACTION_MOVE)
    {
      mBtn.setImageBitmap(mBmp1);
    }
    else if(event.getAction() == MotionEvent.ACTION_UP ||
        event.getAction() == MotionEvent.ACTION_OUTSIDE)
    {
      mBtn.setImageBitmap(mBmp0);
    }




public void onTouchUp() {
if(!mIsEnable)
  return ;


mBtn.setImageBitmap(mBmp0);
}






內存問題,大內存對象釋放 ,靜態Activity 。
全局數據問題


scale 時, 怪異的 android BitmapFactory decodeStream 行爲 。


全局數據
硬盤保存的,臨時性全局訪問的


理論上可以提供單個activity kill 。但是實際上只能kill proces。


save 在 onstop 的時候 ,就保存了。真正kill 的時候,無法保存任何信息。


如何定製 錯誤對話框,UI 線程可能已經死掉了。有些窗口,或者UI 方法可以在其他線程調用。
也許他們已經封裝在 handle 裏面了。




First, note there is a difference between setUncaughtExceptionHandler 
() and setDefaultUncaughtExceptionHandler().  One applies to a single 
thread, the other to all threads in the VM. 
Second, the app framework already provides a global uncaught exception 
handler.  The exception traces with the "AndroidRuntime" tag are 
generated here, and then the VM is killed.  See frameworks/base/core/ 
java/com/android/internal/os/RuntimeInit.java.  If you specify your 
own, you will override the app framework's behavior for all threads. 
how does he find these source code .




http://stackoverflow.com/questions/2681499/android-how-to-auto-restart-application-after-its-been-force-closed
http://stackoverflow.com/questions/601503/how-do-i-obtain-crash-data-from-my-android-application


Appliction  主線程可能已經死掉了,不如開個新程序,傳個flag 給新程序。
intent = PendingIntent.getActivity(YourApplication.getInstance().getBaseContext(), 0,
            new Intent(getIntent()), getIntent().getFlags());
Than in your uncaughtException() method:


AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 2000, intent);
System.exit(2);
Without calling System.exit() will not work. This code will restart your application after 2 seconds.
Eventually you can set some flag in your intent that the application crashed and in your onCreate() method you can show a dialog "I'm sorry, the application crashed, hope never again :)".


AlarmManager  和 PendingIntent
static PendingIntent getActivities (Context context, int requestCode, Intent[] intents, int flags)
set (int type, long triggerAtTime, PendingIntent operation)


if need not when appliction stop ,we should use  handle better than AlarmManager  
handle sendMessageAtTime(Message msg, long uptimeMillis)


dumpsys


Android in Hudson (0) 建置Hudson
http://www.dotblogs.com.tw/yuanchien/archive/2010/11/25/19706.aspx
hudson 持續集成工具




http://stackoverflow.com/questions/3121232/android-popup-window-dismissal
This is because the popup window does not respond to onTouch or onKey events unless it has a background that != null.
The reason the background cannot be null is because of what happens in PopupWindow#preparePopup. If it detects background != null it creates an instance of PopupViewContainer and calls setBackgroundDrawable on that and puts your content view in it. PopupViewContainer is basically a FrameLayout that listens for touch events and the KeyEvent.KEYCODE_BACK event to dismiss the window. If background == null, it doesn't do any of that and just uses your content view. You can, as an alternative to depending on PopupWindow to handle that, extend your root ViewGroup to behave the way you want.
缺省最簡單的處理,還是 setbackdrawable 


事件處理  View dispatchKeyEvent
Activity dispatchKeyEvent is invoked by decoder view 。


getKeyDispatcherState().startTracking(event, this);處理 


if no popupViewContainer ,outside no response 然後定製,可能


http://zhanglimijavaeye.iteye.com/blog/981891
pop.setOutsideTouchable(true);//默認是false,控制pop是否監聽pop以外的觸屏事件。這個方法在pop可觸,並且no focusable時有意義。這意味着在pop外點擊屏幕,


 You might also need to call PopupWindow#setOutsideTouchable(true) if you want it to go away when the user clicks outside of the window boundaries.
 WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
/** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
 * can set this flag to receive a single special MotionEvent with
 * the action
 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
 * touches that occur outside of your window.  Note that you will not
 * receive the full down/move/up gesture, only the location of the
 * first down as an ACTION_OUTSIDE.
 
 
     /**
     * Dispatch a key event to the next view on the focus path. This path runs
     * from the top of the view tree down to the currently focused view. If this
     * view has focus, it will dispatch to itself. Otherwise it will dispatch
     * the next node down the focus path. This method also fires any key
     * listeners.
     *
     * @param event The key event to be dispatched.
     * @return True if the event was handled, false otherwise.
     */
    public boolean dispatchKeyEvent(KeyEvent event) {
        // If any attached key listener a first crack at the event.
        //noinspection SimplifiableIfStatement


        if (android.util.Config.LOGV) {
            captureViewInfo("captureViewKeyEvent", this);
        }


        if (mOnKeyListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                && mOnKeyListener.onKey(this, event.getKeyCode(), event)) {
            return true;
        }


        return event.dispatch(this, mAttachInfo != null
                ? mAttachInfo.mKeyDispatchState : null, this);
    }
    
    
    
    
        /**
     * Pass the touch screen motion event down to the target view, or this
     * view if it is the target.
     *
     * @param event The motion event to be dispatched.
     * @return True if the event was handled by the view, false otherwise.
     */
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED &&
                mOnTouchListener.onTouch(this, event)) {
            return true;
        }
        return onTouchEvent(event);
    }
    }
    
    第一 先判斷 enable 和  是否爲空 ,可以快速 判斷
    第二 先調用監聽器,再調用自己的onTouchEvent 。




位運算,最快捷,底層API 用的最多。


所有的event 都只會dispatch 給 最前一個 view ?Browser 大小浮動按鈕 ,是否只是Frame 前面的 view
http://www.eoeandroid.com/thread-71478-1-1.html
懸浮歌詞(迷你歌詞)效果解讀 
直接加到 windowsmanager ,缺省的懸浮效果。


WindowManager.LayoutParams type




The general type of window. There are three main classes of window types:
Application windows (ranging from FIRST_APPLICATION_WINDOW to LAST_APPLICATION_WINDOW) are normal top-level application windows. For these types of windows, the token must be set to the token of the activity they are a part of (this will normally be done for you if token is null).
Sub-windows (ranging from FIRST_SUB_WINDOW to LAST_SUB_WINDOW) are associated with another top-level window. For these types of windows, the token must be the token of the window it is attached to.
System windows (ranging from FIRST_SYSTEM_WINDOW to LAST_SYSTEM_WINDOW) are special types of windows for use by the system for specific purposes. They should not normally be used by applications, and a special permission is required to use them.




By default a popup window is not focusable ,but is touch able 。


Controls whether the pop-up will be informed of touch events outside
     * of its window.  This only makes sense for pop-ups that are touchable
     * but not focusable, which means touches outside of the window will
     * be delivered to the window behind.  The default is false.
     
     缺省情況下,window 不會監聽outside 事件。
     但是爲什麼 popup view 監聽 需要 ,兩個條件。


如果我們使用FrameLayout作爲activity's content view的父元素(也就是在main.xml裏把它寫在最外層),那麼可以考慮用<merge />替換<FrameLayout />標籤。官方文檔給出的解釋是這樣做可以減少一級佈局層次達到優化佈局的效果. 
merge  到 DecorView 


 attrs.flags = (attrs.flags&~mask) | (flags&mask);  flag 可能有多位數據, mask 可以某一位


floating
     * @return Returns true if the window is configured to be displayed floating
     * on top of whatever is behind it.


    /**
     * Set the gravity of the window, as per the Gravity constants.  This
     * controls how the window manager is positioned in the overall window; it
     * is only useful when using WRAP_CONTENT for the layout width or height.
     * @param gravity The desired gravity constant.
     */
    public void setGravity(int gravity)
    {
        final WindowManager.LayoutParams attrs = getAttributes();
        attrs.gravity = gravity;
        if (mCallback != null) {
            mCallback.onWindowAttributesChanged(attrs);
        }
    }




    /**
     * Enable extended screen features.  This must be called before
     * setContentView().  May be called as many times as desired as long as it
     * is before setContentView().  If not called, no extended features
     * will be available.  You can not turn off a feature once it is requested.
     * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
     *
     * @param featureId The desired features, defined as constants by Window.
     * @return The features that are now set.
     */
    public boolean requestFeature(int featureId) {
        final int flag = 1<<featureId;
        mFeatures |= flag;
        mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
        return (mFeatures&flag) != 0;
    }


setFlag


window callback 


WindowManager.LayoutParams 
flag 後臺窗口,事件處理 ,亮度,大小位置,透明
type 窗口類型


token IBinder  ,支持遠程,Context 不是IBinder 。


parcel Container for a message (data and object references) that can
 * be sent through an IBinder. it is for RPC and it is like bundle 。
parcelable


onlowmemory


 onSaveInstanceState()


onResume 
 This method is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU, and so on. It should do whatever it does very quickly, because the next activity will not be resumed until it returns.
The column labeled "Killable after?" indicates whether or not the system can kill the process hosting the activity at any time after the method returns 。
if pause is killed ,how to dispaly it ?


模擬器 host 錯誤




08-31 07:46:22.161: DEBUG/NetManager(275): Json output String: {"maindo":1,"subdo":2,"sult":{"uid":"100027","username":"a71111","nickname":"\u82cd\u8001\u5e08gnl","realname":"\u82cd\u8001\u5e08","headpicid":"1","isvip":"0","sex":"1","email":"","mobile":"","qq":"0","msn":"","address":"","homepage":"","zipcode":"","phone":"","regip":"0.0.0.0","regdate":"2011-08-29 00:42:08","lastloginip":"","lastlogintime":"2011-08-31 07:39:37","sys_config":{"heartbeat_time":60,"clear_out_session_time":600,"alow_more_login":1,"admin_user_id":100007},"headpic_id":"1","headpic_url":"1.png","headpic_surl":"1.png","message":[],"sn":"28a97469379f9234508bebebb0be02f4"}}




android framework


Util 
IO
Model View 
NetLoader


文件管理器


09-01 03:19:51.335: ERROR/AndroidRuntime(364): java.util.ConcurrentModificationException
09-01 03:19:51.335: ERROR/AndroidRuntime(364):     at java.util.AbstractList$SubAbstractList.size(AbstractList.java:366)
09-01 03:19:51.335: ERROR/AndroidRuntime(364):     at java.util.AbstractCollection.toArray(AbstractCollection.java:340)
09-01 03:19:51.335: ERROR/AndroidRuntime(364):     at java.util.ArrayList.addAll(ArrayList.java:193)








progress bug ,cancel 後要減掉1 。


如何寫testcase 


mantis and SVN  集成


設計的缺陷,網絡狀態預設。
cache 可以集成起來,但是 refresh 。


全部重改,以後這方面性能不是問題。




淘金島 新版本
社區修復了 
進度條有時候無法關閉
修改用戶資料時候,硬鍵盤輸入無效,
大數據量更多保護等問題,
以及刪除部分 無用code 。


鬥地主修復了 在說明中報名出錯的問題。




email 服務器端 直接截取長度了


Office Excel 的 redo undo ,插入時候覆蓋


瀏覽器 取消 progress 。


虛擬物品加上未開發提示
兌換獎品 支持 硬鍵盤
修改 電話硬鍵盤輸入問題




點擊兌換椰果按鈕 進入兌換椰果頁面
點擊贈送按鈕 進入贈送椰果頁面




我的信息 有 bug  




Handle 處理 ,延時是它的一個用處




corner case , 惡意攻擊的只要考慮安全性,而不需要考慮用戶體驗。


用戶體驗的一致。每個都要改。


ListView ,動態增加,數據庫


http://man.ddvip.com/program/java_api_zh/index.html?java/math/RoundingMode.html




2.1 系統 崩潰


list view 處理 不要用static ,一般都能回收。


bug 分析


AUTO_LOGIN 名字 不清晰, 應該是註銷的地方調用 NotSupportAutoLogin 。 清楚的名字,而不是籠統的名字


Intent.FLAG_ACTIVITY_CLEAR_TOP & intent.getFlags()) != 0)




ViewAnimation  need UI handle 。


被電話打斷到後臺後,dialog 不受到影響,toast 還會顯示。
打電話時候,媒體聲音會關閉。


如何把窗口打開到頂部。


Attaching event onWindowVisibilityChanged(int)
onWindowFocusChanged(boolean)


onTrackballEvent (MotionEvent event)
InputEvent
KeyEvent
KeyEvent(long downTime, long eventTime, int action, int code, int repeat, int metaState, int deviceId, int scancode, int flags, int source)
常用的下面
 acttion ,   ,keycode,FLAG_LONG_PRESS 。
keycode 包含很多code 
MotionEvent 無構造器?
View 兩種event ,三個dispatch , 四個事件,多個listener 。
TraceBall  軌跡球 ,能否有鼠標光標
筆記本 觸摸板


if (ViewDebug.TRACE_HIERARCHY) {
    ViewDebug.trace(this, ViewDebug.HierarchyTraceType.INVALIDATE);
}
debug 信息


View position getLeft ()
Left position of this view relative to its parent.


Building Custom Components  ,三種。  還有不繼承的組合,工廠方法創建。
淘金島ListView , 可以定義一個component 。(複合的,還是繼承listView ) ,閉合原則。


如何加入search 功能。抽象的component 加一個 clearAdd 功能。現在是直接訪問OrderAdapter 。


很少用的,放在setField 裏面。而不是構建裏面 但是容易忘掉。(也可以定義多個構建器,既使用簡單,又支持擴展)。


重構code 
注意方法順序,code stytle 。便於閱讀。 有層次,順序。
IDE 輔助Outline ,ctl +o 有field ,摺疊code 。


Addview layout 缺省值
showNext 從其他線程,調用沒有反應。應該有報錯。
resource 

Listview 滾動速度 由scroll 控制,不易定製。


如何用 abstract int getItemViewType (int position) 來重構。不用也可以。共用一個罷了。


smoothScrollToPosition(int position) 。平滑滾動,和select 直接跳轉不一樣。
setSelectionFromTop(int position, int y)
getFirstVisiblePosition()
滾動事件


ListView 手勢
這樣試試@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
        // TODO Auto-generated method stub
        super.dispatchTouchEvent(ev);
        return tgestureDetector.onTouchEvent(ev);
}
return GestureDetector.onTouchEvent(event);  
OnDoubleTapListener
http://wayfarer.iteye.com/blog/460284
Android Gesture Detector
http://blog.csdn.net/cgipro/article/details/5737631
scroll ,tap ,longclick ,fling (快速的,有速度參賽)




ontouch 不一定在view 的location 。但是缺省情況下 會做一個 if (frame.contains(scrolledXInt, scrolledYInt)) {




具體 logic 見 View group dispatchTouchEvent ,都是在這處理。
先處理listener 。也可能consumed 掉。
onInterceptTouchEvent 
http://blog.csdn.net/ddna/article/details/5473293
缺省不攔截,都是先給child 處理,如果child 不處理(只要down 不處理),再自己處理。
攔截後,如果 連down 攔截,target 爲空,那就直接調用自己的touch ,有 target ,傳給target cancel ,
 Don't dispatch this event to our own view, because we already
            // saw it when intercepting;
缺省情況我們不需攔截,特殊情況下才需要。
ListView 會攔截嗎?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章