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
extension UIView { | |
var differentSuperviewsWarningMessage: String { | |
return "Since you are adding a constraint to self.superview, self and the view passed in need to have the same superview. The views you are trying to align do not have the same superview." | |
} | |
func centerInSuperview() { | |
self.centerVerticallyInSuperview() | |
self.centerHorizontallyInSuperview() | |
} | |
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 static MarkerOptions createMarker(Context context, LatLng point, int bedroomCount) { | |
MarkerOptions marker = new MarkerOptions(); | |
marker.position(point); | |
int px = context.getResources().getDimensionPixelSize(R.dimen.map_marker_diameter); | |
View markerView = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.map_circle_text, null); | |
markerView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); | |
markerView.layout(0, 0, px, px); | |
markerView.buildDrawingCache(); | |
TextView bedNumberTextView = (TextView)markerView.findViewById(R.id.bed_num_text_view); | |
Bitmap mDotMarkerBitmap = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888); |
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 Person { | |
public static class Container { | |
public Person the_person; | |
} | |
public static Person fromJson(String json) { | |
Gson gson = new Gson(); | |
Person.Container container = gson.fromJson(json, Person.Container.class); | |
return container.the_person; |
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 FocusChangeEditText extends android.support.v7.widget.AppCompatEditText { | |
public FocusChangeEditText(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
OnFocusChangeListener dismissKeyboardOnTapListener = new OnFocusChangeListener() { | |
@Override | |
public void onFocusChange(View v, boolean hasFocus) { | |
if (!hasFocus) { | |
Keyboard.hide(v); | |
} | |
} |
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
<ImageView | |
android:padding="2dp" | |
android:layout_width="110dp" | |
android:layout_height="110dp" | |
android:src="@drawable/dummy_pic" | |
android:scaleType="centerCrop" | |
android:cropToPadding="true" | |
android:background="@color/white" /> |
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 CustomFontTextView extends TextView { | |
public CustomFontTextView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CustomFontTextView, 0, 0); | |
try { | |
String fontName = ta.getString(R.styleable.CustomFontTextView_text_font); | |
this.setTypeface(Font.fromString(context, fontName)); | |
} finally { | |
ta.recycle(); |
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
class BaseURL { | |
class func getFromEnvironment() -> String { | |
#if DEBUG | |
return "http://192.168.1.126" | |
#else | |
return "https://judgecardx.com" | |
#endif | |
} |
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
class RestApi { | |
class func post(request: NSMutableURLRequest, completion: (response: String?, json: AnyObject?) -> ()) { | |
dataTask(request, method: "POST", completion: completion) | |
} | |
class func put(request: NSMutableURLRequest, completion: (response: String?, json: AnyObject?) -> ()) { | |
dataTask(request, method: "PUT", completion: completion) | |
} |
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.content.Context; | |
import android.content.pm.PackageManager; | |
import android.support.v4.content.ContextCompat; | |
import static android.Manifest.permission.*; | |
public class Permission { | |
public static boolean granted(Context context, String permission) { | |
int permissionCheck = ContextCompat.checkSelfPermission(context, permission); |
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 MyProgressDialog { | |
private static ProgressDialog progressDialog; | |
public static void show(Context context, int messageResourceId) { | |
if (progressDialog != null) { | |
progressDialog.dismiss(); | |
} | |
int style; |
NewerOlder