搜尋此網誌

2017年4月25日 星期二

2017年1月24日 星期二

【Car】車禍請益

ref:
網路

以下是建議

  1. 把所有醫療跟雜項收據收齊妥善保管
    • 再向醫院申請「訴訟用的診斷書」
  2. 等鑑定報告
    • 自費申請「交通裁決表 $3000」
  3. 有受傷的人可以去警察局調資料看報告~並且可以決定要不要告對方傷害
  4. 如果鑑定報告出來對方責任在51%以上就告傷害~警察也會將案子移送
  5. 再來就是看對方以及等開庭 (通常是調解庭談和解金)
  6. 雙方對於調解金不合就是上法院
  7. 判決出來再告民事求償(這部分就要花錢找律師會比較好)
    •  因為跟傷害有關,所以可以在「刑事訴訟」時,向檢察官一併申請「民事」,這樣民事訴訟就不用自費
  8. 民事求償判決出來後申請強制執行
    •  很重要,不要直接跟肇事者拿錢,而是直接從帳戶、薪資扣除之類的


那路權呢,一般就是…
1。主線 > 支線; 
2。左方車要禮讓右方車 (路口,左手的要讓右手)
3。路面上劃有「停止線」、有插「停」車再開標示的路權較小

還有,因為使用自費材料,這部份可能要看診斷書怎麼寫(是必需使用 or),強制險保險公司是否會完全支付,或是自費減去健保額外的部份不支付(就是多出來的4支),也是要問清楚

受傷期間無法工作損失(請老闆開證明),也需要計算進去,在調解時各項單據是你,也是調委的依據。

2017年1月7日 星期六

【Android】Attempt to invoke virtual method 'com.android.volley.Request com.android.volley.RequestQueue.add(com.android.volley.Request)' on a null object reference

當使用Volley時
不必為每一次HTTP請求都創建一個RequestQueue對象,推薦在application中作初始化
所以
public class MyApplication extends Application {

    public static RequestQueue requestQueue;

    @Override
    public void onCreate() {
        super.onCreate();
        requestQueue = Volley.newRequestQueue(this);
    }
}

之後要呼叫時
        RequestQueue mQueue = MyApplication.requestQueue;
        StringRequest getStringRequest = new StringRequest("網址", new ResponseListener(), 
        new ResponseErrorListener());
        mQueue.add(getStringRequest);
但執行結果出現
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.android.volley.Request com.android.volley.RequestQueue.add(com.android.volley.Request)' on a null object reference

解決辦法
ref:
 http://stackoverflow.com/a/31302226

AndroidManifest.xml中
<application android:name="YOURPACKAGENAME.AppController" 
             android:allowbackup="true" 
             android:icon="@drawable/ic_launcher" 
             android:label="@string/app_name"
             android:theme="@style/AppTheme">

2017年1月5日 星期四

【Android】Difference between getContext() , getApplicationContext() , getBaseContext()

ref:
http://stackoverflow.com/a/10641257


  • View.getContext(): Returns the context the view is currently running in. Usually the currently active Activity.
  • Activity.getApplicationContext(): Returns the context for the entire application (the process all the Activities are running inside of). Use this instead of the current Activity context if you need a context tied to the lifecycle of the entire application, not just the current Activity.
  • ContextWrapper.getBaseContext(): If you need access to a Context from within another context, you use a ContextWrapper. The Context referred to from inside that ContextWrapper is accessed via getBaseContext().

2016年12月25日 星期日

【Java】Difference between matches() and find() in Java Regex

ref:
http://stackoverflow.com/a/4450166

http://stackoverflow.com/a/18409048

matches tries to match the expression against the entire string and implicitly add a ^ at the start and $ at the end of your pattern, meaning it will not look for a substring. Hence the output of this code:
public static void main(String[] args) throws ParseException {
    Pattern p = Pattern.compile("\\d\\d\\d");
    Matcher m = p.matcher("a123b");
    System.out.println(m.find());
    System.out.println(m.matches());

    p = Pattern.compile("^\\d\\d\\d$");
    m = p.matcher("123");
    System.out.println(m.find());
    System.out.println(m.matches());
}

/* output:
true
false
true
true
*/
123 is a substring of a123b so the find() method outputs true. matches() only 'sees' a123bwhich is not the same as 123 and thus outputs false.

--------------------------------------------------------------------------------------------------------------------------

matches() will only return true if the full string is matched. find() will try to find the next occurrence within the substring that matches the regex. Note the emphasis on "the next". That means, the result of calling find() multiple times might not be the same. In addition, by using find() you can call start() to return the position the substring was matched.
final Matcher subMatcher = Pattern.compile("\\d+").matcher("skrf35kesruytfkwu4ty7sdfs");
System.out.println("Found: " + subMatcher.matches());
System.out.println("Found: " + subMatcher.find() + " - position " + subMatcher.start());
System.out.println("Found: " + subMatcher.find() + " - position " + subMatcher.start());
System.out.println("Found: " + subMatcher.find() + " - position " + subMatcher.start());
System.out.println("Found: " + subMatcher.find());
System.out.println("Found: " + subMatcher.find());
System.out.println("Matched: " + subMatcher.matches());

System.out.println("-----------");
final Matcher fullMatcher = Pattern.compile("^\\w+$").matcher("skrf35kesruytfkwu4ty7sdfs");
System.out.println("Found: " + fullMatcher.find() + " - position " + fullMatcher.start());
System.out.println("Found: " + fullMatcher.find());
System.out.println("Found: " + fullMatcher.find());
System.out.println("Matched: " + fullMatcher.matches());
System.out.println("Matched: " + fullMatcher.matches());
System.out.println("Matched: " + fullMatcher.matches());
System.out.println("Matched: " + fullMatcher.matches());
Will output:
Found: false
Found: true - position 4
Found: true - position 17
Found: true - position 20
Found: false
Found: false
Matched: false
-----------
Found: true - position 0
Found: false
Found: false
Matched: true
Matched: true
Matched: true
Matched: true
So, be careful when calling find() multiple times if the Matcher object was not reset, even when the regex is surrounded with ^ and $ to match the full string.

【Java】 Regular Expression / 正規表示法 的學習筆記 [精華]

ref:
https://www.javaworld.com.tw/jute/post/view?bid=20&id=130126

REX checker:
https://regex101.com/

http://regexr.com/

2016年12月24日 星期六

【Android】What is different optString() and getString() in JSONObject ?

ref:
http://stackoverflow.com/a/13790789

optString() 和 getString()差別?

The difference is that optString returns the empty string ("") if the key you specify doesn't exist. getString on the other hand throws a JSONException. Use getString if it's an error for the data to be missing, or optString if you're not sure if it will be there.
Edit: Full description from the documentation:
Get an optional string associated with a key. It returns an empty string if there is no such key. If the value is not a string and is not null, then it is converted to a string.

如果你指定的key不存在時,

optString()會回傳 ""

但

getString() 會跳出exception 因為 key為null。