Skip to content

Instantly share code, notes, and snippets.

View Lzyct's full-sized avatar
:shipit:
Code Geek

Mudassir Lzyct

:shipit:
Code Geek
View GitHub Profile
@Lzyct
Lzyct / GetResponse.java
Last active August 13, 2016 06:29
Get return value from Retrofit 2
StatusResponse statusResponse = new StatusResponse(param1,param2,new StatusInterface(){
@Override
public void returnResponse(int status){
switch(status){
case 1: //do your stuff
break;
case 2: //do your stuff
break;
default:
break;
@Lzyct
Lzyct / CustomDialog.java
Created January 5, 2017 11:27
Sample floating
View dialogView = getLayoutInflater().inflate(R.layout.custom_dialog, null);
Dialog customDialog = new Dialog(this, R.style.CustomDialog);
customDialog.setContentView(dialogView);
customDialog.setCancelable(true);
customDialog.getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
customDialog.show();
@Lzyct
Lzyct / TimeAgoUtils.java
Last active February 5, 2017 11:44
Create time ago in android
public class TimeAgoUtils{
public static String getValue(String yourPostingTime){
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", new Locale("id", "ID")); //set your locale
Date postDate;
Date currentDate;
try {
AppController.inputDate2.setTimeZone(TimeZone.getTimeZone("GMT+7")); //set your GMT server current time
postDate = sdf1.parse(yourPostingTime);
long postDateTime = postDate.getTime();
@Lzyct
Lzyct / FragmentPlayer.java
Created February 18, 2017 05:10
AutoPlay Exoplayer
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
LinearLayoutManager layout = (LinearLayoutManager) recyclerView.getLayoutManager();
int currentPosition = layout.findFirstVisibleItemPosition() - 1;
try {
Logger.d("currentPosition : " + currentPosition + "temp : " + previousPosition);
if (responseItemList.get(currentPosition).getFile().get(0).getAttachment_type().toLowerCase()
@Lzyct
Lzyct / layer_step.xml
Created February 21, 2017 04:07
BreadCrumb
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_order_progress_status"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1.0"
tools:ignore="all">
<TextView
@Lzyct
Lzyct / ClickListener.java
Created November 9, 2017 02:48
Recyclerview touch Listener
public interface ClickListener {
void onClick(View view, int position);
void onLongClick(View view, int position);
}
@Lzyct
Lzyct / yourActivit.kt
Created November 13, 2017 15:37
Generate TextInputLayout with TextInputEditText
private fun generateTextInputLayout(count: Int) {
ll_root.removeAllViews() // remove prevous TextInputEditText on root layout
for (item in 1..count) {
//create textInputLayout
val textInputLayout = TextInputLayout(this)
ll_root.addView(textInputLayout) // add View TextInputLayout in LinearLayout
//create textInputEditText
val textInputEditText = TextInputEditText(this)
public class CounterActivity extends AppCompatActivity {
private int nilaiSkor = 0;
private TextView tvCounter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_counter); // layout counter
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import java.util.*
#parse("File Header.java")
class ${NAME} (private val dataList:List<${Model_Class}>): RecyclerView.Adapter<${NAME}.${ViewHolder_Class}>() {
@Lzyct
Lzyct / NetworkBoundResource.kt
Created February 28, 2019 02:05
NetworkBoundResource with Rx
abstract class NetworkBoundResource<ResultType, RequestType> {
private lateinit var result: Flowable<Resource<ResultType>>
init {
// Lazy disk observable.
val diskObservable = Flowable.defer {
loadFromDb()
// Read from disk on Computation Scheduler
.subscribeOn(Schedulers.computation())