Skip to content

Instantly share code, notes, and snippets.

View moltak's full-sized avatar
🎯
Focusing

KyungHo Jung moltak

🎯
Focusing
View GitHub Profile
@moltak
moltak / ActionbarDrawerToggle.java
Last active December 17, 2015 21:29
ActionbarDrawerToggle button
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Pass the event to ActionBarDrawerToggle, if it returns
// true, then it has handled the app icon touch event
if ((item != null) && (item.getItemId() == 16908332) && (mDrawerToggle.isDrawerIndicatorEnabled())) {
if (this.mDrawerLayout.isDrawerVisible(Gravity.LEFT))
this.mDrawerLayout.closeDrawer(Gravity.LEFT);
else {
this.mDrawerLayout.openDrawer(Gravity.LEFT);
}
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@moltak
moltak / gist:5675486
Created May 30, 2013 03:01
DrawerLayout
package com.moltak.usingdrawerwithsherlockandscrollview;
import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
public class MODrawerLayout extends DrawerLayout {
@moltak
moltak / gist:5742940
Last active December 18, 2015 06:59
resource resizer.py
# code updated 2014.05.16
from os import listdir
from os.path import isfile, join
import os
import shutil
from PIL import Image
import string
xxhdpi = './drawable-xxhdpi/'
xhdpi = './drawable-xhdpi/'
@moltak
moltak / gist:5938120
Last active December 19, 2015 10:09
android selector generagtor
from os import listdir
import sys
import os
import string
xml_prefix = '<?xml version="1.0" encoding="utf-8"?>\n' \
+ '<selector xmlns:android="http://schemas.android.com/apk/res/android">\n' \
+ '<item android:drawable="@drawable/'
pressed_postfix = '" android:state_pressed="true"></item>\n'
normal_prefix = '<item android:drawable="@drawable/'
@moltak
moltak / gist:6681204
Created September 24, 2013 06:56
Upload large file
public String sendFileToServer(String filename, String targetUrl) {
String response = "error";
Log.e("Image filename", filename);
Log.e("url", targetUrl);
HttpURLConnection connection = null;
DataOutputStream outputStream = null;
// DataInputStream inputStream = null;
String pathToOurFile = filename;
String urlServer = targetUrl;
@moltak
moltak / gist:7752613
Created December 2, 2013 16:55
MainActivity.java
package com.gradle.app;
import android.content.res.Resources;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@moltak
moltak / gist:7752661
Created December 2, 2013 16:58
build.gradle
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
classpath 'com.android.tools.build:gradle:0.6.+'
@moltak
moltak / gist:7752715
Created December 2, 2013 17:02
MainActivityTest
package com.gradle.app;
import android.content.res.Resources;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.widget.TextView;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@moltak
moltak / gist:7752742
Created December 2, 2013 17:04
RobolectricGradleTestRunner
package com.gradle.app;
import org.junit.runners.model.InitializationError;
import org.robolectric.AndroidManifest;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.res.Fs;
public class RobolectricGradleTestRunner extends RobolectricTestRunner {
public RobolectricGradleTestRunner(Class<?> testClass) throws InitializationError {