1)//**********************************************************************************************************************
//This function is store image
public static void ClickLinear(){
lytDisplayQuote.setDrawingCacheEnabled(true);
imgPrivious.setVisibility(ImageView.INVISIBLE);
imgNext.setVisibility(ImageView.INVISIBLE);
imgfavs.setVisibility(ImageView.INVISIBLE);
Bitmap mBitmap=lytDisplayQuote.getDrawingCache();
if(mBitmap!=null){
StoreBitmap(mBitmap);
System.out.println("Saved");
}
}
//******************************************************************************************************************************
private static void StoreBitmap(Bitmap mBitmap){
try{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes);
//you can create a new file name "test.jpg" in sdcard folder.
File f = new File(Constant.IMAGEURL);
f.createNewFile();
//write the bytes in file
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
fo.close();
lytDisplayQuote.setDrawingCacheEnabled(false);
}
catch (Exception e) {
e.printStackTrace();
}
finally{
imgPrivious.setVisibility(ImageView.VISIBLE);
imgNext.setVisibility(ImageView.VISIBLE);
imgfavs.setVisibility(ImageView.VISIBLE);
}
}
=================================
getTabWidget().getChildAt(0).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DisplayQuote.ClickLinear();
ShareAlertdialog();
tabHost.setCurrentTab(0);
}
});
//This function is store image
public static void ClickLinear(){
lytDisplayQuote.setDrawingCacheEnabled(true);
imgPrivious.setVisibility(ImageView.INVISIBLE);
imgNext.setVisibility(ImageView.INVISIBLE);
imgfavs.setVisibility(ImageView.INVISIBLE);
Bitmap mBitmap=lytDisplayQuote.getDrawingCache();
if(mBitmap!=null){
StoreBitmap(mBitmap);
System.out.println("Saved");
}
}
//******************************************************************************************************************************
private static void StoreBitmap(Bitmap mBitmap){
try{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes);
//you can create a new file name "test.jpg" in sdcard folder.
File f = new File(Constant.IMAGEURL);
f.createNewFile();
//write the bytes in file
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
fo.close();
lytDisplayQuote.setDrawingCacheEnabled(false);
}
catch (Exception e) {
e.printStackTrace();
}
finally{
imgPrivious.setVisibility(ImageView.VISIBLE);
imgNext.setVisibility(ImageView.VISIBLE);
imgfavs.setVisibility(ImageView.VISIBLE);
}
}
=================================
getTabWidget().getChildAt(0).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DisplayQuote.ClickLinear();
ShareAlertdialog();
tabHost.setCurrentTab(0);
}
});
No comments:
Post a Comment