This file contains hidden or 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
| fun <T> convertJsonStringToObject(jsonString: String?, objectClass: Class<T>?): T { | |
| return Gson().fromJson(jsonString, objectClass) | |
| } | |
| fun <T> convertJsonStringToObjectList(jsonString: String): List<T> { | |
| return Gson().fromJson(jsonString, object : TypeToken<List<T?>?>() {}.type) | |
| } |
This file contains hidden or 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
| const val REQUEST_EXTERNAL_STORAGE = 1001 | |
| fun isStoragePermissionGranted(context: Context, activity: Activity): Boolean { | |
| return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
| if (ContextCompat.checkSelfPermission( | |
| context, Manifest.permission.READ_EXTERNAL_STORAGE | |
| ) == PackageManager.PERMISSION_GRANTED | |
| ) { | |
| // Permission is granted | |
| true |
This file contains hidden or 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
| fun convertImageToBase64(imageFile: File): String { | |
| return ByteArrayOutputStream().use { outputStream -> | |
| Base64OutputStream(outputStream, Base64.DEFAULT).use { base64FilterStream -> | |
| imageFile.inputStream().use { inputStream -> | |
| inputStream.copyTo(base64FilterStream) | |
| } | |
| } | |
| return@use outputStream.toString() | |
| } | |
| } |
This file contains hidden or 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"?> | |
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:shape="oval"> | |
| <solid android:color="@color/numbersCircleBG" /> | |
| <size | |
| android:width="120dp" | |
| android:height="120dp" /> | |
| </shape> |
This file contains hidden or 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
| <application | |
| ... | |
| android:theme="@style/AppTheme"> | |
| <activity | |
| android:name=".ui.main.MainActivity" | |
| android:label="@string/app_name" /> | |
| <activity | |
| android:name=".ui.main.SplashScreenActivity" | |
| android:configChanges="orientation|keyboardHidden|screenSize" | |
| android:theme="@style/FullscreenTheme"> |
This file contains hidden or 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
| open class BaseActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| val configuration: Configuration = resources.configuration | |
| configuration.setLayoutDirection(Locale("fa")) | |
| resources.updateConfiguration(configuration, resources.displayMetrics) | |
| } | |
| } |
This file contains hidden or 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
| abstract class BaseAdapter<T>(private val itemClickListener: OnItemClickListener<T>) : | |
| RecyclerView.Adapter<BaseAdapter<T>.MyViewHolder>() { | |
| interface OnItemClickListener<T> { | |
| fun onItemClick(item: T) | |
| } | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { | |
| val binding = DataBindingUtil.inflate<ViewDataBinding>( | |
| LayoutInflater.from(parent.context), |
This file contains hidden or 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 CustomeRecyclerViewAdapter extends RecyclerView.Adapter<CustomeRecyclerViewAdapter.CustomViewHolder> { | |
| private Context mContext; | |
| private List<T> dataList = new ArrayList<>(); | |
| private OnItemClickedListener onItemClickedListener; | |
| // for load more | |
| private final int VIEW_TYPE_ITEM = 0; | |
| private final int VIEW_TYPE_LOADING = 1; | |
| private OnLoadMoreListener onLoadMoreListener; |
This file contains hidden or 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 ResponseWrapper<T> { | |
| @NonNull | |
| private Status status; | |
| @Nullable | |
| private T data; | |
| @Nullable | |
| private Integer errorCode; |
NewerOlder