NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/*
*
* @copyright : ToXSL Technologies Pvt. Ltd. < www.toxsl.com >
* @author : Shiv Charan Panjeta < [email protected] >
* All Rights Reserved.
* Proprietary and confidential : All information contained herein is, and remains
* the property of ToXSL Technologies Pvt. Ltd. and its partners.
* Unauthorized copying of this file, via any medium is strictly prohibited.
*
*/

package com.zstash.ui.base

import android.app.Dialog
import android.content.Context
import android.graphics.Rect
import android.view.MotionEvent
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.CompoundButton
import android.widget.EditText
import com.toxsl.restfulClient.api.RestFullClient
import com.toxsl.restfulClient.api.SyncEventListener
import com.zstash.BuildConfig
import com.zstash.R
import com.zstash.utils.API
import com.zstash.utils.Const
import com.zstash.utils.PrefStore
import org.json.JSONObject
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response


open class BaseDialog : Dialog, View.OnClickListener, SyncEventListener, CompoundButton.OnCheckedChangeListener {
var baseActivity: BaseActivity?
var store: PrefStore? = null
var restFullClient: RestFullClient? = null
var api: API? = null

constructor(context: Context) : super(context, R.style.animateDialog) {
baseActivity = context as BaseActivity
store = baseActivity?.store
if (baseActivity!!.restFullClient == null) {
baseActivity!!.restFullClient = RestFullClient.getInstance(
baseActivity!!)
baseActivity!!.apiInstance = restFullClient!!.getRetrofitInstance(Const.SERVER_REMOTE_URL,BuildConfig.VERSION_NAME)
baseActivity!!.api = baseActivity!!.apiInstance!!.create(API::class.java)

}
restFullClient = baseActivity!!.restFullClient
api = baseActivity!!.api
}

constructor(context: BaseActivity, customDialog: Int) : super(context, customDialog) {
baseActivity = context
store = baseActivity?.store
if (baseActivity!!.restFullClient == null) {
baseActivity!!.restFullClient = RestFullClient.getInstance(
baseActivity!!)
baseActivity!!.apiInstance = restFullClient!!.getRetrofitInstance(Const.SERVER_REMOTE_URL,BuildConfig.VERSION_NAME)
baseActivity!!.api = baseActivity!!.apiInstance!!.create(API::class.java)

}
restFullClient = baseActivity!!.restFullClient
api = baseActivity!!.api
}


override fun onClick(v: View) {
hideKeyBoardDialog()
}

//hide keyboard on click outside the edittext
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
if (event.action == MotionEvent.ACTION_DOWN) {
val v = currentFocus
if (v is EditText) {
val outRect = Rect()
v.getGlobalVisibleRect(outRect)
if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) {
v.clearFocus()
val imm = baseActivity?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(v.getWindowToken(), 0)
}
}
}
return super.dispatchTouchEvent(event)
}

private fun hideKeyBoardDialog() {
val im = baseActivity?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
if (im != null && window != null) {
im.hideSoftInputFromWindow(window?.decorView?.windowToken, 0)
}
}

override fun onSyncStart() {
baseActivity?.onSyncStart()
}

override fun onSyncFinish() {
baseActivity?.onSyncFinish()
}

override fun onSyncSuccess(responseCode: Int, responseMessage: String, responseUrl: String, response: String?) {

}

override fun onSyncFailure(errorCode: Int, t: Throwable?, response: Response<String>?, call: Call<String>?, callBack: Callback<String>?) {
baseActivity!!.onSyncFailure(errorCode, t, response, call, callBack)
}

override fun onCheckedChanged(buttonView: CompoundButton, isChecked: Boolean) {

}


fun showToast(msg: String) {
baseActivity?.showToast(msg)
}

fun showToastOne(s: String) {
baseActivity?.showToastOne(s)
}


fun setOnDialogClickListener(onDialogClickListener: OnDialogClickListener) {
this.onDialogClickListener = onDialogClickListener
}

private var onDialogClickListener: OnDialogClickListener? = null

fun onDialogClick(vararg itemData: Any) {
if (onDialogClickListener != null) {
onDialogClickListener!!.onDialogClick(*itemData)
}
}

interface OnDialogClickListener {
fun onDialogClick(vararg itemData: Any)
}

fun errorHandle(jsonObject: JSONObject) {
if (jsonObject.has("error")) {
showToastOne(jsonObject.getString("error"))
}
}
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.