Browse Source

Обновить 'Памятка.txt'

Talengek9984 3 years ago
parent
commit
da6af60429
1 changed files with 226 additions and 217 deletions
  1. 226 217
      Памятка.txt

+ 226 - 217
Памятка.txt

@@ -1,217 +1,226 @@
- lateinit var bindingClass: ActivitySignInScreenBinding
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        bindingClass = ActivitySignInScreenBinding.inflate(layoutInflater)
-        setContentView(bindingClass.root)
-
-        // Run volley
-        bindingClass.bSingin.setOnClickListener {
-            val url = "http://smarthome.madskill.ru/auth/user"
-
-            // Post parameters
-            // Form fields and values
-            val params = HashMap<String,String>()
-            params.put("email", "vasya@mail.com")
-            params.put("password", "qwerty")
-            params.put("uuid", "5FA1B987-3890-4A87-9712-ACDEAD0173AE")
-            params.put("hash", "5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9")
-            val jsonObject = (params as Map<*, *>?)?.let { it1 -> JSONObject(it1) }
-
-
-
-            // Volley post request with parameters
-            val request = JsonObjectRequest(Request.Method.OPTIONS,url,jsonObject,
-                { response ->
-                    // Process the json
-                    try {
-                        Log.d("tag1","Response: $response" )
-
-                    }catch (e:Exception){
-                        bindingClass.textView.text = "Exception: $e"
-                    }
-
-                }, {
-                    // Error in request
-                    Log.d("tag1","Volley error: $it")
-                })
-
-
-            // Volley request policy, only one time request to avoid duplicate transaction
-            request.retryPolicy = DefaultRetryPolicy(
-                DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
-                // 0 means no retry
-                0, // DefaultRetryPolicy.DEFAULT_MAX_RETRIES = 2
-                1f // DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
-            )
-
-            // Add the volley post request to the request queue
-            VolleySingleton.getInstance(this).addToRequestQueue(request)
-        }
-    }
-}
-
-
-
-.....................................................................................
-
-
-
-
-import android.content.Context
-import com.android.volley.Request
-import com.android.volley.RequestQueue
-import com.android.volley.toolbox.Volley
-
-
-class VolleySingleton constructor(context: Context) {
-    companion object {
-        @Volatile
-        private var INSTANCE: VolleySingleton? = null
-        fun getInstance(context: Context) =
-            INSTANCE ?: synchronized(this) {
-                INSTANCE ?: VolleySingleton(context).also {
-                    INSTANCE = it
-                }
-            }
-    }
-
-    private val requestQueue: RequestQueue by lazy {
-        // applicationContext is key, it keeps you from leaking the
-        // Activity or BroadcastReceiver if someone passes one in.
-        Volley.newRequestQueue(context.applicationContext)
-    }
-
-    fun <T> addToRequestQueue(req: Request<T>) {
-        requestQueue.add(req)
-    }
-}
-
-
-
-
-
-....................................................................................
-
-
-
-
-
-var start:Boolean=true
-        Thread{
-            while (start){
-                Thread.sleep(5000)
-                runOnUiThread {
-                    val intent = Intent(this, MainActivity2::class.java)
-                    startActivity(intent)
-                }
-                start = false
-            }
-        }.start()
-    }
-
-
-
-...................................................................................
-
-
-
-
-    lateinit var bindingClass:ActivityMainBinding
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        bindingClass = ActivityMainBinding.inflate(layoutInflater)
-        setContentView(bindingClass.root)
-
-
-        bindingClass.imageView1.animate().setDuration(4500).rotationBy(360f).start()
-
-        // Run volley
-            val url = "http://smarthome.madskill.ru/app"
-
-            // Post parameters
-            // Form fields and values
-            val params= HashMap<String,String>()
-            params.put("appId", "com.example.myapplication")
-            params.put("competitor", "Competitor-1")
-
-            val jsonObject = JSONObject(params.toString())
-
-
-
-            val request = JsonObjectRequest(Request.Method.POST,url,jsonObject,
-                { response->
-                    // Process the json
-                    try {
-                        Log.d("tag1","Response: $response")
-
-
-                    }catch (e:Exception){
-                        Log.d("tag1","Exception: $e")
-                    }
-
-                }, {
-                    // Error in request
-                    Log.d("tag1","Volley error: $it")
-                })
-
-
-            // Volley request policy, only one time request to avoid duplicate transaction
-            request.retryPolicy = DefaultRetryPolicy(
-                DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
-                // 0 means no retry
-                0, // DefaultRetryPolicy.DEFAULT_MAX_RETRIES = 2
-                1f // DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
-            )
-
-            // Add the volley post request to the request queue
-            VolleySingleton.getInstance(this).addToRequestQueue(request)
-
-
-
-        var start_acty = true
-        Thread{
-            while (start_acty){
-                Thread.sleep(5000)
-                runOnUiThread{
-                    val intent = Intent(this, SignIn_Screen::class.java)
-                    startActivity(intent)
-                }
-                start_acty = false
-            }
-        }.start()
-    }
-
-....................................................................................
-
-
-
-                    val toast = Toast.makeText(applicationContext,
-                        "Текст",
-                        Toast.LENGTH_SHORT)
-                    toast.setGravity(Gravity.CENTER, 0, 0)
-                    toast.show()
-
-...................................................................................
-
-
-
-    <uses-permission android:name="android.permission.INTERNET"/>
-
-
-..................................................................................
-
-
-
-buildFeatures{
-        viewBinding true
-    }
-}
-
-dependencies {
-
-    implementation 'com.android.volley:volley:1.2.1'
-
-.................................................................................
-
-
-
+ lateinit var bindingClass: ActivitySignInScreenBinding
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        bindingClass = ActivitySignInScreenBinding.inflate(layoutInflater)
+        setContentView(bindingClass.root)
+
+        // Run volley
+        bindingClass.bSingin.setOnClickListener {
+            val url = "http://smarthome.madskill.ru/auth/user"
+
+            // Post parameters
+            // Form fields and values
+            val params = HashMap<String,String>()
+            params.put("email", "vasya@mail.com")
+            params.put("password", "qwerty")
+            params.put("uuid", "5FA1B987-3890-4A87-9712-ACDEAD0173AE")
+            params.put("hash", "5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9")
+            val jsonObject = (params as Map<*, *>?)?.let { it1 -> JSONObject(it1) }
+
+
+
+            // Volley post request with parameters
+            val request = JsonObjectRequest(Request.Method.OPTIONS,url,jsonObject,
+                { response ->
+                    // Process the json
+                    try {
+                        Log.d("tag1","Response: $response" )
+
+                    }catch (e:Exception){
+                        bindingClass.textView.text = "Exception: $e"
+                    }
+
+                }, {
+                    // Error in request
+                    Log.d("tag1","Volley error: $it")
+                })
+
+
+            // Volley request policy, only one time request to avoid duplicate transaction
+            request.retryPolicy = DefaultRetryPolicy(
+                DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
+                // 0 means no retry
+                0, // DefaultRetryPolicy.DEFAULT_MAX_RETRIES = 2
+                1f // DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
+            )
+
+            // Add the volley post request to the request queue
+            VolleySingleton.getInstance(this).addToRequestQueue(request)
+        }
+    }
+}
+
+
+
+.....................................................................................
+
+
+
+
+import android.content.Context
+import com.android.volley.Request
+import com.android.volley.RequestQueue
+import com.android.volley.toolbox.Volley
+
+
+class VolleySingleton constructor(context: Context) {
+    companion object {
+        @Volatile
+        private var INSTANCE: VolleySingleton? = null
+        fun getInstance(context: Context) =
+            INSTANCE ?: synchronized(this) {
+                INSTANCE ?: VolleySingleton(context).also {
+                    INSTANCE = it
+                }
+            }
+    }
+
+    private val requestQueue: RequestQueue by lazy {
+        // applicationContext is key, it keeps you from leaking the
+        // Activity or BroadcastReceiver if someone passes one in.
+        Volley.newRequestQueue(context.applicationContext)
+    }
+
+    fun <T> addToRequestQueue(req: Request<T>) {
+        requestQueue.add(req)
+    }
+}
+
+
+
+
+
+....................................................................................
+
+
+
+
+
+var start:Boolean=true
+        Thread{
+            while (start){
+                Thread.sleep(5000)
+                runOnUiThread {
+                    val intent = Intent(this, MainActivity2::class.java)
+                    startActivity(intent)
+                }
+                start = false
+            }
+        }.start()
+    }
+
+
+
+...................................................................................
+
+
+
+
+    lateinit var bindingClass:ActivityMainBinding
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        bindingClass = ActivityMainBinding.inflate(layoutInflater)
+        setContentView(bindingClass.root)
+
+
+        bindingClass.imageView1.animate().setDuration(4500).rotationBy(360f).start()
+
+        // Run volley
+            val url = "http://smarthome.madskill.ru/app"
+
+            // Post parameters
+            // Form fields and values
+            val params= HashMap<String,String>()
+            params.put("appId", "com.example.myapplication")
+            params.put("competitor", "Competitor-1")
+
+            val jsonObject = JSONObject(params.toString())
+
+
+
+            val request = JsonObjectRequest(Request.Method.POST,url,jsonObject,
+                { response->
+                    // Process the json
+                    try {
+                        Log.d("tag1","Response: $response")
+
+
+                    }catch (e:Exception){
+                        Log.d("tag1","Exception: $e")
+                    }
+
+                }, {
+                    // Error in request
+                    Log.d("tag1","Volley error: $it")
+                })
+
+
+            // Volley request policy, only one time request to avoid duplicate transaction
+            request.retryPolicy = DefaultRetryPolicy(
+                DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
+                // 0 means no retry
+                0, // DefaultRetryPolicy.DEFAULT_MAX_RETRIES = 2
+                1f // DefaultRetryPolicy.DEFAULT_BACKOFF_MULT
+            )
+
+            // Add the volley post request to the request queue
+            VolleySingleton.getInstance(this).addToRequestQueue(request)
+
+
+
+        var start_acty = true
+        Thread{
+            while (start_acty){
+                Thread.sleep(5000)
+                runOnUiThread{
+                    val intent = Intent(this, SignIn_Screen::class.java)
+                    startActivity(intent)
+                }
+                start_acty = false
+            }
+        }.start()
+    }
+
+....................................................................................
+
+
+
+                    val toast = Toast.makeText(applicationContext,
+                        "Текст",
+                        Toast.LENGTH_SHORT)
+                    toast.setGravity(Gravity.CENTER, 0, 0)
+                    toast.show()
+
+...................................................................................
+
+
+
+    <uses-permission android:name="android.permission.INTERNET"/>
+
+
+..................................................................................
+
+
+
+buildFeatures{
+        viewBinding true
+    }
+}
+
+dependencies {
+
+    implementation 'com.android.volley:volley:1.2.1'
+
+.................................................................................
+
+
+val qwe = Intent(this, MainActivity3::class.java)
+                        qwe.putExtra("token", bindingClass.textView.text.toString())
+                        
+val token = intent.getStringExtra("token").toString()
+                        bindingClass.textView5.text = token
+                        
+      
+................................................................................
+
+