봉천동 샤로수길에 있는 텐동 요츠야

 

스페셜 텐동을 먹었는데, 튀김이 맛있음.

저녁에 8시쯤 가니 온천 계란은 하나밖에 안남아있고 사라다도 없다고..ㅠ

호로요이도 판매하고 있고 과일 탄산도 있어서 좋음.

 

내부가 바형태밖에 없고 10명정도 밖에 수용이 안됨.

 

아나고튀김 예술!!

 

but.

최근 생활의 달인에 방송되고 난 후 줄이 생김...

줄이 줄어들 때까진 이제 못갈듯..

 

 

 

 

가산디지털단지 트래블앤쿡

 

회사들이 많은 곳이라.. 사람이 많을 줄 알았는데 생각보다 사람이 없어서..

음식도 금방 나오고 여유롭게 식사!

떡볶이는 언제나 맛있음

 

 

 

 

 

 

 

 

 

 

이제는 없어진 간식 시간... ㅠㅠ

매주 금요일 오후 시간에 있던 간식 시간이 나름의 활력소가 됐는데..

이제는 사라짐.. ㅠㅠ

아쉽 ,,

 

 

 

가산디지털단지 현대아울렛 6층에 있는 [김피라]

 

맛있는 편이에요~ 치츠 듬뿍 들어있던 떡볶이는 식으니 좀 느끼해서.. 전 다른 떡볶이가 더 맛있었던 것 같네요.

 

 

'맛있는 상상' 카테고리의 다른 글

[신림] 성민양꼬치  (0) 2017.03.06
[가산디지털단지] 대륭포스트 6차 마포갈매기  (0) 2017.03.06
[봉천동] 텐동요츠야  (0) 2017.03.06
[가산디지털단지] 트래블앤쿡  (0) 2017.03.06
회사 간식시간  (0) 2017.03.06

땡겨서 새로고침 기능. Pull To Refresh.


이전에 사용하던 pull to refresh lib는 더이상 사용하지 않는 듯 하고 ...

안드로이드에서 제공하는 SwipeDrawer도 17부터 deprecated 돼버려서 ...

검색 해보니 커스텀 가능한 pull to refresh lib를 소개합니다.


"CustomSwipeRefreshLayout"


https://github.com/xyxyLiu/SwipeRefreshLayout

 
 


ListView, ViewPager, WebView 에서 사용 가능하고,

기존에 SwipeDrawer처럼 Progress Bar만 남기고 view가 사라지기도 하고,

기존의 pull to refresh처럼 현재 진행상태를 상단 view에서 표시하는 것도 가능합니다.


1. build.gradle에 아래 한 줄 추가 해 주시구요.

compile 'com.reginald.swiperefresh:library:1.1.0'


2. layout

(progress bar를 사용하지 않기 때문에 transparent로 지정했습니다.)

<com.reginald.swiperefresh.CustomSwipeRefreshLayout xmlns:swiperefresh="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
swiperefresh:enable_top_progress_bar="true"
swiperefresh:keep_refresh_head="true"
swiperefresh:refresh_mode="pull_mode"
swiperefresh:return_to_header_duration="500"
swiperefresh:return_to_top_duration="500"
swiperefresh:time_out_refresh_complete="500"
swiperefresh:time_out_return_to_top="500"
swiperefresh:top_progress_bar_color_1="@android:color/transparent"
swiperefresh:top_progress_bar_color_2="@android:color/transparent"
swiperefresh:top_progress_bar_color_3="@android:color/transparent"
swiperefresh:top_progress_bar_color_4="@android:color/transparent">

<RelativeLayout
android:id="@+id/rl_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>

</com.reginald.swiperefresh.CustomSwipeRefreshLayout>


3. MainActivity

public class MainActivity extends Activity {
private CustomSwipeRefreshLayout swipeRefreshLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// pull to refresh
swipeRefreshLayout = (CustomSwipeRefreshLayout) findViewById(R.id.layout_refresh);

swipeRefreshLayout.setCustomHeadview(new RefreshView(this));
swipeRefreshLayout.setTriggerDistance(50);
swipeRefreshLayout.setOnRefreshListener(new CustomSwipeRefreshLayout.OnRefreshListener() {
@Override

 swipeRefreshLayout.setOnRefreshListener(new CustomSwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
// refresh 처리
}
});

}


4. RefreshView

public class RefreshView extends LinearLayout implements CustomSwipeRefreshLayout.CustomSwipeRefreshHeadLayout {

private static final boolean DEBUG = false;

private static final SparseArray<String> STATE_MAP = new SparseArray<>();
private ViewGroup mContainer;
private ImageView mImageView;
private ImageView mProgressBar;
private int mState = -1;
private Animation loadingAnim;
private Context context;

{
STATE_MAP.put(0, "STATE_NORMAL");
STATE_MAP.put(1, "STATE_READY");
STATE_MAP.put(2, "STATE_REFRESHING");
STATE_MAP.put(3, "STATE_COMPLETE");
}

public RefreshView(Context context) {
super(context);
this.context = context;
setupLayout();
}

private void setupLayout() {
ViewGroup.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mContainer = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.view_main_refresh, null);
addView(mContainer, lp);
setGravity(Gravity.BOTTOM);
mImageView = (ImageView) findViewById(com.reginald.swiperefresh.R.id.default_header_arrow);
mProgressBar = (ImageView) findViewById(com.reginald.swiperefresh.R.id.default_header_progressbar);
loadingAnim = AnimationUtils.loadAnimation(context, R.anim.anim_loading_rotate);
setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent));
}

@Override
public void onStateChange(CustomSwipeRefreshLayout.State state, CustomSwipeRefreshLayout.State lastState) {
if (DEBUG)
Log.d("csrh", "onStateChange state = " + state + ", lastState = " + lastState);
int stateCode = state.getRefreshState();
int lastStateCode = lastState.getRefreshState();
float percent = state.getPercent();

switch (stateCode) {
case CustomSwipeRefreshLayout.State.STATE_NORMAL:
if (percent > 0.5f) {
setImageRotation((percent - 0.5f) * 180 / 0.5f);
} else {
setImageRotation(0);
}

if (stateCode != lastStateCode) {
//normal 상태처리
}
break;
case CustomSwipeRefreshLayout.State.STATE_READY:
if (stateCode != lastStateCode) {
//refresh 준비
setImageRotation(180);
}
break;
case CustomSwipeRefreshLayout.State.STATE_REFRESHING:
if (stateCode != lastStateCode) {
// refresh 중의 view처리
}
break;

case CustomSwipeRefreshLayout.State.STATE_COMPLETE:
if (stateCode != lastStateCode) {
// refresh가 끝난 후 view 처리
}
break;
default:
}
mState = stateCode;
}


private void setImageRotation(float rotation) {
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
mImageView.setRotation(rotation);
} else {
if (mImageView.getTag() == null){
mImageView.setTag(0f);
}
mImageView.clearAnimation();
Float lastDegree = (Float)mImageView.getTag();
RotateAnimation rotate = new RotateAnimation(lastDegree, rotation,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
mImageView.setTag(rotation);
rotate.setFillAfter(true);
mImageView.startAnimation(rotate);
}
}
}

 

문자 수신 시 앱에서 문자를 인식 할 수 있습니다.


Receiver 하나 등록하면 바로 가능합니다.


1. AnddroidManifest에 permission 등록 및 receiver 등록

<!-- SMS receive permission -->
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<!-- SMS read -->
<uses-permission android:name="android.permission.READ_SMS" />
<!-- SMS receiver -->
<receiver android:name=".receiver.SmsReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

2. BroadCaseReceiver class 만들기

public class SmsReceiver extends BroadcastReceiver {
public static final String TAG = "SmsReceiver";
public static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";

@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION)) {
Bundle bundle = intent.getExtras();
if(null == bundle) {
return;
}

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
SmsMessage[] smsMessages = Telephony.Sms.Intents.getMessagesFromIntent(intent);

for(int i = 0 ; i < smsMessages.length ; i++) {
SmsMessage smsMessage = smsMessages[i];
setMessage(context, smsMessage);
}
} else {
Object[] pdusObj = (Object[]) bundle.get("pdus");
if(null == pdusObj) {
return;
}
SmsMessage[] smsMessages = new SmsMessage[pdusObj.length];
for(int i = 0 ; i < pdusObj.length ; i++) {
smsMessages[i] = SmsMessage.createFromPdu((byte[]) pdusObj[i]);

setMessage(context, smsMessages[i]);
}
}
}
}

private void setMessage(Context context, SmsMessage smsMessages) {
Log.d(TAG, "DisplayMEssageBody :: " + smsMessages.getDisplayMessageBody());
Log.d(TAG, "DisplayOrinatingAddress" + smsMessages.getDisplayOriginatingAddress());
Log.d(TAG, "EmailBody :: " + smsMessages.getEmailBody());
Log.d(TAG, "originatingAddress :: " + smsMessages.getOriginatingAddress());
Log.d(TAG, "MessageBody :: " + smsMessages.getMessageBody());
Log.d(TAG, "serviceCenterAddress :: " + smsMessages.getServiceCenterAddress());
Log.d(TAG, "time :: " + smsMessages.getTimestampMillis());

// Todo 요기에서 message를 가지고 작업하시면 됩니다.
}
}

 

public static int getpToPx(Context context, int dp) {
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());
}

 

내부 저장소 용량 구하기.


1. 총 용량

public static String getLocalTotalMemory() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = 0;
long totalBlocks = 0;
if(Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
blockSize = stat.getBlockSizeLong();
totalBlocks = stat.getBlockCountLong();
} else {
blockSize = stat.getBlockSize();
totalBlocks = stat.getBlockCount();
}
return formatMemorySize(totalBlocks * blockSize);
}

2. 사용가능한 용량

public static String getCurrentRemainLocalMemory() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = 0;
long availableBlocks = 0;
if(Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
blockSize = stat.getBlockSizeLong();
availableBlocks = stat.getAvailableBlocksLong();
} else {
blockSize = stat.getBlockSize();
availableBlocks = stat.getAvailableBlocks();
}

return formatMemorySize(availableBlocks * blockSize);
}


3. 용량의 단위 정하기

public static String formatMemorySize(long memory) {
String suffix = null;

double size = 0;

if(memory >= 1024){
suffix = "_KB";
size = (double) (memory / 1024);

if(size >= 1024) {
suffix = "_MB";
size = (double) (size / 1024);

if(size >= 1024) {
suffix = "_GB";
size = (double) (size / 1024);
}
}
}

size = Math.round(size * 10d)/10d;

StringBuilder resultBuffer = new StringBuilder(Double.toString(size));

if(suffix != null){
resultBuffer.append(suffix);
}

return resultBuffer.toString();
}

ListView를 대용해 사용가능한 RecyclerView

CardView, 가로 스크롤, 세로 스크롤 등 활용도가 높음


1.xml

layout의 원하는 위치에 Recyclerview를 넣는다.

<android.support.v7.widget.RecyclerView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"></android.support.v7.widget.RecyclerView>


2. 초기화

public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {

RecyclerView listView = (RecyclerView) view.findViewById(R.id.list_view);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); // horizonta, vertical 옵션에 따라 가로/세로 list
listView.setHasFixedSize(true);
listView.setLayoutManager(layoutManager);

TestAdapter adapter = new TestAdapter(getActivity(), R.layout.row_item, testarrayList);
listView.setAdapter(adapter);

}
}


3. Adapter

class TestAdapter extends RecyclerView.Adapter<TestAdapter.ViewHolder> {
private final int resource;
private Context context;
private List<String> list;

public TestAdapter(Context context, @AnyRes int resource, List<String> list) {
this.resource = resource;
this.context = context;
this.list = list;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(resource, null);

return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final String item = getItem(position);

holder.title.setText(item);

}

@Override
public int getItemCount() {
return list.size();
}

private String getItem(int position) {
return list.get(position);
}

public void clear() {
if(null != list) {
list.clear();
}
}

public void addAll(List<String> list) {
this.list = list;
notifyDataSetChanged();
}

public class ViewHolder extends RecyclerView.ViewHolder {
public final TextView title;

public ViewHolder(View parent) {
super(parent);


title= (TextView) parent.findViewById(R.id.title);
}
}
}

 

'안드로이드' 카테고리의 다른 글

db -> px 단위 변경  (0) 2017.03.06
안드로이드 내부 저장소 용량 구하기  (0) 2017.03.06
공유 가능 앱 리스트 가져오기  (0) 2017.03.06
안드로이드 앱의 cpu 사용량 구하기  (0) 2017.03.06
AsyncTask  (0) 2011.09.06

안드로이드 공유하기에 흔히 사용하는 Intent.

공유하기 팝업을 커스텀 하고 싶을 때 list만 가져와서 dialog를 만들면 된다.


Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");

List<ResolveInfo> resolveInfoList = context.getPackageManager().queryIntentActivities(shareIntent, 0);


​앱 선택 시 처리


ResolveInfo resolveInfo = resolveInfoList.get(selectPosition);
ActivityInfo activityInfo = resolveInfo.activityInfo;

ComponentName name = new ComponentName(activityInfo.applicationInfo.packageName, activityInfo.name);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setComponent(name);

//TODO ssok by 추후 공유 메시지, url 변경 필요
shareIntent.putExtra(Intent.EXTRA_TEXT, "공유하고자 하는 문구");

startActivity(shareIntent);

 

'안드로이드' 카테고리의 다른 글

안드로이드 내부 저장소 용량 구하기  (0) 2017.03.06
안드로이드 RecyclerView 사용하기 예제  (0) 2017.03.06
안드로이드 앱의 cpu 사용량 구하기  (0) 2017.03.06
AsyncTask  (0) 2011.09.06
AppWidget  (0) 2011.07.28

+ Recent posts