Skip to content

Commit

Permalink
Fix openMF#50 Rename variables to follow the general convention
Browse files Browse the repository at this point in the history
  • Loading branch information
yashk2000 committed Aug 29, 2020
1 parent 34c7f09 commit ae4dec2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class ClientSearchAdapter(var clientList: List<Client>, var context: Context, va
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val clientName: TextView? = view.client_name
val clientAccountNo: TextView? = view.client_account_no
private val linear_layout: LinearLayout? = view.client_search_row
private val linearLayout: LinearLayout? = view.client_search_row

fun setItem(item: Client, listener: (Client) -> Unit) {
linear_layout?.setOnClickListener { listener(item) }
linearLayout?.setOnClickListener { listener(item) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SelectedImageAdapter(private val items: ArrayList<Bitmap?>, val context: C
}

override fun onBindViewHolder(holder: SelectedImageViewHolder, position: Int) {
holder.selected_image_imageview?.setImageBitmap(items.get(position))
holder.selectedImageImageview?.setImageBitmap(items.get(position))
holder.setItem(position)
}

Expand All @@ -28,7 +28,7 @@ class SelectedImageAdapter(private val items: ArrayList<Bitmap?>, val context: C
}

inner class SelectedImageViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val selected_image_imageview: ImageView? = view.selected_image
val selectedImageImageview: ImageView? = view.selected_image
private val removeButton: ImageButton? = view.remove_button
fun setItem(position: Int) {
removeButton?.setOnClickListener { removeImage(position) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ open class BaseActivity : AppCompatActivity(), BaseActivityCallback {
* Used for setting title of Toolbar
* @param title String you want to display as title
*/
fun setActionBarTitle(title: String?) {
private fun setActionBarTitle(title: String?) {
if (supportActionBar != null && getTitle() != null) {
setTitle(title)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import org.mifos.visionppi.adapters.SelectedImageAdapter
class ComputerVisionActivity : AppCompatActivity(), ComputerVisionMVPView {

private val images = ArrayList<Bitmap?>()
private val PICK_FROM_GALLERY = 1
private val CAMERA_REQUEST = 2
private val MY_CAMERA_PERMISSION_CODE = 100
private val pickFromGallery = 1
private val cameraRequest = 2
private val myCameraPermissionCode = 100

private val labelList: MutableList<String> = ArrayList()

Expand Down Expand Up @@ -143,7 +143,7 @@ class ComputerVisionActivity : AppCompatActivity(), ComputerVisionMVPView {
ActivityCompat.requestPermissions(
this@ComputerVisionActivity,
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE),
PICK_FROM_GALLERY
pickFromGallery
)
} else {
val intent = Intent()
Expand All @@ -163,10 +163,10 @@ class ComputerVisionActivity : AppCompatActivity(), ComputerVisionMVPView {
override fun fetchFromCamera() {
try {
if (ActivityCompat.checkSelfPermission(applicationContext, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA), MY_CAMERA_PERMISSION_CODE)
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.CAMERA), myCameraPermissionCode)
} else {
val cameraIntent = Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(cameraIntent, CAMERA_REQUEST)
startActivityForResult(cameraIntent, cameraRequest)
}
} catch (e: Exception) {
e.printStackTrace()
Expand Down Expand Up @@ -233,7 +233,7 @@ class ComputerVisionActivity : AppCompatActivity(), ComputerVisionMVPView {
}
}

if (requestCode === CAMERA_REQUEST && resultCode === Activity.RESULT_OK) {
if (requestCode === cameraRequest && resultCode === Activity.RESULT_OK) {
val photoCaptured = data?.extras?.get("data") as Bitmap
images.add(photoCaptured)
selected_images_list.adapter = SelectedImageAdapter(images, this) { position: Int -> imageRemove(position) }
Expand All @@ -242,28 +242,28 @@ class ComputerVisionActivity : AppCompatActivity(), ComputerVisionMVPView {

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
when (requestCode) {
PICK_FROM_GALLERY ->
pickFromGallery ->
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
val galleryIntent =
Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
startActivityForResult(galleryIntent, PICK_FROM_GALLERY)
startActivityForResult(galleryIntent, pickFromGallery)
} else {
showToastMessage(getString(R.string.cant_open_gallery))
}
}

if (requestCode === MY_CAMERA_PERMISSION_CODE) {
if (requestCode === myCameraPermissionCode) {
if (grantResults[0] === PackageManager.PERMISSION_GRANTED) {
showToastMessage("Camera permission granted")
val cameraIntent = Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(cameraIntent, CAMERA_REQUEST)
startActivityForResult(cameraIntent, cameraRequest)
} else {
showToastMessage("Camera permission denied")
}
}
}

fun imageRemove(position: Int) {
private fun imageRemove(position: Int) {
images.removeAt(position)
selected_images_list.adapter = SelectedImageAdapter(images, this) { position: Int -> imageRemove(position) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UserProfilePresenter : BasePresenter<UserProfileMVPView>() {
fun fetchUserDetails(activity: Activity, context: Context): User {
val mPrefManager = PrefManager()
val sharedPref = activity.getSharedPreferences(context.getString(R.string.pref_file_name), Context.MODE_PRIVATE)
val userJsonString = sharedPref.getString(mPrefManager.USER_DETAILS, " ")
val userJsonString = sharedPref.getString(mPrefManager.userDetails, " ")

return gson.fromJson(userJsonString, User::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import org.mifos.visionppi.models.User

class PrefManager {

val USER_DETAILS = "user_details"
private val USERNAME = "username"
private val PASSWORD = "password"
val userDetails = "user_details"
private val username = "username"
private val password = "password"
private val gson: Gson = Gson()

private fun putString(preferenceKey: String, preferenceValue: String, activity: Activity, context: Context) {
Expand All @@ -29,12 +29,12 @@ class PrefManager {
}

fun saveUser(user: User, context: Context, activity: Activity) {
putString(USER_DETAILS, gson.toJson(user), activity, context)
putString(userDetails, gson.toJson(user), activity, context)
}

fun saveLoginCredentials(username: String, password: String, context: Context, activity: Activity) {
putString(USERNAME, username, activity, context)
putString(PASSWORD, password, activity, context)
putString(this.username, username, activity, context)
putString(this.password, password, activity, context)
}

fun clear(activity: Activity, context: Context) {
Expand Down

0 comments on commit ae4dec2

Please sign in to comment.