mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 07:49:28 +00:00
Apply user information in drawer.
This commit is contained in:
parent
11e4cba9de
commit
f0b9058894
@ -56,7 +56,7 @@ public class GetUsersHelper {
|
||||
* @param udbHelper User database helper
|
||||
*/
|
||||
public GetUsersHelper(@NonNull Context context, @NonNull UsersInfosDbHelper udbHelper){
|
||||
mContext = context;
|
||||
mContext = context.getApplicationContext();
|
||||
this.udbHelper = udbHelper;
|
||||
}
|
||||
|
||||
@ -304,11 +304,11 @@ public class GetUsersHelper {
|
||||
|
||||
|
||||
//Convert the IDs into a string
|
||||
String id_string = "";
|
||||
StringBuilder id_string = new StringBuilder();
|
||||
for(int id : IDs) {
|
||||
id_string += id + ",";
|
||||
id_string.append(id).append(",");
|
||||
}
|
||||
requestParameters.addString("usersID", id_string);
|
||||
requestParameters.addString("usersID", id_string.toString());
|
||||
|
||||
|
||||
try {
|
||||
|
@ -18,6 +18,7 @@ import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.BuildConfig;
|
||||
@ -28,6 +29,8 @@ import org.communiquons.android.comunic.client.data.helpers.AccountHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.ConversationsListHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.DatabaseHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.DebugHelper;
|
||||
import org.communiquons.android.comunic.client.data.helpers.GetUsersHelper;
|
||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||
import org.communiquons.android.comunic.client.data.runnables.FriendRefreshLoopRunnable;
|
||||
import org.communiquons.android.comunic.client.data.services.NotificationsService;
|
||||
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
||||
@ -46,6 +49,7 @@ import org.communiquons.android.comunic.client.ui.listeners.onPostOpenListener;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.openConversationListener;
|
||||
import org.communiquons.android.comunic.client.ui.listeners.updateConversationListener;
|
||||
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
|
||||
import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage;
|
||||
|
||||
|
||||
/**
|
||||
@ -72,11 +76,6 @@ public class MainActivity extends AppCompatActivity implements
|
||||
*/
|
||||
private AccountHelper accountHelper;
|
||||
|
||||
/**
|
||||
* Account utils object
|
||||
*/
|
||||
private AccountUtils aUtils;
|
||||
|
||||
/**
|
||||
* Friends list refresh thread
|
||||
*/
|
||||
@ -251,6 +250,44 @@ public class MainActivity extends AppCompatActivity implements
|
||||
|
||||
NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
//Get information about the user
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final UserInfo info = new GetUsersHelper(getApplicationContext()).getSingle(
|
||||
new AccountUtils(getApplicationContext()).get_current_user_id(), false);
|
||||
|
||||
//Apply user information
|
||||
if(mDrawer != null){
|
||||
mDrawer.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
applyUserInfoInDrawer(info);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply current user information in the drawer
|
||||
*
|
||||
* @param info Information about the user to apply
|
||||
*/
|
||||
private void applyUserInfoInDrawer(@Nullable UserInfo info){
|
||||
|
||||
//Check for errors
|
||||
if(info == null){
|
||||
Toast.makeText(MainActivity.this, R.string.err_get_user_info,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
//Apply user information
|
||||
((TextView)findViewById(R.id.current_user_name)).setText(info.getDisplayFullName());
|
||||
((WebUserAccountImage)findViewById(R.id.current_user_account_image)).setUser(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,6 +54,13 @@ public class AdvancedUserInfoFragment extends Fragment {
|
||||
this.mAdvancedUserInfo = advancedUserInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setRetainInstance(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
@ -12,8 +12,8 @@
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
<org.communiquons.android.comunic.client.ui.views.WebUserAccountImage
|
||||
android:id="@+id/current_user_account_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/nav_header_desc"
|
||||
@ -21,6 +21,7 @@
|
||||
android:src="@drawable/default_account_image" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/current_user_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||
|
Loading…
Reference in New Issue
Block a user