select a.id, a.title, a.subtitle, a.createddate, a.user_id,
u.username, u.displayname, u.thumburl,
CONCAT(
'[',
GROUP_CONCAT(DISTINCT(
CONCAT(
CONCAT('{"id":"',m.id,'"'),
CONCAT(', "typecode":"',m.typecode,'"'),
CONCAT(', "thumburl":"',ifnull(m.thumburl,''),'"}')
)
) ORDER BY m.typecode, am.ordering ASC SEPARATOR ',' ),
']'
) as medias
from (
select id, title, subtitle, createddate, user_id from article
where user_id in (select user_id from follow where follow_user_id = 33 OR user_id = 33)
) as a
left join article_media as am on a.id = am.article_id
left join media as m on am.media_id = m.id
left join (
select u.id, u.username, u.displayname, u.picture_id, m.thumburl
from (
select id, username, displayname, picture_id from user
where id in (select user_id from follow where follow_user_id = 33 OR user_id = 33)
) as u
left join media as m on u.picture_id = m.id
) as u on a.user_id = u.id
where u.username != 'root'
group by a.id
Thursday, January 29, 2015
Wednesday, January 21, 2015
windows batch file using echo current directory or file
@echo off
echo ------------------------------
echo %cd%
:: folder
echo %~dp0%0
:: folder\ + filename.bat
echo %~f0
:: filefullname.bat
echo %~dpn0
:: filefullname
echo %~n0
:: filename
echo ------------------------------
echo ------------------------------
echo %cd%
:: folder
echo %~dp0%0
:: folder\ + filename.bat
echo %~f0
:: filefullname.bat
echo %~dpn0
:: filefullname
echo %~n0
:: filename
echo ------------------------------
Sunday, January 18, 2015
android custom textview with round stroke drawing
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint.Join;
import android.graphics.Paint.Style;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.widget.TextView;
import com.hiimeloyun.android.R;
/**
*
* @author boroo
*/
public class StrokeTextView extends TextView {
private final int strokeColor;
private final float strokeWidth;
TextPaint paint = new TextPaint();
public StrokeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.StrokeStyleable, 0, 0);
strokeWidth = a.getDimension(R.styleable.StrokeStyleable_strokeWidth, 10);
strokeColor = a.getColor(R.styleable.StrokeStyleable_strokeColor, Color.BLACK);
}
// overridden methods
@Override
protected void onDraw(Canvas canvas) {
final ColorStateList textColor = getTextColors();
paint = this.getPaint();
paint.setStyle(Style.STROKE);
paint.setStrokeJoin(Join.ROUND);
paint.setStrokeMiter(10);
this.setTextColor(strokeColor);
paint.setStrokeWidth(strokeWidth);
super.onDraw(canvas);
paint.setStyle(Style.FILL);
setTextColor(textColor);
super.onDraw(canvas);
}
}
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint.Join;
import android.graphics.Paint.Style;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.widget.TextView;
import com.hiimeloyun.android.R;
/**
*
* @author boroo
*/
public class StrokeTextView extends TextView {
private final int strokeColor;
private final float strokeWidth;
TextPaint paint = new TextPaint();
public StrokeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.StrokeStyleable, 0, 0);
strokeWidth = a.getDimension(R.styleable.StrokeStyleable_strokeWidth, 10);
strokeColor = a.getColor(R.styleable.StrokeStyleable_strokeColor, Color.BLACK);
}
// overridden methods
@Override
protected void onDraw(Canvas canvas) {
final ColorStateList textColor = getTextColors();
paint = this.getPaint();
paint.setStyle(Style.STROKE);
paint.setStrokeJoin(Join.ROUND);
paint.setStrokeMiter(10);
this.setTextColor(strokeColor);
paint.setStrokeWidth(strokeWidth);
super.onDraw(canvas);
paint.setStyle(Style.FILL);
setTextColor(textColor);
super.onDraw(canvas);
}
}
Thursday, January 15, 2015
Selector, Layer-list and shape/bitmap in the same xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<layer-list>
<item>
<shape android:shape="rectangle">
<size android:width="90dp" android:height="90dp" />
<solid android:color="#9933CC" />
</shape>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/main_achievements_synthesis" />
</item>
</layer-list>
</item>
<item>
<layer-list>
<item>
<shape android:shape="rectangle">
<size android:width="90dp" android:height="90dp" />
<solid android:color="#AA66CC" />
</shape>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/main_achievements_synthesis" />
</item>
</layer-list>
</item>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<selector>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<size android:width="90dp" android:height="90dp" />
<solid android:color="#9933CC" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<size android:width="90dp" android:height="90dp" />
<solid android:color="#AA66CC" />
</shape>
</item>
</selector>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/main_achievements_synthesis" />
</item>
</layer-list>
version2
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="5dp"/>
<solid android:color="#D0D0D0"/>
</shape>
</item>
<item>
<inset android:insetBottom="2dp">
<selector>
<item android:state_pressed="false">
<shape android:shape="rectangle">
<corners android:radius="3dp"/>
<solid android:color="#006600" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="3dp"/>
<solid android:color="#003300" />
</shape>
</item>
</selector>
</inset>
</item>
</layer-list>
Subscribe to:
Posts (Atom)