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
class VPMainAdapter : RecyclerView.Adapter<VPMainAdapter.MyViewHolder>() { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { | |
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. | |
} | |
override fun getItemCount(): Int { | |
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. | |
} | |
override fun onBindViewHolder(holder: MyViewHolder, position: Int) { |
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
class VPMainAdapter(var data:ArrayList<PageModel>) : RecyclerView.Adapter<VPMainAdapter.MyViewHolder>() { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder { | |
return MyViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.vp_item, parent,false)) | |
} | |
override fun getItemCount(): Int { | |
return data.size | |
} | |
override fun onBindViewHolder(holder: MyViewHolder, position: Int) { |
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
class MainActivity : AppCompatActivity() { | |
val data: ArrayList<PageModel> = ArrayList() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
prepareData() | |
prepareViewPager() | |
} |
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
try{ | |
$device = new DeviceKey(); | |
$device->user_id = $user->id; | |
$device->device_key = request('device_key'); | |
$device->save(); | |
}catch(QueryException $e){} |
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
private fun getRetrofit(c: Context): Retrofit { | |
val pref = c.getSharedPreferences(SharedKey.Session.SESSION, MODE_PRIVATE) | |
val client = OkHttpClient.Builder().addInterceptor { chain -> | |
val newRequest = chain.request().newBuilder() | |
.addHeader("Authorization", "Bearer " + pref.getString(SharedKey.Session.TOKEN, "")!!) | |
.build() | |
chain.proceed(newRequest) | |
}.build() | |
return Retrofit.Builder().baseUrl(baseUrl).client(client).addConverterFactory( |
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
object Request{ | |
suspend fun login(context:Context, email:String, password:String, token:String):UserModel?{ | |
val api = getApiService(context) | |
val request = api.login(email, password, token) | |
return try{ | |
return request.await().body()!! | |
}catch (e: Exception){ | |
Log.e("TAG", "Login Failed" + e.message) | |
null | |
} |
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
private fun doUpload(fileToUpload: MultipartBody.Part) { | |
uploadJob = CoroutineScope(Dispatchers.IO).launch { | |
val result = Request.uploadImg(baseContext, fileToUpload) | |
withContext(Dispatchers.Main) { | |
if (result.result == true) onSucceed(result) | |
} | |
} | |
} |
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
if (data[i].value != null) { | |
Glide.with(c).load(data[i].value).apply( | |
RequestOptions() | |
.placeholder(R.drawable.loading) | |
.fitCenter() | |
).into(myViewHolder.itemView.img_thumbnail) | |
myViewHolder.itemView.img_thumbnail.setOnClickListener { | |
var i = Intent(c, ImageActivity::class.java) | |
i.putExtra(SharedKey.App.ID, data[myViewHolder.adapterPosition].value) |
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
v.img_icon.run { | |
when(data[i].permissionTypeId){ | |
1 -> setImageDrawable(ContextCompat.getDrawable(c, R.drawable.ic_plus)) | |
2 -> setImageDrawable(ContextCompat.getDrawable(c, R.drawable.ic_permission_green)) | |
3 -> setImageDrawable(ContextCompat.getDrawable(c, R.drawable.ic_clock_orange)) | |
} | |
} | |
v.tv_status.run{ | |
when(data[i].statusId){ |
OlderNewer