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
# Git Commit standards | |
## _For better understanding & reviews_ | |
Here im suggesting a useful way for writing better commit messages. Set your commit message template to: | |
download this template and save as ~/.git_commit_msg.txt | |
https://gist.github.com/januprasad/76bbde852fd1f943eb486de2848a0772 | |
then run this command in your terminal | |
git config --global commit.template ~/.git_commit_msg.txt |
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
<receiver | |
android:name=".AlarmReceiver" | |
android:enabled="true" | |
android:exported="false" /> |
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 AlarmReceiver : BroadcastReceiver() { | |
override fun onReceive(context: Context, intent: Intent) { | |
// This method is called when the BroadcastReceiver is receiving an Intent broadcast. | |
val notificationUtils = NotificationUtils(context) | |
val notification = notificationUtils.getNotificationBuilder().build() | |
notificationUtils.getManager().notify(150, notification) | |
} | |
} |
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 NotificationUtils(base: Context) : ContextWrapper(base) { | |
val MYCHANNEL_ID = "App Alert Notification ID" | |
val MYCHANNEL_NAME = "App Alert Notification" | |
private var manager: NotificationManager? = null | |
init { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
createChannels() |
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 startAlarm(calendar: Calendar) { | |
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager | |
val intent = Intent(this, AlarmReceiver::class.java) | |
val pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0) | |
alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.timeInMillis, pendingIntent) | |
} |
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
override fun onTimeSet(timePicker: TimePicker?, hour: Int, minute: Int) { | |
val calendar = Calendar.getInstance() | |
calendar.set(Calendar.HOUR_OF_DAY, hour) | |
calendar.set(Calendar.MINUTE, minute) | |
calendar.set(Calendar.SECOND, 0) | |
startAlarm(calendar) | |
} |
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() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
} | |
} |
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 TimePickerFragment : DialogFragment() { | |
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
// Use the current time as the default values for the picker | |
val calendar: Calendar = Calendar.getInstance() | |
val hour = calendar.get(Calendar.HOUR) | |
val minute = calendar.get(Calendar.MINUTE) | |
/** Create a new instance of TimePickerDialog and return it |
NewerOlder