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 closeActivitiesGoLogin(context: Context?) { | |
| val intent = Intent(context, LoginActivity::class.java) | |
| val cn = intent.component | |
| val mainIntent = Intent.makeRestartActivityTask(cn) | |
| context?.startActivity(mainIntent) | |
| } |
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
| Description of this regular expression is as below: | |
| Passwords will contain at least 1 upper case letter | |
| Passwords will contain at least 1 lower case letter | |
| Passwords will contain at least 1 number or special character | |
| Passwords will contain at least 8 characters in length | |
| Password maximum length should not be arbitrarily limited | |
| (?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$ |
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 Snackbar.setTextColor(color: Int): Snackbar { | |
| val tv = view.findViewById(android.support.design.R.id.snackbar_text) as TextView | |
| tv.setTextColor(color) | |
| return this | |
| } |
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 AppCompatActivity.hideKeyBoard(){ | |
| val view = this.currentFocus | |
| if (view != null) { | |
| val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager | |
| inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) | |
| } |
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 AppCompatActivity.toggleHideShowKeyboard() { | |
| val inputMethodManager = this.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager | |
| when { | |
| inputMethodManager.isActive -> inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0) | |
| else -> inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0) // hide | |
| } | |
| } |
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
| class CircularImageView : ImageView { | |
| constructor(context: Context) : super(context) {} | |
| constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {} | |
| constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {} | |
| override fun onDraw(canvas: Canvas) { |
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 roundedBitmap(bitmap: Bitmap): RoundedBitmapDrawable { | |
| val roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(Resources.getSystem(), bitmap) | |
| roundedBitmapDrawable.isCircular = true | |
| roundedBitmapDrawable.cornerRadius = Math.max(bitmap.width, bitmap.height) / 2.0f | |
| return roundedBitmapDrawable | |
| } |
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
| object RetrofitGetAPIWithAuth { | |
| private val BASE_URL = BuildConfig.API_BASE | |
| private var retrofit: Retrofit? = null | |
| private val tokenLoginModel: TokenLoginModel? = obtainTokenLoginModel() | |
| private val accessToken = tokenLoginModel?.access_token | |
| class HeaderInterceptor : Interceptor { | |
| @Throws(IOException::class) | |
| override fun intercept(chain: Interceptor.Chain): Response { | |
| var request = chain.request() |
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
| import android.app.Activity; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import android.content.pm.ResolveInfo; | |
| import android.content.res.AssetFileDescriptor; | |
| import android.database.Cursor; | |
| import android.graphics.Bitmap; | |
| import android.graphics.BitmapFactory; | |
| import android.graphics.Matrix; | |
| import android.media.ExifInterface; |
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 AccountAuthenticator extends AbstractAccountAuthenticator { | |
| private final Context context; | |
| @Inject @ClientId String clientId; | |
| @Inject @ClientSecret String clientSecret; | |
| @Inject ApiService apiService; | |
| public AccountAuthenticator(Context context) { | |
| super(context); |