/* * Draw traversal performs several drawing steps which must be executed * in the appropriate order: * * 1. Draw the background * 2. If necessary, save the canvas' layers to prepare for fading * 3. Draw view's content * 4. Draw children * 5. If necessary, draw the fading edges and restore layers * 6. Draw decorations (scrollbars for instance) */
When implementing a view, implement onDraw instead of draw(Canvas)
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('7654,7698,7782,7788',',',help_topic_id+1),',',-1) AS num FROM mysql.help_topic WHERE help_topic_id < LENGTH('7654,7698,7782,7788')-LENGTH(REPLACE('7654,7698,7782,7788',',',''))+1
-- 和0做比较避免出现负值 update products set stocks=greatest(stocks-10,0) where product_id=55635
UPDATE goods AS g SET stock = greatest((SELECTSUM(stocks) FROM products AS p WHERE p.`goods_id` = g.`goods_id`), 0) WHERE goods_id=1234
没有时插入或存在时忽略
1
INSERT IGNORE INTO task_link (user_id, task_id) VALUES (20021413, 50000)
duplicate entry for key
1 2
SELECT GROUP_CONCAT(id),user_id,task_id,count(1) as cnt FROM task_link groupby user_id,task_id having cnt >1; deletefrom task_link where id in (100,137,131,138,136,125,124);
UPDATE cc_brief_video_author SET user_id =TRIM(TRAILING'.0'from user_id)
删除重复的关键词
1 2 3 4 5 6 7
DELETEfrom cc_brief_keyword_v2 WHERE id notin ( SELECTmin(id) FROM cc_brief_keyword_v2 GROUPBY keyword HAVINGcount(keyword) >1 ) and keyword in ( SELECT keyword FROM cc_brief_keyword_v2 GROUPBY keyword HAVINGcount(keyword) >1 )
publicstaticvoidstart(Activity context, Class clazz){ Intentintent=newIntent(context, clazz); context.startActivity(intent); }
publicstaticclassLoginActivityextendsSingleFragmentActivity { @Override public Fragment createFragment() { returnnewLoginFragment(); } }
publicstaticclassForgetPasswordActivityextendsSingleFragmentActivity { @Override public Fragment createFragment() { returnnewForgetPasswordFragment(); } }
publicstaticclassRegisterActivityextendsSingleFragmentActivity { @Override public Fragment createFragment() { returnnewRegisterFragment(); } }
publicstaticclassAddDeviceActivityextendsSingleFragmentActivity { @Override public Fragment createFragment() { returnnewAddDeviceFragment(); } } }
<!-- In my case, this is working perfectly.. I have added below two line codes inside manifest file --> <application tools:replace="android:appComponentFactory" android:appComponentFactory="whateverString">
// create method to set listener in CustomActivity publicvoidsetOnBackPressedListener(OnBackPressedListener onBackPressedListener) { this.onBackPressedListener = onBackPressedListener; }
// in override onBackPressed implement something like that @Override publicvoidonBackPressed() { if (onBackPressedListener != null) onBackPressedListener.doBack(); else super.onBackPressed(); }
// in your fragment in onCreateView you should add our listener @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { activity = getActivity(); ((CustomActivity)activity).setOnBackPressedListener(newOnBackPressedListener(){ @override publicvoiddoBack(){ // do your logic } }); return view; }