mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
change MainActivity to use AvatarView
This commit is contained in:
parent
2ba9990171
commit
e405f433fd
3 changed files with 31 additions and 27 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="24dip"
|
||||
|
|
@ -15,11 +16,14 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp" />
|
||||
|
||||
<ImageView
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:layout_width="@dimen/avatar_small_width"
|
||||
android:layout_height="@dimen/avatar_small_height"
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:showBackground="false"
|
||||
app:showMount="false"
|
||||
app:showPet="false" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
|||
|
|
@ -1,16 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="24dip"
|
||||
android:paddingEnd="24dip"
|
||||
android:paddingStart="24dip"
|
||||
android:paddingRight="24dip">
|
||||
<ImageView
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:layout_width="@dimen/avatar_small_width"
|
||||
android:layout_height="@dimen/avatar_small_height"
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:showBackground="false"
|
||||
app:showMount="false"
|
||||
app:showPet="false" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import com.habitrpg.android.habitica.events.commands.OpenMenuItemCommand;
|
|||
import com.habitrpg.android.habitica.events.commands.SellItemCommand;
|
||||
import com.habitrpg.android.habitica.events.commands.UnlockPathCommand;
|
||||
import com.habitrpg.android.habitica.events.commands.UpdateUserCommand;
|
||||
import com.habitrpg.android.habitica.ui.AvatarView;
|
||||
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
|
||||
import com.habitrpg.android.habitica.ui.menu.MainDrawerBuilder;
|
||||
import com.habitrpg.android.habitica.ui.TutorialView;
|
||||
|
|
@ -38,7 +39,6 @@ import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment;
|
|||
import com.habitrpg.android.habitica.ui.fragments.GemsPurchaseFragment;
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
|
||||
import com.habitrpg.android.habitica.userpicture.BitmapUtils;
|
||||
import com.habitrpg.android.habitica.userpicture.UserPicture;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.SuppressedModals;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Tag;
|
||||
|
|
@ -164,8 +164,8 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
private APIHelper apiHelper;
|
||||
private AlertDialog faintDialog;
|
||||
|
||||
private UserPicture sideUserPicture;
|
||||
private UserPicture dialogUserPicture;
|
||||
private AvatarView mSideAvatarView;
|
||||
private AvatarView mDialogAvatarView;
|
||||
|
||||
private Date lastSync;
|
||||
|
||||
|
|
@ -199,8 +199,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
drawer = MainDrawerBuilder.CreateDefaultBuilderSettings(this, toolbar, accountHeader)
|
||||
.build();
|
||||
drawer.setSelectionAtPosition(1, false);
|
||||
this.sideUserPicture = new UserPicture(this, true, false);
|
||||
this.dialogUserPicture = new UserPicture(this, false, false);
|
||||
mSideAvatarView = new AvatarView(this, true, false, false);
|
||||
|
||||
if (this.filterDrawer == null) {
|
||||
filterDrawer = new DrawerBuilder()
|
||||
|
|
@ -579,9 +578,9 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
}
|
||||
}
|
||||
profile.withName(user.getProfile().getName());
|
||||
sideUserPicture.setUser(this.user);
|
||||
sideUserPicture.setPictureWithRunnable(avatar -> {
|
||||
profile.withIcon(avatar);
|
||||
mSideAvatarView.setUser(user);
|
||||
mSideAvatarView.onAvatarImageReady(avatarImage -> {
|
||||
profile.withIcon(avatarImage);
|
||||
accountHeader.updateProfile(profile);
|
||||
});
|
||||
accountHeader.updateProfile(profile);
|
||||
|
|
@ -993,9 +992,8 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
hpBar.setPartyMembers(true);
|
||||
AvatarWithBarsViewModel.setHpBarData(hpBar, user.getStats(), this);
|
||||
|
||||
ImageView avatarView = (ImageView) customView.findViewById(R.id.avatarView);
|
||||
this.dialogUserPicture.setUser(this.user);
|
||||
this.dialogUserPicture.setPictureOn(avatarView);
|
||||
mDialogAvatarView = (AvatarView) customView.findViewById(R.id.avatarView);
|
||||
mDialogAvatarView.setUser(user);
|
||||
}
|
||||
|
||||
this.faintDialog = new AlertDialog.Builder(this)
|
||||
|
|
@ -1027,11 +1025,16 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
if (customView != null) {
|
||||
TextView detailView = (TextView) customView.findViewById(R.id.levelupDetail);
|
||||
detailView.setText(this.getString(R.string.levelup_detail, level));
|
||||
ImageView avatarView = (ImageView) customView.findViewById(R.id.avatarView);
|
||||
this.dialogUserPicture.setUser(this.user);
|
||||
this.dialogUserPicture.setPictureOn(avatarView);
|
||||
mDialogAvatarView = (AvatarView) customView.findViewById(R.id.avatarView);
|
||||
mDialogAvatarView.setUser(user);
|
||||
}
|
||||
|
||||
final ShareEvent event = new ShareEvent();
|
||||
event.sharedMessage = getString(R.string.share_levelup, level) + " https://habitica.com/social/level-up";
|
||||
AvatarView avatarView = new AvatarView(this, true, true, true);
|
||||
avatarView.setUser(user);
|
||||
avatarView.onAvatarImageReady(avatarImage -> event.shareImage = avatarImage);
|
||||
|
||||
AlertDialog alert = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.levelup_header)
|
||||
.setView(customView)
|
||||
|
|
@ -1039,15 +1042,8 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
|
|||
checkClassSelection();
|
||||
})
|
||||
.setNeutralButton(R.string.share, (dialog, which) -> {
|
||||
ShareEvent event = new ShareEvent();
|
||||
event.sharedMessage = getString(R.string.share_levelup, level) + " https://habitica.com/social/level-up";
|
||||
UserPicture picture = new UserPicture(this, true, true);
|
||||
picture.setUser(this.user);
|
||||
picture.setPictureWithRunnable(avatarBitmap -> {
|
||||
event.shareImage = avatarBitmap;
|
||||
EventBus.getDefault().post(event);
|
||||
dialog.dismiss();
|
||||
});
|
||||
EventBus.getDefault().post(event);
|
||||
dialog.dismiss();
|
||||
})
|
||||
.create();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue