Created
January 26, 2016 11:09
-
-
Save lanetteamkaushal/d77a6d6482b5992b5525 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.lcom75.checkuilasync; | |
import android.graphics.Bitmap; | |
import android.os.Bundle; | |
import android.support.design.widget.FloatingActionButton; | |
import android.support.design.widget.Snackbar; | |
import android.support.v7.app.AppCompatActivity; | |
import android.support.v7.widget.Toolbar; | |
import android.util.Log; | |
import android.view.View; | |
import android.view.Menu; | |
import android.view.MenuItem; | |
import com.nostra13.universalimageloader.core.DisplayImageOptions; | |
import com.nostra13.universalimageloader.core.ImageLoader; | |
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; | |
import java.io.IOException; | |
public class MainActivity extends AppCompatActivity { | |
protected DisplayImageOptions options; | |
protected ImageLoader imageLoader = ImageLoader.getInstance(); | |
ImageLoaderConfiguration config; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | |
setSupportActionBar(toolbar); | |
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); | |
fab.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) | |
.setAction("Action", null).show(); | |
} | |
}); | |
Bitmap bitmap; | |
options = new DisplayImageOptions.Builder() | |
.cacheInMemory(true) | |
.cacheOnDisk(true) | |
.considerExifParams(true) | |
.bitmapConfig(Bitmap.Config.RGB_565) | |
.build(); | |
config = new ImageLoaderConfiguration.Builder(this).build(); | |
imageLoader.init(config); | |
thread.start(); | |
} | |
private String TAG = MainActivity.class.getSimpleName(); | |
Thread thread = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
try { | |
Bitmap bitmap = imageLoader.loadImageSync("http://www.google.com/thumbnail.png"); | |
} catch (Exception e) { | |
Log.d(TAG, "It seems exceptions :" + e.getMessage()); | |
} | |
} | |
}); | |
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
// Inflate the menu; this adds items to the action bar if it is present. | |
getMenuInflater().inflate(R.menu.menu_main, menu); | |
return true; | |
} | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
// Handle action bar item clicks here. The action bar will | |
// automatically handle clicks on the Home/Up button, so long | |
// as you specify a parent activity in AndroidManifest.xml. | |
int id = item.getItemId(); | |
//noinspection SimplifiableIfStatement | |
if (id == R.id.action_settings) { | |
return true; | |
} | |
return super.onOptionsItemSelected(item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment