This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2013 YROM.NET | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
protected Response<?> parseNetworkResponse(NetworkResponse response) { | |
try { | |
String json = new String(response.data, | |
HttpHeaderParser.parseCharset(response.headers)); | |
... // parseing json | |
return Response.success(obj, cache(response, 60)); | |
} catch (Exception e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void setActionBarTranslation(float y) { | |
// Figure out the actionbar height | |
int actionBarHeight = 0; | |
TypedValue tv = new TypedValue(); | |
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { | |
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics()); | |
} | |
// A hack to add the translation to the action bar | |
ViewGroup content = ((ViewGroup) findViewById(android.R.id.content).getParent()); | |
int children = content.getChildCount(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if android.hardware.telephony feature is available. | |
if (getPackageManager().hasSystemFeature("android.hardware.telephony")) { | |
Log.d("Mobile Test", "Running on phone"); | |
// Check if android.hardware.touchscreen feature is available. | |
} else if (getPackageManager().hasSystemFeature("android.hardware.touchscreen")) { | |
Log.d("Tablet Test", "Running on devices that don't support telphony but have a touchscreen."); | |
} else { | |
Log.d("TV Test", "Running on a TV!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the remote server | |
SocketAddress remote = new InetSocketAddress(Inet4Address.getByName(hostName), port); | |
// open a selector | |
Selector selector = Selector.open(); | |
// open a channel | |
SocketChannel channel = SocketChannel.open(); | |
// non-blocking | |
channel.configureBlocking(false); | |
// pending connect | |
channel.connect(remote); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collection; | |
import java.util.List; | |
import android.content.Context; | |
import android.support.v7.widget.RecyclerView.ViewHolder; | |
public abstract class ArrayAdapter<T, VH extends ViewHolder> extends BaseAdapter<T, VH> { | |
private List<T> mItems; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Rect; | |
import android.support.v7.widget.GridLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; | |
public class SpacesItemDecoration extends RecyclerView.ItemDecoration { | |
private int space; | |
private int spanCount; | |
private int lastItemInFirstLane = -1; | |
public SpacesItemDecoration(int space) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PagerActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_paper); | |
ViewPager pager = (ViewPager) findViewById(R.id.pager); | |
pager.setAdapter(new PageAdapter(getSupportFragmentManager())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.maven.artifact.ant.DependenciesTask; | |
import org.apache.maven.artifact.ant.RemoteRepository; | |
import org.apache.maven.model.Dependency; | |
import org.apache.tools.ant.Project; | |
import org.junit.runners.model.InitializationError; | |
import org.robolectric.RobolectricTestRunner; | |
import org.robolectric.internal.dependency.DependencyJar; | |
import org.robolectric.internal.dependency.DependencyResolver; | |
import org.robolectric.util.Util; |
OlderNewer