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
package com.malwinder.kotlindemo.recyclerview | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.annotation.LayoutRes | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.LinearLayoutManager | |
import androidx.recyclerview.widget.ListAdapter | |
import androidx.recyclerview.widget.RecyclerView |
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
package com.malwinder.kotlindemo.preference | |
import android.app.Application | |
import android.content.Context | |
import android.content.SharedPreferences | |
import com.google.gson.GsonBuilder | |
/** | |
* Singleton class for managing preferences for POJO or model class's object. | |
* @author Malwinder Singh |
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 launchStudentDetailsActivity(id: String, name: String, totalScore: Int) { | |
val intent = Intent(this, StudentDetailsActivity::class.java) | |
intent.replaceExtras(getExtras(id, name, totalScore)) | |
startActivity(intent) | |
} | |
private fun launchStudentEditorActivity(id: String, name: String, totalScore: Int) { | |
val intent = Intent(this, StudentEditorActivity::class.java) | |
intent.replaceExtras(getExtras(id, name, totalScore)) | |
startActivity(intent) |
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 launch(id: String, name: String, totalScore: Int, className: Class) { | |
val intent = Intent(this, className) | |
intent.replaceExtras(getExtras(id, name, totalScore)) | |
startActivity(intent) | |
} | |
private fun getExtras(id: String, name: String, totalScore: Int): Bundle { | |
val extras = Bundle() | |
extras.putString(EXTRA_STUDENT_ID, id) | |
extras.putString(EXTRA_STUDENT_NAME, name) |
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 launchStudentDetailsActivity(id: String, name: String, totalScore : Int) { | |
val intent = Intent(this, StudentDetailsActivity::class.java) | |
intent.putExtra(EXTRA_STUDENT_ID, id) | |
intent.putExtra(EXTRA_STUDENT_NAME, name) | |
//Suppose "totalScore" is score of student in 5 subjects. | |
val totalPercentage = totalScore / 5 | |
intent.putExtra(EXTRA_STUDENT_PERCENTAGE, totalPercentage) | |
startActivity(intent) |