This file contains 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.content.Context | |
import org.jetbrains.anko.runOnUiThread | |
class RunOnUiThread(var context: Context?) { | |
fun safely(dothis: () -> Unit) { | |
if (context != null) { | |
context?.runOnUiThread { | |
try { | |
dothis.invoke() | |
} catch (e: Exception) { |
This file contains 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.content.Context | |
import android.graphics.Typeface | |
import com.zoho.zohosocial.utils.MLog | |
import java.util.* | |
object FontsHelper { | |
private val TAG = "TypefaceHelper" | |
private val fontsCache = Hashtable<String, Typeface>() |
This file contains 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 androidx.fragment.app.FragmentActivity | |
import android.view.inputmethod.InputMethodManager | |
class HideKeypad { | |
fun now(activity: Any?) { | |
if (activity != null) { | |
if (activity is Activity) { | |
val inputManager = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager |
This file contains 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.content.Context | |
import android.content.SharedPreferences | |
import android.preference.PreferenceManager | |
object PreferencesManager { | |
fun defaultPrefs(context: Context): SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) | |
fun customPrefs(context: Context, name: String): SharedPreferences = context.getSharedPreferences(name, Context.MODE_PRIVATE) | |
inline fun SharedPreferences.edit(operation: (SharedPreferences.Editor) -> Unit) { |
This file contains 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.content.Context | |
import android.view.MotionEvent | |
import androidx.viewpager.widget.ViewPager | |
import android.util.AttributeSet | |
class LockableViewPager : ViewPager { | |
var swipeLocked: Boolean = true | |
constructor(context: Context) : super(context) |
This file contains 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.content.Context | |
import android.util.AttributeSet | |
import android.view.MotionEvent | |
class AnimationlessViewpager : androidx.viewpager.widget.ViewPager { | |
var swipeLocked: Boolean = true | |
constructor(context: Context) : super(context) |
This file contains 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.content.ClipData | |
import android.content.ClipboardManager | |
import android.content.Context | |
import android.widget.Toast | |
object ClipBoardManager { | |
fun copy(ctx: Context, text: String, message: String = "") { | |
val myClipboard = ctx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager | |
val myClip = ClipData.newPlainText(message, text) | |
myClipboard.primaryClip = myClip |
This file contains 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.content.Context | |
import androidx.core.view.inputmethod.EditorInfoCompat | |
import androidx.core.view.inputmethod.InputConnectionCompat | |
import androidx.appcompat.widget.AppCompatEditText | |
import android.util.AttributeSet | |
import android.view.inputmethod.EditorInfo | |
import android.view.inputmethod.InputConnection | |
import android.widget.Toast | |
import com.zoho.zohosocial.utils.RunOnUiThread |
This file contains 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.content.Context | |
import android.net.ConnectivityManager | |
object NetworkUtil { | |
fun isConnected(context: Context): Boolean { | |
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val activeNetwork = cm.activeNetworkInfo | |
return activeNetwork != null && activeNetwork.isConnectedOrConnecting | |
} | |
} |
This file contains 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.content.Context | |
import android.util.AttributeSet | |
import android.widget.FrameLayout | |
class SquareLayout : FrameLayout { | |
constructor(context: Context) : super(context) | |
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) | |
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) |
OlderNewer