Nav Avater - Changes
This commit is contained in:
parent
db3d15fa0a
commit
f3e410a679
3 changed files with 34 additions and 6 deletions
|
@ -13,6 +13,7 @@ import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.support.design.widget.NavigationView;
|
import android.support.design.widget.NavigationView;
|
||||||
import android.support.v4.view.GravityCompat;
|
import android.support.v4.view.GravityCompat;
|
||||||
|
@ -26,6 +27,7 @@ import android.widget.ImageView;
|
||||||
|
|
||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -48,12 +50,15 @@ public class MainActivity extends AppCompatActivity
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
public static final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
|
public static final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
|
||||||
private ImageView menu_avatar;
|
private ImageView menu_avatar;
|
||||||
|
private MainActivity self;
|
||||||
|
private NavigationView nav_view;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
this.self = this;
|
||||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
toolbar.setTitle("Personal Notes");
|
toolbar.setTitle("Personal Notes");
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
@ -65,6 +70,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||||
|
@ -78,8 +85,11 @@ public class MainActivity extends AppCompatActivity
|
||||||
//get Bundle data (UserString)
|
//get Bundle data (UserString)
|
||||||
Bundle b = getIntent().getExtras();
|
Bundle b = getIntent().getExtras();
|
||||||
this.user = new User(b.getString("UserData"));
|
this.user = new User(b.getString("UserData"));
|
||||||
menu_avatar = (ImageView)findViewById(R.id.user_avatar);
|
|
||||||
//TODO - Change the menu_avatar to user.getAvatar()
|
//Get The Nav_View Avatar View
|
||||||
|
nav_view = (NavigationView) findViewById(R.id.nav_view);
|
||||||
|
View header_v = nav_view.getHeaderView(0);
|
||||||
|
menu_avatar = (ImageView)header_v.findViewById(R.id.nav_user_avatar);
|
||||||
|
|
||||||
|
|
||||||
//Change Layout
|
//Change Layout
|
||||||
|
@ -92,6 +102,9 @@ public class MainActivity extends AppCompatActivity
|
||||||
Log.d(TAG, "Changed");
|
Log.d(TAG, "Changed");
|
||||||
gpsUtils = new GPSUtils(this);
|
gpsUtils = new GPSUtils(this);
|
||||||
gpsUtils.getLocation();
|
gpsUtils.getLocation();
|
||||||
|
|
||||||
|
//Change The Avatar
|
||||||
|
new setUserAvatar().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -156,7 +169,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
SharedPreferences sharedPref = this.getSharedPreferences(MainActivity.LOCAL_DATA_TSN, Context.MODE_PRIVATE);
|
SharedPreferences sharedPref = this.getSharedPreferences(MainActivity.LOCAL_DATA_TSN, Context.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = sharedPref.edit();
|
SharedPreferences.Editor editor = sharedPref.edit();
|
||||||
editor.remove("UserId");
|
editor.remove("UserData");
|
||||||
editor.commit();
|
editor.commit();
|
||||||
Intent loginActivity = new Intent(MainActivity.this, LoginActivity.class);
|
Intent loginActivity = new Intent(MainActivity.this, LoginActivity.class);
|
||||||
startActivity(loginActivity);
|
startActivity(loginActivity);
|
||||||
|
@ -188,4 +201,19 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
public String getUserId(){return user.getId();}
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String Serialise(){
|
public String Serialise(){
|
||||||
return id + "||" + username + "||" + password + "||" + email + "||" + serialiseNoteList();
|
return id + ATTARS_DELIMETER + username + ATTARS_DELIMETER + password + ATTARS_DELIMETER + email + ATTARS_DELIMETER +avatar + ATTARS_DELIMETER + serialiseNoteList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String serialiseNoteList() {
|
private String serialiseNoteList() {
|
||||||
|
@ -126,7 +126,7 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "Id: "+id+" UserName: " + username +" Password: " +password +" email: " + email+ " Liked Notes: "+liked_notes.toString();
|
return "Id: "+id+" UserName: " + username +" Password: " +password +" email: " + email+ " Avatar: " +avatar+" Liked Notes: "+liked_notes.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="70dp"
|
android:layout_width="70dp"
|
||||||
android:layout_height="70dp"
|
android:layout_height="70dp"
|
||||||
android:id="@+id/user_avatar"
|
android:id="@+id/nav_user_avatar"
|
||||||
android:src="@drawable/default_avatar"
|
android:src="@drawable/default_avatar"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
|
|
Loading…
Reference in a new issue