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
view.post(new Runnable() { | |
@Override | |
public void run() { | |
int width = view.getWidth(); | |
int height = view.getHeight(); | |
//do something cool with width and height | |
} | |
}); |
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
package com.cool.vicky.contentprovider; | |
import android.database.Cursor; | |
import android.provider.ContactsContract; | |
import android.support.v4.app.LoaderManager; | |
import android.support.v4.content.CursorLoader; | |
import android.support.v4.content.Loader; | |
import android.support.v4.widget.SimpleCursorAdapter; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; |
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
Follow this code to sort any ArrayList | |
Collections.sort(empList, new Comparator<Employee>(){ | |
public int compare(Employee emp1, Employee emp2) { | |
// ## Ascending order | |
return emp1.getFirstName().compareToIgnoreCase(emp2.getFirstName()); // To compare string values | |
// return Integer.valueOf(emp1.getId()).compareTo(emp2.getId()); // To compare integer values |
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
private boolean isMyServiceRunning(Class<?> serviceClass) { | |
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); | |
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { | |
if (serviceClass.getName().equals(service.service.getClassName())) { | |
return true; | |
} | |
} | |
return false; | |
} |
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
<?php | |
/* | |
Parameter Example | |
$data = array('post_id'=>'12345','post_title'=>'A Blog post'); | |
$target = 'single tocken id or topic name'; | |
or | |
$target = array('token1','token2','...'); // up to 1000 in one request | |
*/ | |
public function sendMessage($data,$target){ | |
//FCM api URL |
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.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public class InitActivity { | |
public InitActivity() { | |
logger.debug("Activity loading...."); | |
} | |
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 MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val button = findViewById(R.id.button) | |
val editText = findViewById(R.id.editText) as EditText | |
button.setOnClickListener { |
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 FileLoggingTree extends Timber.DebugTree { | |
private static final String TAG = FileLoggingTree.class.getSimpleName(); | |
private Context context; | |
public FileLoggingTree(Context context) { | |
this.context = context; | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest package="com.yoscholar.deliveryboy" | |
xmlns:android="http://schemas.android.com/apk/res/android"> | |
<application | |
android:name=".application.MyApplication" | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:supportsRtl="true" |
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 MyApplication extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
Timber.plant(new FileLoggingTree(getApplicationContext())); | |
} | |
} |
OlderNewer