Skip to content

Instantly share code, notes, and snippets.

View RanjitPati's full-sized avatar
😉

Ranjit Pati RanjitPati

😉
View GitHub Profile
public class MyApplication extends Application {
private static final int JOB_ID = 3 * 9;
@Override
public void onCreate() {
super.onCreate();
if(!isJobServiceOn()){
ComponentName mComponentName = new ComponentName(this, AnalyticsService.class);
//Now create a JobInfo and give
JobInfo mJobInfo = new JobInfo.Builder(JOB_ID, mComponentName)
<service android:name="com.beeonics.android.fs.analytics.AnalyticsService"
android:permission="android.permission.BIND_JOB_SERVICE"/>
public class AnalyticsService extends JobService {
@Override
public boolean onStartJob(JobParameters params) {
//let's update the analytics stuff when the job starts
//you can skip this method if it seems complex. we will understand this in GreenDAO tutorials
updateAnaliticsData();
//return false if the task is small and it will finish inside this onStartJob method or else true if your task is bigger
//I am returning true because I am running a network operation which will use a background thread
package com.myapplicationpalettetest;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.graphics.Palette;
import android.widget.Button;
import android.widget.ImageView;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/tiger"
android:layout_weight="4"/>
dependencies {
implementation 'com.android.support:palette-v7:28.0.0'
}
//Fresco Image Loader
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
return chain.proceed(chain.request().newBuilder().addHeader("YOUR_KEY", "YOUR_VALUE").build());//here key and value are provided by the server
}
}).build();
ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
.newBuilder(this, client)
String url = "Your Image Url";
Uri uri = Uri.parse(url);
your)simple_draweeview.setImageURI(uri);
package com.ajk.frescotestapp;
import android.app.Application;
import com.facebook.drawee.backends.pipeline.Fresco;
public class MyApplication extends Application {
@Override
public void onCreate() {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
/*Fresco Image Loader*/
implementation 'com.facebook.fresco:fresco:1.13.0'
}