Commit 28256995 authored by Varun Patil's avatar Varun Patil

Open webview on achievement offer tap

parent f928ede8
......@@ -70,6 +70,7 @@ public class Constants {
public static final String WV_TYPE_UPDATE_EVENT = "update_event";
public static final String WV_TYPE_UPDATE_BODY = "update_body";
public static final String WV_TYPE_ACHIEVEMENTS = "achievements";
public static final String WV_TYPE_NEW_OFFERED_ACHIEVEMENT = "achievements_new_offered";
public static final String WV_TYPE_URL = "url_type";
public static final String WV_ID = "id";
public static final String WV_URL = "url";
......
package app.insti.adapter;
import android.os.Bundle;
import android.view.View;
import androidx.fragment.app.Fragment;
......@@ -7,14 +8,17 @@ import androidx.fragment.app.Fragment;
import java.util.ArrayList;
import java.util.List;
import app.insti.Constants;
import app.insti.R;
import app.insti.Utils;
import app.insti.activity.MainActivity;
import app.insti.api.model.Achievement;
import app.insti.api.model.Body;
import app.insti.api.model.Event;
import app.insti.api.model.OfferedAchievement;
import app.insti.api.model.Role;
import app.insti.api.model.User;
import app.insti.fragment.WebViewFragment;
import app.insti.interfaces.CardInterface;
public class GenericAdapter extends CardAdapter<CardInterface> {
......@@ -41,6 +45,13 @@ public class GenericAdapter extends CardAdapter<CardInterface> {
} else {
Utils.openBodyFragment(a.getAchievementBody(), fragment, view.findViewById(R.id.object_picture));
}
} else if (cardInterface instanceof OfferedAchievement) {
WebViewFragment webViewFragment = new WebViewFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_NEW_OFFERED_ACHIEVEMENT);
bundle.putString(Constants.WV_ID, ((OfferedAchievement) cardInterface).getAchievementID());
webViewFragment.setArguments(bundle);
Utils.updateFragment(webViewFragment, fragment.getActivity());
}
}
......
......@@ -73,7 +73,8 @@ public class WebViewFragment extends BaseFragment {
// Check for arguments
final String type = args.getString(Constants.WV_TYPE);
final String ID = args.getString(Constants.WV_ID);
String ID = args.getString(Constants.WV_ID);
if (ID == null) { ID = ""; }
switch (type) {
case Constants.WV_TYPE_ADD_EVENT:
......@@ -96,6 +97,11 @@ public class WebViewFragment extends BaseFragment {
setTitle("Achievements");
break;
case Constants.WV_TYPE_NEW_OFFERED_ACHIEVEMENT:
url += "/achievement-new/" + ID;
setTitle("Achievements");
break;
case Constants.WV_TYPE_URL:
return args.getString(Constants.WV_URL);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment