Skip to content

md-shahin-miah/AndroidUtils

 
 

Repository files navigation

Android Utils

alt text

To get a Git project into your build

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		maven { url 'https://jitpack.io' }
	}
     }
  

Step 2. Add the dependency

dependencies {
    implementation 'com.github.xihadulislam:AndroidUtils:2.0.2'
}
  

Usage

Access shared preference easily

       val sharePrefSettings = AndroidUtils.getSharePrefSetting(this);

        sharePrefSettings.setBoolValue("key", false)

        val kBoolean = sharePrefSettings.getBoolValue("key")

        sharePrefSettings.setStringValue("key2", "xihad islam")

        val xd = sharePrefSettings.getStringValue("key2");
        AndroidUtils.toast(this, xd)

Here a Sample code snippet

  toast.setOnClickListener {
            AndroidUtils.toast(this, "show something")
        }

        showSnack.setOnClickListener {
            AndroidUtils.getSnackBar(this).snackBar("show something")
        }

        showSnackSuccess.setOnClickListener {
            AndroidUtils.getSnackBar(this).successSnack(root, "show something")
        }

        showSnackInfo.setOnClickListener {
            AndroidUtils.getSnackBar(this).infoSnack(root, "show something", Gravity.BOTTOM, fun() {
                AndroidUtils.toast(this, "click")
            })
        }

        showSnackWarning.setOnClickListener {
            AndroidUtils.getSnackBar(this).warningSnack(root, "show something")
        }

        showSnackError.setOnClickListener {
            AndroidUtils.getSnackBar(this).errorSnack(root, "show something")
        }

Intent several activities just need one line code

           startNextActivity.setOnClickListener {
            AndroidUtils.getIntent().startNextActivity(this, SecondActivity::class.java)
        }

        afterNextActivity.setOnClickListener {
            AndroidUtils.getIntent().afterNextActivity(this, 2000, SecondActivity::class.java)
        }

        startFacebookIntent.setOnClickListener {
            AndroidUtils.getIntent().startFacebookIntent(this, "url")
        }

      

Check Internet connection is available or not.

    if (AndroidUtils.getAppUtil().isInternetAvailable(this)) {
                AndroidUtils.toast(this, "Available")
            }

You can Play a mediaPlayer just calling one method.

    

Sample project

Clone this repo and check out the app module.

Author

This is my First built library, so if you face any issues or errors feel free to tell me. I will update it continuously.

Share

Like this project? Why not share to your friend :)

            

Licence

Copyright 2021 @xihad islam.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

A Utils library to help developers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 100.0%