fullprofile: show avatar / stats / attributes / equipment

This commit is contained in:
Negue 2016-08-03 00:12:15 +02:00
parent 2ddc426d6b
commit 246926f23f
23 changed files with 789 additions and 12 deletions

View file

@ -110,6 +110,16 @@
tools:ignore="UnusedAttribute"
android:label="@string/invite_users">
</activity>
<activity
android:name=".ui.activities.FullProfileActivity"
android:theme="@style/AppThemeWithActionBarBlackText"
android:parentActivityName=".ui.activities.MainActivity"
android:screenOrientation="portrait"
tools:ignore="UnusedAttribute">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.activities.MainActivity" />
</activity>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"

View file

@ -0,0 +1,240 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
style="@style/CardView.Default"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blurb"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
<ImageView
android:id="@+id/profile_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/profile_blurb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Blurb" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
style="@style/CardView.Default"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:id="@+id/avatar_with_bars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:adjustViewBounds="true"
android:background="@color/transparent"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.habitrpg.android.habitica.ui.AvatarView
android:id="@+id/avatarView"
android:layout_width="@dimen/avatar_header_width"
android:layout_height="@dimen/avatar_header_height"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
app:showBackground="true"
app:showMount="true"
app:showPet="true" />
<LinearLayout
android:id="@+id/LL_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/hpBar"
layout="@layout/value_bar" />
<include
android:id="@+id/xpBar"
layout="@layout/value_bar" />
<include
android:id="@+id/mpBar"
layout="@layout/value_bar" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/lvl_tv"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:drawableLeft="@drawable/ic_header_warrior"
android:drawablePadding="6dp"
android:drawableStart="@drawable/ic_header_warrior"
android:gravity="center"
android:textSize="14sp" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="36dp"
android:gravity="center_vertical">
<TextView
android:id="@+id/gems_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawableLeft="@drawable/ic_header_gem"
android:drawablePadding="8dp"
android:drawableStart="@drawable/ic_header_gem"
android:gravity="center"
android:textSize="14sp" />
<TextView
android:id="@+id/gold_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawableLeft="@drawable/ic_header_gold"
android:drawablePadding="6dp"
android:drawableStart="@drawable/ic_header_gold"
android:gravity="center"
android:textSize="14sp" />
<TextView
android:id="@+id/silver_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:drawableLeft="@drawable/ic_header_silver"
android:drawablePadding="6dp"
android:drawableStart="@drawable/ic_header_silver"
android:gravity="center"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
style="@style/CardView.Default"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Equipment"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
<ProgressBar
android:id="@+id/avatar_equip_progress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminate="true" />
<TableLayout
android:id="@+id/equipment_table"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</TableLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
style="@style/CardView.Default"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Attributes"
android:textSize="@dimen/abc_text_size_title_material"
android:textStyle="bold" />
<ProgressBar
android:id="@+id/avatar_attributes_progress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminate="true" />
<TableLayout
android:id="@+id/attributes_table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,1"
android:visibility="gone">
</TableLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">
<TextView
android:id="@+id/tableRowTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TableLayout
android:id="@+id/tableRowAttributesTable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:stretchColumns="0,1"
android:layout_marginBottom="5dp">
</TableLayout>
</TableRow>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/tableRowTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tableRowTextView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:gravity="right" />
</TableRow>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp">
<TextView
android:id="@+id/tableRowTextView1"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="2"
android:ellipsize="end"/>
<TextView
android:id="@+id/tableRowTextView2"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp" />
</TableRow>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/tableRowTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"/>
<TextView
android:id="@+id/tableRowTextView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp" />
</TableRow>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".ui.activities.TaskFormActivity">
<item android:id="@+id/private_message"
android:title="PM"
android:orderInCategory="100"
app:showAsAction="always"
/>
</menu>

View file

@ -82,6 +82,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.net.ssl.SSLException;
@ -120,6 +121,8 @@ public class APIHelper implements Action1<Throwable> {
private final Retrofit retrofitAdapter;
private AlertDialog displayedAlert;
public String languageCode;
//private OnHabitsAPIResult mResultListener;
//private HostConfig mConfig;
public APIHelper(GsonConverterFactory gsonConverter, HostConfig hostConfig) {
@ -129,6 +132,8 @@ public class APIHelper implements Action1<Throwable> {
Crashlytics.getInstance().core.setUserName(this.hostConfig.getUser());
Amplitude.getInstance().setUserId(this.hostConfig.getUser());
languageCode = Locale.getDefault().getLanguage();
Interceptor remove_data_interceptor = chain -> {
Response response = chain.proceed(chain.request());
String stringJson = response.body().string();

View file

@ -19,10 +19,17 @@ import rx.schedulers.Schedulers;
public class ContentCache {
private ApiService apiService;
private String language;
public ContentCache(ApiService apiService) {
this.apiService = apiService;
this.language = "en";
}
public ContentCache(ApiService apiService, String language) {
this.apiService = apiService;
this.language = language;
}
public void GetQuestContent(final String key, final QuestContentCallback cb) {
@ -73,7 +80,7 @@ public class ContentCache {
}
private <T> void getContentAndSearchFor(final String typeOfSearch, final String searchKey, final GotContentEntryCallback<T> gotEntry) {
apiService.getContent()
apiService.getContent(language)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(contentResult -> {
@ -117,7 +124,7 @@ public class ContentCache {
private void getContentAndSearchForList(final String typeOfSearch, final List<String> searchKeys, final GotContentEntryCallback<List<ItemData>> gotEntry) {
List<ItemData> resultList = new ArrayList<>();
apiService.getContent()
apiService.getContent(language)
.flatMap(contentResult -> {
List<ItemData> itemList = new ArrayList<ItemData>(contentResult.gear.flat);
itemList.add(contentResult.potion);

View file

@ -150,7 +150,9 @@ public class HabiticaApplication extends MultiDexApplication {
int lastInstalledVersion = sharedPrefs.getInt("last_installed_version", 0);
if (lastInstalledVersion < info.versionCode) {
sharedPrefs.edit().putInt("last_installed_version", info.versionCode).apply();
this.lazyApiHelper.get().apiService.getContent()
APIHelper apiHelper = this.lazyApiHelper.get();
apiHelper.apiService.getContent(apiHelper.languageCode)
.compose(this.lazyApiHelper.get().configureApiCallObserver())
.subscribe(contentResult -> {
}, throwable -> {

View file

@ -5,6 +5,7 @@ import com.habitrpg.android.habitica.modules.ApiModule;
import com.habitrpg.android.habitica.modules.AppModule;
import com.habitrpg.android.habitica.ui.activities.AboutActivity;
import com.habitrpg.android.habitica.ui.activities.ClassSelectionActivity;
import com.habitrpg.android.habitica.ui.activities.FullProfileActivity;
import com.habitrpg.android.habitica.ui.activities.GroupFormActivity;
import com.habitrpg.android.habitica.ui.activities.IntroActivity;
import com.habitrpg.android.habitica.ui.activities.LoginActivity;
@ -156,4 +157,6 @@ public interface AppComponent {
void inject(ShopsFragment shopsFragment);
void inject(ShopFragment shopFragment);
void inject(FullProfileActivity fullProfileActivity);
}

View file

@ -0,0 +1,9 @@
package com.habitrpg.android.habitica.events.commands;
public class OpenFullProfileCommand {
public String MemberId;
public OpenFullProfileCommand(String memberId){
MemberId = memberId;
}
}

View file

@ -193,4 +193,14 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
EventBus.getDefault().post(new OpenGemPurchaseFragmentCommand());
}
public void hideGems() {
gemsText.setVisibility(View.GONE);
}
public void valueBarLabelsToBlack() {
hpBar.setPartyMembers(true);
mpBar.setPartyMembers(true);
xpBar.setPartyMembers(true);
}
}

View file

@ -0,0 +1,372 @@
package com.habitrpg.android.habitica.ui.activities;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import com.habitrpg.android.habitica.APIHelper;
import com.habitrpg.android.habitica.ContentCache;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.components.AppComponent;
import com.habitrpg.android.habitica.ui.AvatarView;
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
import com.magicmicky.habitrpgwrapper.lib.models.Buffs;
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
import com.magicmicky.habitrpgwrapper.lib.models.Outfit;
import com.magicmicky.habitrpgwrapper.lib.models.Profile;
import com.magicmicky.habitrpgwrapper.lib.models.Stats;
import com.magicmicky.habitrpgwrapper.lib.models.tasks.ItemData;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import butterknife.BindView;
public class FullProfileActivity extends BaseActivity {
private String userId;
private ContentCache contentCache;
@Inject
APIHelper apiHelper;
@BindView(R.id.profile_image)
ImageView profile_image;
@BindView(R.id.profile_blurb)
TextView blurbTextView;
@BindView(R.id.avatarView)
AvatarView avatarView;
@BindView(R.id.attributes_table)
TableLayout attributesTableLayout;
@BindView(R.id.equipment_table)
TableLayout equipmentTableLayout;
@BindView(R.id.avatar_attributes_progress)
ProgressBar attributesProgress;
@BindView(R.id.avatar_equip_progress)
ProgressBar equipmentProgress;
@BindView(R.id.avatar_with_bars)
View avatar_with_bars;
private AvatarWithBarsViewModel avatarWithBars;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
this.userId = bundle.getString("userId");
setTitle("loading member data..");
apiHelper.apiService.GetMember(this.userId)
.compose(apiHelper.configureApiCallObserver())
.subscribe(habitRPGUser -> updateView(habitRPGUser),
throwable -> {});
this.contentCache = new ContentCache(apiHelper.apiService, apiHelper.languageCode);
avatarWithBars = new AvatarWithBarsViewModel(this, avatar_with_bars);
avatarWithBars.hideGems();
avatarWithBars.valueBarLabelsToBlack();
avatar_with_bars.setBackgroundColor(getResources().getColor(R.color.transparent));
}
private void updateView(HabitRPGUser user) {
Profile profile = user.getProfile();
Stats stats = user.getStats();
setTitle(profile.getName());
String imageUrl = profile.getImageUrl();
if (imageUrl == null || imageUrl.isEmpty()) {
profile_image.setVisibility(View.INVISIBLE);
} else {
profile_image.setImageURI(Uri.parse(imageUrl));
}
String blurbText = profile.getBlurb();
if (blurbText != null && !blurbText.isEmpty()) {
blurbTextView.setText(blurbText);
}
avatarView.setUser(user);
avatarWithBars.updateData(user);
addLevelAttributes(stats, user);
}
// region Utils
private String upperCaseFirstLetter(String s){
return Character.toUpperCase(s.charAt(0)) + s.substring(1);
}
private void stopAndHideProgress(ProgressBar bar){
bar.setIndeterminate(false);
bar.setVisibility(View.GONE);
}
private String getCeiledValue(float val){
return ((int)Math.ceil(val)) + "";
}
private void addAttributeRow(TableLayout table, String key, float val){
int intVal = (int) Math.ceil(val);
if(intVal == 0)
return;
addTableRow(table, key, intVal+"", R.layout.fullprofile_attributetablerow_two_textviews);
}
private void addTableRow(TableLayout table, String key, float val){
int intVal = (int) Math.ceil(val);
if(intVal == 0)
return;
addTableRow(table, key, intVal+"", R.layout.fullprofile_tablerow_two_textviews);
}
private void addTableRow(TableLayout table, String key, String value){
addTableRow(table, key, value, R.layout.fullprofile_tablerow_two_textviews);
}
private void addTableRow(TableLayout table, String key, String value, int resourceId){
TableRow tableRow = (TableRow)getLayoutInflater().inflate(resourceId, null);
TextView keyTextView = (TextView)tableRow.findViewById(R.id.tableRowTextView1);
keyTextView.setText(key);
TextView valueTextView = (TextView)tableRow.findViewById(R.id.tableRowTextView2);
valueTextView.setText(value);
table.addView(tableRow);
}
// endregion
// region Stats
StatHelper strHelper;
StatHelper intHelper;
StatHelper conHelper;
StatHelper perHelper;
private void addLevelAttributes(Stats stats, HabitRPGUser user)
{
float byLevelStat = stats.getLvl()/2.0f;
strHelper = getStatHelper("Strength: ");
strHelper.add("Level: ", byLevelStat);
intHelper = getStatHelper("Intelligence:");
intHelper.add("Level: ", byLevelStat);
conHelper = getStatHelper("Constitution:");
conHelper.add("Level: ", byLevelStat);
perHelper = getStatHelper("Perception:");
perHelper.add("Level: ", byLevelStat);
Outfit outfit = user.getItems().getGear().getEquipped();
ArrayList<String> outfitList = new ArrayList<>();
outfitList.add(outfit.getArmor());
outfitList.add(outfit.getBack());
outfitList.add(outfit.getBody());
outfitList.add(outfit.getEyeWear());
outfitList.add(outfit.getHead());
outfitList.add(outfit.getHeadAccessory());
outfitList.add(outfit.getShield());
outfitList.add(outfit.getWeapon());
contentCache.GetItemDataList(outfitList, obj ->{
GotGear(obj, user);
addNormalAddBuffAttributes(stats);
stopAndHideProgress(attributesProgress);
attributesTableLayout.setVisibility(View.VISIBLE);
});
}
public void GotGear(List<ItemData> obj, HabitRPGUser user) {
float strAttributes = 0;
float intAttributes = 0;
float conAttributes = 0;
float perAttributes = 0;
// Summarize stats and fill equipment table
for (ItemData i : obj){
int str_ = (int)i.getStr();
int int_ = (int)i.get_int();
int con_ = (int)i.getCon();
int per_ = (int) i.getPer();
strAttributes+= str_;
intAttributes+= int_;
conAttributes+= con_;
perAttributes+= per_;
StringBuilder sb = new StringBuilder();
if(str_ != 0){
sb.append("STR "+str_+", ");
}
if(int_ != 0){
sb.append("INT "+int_+", ");
}
if(con_ != 0){
sb.append("CON "+con_+", ");
}
if(per_ != 0){
sb.append("PER "+per_+", ");
}
// remove the last comma
if(sb.length() > 2)
{
sb.delete(sb.length()-2, sb.length());
}
addTableRow(equipmentTableLayout,i.getText(), sb.toString(), R.layout.fullprofile_equipment_tablerow);
}
stopAndHideProgress(equipmentProgress);
equipmentTableLayout.setVisibility(View.VISIBLE);
strHelper.add("Equipment: ", strAttributes);
intHelper.add("Equipment: ", intAttributes);
conHelper.add("Equipment: ", conAttributes);
perHelper.add("Equipment: ", perAttributes);
if(!user.getPreferences().isDisableClasses()){
float strClassBonus = 0;
float intClassBonus = 0;
float conClassBonus = 0;
float perClassBonus = 0;
switch(user.getStats().get_class()){
case rogue:
strClassBonus = strAttributes * 0.5f;
perClassBonus = perAttributes * 0.5f;
break;
case healer:
conClassBonus = conAttributes * 0.5f;
intClassBonus = intClassBonus * 0.5f;
break;
case warrior:
strClassBonus = strAttributes * 0.5f;
conClassBonus = conAttributes * 0.5f;
break;
case wizard:
intClassBonus = intClassBonus * 0.5f;
perClassBonus = perAttributes * 0.5f;
break;
}
strHelper.add("Class-Bonus: ", strClassBonus);
intHelper.add("Class-Bonus: ", intClassBonus);
conHelper.add("Class-Bonus: ", conClassBonus);
perHelper.add("Class-Bonus: ", perClassBonus);
}
}
private void addNormalAddBuffAttributes(Stats stats){
Buffs buffs = stats.getBuffs();
strHelper.add("Allocated: ", stats.getStr());
strHelper.add("Boosts: ", buffs.getStr());
intHelper.add("Allocated: ", stats.get_int());
intHelper.add("Boosts: ", buffs.get_int());
conHelper.add("Allocated: ", stats.getCon());
conHelper.add("Boosts: ", buffs.getCon());
perHelper.add("Allocated: ", stats.getPer());
perHelper.add("Boosts: ", buffs.getPer());
}
private StatHelper getStatHelper(String label){
TableRow tableRow = (TableRow)getLayoutInflater().inflate(R.layout.fullprofile_attributetablerow, null);
TextView keyTextView = (TextView)tableRow.findViewById(R.id.tableRowTextView1);
attributesTableLayout.addView(tableRow);
TableLayout layout = (TableLayout)tableRow.findViewById(R.id.tableRowAttributesTable);
return new StatHelper(layout, keyTextView, label);
}
public class StatHelper
{
private TableLayout layout;
private TextView textViewLabel;
private String attributeName;
public float currentStatCount = 0;
public StatHelper(TableLayout layout, TextView label, String attributeName){
this.layout = layout;
this.textViewLabel = label;
this.attributeName = attributeName;
}
public void add(String label, float value){
addAttributeRow(layout, label, value);
currentStatCount += value;
textViewLabel.setText(attributeName+" "+ getCeiledValue(currentStatCount));
}
}
// endregion
// region Navigation
@Override
public boolean onSupportNavigateUp() {
finish();
return true;
}
@Override
public void onBackPressed() {
finish();
}
// endregion
// region BaseActivity-Overrides
@Override
protected int getLayoutResId() {
return R.layout.activity_full_profile;
}
@Override
protected void injectActivity(AppComponent component) {
component.inject(this);
}
// endregion
}

View file

@ -49,7 +49,7 @@ public class IntroActivity extends BaseActivity implements View.OnClickListener,
this.skipButton.setOnClickListener(this);
this.finishButton.setOnClickListener(this);
apiHelper.apiService.getContent()
apiHelper.apiService.getContent(apiHelper.languageCode)
.compose(apiHelper.configureApiCallObserver())
.subscribe(contentResult -> {
}, throwable -> {

View file

@ -1096,7 +1096,7 @@ public class MainActivity extends BaseActivity implements Action1<Throwable>, Ha
public void reloadContent(ReloadContentEvent event) {
if (!this.isloadingContent) {
this.isloadingContent = true;
this.apiHelper.apiService.getContent()
this.apiHelper.apiService.getContent(apiHelper.languageCode)
.compose(apiHelper.configureApiCallObserver())
.subscribe(contentResult -> {
isloadingContent = false;

View file

@ -2,12 +2,15 @@ package com.habitrpg.android.habitica.ui.adapter.social;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.databinding.ValueBarBinding;
import com.habitrpg.android.habitica.events.commands.OpenFullProfileCommand;
import com.habitrpg.android.habitica.ui.AvatarView;
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
import com.habitrpg.android.habitica.ui.activities.SetupActivity;
import com.habitrpg.android.habitica.ui.helpers.ViewHelper;
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.databinding.DataBindingUtil;
import android.support.v4.content.ContextCompat;
@ -17,6 +20,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.greenrobot.eventbus.EventBus;
import java.util.List;
import butterknife.BindView;
@ -121,6 +126,15 @@ public class PartyMemberRecyclerViewAdapter extends RecyclerView.Adapter<PartyMe
}
ViewHelper.SetBackgroundTint(classBackground, ContextCompat.getColor(context, colorResourceID));
userName.setText(user.getProfile().getName());
itemView.setClickable(true);
itemView.setOnClickListener(view -> {
OpenFullProfileCommand cmd = new OpenFullProfileCommand(user.getId());
EventBus.getDefault().post(cmd);
});
}
}
}

View file

@ -16,6 +16,7 @@ import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import rx.Observable;
@ -29,7 +30,7 @@ public class RewardsRecyclerViewAdapter extends BaseTasksRecyclerViewAdapter<Rew
super(taskType, tagsHelper, layoutResource, newContext, user.getId());
this.user = user;
this.apiHelper = apiHelper;
this.contentCache = new ContentCache(apiHelper.apiService);
this.contentCache = new ContentCache(apiHelper.apiService, apiHelper.languageCode);
}
@Override

View file

@ -61,7 +61,7 @@ public class AvatarOverviewFragment extends BaseMainFragment implements AdapterV
super.onCreate(savedInstanceState);
if (this.apiHelper != null) {
this.apiHelper.apiService.getContent()
this.apiHelper.apiService.getContent(apiHelper.languageCode)
.compose(apiHelper.configureApiCallObserver())
.subscribe(contentResult -> {
}, throwable -> {

View file

@ -14,6 +14,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.Locale;
public class TavernFragment extends BaseMainFragment {
public ViewPager viewPager;
@ -60,7 +62,7 @@ public class TavernFragment extends BaseMainFragment {
TavernFragment.this.tabLayout.setupWithViewPager(TavernFragment.this.viewPager);
}
ContentCache contentCache = new ContentCache(apiHelper.apiService);
ContentCache contentCache = new ContentCache(apiHelper.apiService, apiHelper.languageCode);
contentCache.GetQuestContent(group.quest.key, content -> {
if (questInfoFragment != null) {

View file

@ -3,6 +3,8 @@ package com.habitrpg.android.habitica.ui.fragments.social.party;
import com.habitrpg.android.habitica.ContentCache;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.components.AppComponent;
import com.habitrpg.android.habitica.events.commands.OpenFullProfileCommand;
import com.habitrpg.android.habitica.ui.activities.FullProfileActivity;
import com.habitrpg.android.habitica.ui.activities.GroupFormActivity;
import com.habitrpg.android.habitica.ui.activities.PartyInviteActivity;
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment;
@ -25,6 +27,8 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -53,7 +57,7 @@ public class PartyFragment extends BaseMainFragment {
viewPager.setCurrentItem(0);
contentCache = new ContentCache(apiHelper.apiService);
contentCache = new ContentCache(apiHelper.apiService, apiHelper.languageCode);
// Get the full group data
if (this.user != null && this.user.getParty() != null && this.user.getParty().id != null) {
@ -338,4 +342,16 @@ public class PartyFragment extends BaseMainFragment {
tabLayout.setupWithViewPager(viewPager);
}
}
@Subscribe
public void onEvent(OpenFullProfileCommand cmd)
{
Bundle bundle = new Bundle();
bundle.putString("userId", cmd.MemberId);
Intent intent = new Intent(activity, FullProfileActivity.class);
intent.putExtras(bundle);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
}
}

View file

@ -47,7 +47,7 @@ public interface ApiService {
Observable<Status> getStatus();
@GET("content")
Observable<ContentResult> getContent();
Observable<ContentResult> getContent(@Query("language") String language);
/* user API */
@ -230,6 +230,9 @@ public interface ApiService {
Observable<PurchaseValidationResult> validatePurchase(@Body PurchaseValidationRequest request);
//Members URL
@GET("members/{mid}")
Observable<HabitRPGUser> GetMember(@Path("mid") String memberId);
@POST("members/send-private-message")
Observable<PostChatMessageResult> postPrivateMessage(@Body HashMap<String, String> messageDetails);

View file

@ -26,7 +26,7 @@ public class Stats extends PlayerMinStats {
}
public Integer getMaxHealth() {
return maxHealth != null ? maxHealth : Integer.valueOf(0);
return maxHealth != null ? maxHealth : Integer.valueOf(50);
}
public void setMaxHealth(Integer maxHealth) {