Skip to content

Instantly share code, notes, and snippets.

@bamssong
bamssong / gist:be3fbc34649b46228ed3
Created March 5, 2016 07:20
configured network connect.
List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
for (WifiConfiguration i : list) {
if (i.SSID != null && i.SSID.equals("\"" + ssid + "\"")) {
wifiManager.disconnect();
wifiManager.enableNetwork(i.networkId, true);
wifiManager.reconnect();
}
}
@bamssong
bamssong / swift constraints
Created February 16, 2016 05:48
swift constraints
func visibleBottomView(type: Type, info : MarkerInfo) {
for constraint in self.bottomView.constraints as [NSLayoutConstraint] {
if constraint.identifier == "bottom_height" {
constraint.constant = 240
}
}
}
func goneBottonView() {
for constraint in self.bottomView.constraints as [NSLayoutConstraint] {
@bamssong
bamssong / shader
Created November 29, 2015 17:10
android text shader
TextView secondTextView = new TextView(this);
Shader textShader=new LinearGradient(0, 0, 0, 20,
new int[]{Color.GREEN,Color.BLUE},
new float[]{0, 1}, TileMode.CLAMP);
secondTextView.getPaint().setShader(textShader);
public class MainActivity extends ActionBarActivity {
private int type;
public static final int KEY_ONE = 1;
public static final int KEY_TWO = 2;
@IntDef({KEY_ONE, KEY_TWO})
public @interface KeyType{}
@bamssong
bamssong / android Random color -> view setColor
Created October 5, 2015 13:10
android Random color -> view setColor
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
v.setBackgroundColor(color);
@bamssong
bamssong / android VerticalViewPager
Created October 5, 2015 07:09
android VerticalViewPager
/**
* Uses a combination of a PageTransformer and swapping X & Y coordinates
* of touch events to create the illusion of a vertically scrolling ViewPager.
*
* Requires API 11+
*
*/
public class VerticalViewPager extends ViewPager {
public VerticalViewPager(Context context) {
private String getWifiIp() throws SocketException {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
en.hasMoreElements(); ) {
NetworkInterface intf = en.nextElement();
if (intf.isLoopback()) {
continue;
}
if (intf.isVirtual()) {
continue;
}
RestAdapter.Builder builder= new RestAdapter.Builder()
.setRequestInterceptor(new RequestInterceptor() {
@Override
public void intercept(RequestFacade request) {
request.addHeader("Accept", "application/json;versions=1");
if (MyApplicationUtils.isNetworkAvailable(context)) {
int maxAge = 60; // read from cache for 1 minute
request.addHeader("Cache-Control", "public, max-age=" + maxAge);
} else {
int maxStale = 60 * 60 * 24 * 28; // tolerate 4-weeks stale
// 웹페이지 띄우기
Uri uri = Uri.parse("http://www.google.com");
Intent it = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);
// 구글맵 띄우기
Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);
@bamssong
bamssong / ObjectAnimator
Created September 19, 2015 16:43
view animation
final ObjectAnimator oa = ObjectAnimator.ofFloat(view, "x", 100f);
oa.setDuration(5000);
oa.start();