use of com.squareup.picasso.Picasso in project Rashr by DsLNeXuS.
the class RecoverySystemFragment method onCreateView.
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
mActivity = (RashrActivity) getActivity();
final ScrollView root = (ScrollView) inflater.inflate(R.layout.fragment_recovery_system, container, false);
ButterKnife.bind(this, root);
mContext = root.getContext();
tvTitle.setText(mTitle.toUpperCase());
tvDesc.setText(mDesc);
ArrayList<String> formatedVersions = new ArrayList<>();
for (String versionLinks : mVersions) {
formatedVersions.add(formatName(versionLinks, mTitle));
}
final ArrayAdapter<String> adapter = new ArrayAdapter<>(root.getContext(), android.R.layout.simple_list_item_1, formatedVersions);
spVersions.setAdapter(adapter);
spVersions.setSelection(0);
tvDev.setText(mDev);
if (mLogo == 0) {
imLogo.setVisibility(View.GONE);
} else {
imLogo.setImageResource(mLogo);
}
bFlash.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
flashSupportedRecovery(mTitle, mVersions.get(spVersions.getSelectedItemPosition()));
}
});
if (mScreenshotURL == null) {
ScreenshotLayout.setVisibility(View.GONE);
} else {
try {
Downloader links = new Downloader(new URL(mScreenshotURL), new File(mContext.getExternalCacheDir(), "screenshots.json"));
links.setOverrideFile(true);
links.setOnDownloadListener(new Downloader.OnDownloadListener() {
@Override
public void onSuccess(File file) {
try {
String res = Common.fileContent(file);
JSONArray arr = new JSONArray(res);
for (int i = 0; i < arr.length(); i++) {
final String name = arr.get(i).toString();
// Skip file that lists content of url
if (name.equals("getScreenshots.php"))
continue;
if (name.equals("index.php"))
continue;
// All others are filenames of screenshots
AppCompatImageView iv = (AppCompatImageView) inflater.inflate(R.layout.recovery_screenshot, ScreenshotLayout, false);
ScreenshotLayout.addView(iv);
Picasso picasso = Picasso.with(mContext);
picasso.setLoggingEnabled(BuildConfig.DEBUG);
picasso.setIndicatorsEnabled(BuildConfig.DEBUG);
picasso.load(mScreenshotURL + "/" + name).placeholder(R.drawable.ic_launcher_web).into(iv);
}
} catch (JSONException | IOException e) {
onFail(e);
}
}
@Override
public void onFail(Exception e) {
e.printStackTrace();
}
});
links.download();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
return root;
}
use of com.squareup.picasso.Picasso in project Tusky by tuskyapp.
the class TuskyApplication method initPicasso.
protected void initPicasso() {
// Initialize Picasso configuration
Picasso.Builder builder = new Picasso.Builder(this);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
builder.downloader(new OkHttp3Downloader(OkHttpUtils.getCompatibleClient(preferences)));
if (BuildConfig.DEBUG) {
builder.listener((picasso, uri, exception) -> exception.printStackTrace());
}
try {
Picasso.setSingletonInstance(builder.build());
} catch (IllegalStateException e) {
throw new RuntimeException(e);
}
}
use of com.squareup.picasso.Picasso in project Lets-Chat by kshitiz1007.
the class LetsChat method onCreate.
@Override
public void onCreate() {
super.onCreate();
mAuth = FirebaseAuth.getInstance();
FirebaseUser mUser = mAuth.getCurrentUser();
// ---DO IT WHENEVER YOU GET TIME---
if (mUser != null) {
// ---FIREBASE OFFLINE FEATURE---
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
// ---PIACSSO OFFLINE FEATURE--
mAuth = FirebaseAuth.getInstance();
Picasso.Builder builder = new Picasso.Builder(this);
builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
Picasso built = builder.build();
built.setIndicatorsEnabled(true);
built.setLoggingEnabled(true);
Picasso.setSingletonInstance(built);
// String user_id = mAuth.getCurrentUser().getUid();
// Log.e("Current user inside : ",user_id);
// ---SEETING TIME_STAMP ON DISCONNECT-----
mUserDatabase = FirebaseDatabase.getInstance().getReference().child("users").child(mAuth.getCurrentUser().getUid());
mUserDatabase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot != null) {
mUserDatabase.child("online").onDisconnect().setValue(ServerValue.TIMESTAMP);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
use of com.squareup.picasso.Picasso in project sbt-android by scala-android.
the class DebugDataModule method providePicasso.
@Provides
@Singleton
Picasso providePicasso(OkHttpClient client, NetworkBehavior behavior, @IsMockMode boolean isMockMode, Application app) {
Picasso.Builder builder = new Picasso.Builder(app).downloader(new OkHttpDownloader(client));
if (isMockMode) {
builder.addRequestHandler(new MockRequestHandler(behavior, app.getAssets()));
}
builder.listener((picasso, uri, exception) -> {
Timber.e(exception, "Error while loading image " + uri);
});
return builder.build();
}
use of com.squareup.picasso.Picasso in project android-sdk-examples by IndoorAtlas.
the class MapsOverlayActivity method fetchFloorPlanBitmap.
/**
* Download floor plan using Picasso library.
*/
private void fetchFloorPlanBitmap(final IAFloorPlan floorPlan) {
final String url = floorPlan.getUrl();
if (mLoadTarget == null) {
mLoadTarget = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.d(TAG, "onBitmap loaded with dimensions: " + bitmap.getWidth() + "x" + bitmap.getHeight());
setupGroundOverlay(floorPlan, bitmap);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
// N/A
}
@Override
public void onBitmapFailed(Drawable placeHolderDraweble) {
showInfo("Failed to load bitmap");
mOverlayFloorPlan = null;
}
};
}
RequestCreator request = Picasso.with(this).load(url);
final int bitmapWidth = floorPlan.getBitmapWidth();
final int bitmapHeight = floorPlan.getBitmapHeight();
if (bitmapHeight > MAX_DIMENSION) {
request.resize(0, MAX_DIMENSION);
} else if (bitmapWidth > MAX_DIMENSION) {
request.resize(MAX_DIMENSION, 0);
}
request.into(mLoadTarget);
}
Aggregations