How to use httpGet method of com.example.fuel.MainActivity class

Best Fuel code snippet using com.example.fuel.MainActivity.httpGet

ToiletDetails.kt

Source:ToiletDetails.kt Github

copy

Full Screen

2import android.support.v7.app.AppCompatActivity3import android.os.Bundle4import android.provider.Settings5import android.view.View6import com.github.kittinunf.fuel.httpGet7import com.github.kittinunf.fuel.json.responseJson8import android.os.VibrationEffect9import android.os.Build10import android.content.Context.VIBRATOR_SERVICE11import android.os.Vibrator12import android.widget.*13import java.util.*14class ToiletDetails : AppCompatActivity() {15 val timer = Timer()16 val toiletID: String by lazy {17 intent.getStringExtra("toiletID")18 }19 val androidID: String by lazy {20 Settings.Secure.getString(baseContext.getContentResolver(), Settings.Secure.ANDROID_ID)21 }22 val spinner: FrameLayout by lazy {23 findViewById<FrameLayout>(R.id.progressBarHolder);24 }25 override fun onCreate(savedInstanceState: Bundle?) {26 super.onCreate(savedInstanceState)27 setContentView(R.layout.activity_toilet_details)28 val activity = this29 spinner.visibility = View.VISIBLE30 runOnUiThread {31 activity.reloadDetails(true)32 }33 timer.scheduleAtFixedRate(object: TimerTask() {34 override fun run() {35 runOnUiThread(object : Runnable {36 override fun run() {37 activity.reloadDetails()38 }39 })40 }41 }, 5000, 5000)42 activity.findViewById<Button>(R.id.reservationButton).setOnClickListener {43 runOnUiThread {44 val uri = MainActivity.BASE_URI + "register/" + toiletID + "/andoid/" + androidID45 uri.httpGet().responseJson { request, response, result ->46 if (response.statusCode != 200) {47 activity.runOnUiThread {48 Toast.makeText(baseContext, "Problem z zapisaniem", Toast.LENGTH_SHORT).show()49 }50 } else {51 runOnUiThread {52 spinner.visibility = View.VISIBLE53 reloadDetails(true)54 }55 }56 }57 }58 }59 activity.findViewById<Button>(R.id.goOutButton).setOnClickListener {60 runOnUiThread {61 val uri = MainActivity.BASE_URI + "unregister/" + toiletID + "/andoid/" + androidID62 uri.httpGet().responseJson { request, response, result ->63 if (response.statusCode != 200) {64 activity.runOnUiThread {65 Toast.makeText(baseContext, "Problem z zapisaniem", Toast.LENGTH_SHORT).show()66 }67 } else {68 runOnUiThread {69 spinner.visibility = View.VISIBLE70 reloadDetails(true)71 }72 }73 }74 }75 }76 activity.findViewById<Button>(R.id.dirtButton).setOnClickListener {77 runOnUiThread {78 val uri = MainActivity.BASE_URI + "dirt/" + toiletID79 uri.httpGet().responseJson { request, response, result ->80 if (response.statusCode != 200) {81 activity.runOnUiThread {82 Toast.makeText(baseContext, "Problem z zapisaniem", Toast.LENGTH_SHORT).show()83 }84 } else {85 runOnUiThread {86 spinner.visibility = View.VISIBLE87 reloadDetails(true)88 }89 }90 }91 }92 }93 activity.findViewById<Button>(R.id.cleanButton).setOnClickListener {94 runOnUiThread {95 val uri = MainActivity.BASE_URI + "clean/" + toiletID96 uri.httpGet().responseJson { request, response, result ->97 if (response.statusCode != 200) {98 activity.runOnUiThread {99 Toast.makeText(baseContext, "Problem z zapisaniem", Toast.LENGTH_SHORT).show()100 }101 } else {102 runOnUiThread {103 spinner.visibility = View.VISIBLE104 reloadDetails(true)105 }106 }107 }108 }109 }110 activity.findViewById<Button>(R.id.acceptButton).setOnClickListener {111 runOnUiThread {112 val uri = MainActivity.BASE_URI + "accept/" + toiletID + "/andoid/" + androidID113 uri.httpGet().responseJson { request, response, result ->114 if (response.statusCode != 200) {115 activity.runOnUiThread {116 Toast.makeText(baseContext, "Problem z zapisaniem", Toast.LENGTH_SHORT).show()117 }118 } else {119 runOnUiThread {120 spinner.visibility = View.VISIBLE121 reloadDetails(true)122 }123 }124 }125 }126 }127 }128 override fun onDestroy() {129 super.onDestroy()130 timer.cancel()131 }132 private fun reloadDetails(spinnerChange: Boolean = false)133 {134 runOnUiThread {135 val uri = MainActivity.BASE_URI + "details/" + toiletID136 val activity = this137 uri.httpGet().responseJson { request, response, result ->138 runOnUiThread {139 if (response.statusCode != 200) {140 activity.runOnUiThread {141 Toast.makeText(baseContext, "Problem z pobraniem listy ", Toast.LENGTH_SHORT).show()142 }143 } else {144 val details = result.get().obj().getJSONObject("detail")145 val reservations = result.get().obj().getJSONArray("reservations")146 activity.title = details.getString("name")147 if (reservations.length() == 0) {148 activity.findViewById<TextView>(R.id.queue).text = "Brak osób w kolejce"149 } else {150 activity.findViewById<TextView>(R.id.queue).text =151 "W kolejce " + reservations.length() + " świnki"...

Full Screen

Full Screen

EditTradeActivity.kt

Source:EditTradeActivity.kt Github

copy

Full Screen

...13import com.example.kalepa.models.Product14import com.example.kalepa.models.RawProduct15import com.example.kalepa.models.Trade16import com.github.kittinunf.fuel.android.extension.responseJson17import com.github.kittinunf.fuel.httpGet18import com.github.kittinunf.fuel.httpPost19import com.github.kittinunf.fuel.httpPut20import com.github.kittinunf.result.Result21import kotlinx.android.synthetic.main.activity_edit_trade.*22import org.jetbrains.anko.toast23import org.json.JSONArray24import org.json.JSONObject25class EditTradeActivity : AppCompatActivity() {26 private var products = ArrayList<RawProduct>()27 private var productIds = ArrayList<String>()28 private var product = Product()29 val trade: Trade by extra(TRADE_ARG)30 override fun onCreate(savedInstanceState: Bundle?) {31 super.onCreate(savedInstanceState)32 setContentView(R.layout.activity_edit_trade)33 n_recyclerView_edit_trade_products.layoutManager = GridLayoutManager(this, 1)34 n_swipeRefreshView_edit_trade_products.setOnRefreshListener {35 products.clear()36 loadProducts()37 n_swipeRefreshView_edit_trade_products.isRefreshing = false38 }39 loadProducts()40 }41 private fun loadProducts() {42 val builder = AlertDialog.Builder(this)43 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)44 val message = dialogView.findViewById<TextView>(R.id.message)45 message.text = "Cargando productos..."46 builder.setView(dialogView)47 builder.setCancelable(false)48 val dialog = builder.create()49 dialog.show()50 val url = MainActivity().projectURL + "/products/" + SharedApp.prefs.userId.toString()51 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))52 req.responseJson { request, response, result ->53 when (result) {54 is Result.Failure -> {55 dialog.dismiss()56 toast("Error cargando sus productos, intentelo de nuevo más tarde")57 }58 is Result.Success -> {59 Initialize(result.value)60 dialog.dismiss()61 }62 }63 }64 }65 private fun show(items: List<RawProduct>) {66 val categoryItemAdapters = items.map(this::createCategoryItemAdapter)67 n_recyclerView_edit_trade_products.adapter = MainListAdapter(categoryItemAdapters)68 }69 private fun createCategoryItemAdapter(product: RawProduct)70 = OfferAdapter(product,71 { updateIdList(product) } )72 private fun updateIdList(product: RawProduct){73 val p_id = product.id.toString()74 if (productIds.contains(p_id)) {75 productIds.remove(p_id)76 } else {77 productIds.add(p_id)78 }79 }80 private fun Initialize (jsonProducts: JSONObject) {81 val length = jsonProducts.get("length").toString().toInt()82 val list = jsonProducts.get("list")83 if (list is JSONArray){84 for (i in 0 until length) {85 var product = RawProduct()86 product.fromJSON(list.getJSONObject(i))87 products.add(product)88 }89 }90 show(products)91 n_edit_trade_buy_button.setOnClickListener {92 updateTrade()93 }94 val builder = AlertDialog.Builder(this)95 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)96 val message = dialogView.findViewById<TextView>(R.id.message)97 message.text = "Cargando productos..."98 builder.setView(dialogView)99 builder.setCancelable(false)100 val dialog = builder.create()101 dialog.show()102 val product_id: String? = trade.product_id.toString()103 val url = MainActivity().projectURL + "/product/" + product_id104 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))105 req.responseJson { request, response, result ->106 when (result) {107 is Result.Failure -> {108 dialog.dismiss()109 toast("Error cargando sus productos, intentelo de nuevo más tarde")110 }111 is Result.Success -> {112 product.fromJSON(result.value)113 dialog.dismiss()114 }115 }116 }117 }118 private fun updateTrade() {...

Full Screen

Full Screen

ProfileNotificationsFragment.kt

Source:ProfileNotificationsFragment.kt Github

copy

Full Screen

...17import com.example.kalepa.models.Notification18import com.example.kalepa.models.RawProduct19import com.github.kittinunf.fuel.android.extension.responseJson20import com.github.kittinunf.fuel.httpDelete21import com.github.kittinunf.fuel.httpGet22import com.github.kittinunf.result.Result23import kotlinx.android.synthetic.main.fragment_profile_notifications.*24import org.jetbrains.anko.support.v4.toast25import org.jetbrains.anko.toast26import org.json.JSONArray27import org.json.JSONObject28class ProfileNotificationsFragment: Fragment() {29 private var notifications = ArrayList<Notification>()30 companion object {31 fun newInstance(): ProfileNotificationsFragment {32 return ProfileNotificationsFragment()33 }34 }35 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =36 inflater.inflate(R.layout.fragment_profile_notifications, container, false)37 override fun onActivityCreated(savedInstanceState: Bundle?) {38 super.onActivityCreated(savedInstanceState)39 n_recyclerView_notifications.layoutManager = GridLayoutManager(context!!, 1)40 n_swipeRefreshView_notifications.setOnRefreshListener {41 notifications.clear()42 loadNotifications()43 n_swipeRefreshView_notifications.isRefreshing = false44 }45 loadNotifications()46 }47 private fun loadNotifications() {48 val builder = AlertDialog.Builder(context)49 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)50 val message = dialogView.findViewById<TextView>(R.id.message)51 message.text = "Cargando notificaciones..."52 builder.setView(dialogView)53 builder.setCancelable(false)54 val dialog = builder.create()55 dialog.show()56 val url = MainActivity().projectURL + "/notifications"57 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))58 req.responseJson { request, response, result ->59 when (result) {60 is Result.Failure -> {61 dialog.dismiss()62 toast("Error cargando notificaciones, intentelo de nuevo más tarde")63 }64 is Result.Success -> {65 Initialize(result.value)66 dialog.dismiss()67 }68 }69 }70 }71 private fun show(items: List<Notification>) {72 val categoryItemAdapters = items.map(this::createCategoryItemAdapter)73 n_recyclerView_notifications.adapter = MainListAdapter(categoryItemAdapters)74 }75 private fun createCategoryItemAdapter(notification: Notification)76 = NotificationAdapter(notification,77 { showProduct(notification) },78 { deleteNotification(notification) })79 private fun Initialize (jsonProducts: JSONObject) {80 val length = jsonProducts.get("length").toString().toInt()81 val list = jsonProducts.get("list")82 if (list is JSONArray){83 for (i in 0 until length) {84 var notification = Notification()85 notification.fromJSON(list.getJSONObject(i))86 notifications.add(notification)87 }88 }89 show(notifications)90 m_notifications_deleteAll.setOnClickListener {91 deleteAllNotifications()92 }93 }94 private fun showProduct(notification: Notification) {95 val builder = AlertDialog.Builder(context)96 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)97 val message = dialogView.findViewById<TextView>(R.id.message)98 message.text = "Cargando producto..."99 builder.setView(dialogView)100 builder.setCancelable(false)101 val dialog = builder.create()102 dialog.show()103 val url = MainActivity().projectURL + "/product/" + notification.product_id104 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))105 req.responseJson { request, response, result ->106 when (result) {107 is Result.Failure -> {108 toast("Error cargando el producto")109 }110 is Result.Success -> {111 Launch(result.value)112 dialog.dismiss()113 }114 }115 }116 }117 private fun Launch(jsonObject: JSONObject) {118 val product: RawProduct = RawProduct()...

Full Screen

Full Screen

SearchFragment.kt

Source:SearchFragment.kt Github

copy

Full Screen

...10import com.example.kalepa.Preferences.SharedApp11import com.example.kalepa.R12import com.example.kalepa.models.RawProduct13import com.github.kittinunf.fuel.android.extension.responseJson14import com.github.kittinunf.fuel.httpGet15import com.github.kittinunf.fuel.httpPost16import com.github.kittinunf.result.Result17import kotlinx.android.synthetic.main.fragment_search.*18import org.jetbrains.anko.support.v4.toast19import org.jetbrains.anko.toast20import org.json.JSONArray21import org.json.JSONObject22class SearchFragment: Fragment() {23 private var category: String = ""24 private var serverCategories = ArrayList<String>()25 companion object {26 fun newInstance(): SearchFragment {27 return SearchFragment()28 }29 }30 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =31 inflater.inflate(R.layout.fragment_search, container, false)32 override fun onActivityCreated(savedInstanceState: Bundle?) {33 super.onActivityCreated(savedInstanceState)34 val builder = AlertDialog.Builder(context!!)35 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)36 val message = dialogView.findViewById<TextView>(R.id.message)37 message.text = "Cargando..."38 builder.setView(dialogView)39 builder.setCancelable(false)40 val dialog = builder.create()41 dialog.show()42 val url = MainActivity().projectURL + "/categories"43 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))44 req.responseJson { request, response, result ->45 when (result) {46 is Result.Failure -> {47 toast("Error cargando categorías")48 dialog.dismiss()49 MainActivity.start(context!!)50 }51 is Result.Success -> {52 val jsonObject = result.value53 val aux = jsonObject.get("list").toString()54 val separate = aux.split("""(\",\")|(\[\")|(\"\])""".toRegex())55 serverCategories = ArrayList(separate.slice(IntRange(1,separate.size-2)))56 dialog.dismiss()57 }...

Full Screen

Full Screen

ChatListActivity.kt

Source:ChatListActivity.kt Github

copy

Full Screen

...11import com.example.kalepa.Preferences.SharedApp12import com.example.kalepa.models.Trade13import com.example.kalepa.models.User14import com.github.kittinunf.fuel.android.extension.responseJson15import com.github.kittinunf.fuel.httpGet16import com.github.kittinunf.result.Result17import kotlinx.android.synthetic.main.activity_chat_list.*18import org.jetbrains.anko.toast19import org.json.JSONArray20import org.json.JSONObject21class ChatListActivity : AppCompatActivity() {22 private var trades = ArrayList<Trade>()23 override fun onCreate(savedInstanceState: Bundle?) {24 super.onCreate(savedInstanceState)25 setContentView(R.layout.activity_chat_list)26 n_recyclerView_cl.layoutManager = GridLayoutManager(this, 1)27 n_swipeRefreshView_cl.setOnRefreshListener {28 trades.clear()29 loadTrades()30 n_swipeRefreshView_cl.isRefreshing = false31 }32 loadTrades()33 }34 private fun loadTrades() {35 val builder = AlertDialog.Builder(this)36 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)37 val message = dialogView.findViewById<TextView>(R.id.message)38 message.text = "Cargando intercambios..."39 builder.setView(dialogView)40 builder.setCancelable(false)41 val dialog = builder.create()42 dialog.show()43 val url = MainActivity().projectURL + "/trades"44 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))45 req.responseJson { request, response, result ->46 when (result) {47 is Result.Failure -> {48 dialog.dismiss()49 toast("Error cargando sus intercambios, intentelo de nuevo más tarde")50 }51 is Result.Success -> {52 Initialize(result.value)53 dialog.dismiss()54 }55 }56 }57 }58 private fun show(items: List<Trade>) {59 val categoryItemAdapters = items.map(this::createCategoryItemAdapter)60 n_recyclerView_cl.adapter = MainListAdapter(categoryItemAdapters)61 }62 private fun createCategoryItemAdapter(trade: Trade)63 = TradeAdapter(trade,64 { showTrade(trade) })65 private fun showTrade(trade: Trade) {66 ChatActivity.start(this, trade)67 }68 private fun Initialize (jsonProducts: JSONObject) {69 val builder = AlertDialog.Builder(this)70 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)71 val message = dialogView.findViewById<TextView>(R.id.message)72 message.text = "Cargando intercambios..."73 builder.setView(dialogView)74 builder.setCancelable(false)75 val dialog = builder.create()76 dialog.show()77 val length = jsonProducts.get("length").toString().toInt()78 val list = jsonProducts.get("list")79 if (list is JSONArray) {80 for (i in 0 until length) {81 var trade = Trade()82 trade.fromJSON(list.getJSONObject(i))83 trades.add(trade)84 }85 }86 if (list is JSONArray) {87 loadUsers(0, length, list)88 }89 dialog.dismiss()90 }91 private fun loadUsers(i: Int, lenght: Int, list: JSONArray) {92 if (i == lenght) {93 loadProducts(0,lenght,list)94 } else {95 var url: String96 if(trades[i].seller_id.equals(SharedApp.prefs.userId.toString())) {97 url = MainActivity().projectURL + "/user/" + trades[i].buyer_id98 } else {99 url = MainActivity().projectURL + "/user/" + trades[i].seller_id100 }101 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))102 req.responseJson { request, response, result ->103 when (result) {104 is Result.Success -> {105 val jsonUser = result.value106 trades[i].other_avatar = jsonUser.get("avatar").toString()107 trades[i].other_nick = jsonUser.get("nick").toString()108 loadUsers(i+1,lenght,list)109 }110 is Result.Failure -> {111 loadUsers(i+1,lenght,list)112 }113 }114 }115 }116 }117 private fun loadProducts(i: Int, lenght: Int, list: JSONArray) {118 if (i == lenght) {119 show(trades)120 } else {121 val url2 = MainActivity().projectURL + "/product/" + trades[i].product_id122 val req2 = url2.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))123 req2.responseJson { request, response, result ->124 when (result) {125 is Result.Success -> {126 val jsonProduct = result.value127 trades[i].product_img = jsonProduct.get("main_img").toString()128 loadProducts(i+1, lenght, list)129 }130 is Result.Failure -> {131 loadProducts(i+1, lenght, list)132 }133 }134 }135 }136 }...

Full Screen

Full Screen

ProfileCommentsFragment.kt

Source:ProfileCommentsFragment.kt Github

copy

Full Screen

...16import com.example.kalepa.R17import com.example.kalepa.models.Comment18import com.github.kittinunf.fuel.android.extension.responseJson19import com.github.kittinunf.fuel.httpDelete20import com.github.kittinunf.fuel.httpGet21import com.github.kittinunf.result.Result22import kotlinx.android.synthetic.main.fragment_profile_comments.*23import org.jetbrains.anko.support.v4.toast24import org.json.JSONArray25import org.json.JSONObject26class ProfileCommentsFragment: Fragment() {27 private var comments = ArrayList<Comment>()28 companion object {29 fun newInstance(user_id: Int): ProfileCommentsFragment {30 val myFragment = ProfileCommentsFragment()31 val args = Bundle()32 args.putInt("user_id", user_id)33 myFragment.arguments = args34 return myFragment35 }36 }37 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =38 inflater.inflate(R.layout.fragment_profile_comments, container, false)39 override fun onActivityCreated(savedInstanceState: Bundle?) {40 super.onActivityCreated(savedInstanceState)41 n_recyclerView_comments.layoutManager = GridLayoutManager(context!!, 1)42 n_swipeRefreshView_comments.setOnRefreshListener {43 comments.clear()44 loadComments()45 n_swipeRefreshView_comments.isRefreshing = false46 }47 loadComments()48 }49 private fun loadComments() {50 val user_id = arguments!!.getInt("user_id",0)51 val builder = AlertDialog.Builder(context)52 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)53 val message = dialogView.findViewById<TextView>(R.id.message)54 message.text = "Cargando comentarios..."55 builder.setView(dialogView)56 builder.setCancelable(false)57 val dialog = builder.create()58 dialog.show()59 val url = MainActivity().projectURL + "/comments/" + user_id.toString()60 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))61 req.responseJson { request, response, result ->62 when (result) {63 is Result.Failure -> {64 dialog.dismiss()65 toast("Error cargando notificaciones, intentelo de nuevo más tarde")66 }67 is Result.Success -> {68 Initialize(result.value)69 dialog.dismiss()70 }71 }72 }73 }74 private fun show(items: List<Comment>) {...

Full Screen

Full Screen

MainActivity.kt

Source:MainActivity.kt Github

copy

Full Screen

...5import android.os.Bundle6import android.view.View7import android.widget.EditText8import com.github.kittinunf.fuel.core.ResponseDeserializable9import com.github.kittinunf.fuel.httpGet10import com.github.kittinunf.fuel.json.responseJson11import com.github.kittinunf.result.Result12import com.github.kittinunf.fuel.gson.responseObject13class MainActivity : AppCompatActivity() {14 val EXTRA_MESSAGE: String = "com.example.emptyapp.MESSAGE"15 override fun onCreate(savedInstanceState: Bundle?) {16 super.onCreate(savedInstanceState)17 setContentView(R.layout.activity_main)18 }19 /* Sendボタン押下時 */20 fun sendMessage(view: View) {21 val intent: Intent = Intent(this@MainActivity,22 DisplayMessageActivity::class.java)23 val editText: EditText = findViewById(R.id.editText) as EditText24 val message: String = editText.text.toString()25 val args: Array<String> = arrayOf("green", "red", "blue")26 //val generateAddress : GenerateAddress? = main(args)27 //println("generateAddress:${generateAddress?.address}")28 //val result = getText("https://bsvnodeapi.herokuapp.com/generateaddress/test")29 //println(result)30 intent.putExtra(EXTRA_MESSAGE, message)31 startActivity(intent)32 }33// fun getText(url: String): String {34// val (_, _, result) = url.httpGet().responseString()35//36// return when (result) {37// is Result.Failure -> {38// println("failed")39// val ex = result.getException()40// println(ex.toString())41// ex.toString()42// }43// is Result.Success -> {44// result.get()45// }46// }47// }48// //https://www.yuulinux.tokyo/15220/49// data class GenerateAddress (50// var address: String,51// var privatekey_wif: String52// )53 54// fun main(args: Array<String>) : GenerateAddress? {55//// "https://www.yuulinux.tokyo/demo/bs-tender-server-mock/test.json".httpGet().responseObject<User> { req, res, result ->56//// val(user,err) = result57//// println("user:${user}")58//// }59// val generateAddress: GenerateAddress = GenerateAddress("", "")60// val httpAsync = "https://bsvnodeapi.herokuapp.com/generateaddress/test"61// .httpGet()62// .responseObject<GenerateAddress> { request, response, result ->63// when (result) {64// is Result.Failure -> {65// //val ex = result.getException()66// //println("failed request")67// //println(ex)68// //val(generateAddress,err) = result69// }70// is Result.Success -> {71//// val data = result.get()72//// val json = result.value.obj()73//// val results =json.get("results") as JSONArray74//// println("success request")75//// println(data)76// val(generateAddress,err) = result77// println("aaaagenerateaddress:${generateAddress}")78// generateAddress79// }80// }81// }82//83// //httpAsync.join()84// println(generateAddress.address)85// return null//httpAsync86// }87// fun main(args: Array<String>) {88//89// // 非同期処理90// val baseUrl = "https://bsvnodeapi.herokuapp.com"91// val generateAddressTest = baseUrl + "/generateaddress/test"92// "https://bsvnodeapi.herokuapp.com/generateaddress/test".httpGet().response { request, response, result ->93// when (result) {94// is Result.Success -> {95// // レスポンスボディを表示96// println("非同期処理の結果:" + String(response.data))97// }98// is Result.Failure -> {99// println("通信に失敗しました。")100// }101// }102// }103//104// // 同期処理105// val triple = "https://bsvnodeapi.herokuapp.com/generateaddress/test".httpGet().response()106// // レスポンスボディを表示107// println("同期処理の結果:" + String(triple.second.data))108//109// val triple1 = "https://www.casareal.co.jp/".httpGet().response()110// // レスポンスボディを表示111// println("同期処理の結果:" + String(triple1.second.data))112// }113}...

Full Screen

Full Screen

WishListFragment.kt

Source:WishListFragment.kt Github

copy

Full Screen

...15import com.example.kalepa.ProductBuyActivity16import com.example.kalepa.R17import com.example.kalepa.models.RawProduct18import com.github.kittinunf.fuel.android.extension.responseJson19import com.github.kittinunf.fuel.httpGet20import com.github.kittinunf.result.Result21import kotlinx.android.synthetic.main.fragment_wishlist.*22import org.jetbrains.anko.support.v4.toast23import org.json.JSONArray24import org.json.JSONObject25class WishListFragment: Fragment() {26 private var products = ArrayList<RawProduct>()27 companion object {28 fun newInstance(): WishListFragment {29 return WishListFragment()30 }31 }32 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? =33 inflater.inflate(R.layout.fragment_wishlist, container, false)34 override fun onActivityCreated(savedInstanceState: Bundle?) {35 super.onActivityCreated(savedInstanceState)36 n_recyclerView_wish.layoutManager = GridLayoutManager(context!!, 2)37 n_swipeRefreshView_wish.setOnRefreshListener {38 products.clear()39 loadProducts()40 n_swipeRefreshView_wish.isRefreshing = false41 }42 loadProducts()43 }44 private fun loadProducts() {45 val builder = AlertDialog.Builder(context)46 val dialogView = layoutInflater.inflate(R.layout.progress_dialog,null)47 val message = dialogView.findViewById<TextView>(R.id.message)48 message.text = "Cargando productos..."49 builder.setView(dialogView)50 builder.setCancelable(false)51 val dialog = builder.create()52 dialog.show()53 val url = MainActivity().projectURL + "/user/follows"54 val req = url.httpGet().header(Pair("Cookie", SharedApp.prefs.cookie))55 req.responseJson { request, response, result ->56 when (result) {57 is Result.Failure -> {58 dialog.dismiss()59 toast("Error cargando productos, intentelo de nuevo más tarde")60 }61 is Result.Success -> {62 Initialize(result.value)63 dialog.dismiss()64 }65 }66 }67 }68 private fun show(items: List<RawProduct>) {...

Full Screen

Full Screen

httpGet

Using AI Code Generation

copy

Full Screen

1 public void httpGet(View view) {2 public void success(Request request, Response response, String s) {3 Log.d("MainActivity", "httpGet: " + s);4 }5 public void failure(Request request, Response response, FuelError fuelError) {6 Log.e("MainActivity", "httpGet: " + fuelError);7 }8 });9 }10 * [Fuel](github.com/kittinunf/Fuel)11 * [Fuel Documentation](kittinunf.github.io/Fuel/)

Full Screen

Full Screen

httpGet

Using AI Code Generation

copy

Full Screen

1public void httpGet(View view) {2new Thread(new Runnable() {3public void run() {4HttpClient httpclient = new DefaultHttpClient();5InputStream inputStream = httpResponse.getEntity().getContent();6if(inputStream != null)7result = convertInputStreamToString(inputStream);8result = "Did not work!";9}10}).start();11}12public void httpPost(View view) {13new Thread(new Runnable() {14public void run() {15HttpClient httpclient = new DefaultHttpClient();16String json = "";17try {18json = jsonObject.toString();19StringEntity se = new StringEntity(json);20httpPost.setEntity(se);21httpPost.setHeader("Accept", "application/json");22httpPost.setHeader("Content-type", "application/json");23HttpResponse httpResponse = httpclient.execute(httpPost);24InputStream inputStream = httpResponse.getEntity().getContent();25if(inputStream != null)26result = convertInputStreamToString(inputStream);27result = "Did not work!";28} catch (Exception e) {29Log.d("InputStream", e.getLocalizedMessage());30}31}32}).start();33}34public void httpPut(View view) {35new Thread(new Runnable() {36public void run() {37HttpClient httpclient = new DefaultHttpClient();38String json = "";39try {40json = jsonObject.toString();41StringEntity se = new StringEntity(json);42httpPut.setEntity(se);

Full Screen

Full Screen

httpGet

Using AI Code Generation

copy

Full Screen

1 Log.d("http-activity", result.toString())2 }3 }4 override fun onCreate(savedInstanceState: Bundle?) {5 super.onCreate(savedInstanceState)6 setContentView(R.layout.activity_main)7 }8}

Full Screen

Full Screen

httpGet

Using AI Code Generation

copy

Full Screen

1 public void httpGet(View view) {2 MainActivity.httpGet(url);3 }4 public void httpPost(View view) {5 MainActivity.httpPost(url);6 }7 public void httpDelete(View view) {8 MainActivity.httpDelete(url);9 }10 public void httpPut(View view) {11 MainActivity.httpPut(url);12 }13}14package com.example.fuel;15import android.app.Activity;16import android.content.Intent;17import android.content.pm.PackageManager;18import android.os.Build;19import android.support.v4.app.ActivityCompat;20import android.support.v7.app.AppCompatActivity;21import android.os.Bundle;22import android.util.Log;23import android.view.View;24import android.widget.TextView;25import com.github.kittinunf.fuel.Fuel;26import com.github.kittinunf.fuel.core.FuelError;27import com.github.kittinunf.fuel.core.Method;28import com.github.kittinunf.fuel.core.Request;29import com.github.kittinunf.fuel.core.Response;30import com.github.kittinunf.fuel.core.requests.DownloadRequest;31import com.github.kittinunf.fuel.core.requests.UploadRequest;32import com.github.kittinunf.fuel.core.requests.cUrlRequest;33import com.github.kittinunf.fuel.core.requests.request;34import com.github.kittinunf.fuel.core.requests.streamRequest;35import com.github.kittinunf.fuel.core.requests.taskRequest;36import com.github.kittinunf.result.Result;37import java.io.File;38import java.io

Full Screen

Full Screen

httpGet

Using AI Code Generation

copy

Full Screen

1 display.setText(content);2 }3 });4 }5}6package com.example.fuel;7import java.io.BufferedReader;8import java.io.IOException;9import java.io.InputStream;10import java.io.InputStreamReader;11import java.net.HttpURLConnection;12import java.net.URL;13import java.net.URLConnection;14import android.app.Activity;15import android.os.Bundle;16import android.util.Log;17import android.widget.TextView;18public class MainActivity extends Activity {19 public void onCreate(Bundle savedInstanceState) {20 super.onCreate(savedInstanceState);21 setContentView(R.layout.activity_main);22 }23 public static String httpGet(String urlStr) {24 try {25 URL url = new URL(urlStr);26 URLConnection conn = url.openConnection();27 HttpURLConnection httpConn = (HttpURLConnection) conn;28 httpConn.setRequestMethod("GET");29 httpConn.connect();30 if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {31 InputStream in = httpConn.getInputStream();32 BufferedReader br = new BufferedReader(new InputStreamReader(in));33 String line;34 StringBuilder sb = new StringBuilder();35 while ((line = br.readLine()) != null) {36 sb.append(line);37 }38 return sb.toString();39 }40 } catch (IOException e) {41 Log.d("MainActivity", e.toString());42 }43 return null;44 }45}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful