# Conflicts:
#	app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java
This commit is contained in:
Aran Zaiger 2016-07-08 03:06:21 +03:00
commit 26c272fbe5
4 changed files with 310 additions and 285 deletions

View file

@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="android-android-23">
<CLASSES>
<root url="jar://$USER_HOME$/AppData/Local/Android/sdk/platforms/android-23/android.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -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);
}
}
}

View file

@ -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;
@ -302,7 +305,6 @@ public class PersonalFragment extends Fragment {
noteObject.getBoolean("is_public"),
noteObject.getInt("likes"),
noteObject.getString("avatar"),
noteObject.getString("owner_id"),
jsonArrayToStringArray(noteObject.getJSONArray("tags"))
);
listOfNotes.add(addNote);
@ -336,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());
@ -345,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) {

View file

@ -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);
}
}
}