Skip to content

Instantly share code, notes, and snippets.

@kingjinho
kingjinho / FragmentActivity.kt
Last active November 30, 2022 12:02
FragmentActivity
public class FragmentActivity extends ComponentActivity implements
ActivityCompat.OnRequestPermissionsResultCallback,
ActivityCompat.RequestPermissionsRequestCodeValidator {
...
final FragmentController mFragments = FragmentController.createController(new HostCallbacks());
...
@kingjinho
kingjinho / FragmentContainerView.kt
Last active November 30, 2022 11:31
Contructor of FragmentContainerView
//생성자
internal constructor(
context: Context,
attrs: AttributeSet,
fm: FragmentManager
) : super(context, attrs) {
//생략된 부분에서 이름과 태그를 체크합니다.
...
@kingjinho
kingjinho / activity.xml
Last active November 23, 2022 12:52
기본적인?(보편적인) activity.xml 레이아웃 구조
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
... >
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomnav"
...
app:menu="@menu/bottom_nav_menu" />
@kingjinho
kingjinho / readme.md
Created December 14, 2021 12:56
Find drawdowns

Thanks for reading my stackoverflow questions! Happy Early New 2022!!! :)))))))

class Drawdown {
    var peak: Quote? = null
    var trough: Quote? = null
    var recovered: Quote? = null
    var percentage: Double? = null
    var daysToRecover: String? = null
}
fun setActionButton(btnTitle: String): NotificationBuilder {
val intent = Intent(CONTEXT, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
val pendingIntent = PendingIntent.getActivity(CONTEXT, 0, intent, 0)
mNotificationBuilder.addAction(R.drawable.ic_launcher_playstore, btnTitle, pendingIntent)
return this
}
fun setBlockOfText(blockOfText: String): NotificationBuilder {
mNotificationBuilder.setStyle(
NotificationCompat.BigTextStyle()
//.setBigContentTitle("this is big content title") overrides setContentTitle()
//.setSummaryText("this is summary text") right next to app name
.bigText(blockOfText)
)
return this
}
fun setLargeIcon(largeIconRes: Int): NotificationBuilder {
val bitmap = BitmapFactory.decodeResource(CONTEXT.resources, largeIconRes)
mNotificationBuilder.setLargeIcon(bitmap)
return this
}
private NotificationManagerCompat(Context context) {
 mContext = context;
 mNotificationManager = (NotificationManager) mContext.getSystemService(
 Context.NOTIFICATION_SERVICE);
}
@kingjinho
kingjinho / NotificationCompat.kt
Created July 23, 2020 12:43
NotifcationCompat.kt
/**
* Compatibility library for NotificationManager with fallbacks for older platforms.
*
* <p>To use this class, call the static function {@link #from} to get a
* {@link NotificationManagerCompat} object, and then call one of its
* methods to post or cancel notifications.
*/
public final class NotificationManagerCompat {
private static final String TAG = "NotifManCompat";
private static final String CHECK_OP_NO_THROW = "checkOpNoThrow";
fun notifyUser(num : Int) {
mNotificationManagerCompat = NotificationManagerCompat.from(CONTEXT)
//id: unique in your app. otherwise, it will update to new one
mNotificationManagerCompat.notify(num, mNotificationBuilder.build())
}