mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 07:49:28 +00:00
Current user infos displayed
This commit is contained in:
parent
919f76fd3d
commit
53e60228fe
@ -53,6 +53,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
//Initialize account objects
|
||||
account = new Account(this);
|
||||
|
||||
//Check if user is signed in or not
|
||||
if(!account.signed_in()){
|
||||
//Open the login activity
|
||||
startActivity(new Intent(this, LoginActivity.class));
|
||||
}
|
||||
|
||||
//If it is the first time the application is launched, started the user friends tab
|
||||
if(savedInstanceState == null){
|
||||
openFriendsFragment();
|
||||
|
@ -23,6 +23,9 @@ public class FriendsListFragment extends Fragment {
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
//Retain the fragment
|
||||
setRetainInstance(true);
|
||||
|
||||
//Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_friendslist, container, false);
|
||||
|
||||
|
@ -2,13 +2,21 @@ package org.communiquons.android.comunic.client.fragments;
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.Account.AccountUtils;
|
||||
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
||||
import org.communiquons.android.comunic.client.data.ImageLoadTask;
|
||||
import org.communiquons.android.comunic.client.data.UsersInfo.GetUsersInfos;
|
||||
import org.communiquons.android.comunic.client.data.UsersInfo.UserInfo;
|
||||
|
||||
/**
|
||||
* User informations fragment
|
||||
@ -21,9 +29,47 @@ import org.communiquons.android.comunic.client.R;
|
||||
|
||||
public class UserInfosFragment extends Fragment {
|
||||
|
||||
/**
|
||||
* Application context
|
||||
*/
|
||||
Context mContext;
|
||||
|
||||
/**
|
||||
* Database helper
|
||||
*/
|
||||
DatabaseHelper dbHelper;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_userinfos, container, false);
|
||||
View result = inflater.inflate(R.layout.fragment_userinfos, container, false);
|
||||
|
||||
//Get context
|
||||
mContext = getActivity().getApplicationContext();
|
||||
|
||||
//Open DBHelper if required
|
||||
if(dbHelper == null)
|
||||
dbHelper = new DatabaseHelper(mContext);
|
||||
|
||||
//Get required views
|
||||
final ImageView imageView = (ImageView) result.findViewById(R.id.fragments_userinfos_account_image);
|
||||
final TextView userNameView = (TextView) result.findViewById(R.id.fragments_userinfos_user_name);
|
||||
|
||||
//Retrieve user informations in order to display them
|
||||
int user_id = new AccountUtils(mContext).get_current_user_id();
|
||||
new GetUsersInfos(mContext, dbHelper).get(user_id, new GetUsersInfos.getUserInfosCallback() {
|
||||
@Override
|
||||
public void callback(UserInfo info) {
|
||||
|
||||
//Set the name of the user
|
||||
userNameView.setText(info.getFullName());
|
||||
|
||||
//Get and show the user account image
|
||||
new ImageLoadTask(mContext, info.getAcountImageURL(), imageView).execute();
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable/default_account_image.png
Normal file
BIN
app/src/main/res/drawable/default_account_image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 968 B |
@ -1,11 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello from informations fragment !"/>
|
||||
android:orientation="horizontal"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_centerHorizontal="true">
|
||||
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/fragments_userinfos_account_image"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:contentDescription="User account image"
|
||||
android:src="@drawable/default_account_image"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fragments_userinfos_user_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="6dp"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
tools:text="Full user name"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user