Added Utils.URLtoImageView
This commit is contained in:
parent
e9da6be78d
commit
7347bcb8c4
3 changed files with 33 additions and 16 deletions
|
@ -104,7 +104,7 @@ public class MainActivity extends AppCompatActivity
|
|||
gpsUtils.getLocation();
|
||||
|
||||
//Change The Avatar
|
||||
new setUserAvatar().execute();
|
||||
Utils.URLtoImageView(menu_avatar, user.getAvatar());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -201,19 +201,4 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
public String getUserId(){return user.getId();}
|
||||
|
||||
private class setUserAvatar extends AsyncTask<Void, Void, Bitmap> {
|
||||
|
||||
@Override
|
||||
protected Bitmap doInBackground(Void... v) {
|
||||
Bitmap b = Utils.getBitmapFromURL(self.user.getAvatar());
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap b){
|
||||
self.menu_avatar.setImageBitmap(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@ import android.app.Dialog;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
|
@ -23,6 +25,7 @@ import android.widget.Button;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
@ -335,6 +338,7 @@ public class PersonalFragment extends Fragment {
|
|||
final TextView tags = (TextView) noteViewDialog.findViewById(R.id.ndf_tags_textview);
|
||||
final TextView permission = (TextView) noteViewDialog.findViewById(R.id.ndf_permission_textview);
|
||||
final ImageButton deleteBtn = (ImageButton) noteViewDialog.findViewById(R.id.ndf_delete_imagebutton);
|
||||
final ImageView avatar = (ImageView)noteViewDialog.findViewById(R.id.note_user_avatar);
|
||||
|
||||
|
||||
title.setText(note.getTitle());
|
||||
|
@ -344,6 +348,7 @@ public class PersonalFragment extends Fragment {
|
|||
likes.setText("Likes: " + note.getLikes());
|
||||
tags.setText(note.getTags().toString());
|
||||
permission.setText("Permission: " + (note.isPublic() ? "Public" : "Private"));
|
||||
Utils.URLtoImageView(avatar, note.getAvatar());
|
||||
|
||||
deleteBtn.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -4,7 +4,9 @@ import android.app.ProgressDialog;
|
|||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
|
@ -105,4 +107,29 @@ public class Utils {
|
|||
}
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
public static void URLtoImageView(ImageView iv, String url){
|
||||
new setUserAvatar(iv, url).execute();
|
||||
}
|
||||
|
||||
private static class setUserAvatar extends AsyncTask<Void, Void, Bitmap> {
|
||||
private ImageView iv;
|
||||
private String url;
|
||||
public setUserAvatar(ImageView imageView, String url){
|
||||
this.iv = imageView;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap doInBackground(Void... v) {
|
||||
Bitmap b = Utils.getBitmapFromURL(url);
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap b){
|
||||
iv.setImageBitmap(b);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue