mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 05:09:00 +00:00
challenge detail activity
This commit is contained in:
parent
6ca2b0e6e4
commit
445d1781d7
16 changed files with 422 additions and 56 deletions
|
|
@ -18,6 +18,7 @@
|
|||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:name=".HabiticaApplication"
|
||||
|
|
@ -125,6 +126,15 @@
|
|||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".ui.activities.MainActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.ChallengeDetailActivity"
|
||||
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"
|
||||
|
|
@ -221,5 +231,4 @@
|
|||
<service android:name=".widget.HabitButtonWidgetService"/>
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
||||
|
|
|
|||
207
Habitica/res/layout/activity_challenge_detail.xml
Normal file
207
Habitica/res/layout/activity_challenge_detail.xml
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
<FrameLayout 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"
|
||||
android:id="@+id/overlayFrameLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.activities.MainActivity">
|
||||
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:gravity="center">
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:elevation="0dp"
|
||||
tools:context=".ui.activities.MainActivity">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="false">
|
||||
|
||||
<android.support.design.widget.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="false"
|
||||
app:contentScrim="?attr/colorPrimary"
|
||||
app:expandedTitleMarginEnd="?attr/actionBarSize"
|
||||
app:expandedTitleMarginStart="0dp"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||
app:titleEnabled="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/challenge_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:fitsSystemWindows="true"
|
||||
android:focusable="true"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:focusableInTouchMode="true"
|
||||
app:layout_collapseMode="parallax"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/challenge_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/textColorDark"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/challenge_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/textColorDark"
|
||||
android:lines="3"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:weightSum="1.0">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/leader_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1"
|
||||
android:textColor="@color/textColorDark" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="right">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_people_black_24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/memberCountTextView"
|
||||
android:textColor="@color/textColorDark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingStart="5dp"
|
||||
android:text="0" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="end"
|
||||
android:weightSum="1.0">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/gem_prize_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="end">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_header_gem" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gemPrizeTextView"
|
||||
android:textColor="@color/textColorDark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingStart="5dp"
|
||||
android:text="0" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
android:theme="@style/Toolbar"
|
||||
app:layout_collapseMode="pin"
|
||||
app:popupTheme="@style/Theme.AppCompat.Light" />
|
||||
</android.support.design.widget.CollapsingToolbarLayout>
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/detail_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@color/brand_200"
|
||||
android:elevation="0dp"
|
||||
android:fillViewport="false"
|
||||
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
|
||||
app:layout_anchor="@+id/collapsing_toolbar"
|
||||
app:layout_anchorGravity="bottom"
|
||||
|
||||
app:layout_collapseMode="pin"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="@android:color/white"
|
||||
app:tabMode="fixed" />
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/floating_menu_wrapper"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="8dp"
|
||||
app:layout_behavior="com.habitrpg.android.habitica.ui.helpers.FloatingActionMenuBehavior" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
</android.support.v4.widget.DrawerLayout>
|
||||
</FrameLayout>
|
||||
|
|
@ -2,9 +2,9 @@
|
|||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/card_view"
|
||||
style="@style/CardView.Default"
|
||||
android:clickable="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:layout_margin="5dp">
|
||||
|
||||
<LinearLayout
|
||||
|
|
@ -19,6 +19,12 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/challenge_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:lines="3"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -31,13 +37,13 @@
|
|||
android:layout_weight="0.5">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/leader_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1" />
|
||||
<TextView
|
||||
android:id="@+id/leader_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -47,58 +53,60 @@
|
|||
android:layout_weight="0.5"
|
||||
android:gravity="right">
|
||||
|
||||
<ImageView android:src="@drawable/ic_people_black_24dp"
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp" />
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_people_black_24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/memberCountTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1"
|
||||
android:text="0"
|
||||
android:layout_gravity="center"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingStart="5dp" />
|
||||
android:paddingStart="5dp"
|
||||
android:text="0" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="end"
|
||||
android:weightSum="1.0">
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="end"
|
||||
android:id="@+id/gem_prize_layout">
|
||||
android:weightSum="1.0">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_header_gem" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gemPrizeTextView"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/gem_prize_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1"
|
||||
android:text="0"
|
||||
android:layout_gravity="center"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingStart="5dp" />
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="end">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/ic_header_gem" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gemPrizeTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingStart="5dp"
|
||||
android:text="0" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
|
@ -437,4 +437,5 @@ To start, which parts of your life do you want to improve?</string>
|
|||
<string name="AudioTheme_title">Audio Theme</string>
|
||||
<string name="AudioTheme_summary">Change Habitica\'s Audio Theme</string>
|
||||
<string name="by">by</string>
|
||||
<string name="challenge_details">Challenge Details</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.habitrpg.android.habitica.modules.ApiModule;
|
|||
import com.habitrpg.android.habitica.modules.AppModule;
|
||||
import com.habitrpg.android.habitica.receivers.LocalNotificationActionReceiver;
|
||||
import com.habitrpg.android.habitica.ui.activities.AboutActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.ChallengeDetailActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.ClassSelectionActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.FullProfileActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.GroupFormActivity;
|
||||
|
|
@ -196,4 +197,6 @@ public interface AppComponent {
|
|||
void inject(ChallengeTasksFragment challengeTasksFragment);
|
||||
|
||||
void inject(ChallengeTaskRecyclerViewFragment challengeTaskRecyclerViewFragment);
|
||||
|
||||
void inject(ChallengeDetailActivity challengeDetailActivity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,76 @@
|
|||
package com.habitrpg.android.habitica.ui.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
|
||||
import com.habitrpg.android.habitica.APIHelper;
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.components.AppComponent;
|
||||
import com.habitrpg.android.habitica.ui.adapter.social.ChallengesListViewAdapter.ChallengeViewHolder;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengeTasksFragment;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
public class ChallengeDetailActivity extends BaseActivity {
|
||||
|
||||
public static String CHALLENGE_ID = "CHALLENGE_ID";
|
||||
|
||||
@BindView(R.id.detail_tabs)
|
||||
TabLayout detail_tabs;
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
|
||||
@Inject
|
||||
public APIHelper apiHelper;
|
||||
|
||||
private ChallengeViewHolder challengeViewHolder;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.activity_challenge_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setupToolbar(toolbar);
|
||||
|
||||
getSupportActionBar().setTitle(R.string.challenge_details);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
|
||||
String challengeId = extras.getString(CHALLENGE_ID);
|
||||
|
||||
ChallengeTasksFragment fragment = new ChallengeTasksFragment();
|
||||
fragment.setTabLayout(detail_tabs);
|
||||
fragment.setUser(HabiticaApplication.User);
|
||||
fragment.setChallengeId(challengeId);
|
||||
|
||||
if (getSupportFragmentManager().getFragments() == null) {
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, fragment).commitAllowingStateLoss();
|
||||
} else {
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out, android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
transaction.replace(R.id.fragment_container, fragment).addToBackStack(null).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
apiHelper.apiService.getChallenge(challengeId)
|
||||
.compose(apiHelper.configureApiCallObserver())
|
||||
.subscribe(challenge -> challengeViewHolder.bind(challenge), throwable -> {
|
||||
});
|
||||
|
||||
challengeViewHolder = new ChallengeViewHolder(findViewById(R.id.challenge_header));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void injectActivity(AppComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -51,10 +51,13 @@ public class ChallengesListViewAdapter extends RecyclerView.Adapter<ChallengesLi
|
|||
return challenges.size();
|
||||
}
|
||||
|
||||
public class ChallengeViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public static class ChallengeViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
@BindView(R.id.challenge_name)
|
||||
TextView challengeName;
|
||||
|
||||
@BindView(R.id.challenge_description)
|
||||
TextView challengeDescription;
|
||||
|
||||
@BindView(R.id.leader_label)
|
||||
TextView leaderName;
|
||||
|
||||
|
|
@ -81,6 +84,7 @@ public class ChallengesListViewAdapter extends RecyclerView.Adapter<ChallengesLi
|
|||
this.challenge = challenge;
|
||||
|
||||
challengeName.setText(challenge.name);
|
||||
challengeDescription.setText(challenge.description);
|
||||
|
||||
leaderName.setText(getContext().getString(R.string.by) + " " + getLeaderName(challenge.leader));
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.habitrpg.android.habitica.ui.fragments;
|
|||
|
||||
import com.habitrpg.android.habitica.APIHelper;
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager;
|
||||
import com.habitrpg.android.habitica.ui.activities.IActivityWithFragment;
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.raizlabs.android.dbflow.sql.builder.Condition;
|
||||
|
|
@ -60,9 +61,15 @@ public abstract class BaseMainFragment extends BaseFragment {
|
|||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
this.activity = (MainActivity) getActivity();
|
||||
|
||||
try{
|
||||
this.activity = (MainActivity) getActivity();
|
||||
} catch(Exception ex){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
|
@ -87,7 +94,9 @@ public abstract class BaseMainFragment extends BaseFragment {
|
|||
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
activity.setActiveFragment(this);
|
||||
if(activity != null) {
|
||||
activity.setActiveFragment(this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,8 +159,6 @@ public class ChallengeTaskRecyclerViewFragment extends BaseFragment {
|
|||
// region Challenge specific RecyclerViewAdapters
|
||||
|
||||
private class ChallengeHabitsRecyclerViewAdapter extends SortableTasksRecyclerViewAdapter<HabitViewHolder> {
|
||||
|
||||
|
||||
public ChallengeHabitsRecyclerViewAdapter(String taskType, TagsHelper tagsHelper, int layoutResource, Context newContext, String userID, SortTasksCallback sortCallback) {
|
||||
super(taskType, tagsHelper, layoutResource, newContext, userID, sortCallback);
|
||||
}
|
||||
|
|
@ -172,7 +170,9 @@ public class ChallengeTaskRecyclerViewFragment extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public HabitViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new HabitViewHolder(getContentView(parent));
|
||||
HabitViewHolder habitViewHolder = new HabitViewHolder(getContentView(parent));
|
||||
habitViewHolder.setDisabled(true);
|
||||
return habitViewHolder;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +194,9 @@ public class ChallengeTaskRecyclerViewFragment extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public DailyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new DailyViewHolder(getContentView(parent), dailyResetOffset);
|
||||
DailyViewHolder dailyViewHolder = new DailyViewHolder(getContentView(parent), dailyResetOffset);
|
||||
dailyViewHolder.setDisabled(true);
|
||||
return dailyViewHolder;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +214,9 @@ public class ChallengeTaskRecyclerViewFragment extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public TodoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new TodoViewHolder(getContentView(parent));
|
||||
TodoViewHolder todoViewHolder = new TodoViewHolder(getContentView(parent));
|
||||
todoViewHolder.setDisabled(true);
|
||||
return todoViewHolder;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +233,9 @@ public class ChallengeTaskRecyclerViewFragment extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public RewardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new RewardViewHolder(getContentView(parent));
|
||||
RewardViewHolder rewardViewHolder = new RewardViewHolder(getContentView(parent));
|
||||
rewardViewHolder.setDisabled(true);
|
||||
return rewardViewHolder;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,13 +86,13 @@ public class ChallengeTasksFragment extends BaseMainFragment {
|
|||
public CharSequence getPageTitle(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return activity.getString(R.string.habits);
|
||||
return getContext().getString(R.string.habits);
|
||||
case 1:
|
||||
return activity.getString(R.string.dailies);
|
||||
return getContext().getString(R.string.dailies);
|
||||
case 2:
|
||||
return activity.getString(R.string.todos);
|
||||
return getContext().getString(R.string.todos);
|
||||
case 3:
|
||||
return activity.getString(R.string.rewards);
|
||||
return getContext().getString(R.string.rewards);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments.social.challenges;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
|
|
@ -11,6 +12,8 @@ import android.view.ViewGroup;
|
|||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.components.AppComponent;
|
||||
import com.habitrpg.android.habitica.events.commands.ShowChallengeTasksCommand;
|
||||
import com.habitrpg.android.habitica.ui.activities.ChallengeDetailActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.FullProfileActivity;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
|
@ -88,9 +91,13 @@ public class ChallengesOverviewFragment extends BaseMainFragment {
|
|||
|
||||
@Subscribe
|
||||
public void onEvent(ShowChallengeTasksCommand cmd){
|
||||
ChallengeTasksFragment fragment = new ChallengeTasksFragment();
|
||||
fragment.setChallengeId(cmd.challengeId);
|
||||
|
||||
activity.displayFragment(fragment);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(ChallengeDetailActivity.CHALLENGE_ID, cmd.challengeId);
|
||||
|
||||
Intent intent = new Intent(activity, ChallengeDetailActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ public class BaseTaskViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
@BindColor(R.color.task_gray)
|
||||
int taskGray;
|
||||
|
||||
boolean disabled;
|
||||
|
||||
public BaseTaskViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
|
|
@ -92,7 +94,7 @@ public class BaseTaskViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v != itemView) {
|
||||
if (v != itemView || isDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -105,4 +107,14 @@ public class BaseTaskViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
public boolean canContainMarkdown() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
|
||||
itemView.setEnabled(!disabled);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,4 +163,11 @@ public abstract class ChecklistedViewHolder extends BaseTaskViewHolder implement
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisabled(boolean disabled) {
|
||||
super.setDisabled(disabled);
|
||||
|
||||
this.checkbox.setEnabled(!disabled);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,4 +68,12 @@ public class HabitViewHolder extends BaseTaskViewHolder {
|
|||
event.habit = task;
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisabled(boolean disabled) {
|
||||
super.setDisabled(disabled);
|
||||
|
||||
this.btnPlus.setEnabled(!disabled);
|
||||
this.btnMinus.setEnabled(!disabled);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,5 +90,11 @@ public class RewardViewHolder extends BaseTaskViewHolder {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisabled(boolean disabled) {
|
||||
super.setDisabled(disabled);
|
||||
|
||||
this.rewardButton.setEnabled(!disabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,6 +267,9 @@ public interface ApiService {
|
|||
@GET("tasks/challenge/{challengeId}")
|
||||
Observable<TaskList> getChallengeTasks(@Path("challengeId") String challengeId);
|
||||
|
||||
@GET("challenges/{challengeId}")
|
||||
Observable<Challenge> getChallenge(@Path("challengeId") String challengeId);
|
||||
|
||||
//DEBUG: These calls only work on a local development server
|
||||
|
||||
@POST("debug/add-ten-gems")
|
||||
|
|
|
|||
Loading…
Reference in a new issue