Skip to content

Instantly share code, notes, and snippets.

View mnafian's full-sized avatar
🎯
Focusing

M. Nafian Wildana mnafian

🎯
Focusing
View GitHub Profile
@mnafian
mnafian / MyApp.java
Created January 19, 2016 09:53 — forked from artem-zinnatullin/MyApp.java
If you need to set one font for all TextViews in android application you can use this solution. It will override ALL TextView's typefaces, includes action bar and other standard components, but EditText's password font won't be overriden.
public class MyApp extends Application {
@Override
public void onCreate() {
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
}
}
private RelativeLayout drawInsideEditor;
@Bind(R.id.dp_main_layout)
RelativeLayout mainLayout;
// oncreate
drawInsideEditor = (RelativeLayout) View.inflate(this, R.layout.dp_text_editor_layout, null);
mainLayout.addView(drawInsideEditor);
RelativeLayout drawText = (RelativeLayout) View.inflate(this, R.layout.dp_item_textview_preview, null);
[
{
"class_name" : "XI IPA 1",
"class_subject" : "Biologi"
},
{
"class_name" : "9 C",
"class_subject" : "Matematika"
}
]
@mnafian
mnafian / SampleParameterVolley.java
Created October 23, 2015 14:29
Sample map parameter vor post request volley.
public void orderCart(final String idCustomer, final String cartId, final String addressInvoice, final String addressDelivery, final String carrierId, final String paymentMethod) {
progressDialog.show();
String urlOrderCart = StaticRegisterClass.urlOrder;
StringRequest postReq = new StringRequest(Request.Method.POST,
urlOrderCart,
createMyReqSuccessListenerOrder(),
createMyReqErrorListener()) {
protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
@mnafian
mnafian / SampleLayout.xml
Created October 16, 2015 10:28
SampleLinearLayout 2 vertical
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/cover"
android:orientation="vertica"> <--! dibuat vertical, ini root layout -->
@mnafian
mnafian / Example
Created October 16, 2015 10:17
Email validation edittext support library
// java file :
if (email.isEmpty() || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
_emailText.setError("enter a valid email address");
valid = false;
}
// xmlnya :
<!-- Email Label -->
<android.support.design.widget.TextInputLayout
@mnafian
mnafian / SampleWebView.java
Created October 10, 2015 05:48
Webview support for upload image or file
private void initWebView(final String linkURL) {
pDialog.show();
mWebView = (WebView) findViewById(R.id.content_webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(linkURL);
mWebView.setWebChromeClient(new WebChromeClient() {
public boolean onShowFileChooser(
WebView webView, ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams) {