Skip to content

Instantly share code, notes, and snippets.

View ibrahim-mrq's full-sized avatar
💭
Android Developer

Ibrahim_Mrq ibrahim-mrq

💭
Android Developer
View GitHub Profile
package com.package_name;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.util.AttributeSet;
import android.widget.TextView;
@SuppressLint("AppCompatCustomView")
public class TypeWriter extends TextView {
fun popupImage(context: Context, photo: Drawable) {
val popup = ImagePopup(context as Activity)
popup.initiatePopup(photo)
popup.isFullScreen = false
popup.isHideCloseIcon = false
popup.setBackgroundColor(Color.parseColor("#000000"))
popup.setOnImageClickListener {
popup.dismiss()
popup.isFullScreen = !popup.isFullScreen
package com.intertech.e_bike_bethlehem.network.retrofit
import android.content.Context
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.intertech.e_bike_bethlehem.R
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
override fun onBackPressed() {
if (backPressedTime + 2000 > System.currentTimeMillis()) {
backToasty!!.cancel()
super.onBackPressed()
return
} else {
backToasty = Toast.makeText(this, getString(R.string.back_exit), Toast.LENGTH_SHORT)
backToasty!!.show()
}
public static void replaceFragment(Fragment fragment, @StringRes int title) {
// binding.main.appbar.tvTool.setText(title);
// FragmentManager manager = getSupportFragmentManager();
FragmentManager manager = ((FragmentActivity) context).getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.main_nav_host_fragment, fragment);
transaction.addToBackStack("TAG");
transaction.commit();
}
private android.widget.Toast backToasty;
private long backPressedTime;
@Override
public void onBackPressed() {
if (backPressedTime + 2000 > System.currentTimeMillis()) {
backToasty.cancel();
super.onBackPressed();
return;
} else {
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
class ${NAME}Adapter(val context: Context) : RecyclerView.Adapter<${NAME}Adapter.${NAME}ViewHolder>() {
var list = emptyList<${Model_Name}>()
package com.mrq.library.helpers
import android.app.Dialog
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
package com.mrq.library.helpers
import android.app.Dialog
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup