Skip to content

Instantly share code, notes, and snippets.

View vicky7230's full-sized avatar
🎯
Focusing

Vipin Kumar vicky7230

🎯
Focusing
View GitHub Profile
@vicky7230
vicky7230 / MainActivity.java
Created March 29, 2018 04:30 — forked from gabrielemariotti/MainActivity.java
How to obtain a CardView (support library) with a Image and rounded corners for API<21
ImageView imageView = (ImageView) findViewById(R.id.card_thumbnail_image);
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rose);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
//Default
imageView.setBackgroundResource(R.drawable.rose);
} else {
//RoundCorners
RoundCornersDrawable round = new RoundCornersDrawable(mBitmap,
getResources().getDimension(R.dimen.cardview_default_radius), 0); //or your custom radius
@vicky7230
vicky7230 / MainActivity.java
Created March 29, 2018 04:30 — forked from gabrielemariotti/MainActivity.java
How to obtain a CardView (support library) with a Image and rounded corners for API<21
ImageView imageView = (ImageView) findViewById(R.id.card_thumbnail_image);
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rose);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
//Default
imageView.setBackgroundResource(R.drawable.rose);
} else {
//RoundCorners
RoundCornersDrawable round = new RoundCornersDrawable(mBitmap,
getResources().getDimension(R.dimen.cardview_default_radius), 0); //or your custom radius
class TvPresenter<V : TvMvpView> @Inject constructor(
private val dataManager: DataManager,
private val compositeDisposable: CompositeDisposable
) : BasePresenter<V>(dataManager, compositeDisposable), TvMvpPresenter<V> {
private var page = 1
override fun getTvs() {
compositeDisposable.add(
dataManager.getTvs(
data class Results(
@SerializedName("page")
@Expose
var page: Int? = null,
@SerializedName("total_results")
@Expose
var totalResults: Int? = null,
@SerializedName("total_pages")
@Expose
data class Result(
var type: String = "TV",
@SerializedName("original_name")
@Expose
var originalName: String? = null,
@SerializedName("genre_ids")
@Expose
var genreIds: List<Int>? = null,
class TvFragment : BaseFragment(), TvMvpView, TvAdapter.Callback {
@Inject
lateinit var presenter: TvMvpPresenter<TvMvpView>
@Inject
lateinit var gridLayoutManager: GridLayoutManager
@Inject
lateinit var itemOffsetDecoration: ItemOffsetDecoration
@Inject
lateinit var tvAdapter: TvAdapter
class TvAdapter(private val resultList: MutableList<Result>?) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val TYPE_LOADING = -1
private val TYPE_TV = 1
interface Callback {
fun onTvShowClick(id: Int)
}
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
if (BuildConfig.DEBUG) {
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
}
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(1000, TimeUnit.SECONDS)
.addInterceptor(httpLoggingInterceptor)
commonApiService.sendOtp(phone)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(login -> {
if (!isViewAttached()) {
return;
}
getMvpView().hideLoading();
if (login != null && login.getSuccess() != null) {
if (login.getSuccess()) {
@vicky7230
vicky7230 / Get Path from Uri
Last active August 20, 2018 06:27 — forked from kuraydev/android-real-path-uri.md
Android: How to get Real Path from Uri?
private String getRealPathFromURI(Context context, Uri contentUri) {
Cursor cursor = null;
try {
String[] proj = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
} catch (Exception e) {
Log.e(TAG, "getRealPathFromURI Exception : " + e.toString());