Skip to content

Instantly share code, notes, and snippets.

View vicky7230's full-sized avatar
🎯
Focusing

Vipin Kumar vicky7230

🎯
Focusing
View GitHub Profile
data class Results(
@SerializedName("page")
@Expose
var page: Int? = null,
@SerializedName("total_results")
@Expose
var totalResults: Int? = null,
@SerializedName("total_pages")
@Expose
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(
@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
@vicky7230
vicky7230 / OnItemSelectedListener.java
Created March 15, 2018 05:21 — forked from andreynovikov/OnItemSelectedListener.java
Complete working solution for Android action bar tabs with fragments having separate back stack for each tab.
// Custom interface that enables communication between Fragment and its Activity
public interface OnItemSelectedListener
{
public void onItemSelected(String item);
}
/*
* BottomNavigationLayout library for Android
* Copyright (c) 2016. Nikola Despotoski (http://github.com/NikolaDespotoski).
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
//Schedule Note Syncing
NoteSyncJob.scheduleJob();
}
}
public class NoteJobCreator implements JobCreator {
@Override
@Nullable
public Job create(@NonNull String tag) {
switch (tag) {
case NoteSyncJob.TAG:
return new NoteSyncJob();
default:
return null;
public class NoteApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
JobManager.create(this).addJobCreator(new NoteJobCreator());
}
}
public class NoteSyncJob extends Job {
public static final String TAG = "job_note_sync";
@Override
@NonNull
protected Result onRunJob(@NonNull Params params) {
List<Note> notes = AppDatabase.getNotes();
if (notes.size() > 0) {
NoteSyncApi.sync(notes);