This file contains hidden or 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
public static float convertPixelsToDp(float px){ | |
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); | |
float dp = px / (metrics.densityDpi / 160f); | |
return Math.round(dp); | |
} | |
public static float convertDpToPixel(float dp){ | |
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); | |
float px = dp * (metrics.densityDpi / 160f); | |
return Math.round(px); |
This file contains hidden or 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
import java.text.NumberFormat; | |
import java.text.DecimalFormat; | |
import java.math.RoundingMode; | |
DecimalFormat decimalFormat = new DecimalFormat(); | |
decimalFormat.setDecimalSeparatorAlwaysShown(false) | |
decimalFormat.setMaximumFractionDigits(6) | |
decimalFormat.setRoundingMode(RoundingMode.HALF_UP) | |
This file contains hidden or 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.example.nester.crachreproduce; | |
import android.app.ProgressDialog; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.support.v7.app.AppCompatActivity; | |
public class NoAttachActivity extends AppCompatActivity { | |
private ProgressDialog progressDialog; |
This file contains hidden or 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
import android.content.res.Resources; | |
import android.graphics.drawable.Drawable; | |
import android.text.Spannable; | |
import android.text.SpannableStringBuilder; | |
import android.text.style.ImageSpan; | |
import android.view.View; | |
import android.widget.ImageView; | |
import android.widget.LinearLayout; | |
import android.widget.SearchView; | |
import android.widget.TextView; |
This file contains hidden or 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
CountDownTimer countDownTimer = new CountDownTimer(TIME_MILLIS, 100) { | |
@Override | |
public void onTick(long millisUntilFinished) { | |
double i = (1 - millisUntilFinished / (double) TIME_MILLIS) * 100; | |
progressBar.setProgress((int) i); | |
} | |
@Override | |
public void onFinish() { | |
progressBar.setProgress(100); |
This file contains hidden or 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 connecting the Realm lifecycle to that of LiveData objects. | |
* Realm will remain open for as long as any LiveData objects are being observed. | |
*/ | |
abstract class LiveRealmData<T: RealmModel>(val config: RealmConfiguration) : LiveData<RealmResults<T>>() { | |
private val listener = RealmChangeListener<RealmResults<T>> { results -> value = results } | |
private lateinit var realm: Realm | |
private var results: RealmResults<T>? = null |
This file contains hidden or 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.nesterchung.chart | |
import android.content.Context | |
import android.os.Bundle | |
import android.support.v7.app.AppCompatActivity | |
import android.text.format.DateUtils | |
import android.util.Log | |
import android.view.WindowManager | |
import com.github.mikephil.charting.charts.BarChart | |
import com.github.mikephil.charting.components.AxisBase |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item | |
android:width="260dp" | |
android:height="260dp"> | |
<shape android:shape="rectangle"> | |
<solid android:color="@android:color/transparent" /> | |
</shape> | |
</item> |
This file contains hidden or 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 Presenter { | |
fun onSeekBarSelect(data: Any) { | |
//brabra | |
} | |
} | |
val list = listOf<Any>() | |
val presenter = Presenter() | |
val seekBar = SeekBar(null).apply { | |
setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { | |
override fun onStartTrackingTouch(seekBar: SeekBar?) {} |
This file contains hidden or 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
inline fun <E : IInterface?> RemoteCallbackList<E>.forEach(f: (E) -> Unit) { | |
var i = beginBroadcast() | |
while (i > 0) { | |
i-- | |
try { | |
f(getBroadcastItem(i)) | |
} catch (e: RemoteException) { | |
// The RemoteCallbackList will take care of removing | |
// the dead object for us. | |
} |