Skip to content

Instantly share code, notes, and snippets.

View beigirad's full-sized avatar

Farhad Beigirad beigirad

View GitHub Profile
@beigirad
beigirad / simpleFCM.json
Last active July 21, 2017 20:02
simple body request for Firebase Cloud Messaging
{
"data":{
"notif_title":"title",
"notif_body":"body",
"app_url":"http://google.com/app.apk",
"product_id":"0", //for erlear version to donot force close after get push
"request_type":"update",
"request_value":"8"
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
@beigirad
beigirad / MapFragment.java
Created August 13, 2017 08:58
Separate MapFragment
package ir.beigirad.peyk60.ui;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Point;
import android.location.Address;
import android.location.Geocoder;
Marker setMarker(LatLng location, MarkerType type) {
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(type.equals(MarkerType.Start) ? R.drawable.marker_start : R.drawable.marker_end);
Marker marker = mGoogleMap
.addMarker(
new MarkerOptions()
.position(location)
// .icon(BitmapDescriptorFactory.defaultMarker(type.equals(MarkerType.Start)?BitmapDescriptorFactory.HUE_AZURE:BitmapDescriptorFactory.HUE_GREEN)));
.icon(icon));
@beigirad
beigirad / activity
Created August 19, 2017 18:35
ViewPager + TabLayout
private void setupViewPger() {
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), slider_urls);
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setSelectedTabIndicatorHeight(10);
tabLayout.setupWithViewPager(mViewPager);
}
@beigirad
beigirad / EndlessRecyclerViewScrollListener
Created October 31, 2017 08:25
Endless Scroll Listener
package ir.beigirad.zeroapplication.widget;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
/**
* Created by farhad-mbp on 8/28/17.
@beigirad
beigirad / build.gradle ( Module )
Last active January 23, 2018 15:47
Signing by gradle
android {
...
if (project.hasProperty("myproject.properties") && new File(project.property("myproject.properties")).exists()) {
Properties props = new Properties()
props.load(new FileInputStream(file(project.property("myproject.properties"))))
signingConfigs {
release {
storeFile file(props['storeFile'])
@beigirad
beigirad / interface JAVA
Last active April 15, 2018 20:58
retrofit multipart
@Multipart
@POST("/endpoint")
Call<Post> sendPost(@Part("caption") String caption, @Part MultipartBody.Part image);
@beigirad
beigirad / FingerprintHelper
Last active May 4, 2018 19:31
FingerPrintHelper
@RequiresApi(Build.VERSION_CODES.M)
class FingerprintHelper(var context: Context, var fingerInterface: FingerInterface?) : FingerprintManager.AuthenticationCallback() {
private var keyguardManager: KeyguardManager = context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
private var fingerManager: FingerprintManager = context.getSystemService(Context.FINGERPRINT_SERVICE) as FingerprintManager
private var cancellationSignal: CancellationSignal = CancellationSignal()
private var keyStore: KeyStore? = null
private var keyGenerator: KeyGenerator? = null
private var cipher: Cipher? = null
@beigirad
beigirad / db copy
Created May 15, 2018 08:05
copy files from assets
private void copyDataBase() {
try {
String asstFileDir = "databases/" + DB_NAME;
Log.i(TAG, "Copy DB from " + asstFileDir);
InputStream is = context.getAssets().open(asstFileDir);
Log.i(TAG, "available : " + is.available());
File folder = new File(NEW_DB_PATH);