Skip to content

Instantly share code, notes, and snippets.

zaeem sattar ZaeemSattar

View GitHub Profile
View createCommaSepString.kt
val csvBuilder = StringBuilder()
for (city in models) {
csvBuilder.append(city.number)
csvBuilder.append(",")
}
var csv = csvBuilder.toString()
csv = csv.substring(0, csv.length - ",".length)
View getContacts.kt
class PhoneContactModel {
var id: Int = 0
var name: String = ""
var number: String = ""
var isSelected: Boolean = false
var viewType: Int = 1
var headerName = ""
}
View MenifistPermisions.xml
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_path" />
</provider>
View lottiefilesinfo
https://www.lottiefiles.com/
https://github.com/airbnb/lottie-android
View UploadImageToServerKotlinAsyncTask.kt
// pick single image from gallery
private fun openGalleryImages() {
val intent = Intent(Intent.ACTION_PICK)
intent.type = "image/*"
startActivityForResult(Intent.createChooser(intent, "Select Picture"), TYPE_IMAGE)
}
// get path
View custom_edittext_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-6dp"
android:right="-6dp"
android:top="-3dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
View EndlessRecyclerOnScrollListener.java
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
View LoginCoordinator.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sooq.activities.LoginActivity">
<android.support.design.widget.AppBarLayout
View PagerBannerSLiderKotlin.kt
// how to use
val timer = Timer()
timer.schedule(RemindTask(imageList.size, pager), 0, 5000)
// handler
inner class RemindTask() : TimerTask() {
private var numberOfPages = 0
private lateinit var mViewPager: ViewPager
View PerfectAsyncTask.java
/**
* This Activity displays the screen's UI, creates a TaskFragment
* to manage the task, and receives progress updates and results
* from the TaskFragment when they occur.
*/
public class MainActivity extends Activity implements TaskFragment.TaskCallbacks {
private static final String TAG_TASK_FRAGMENT = "task_fragment";
private TaskFragment mTaskFragment;
You can’t perform that action at this time.