Skip to content

Commit

Permalink
sync now issue fixed (Fixes #762) (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrijal53 authored and leomaxi committed Apr 26, 2019
1 parent 6a78d30 commit f59b3bf
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import org.ole.planet.myplanet.MainApplication;
import org.ole.planet.myplanet.R;
import org.ole.planet.myplanet.base.BaseContainerFragment;
import org.ole.planet.myplanet.base.BaseResourceFragment;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class AchievementFragment extends BaseContainerFragment {
RealmUserModel user;
OnHomeItemClickListener listener;
RealmAchievement achievement;

@Override
public void onAttach(Context context) {
super.onAttach(context);
Expand All @@ -65,8 +67,8 @@ public AchievementFragment() {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_achievement, container, false);
mRealm = new DatabaseService(getActivity()).getRealmInstance();
user = new UserProfileDbHandler(getActivity()).getUserModel();
mRealm = new DatabaseService(MainApplication.context).getRealmInstance();
user = new UserProfileDbHandler(MainApplication.context).getUserModel();
rvOther = v.findViewById(R.id.rv_other_info);
tvGoal = v.findViewById(R.id.tv_goals);
tvName = v.findViewById(R.id.tv_name);
Expand All @@ -86,7 +88,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
achievement = mRealm.where(RealmAchievement.class).equalTo("_id", user.getId() + "@" + user.getPlanetCode()).findFirst();
achievement = mRealm.where(RealmAchievement.class).equalTo("_id", user.getId() + "@" + user.getPlanetCode()).findFirst();
tvFirstName.setText(user.getFirstName());
tvName.setText(String.format("%s %s %s", user.getFirstName(), user.getMiddleName(), user.getLastName()));
if (achievement != null) {
Expand All @@ -95,12 +97,12 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
tvAchievement.setText(achievement.getAchievementsHeader());
llAchievement.removeAllViews();
for (String s : achievement.getAchievements()) {
View v = LayoutInflater.from(getActivity()).inflate(R.layout.row_achievement, null);
View v = LayoutInflater.from(MainApplication.context).inflate(R.layout.row_achievement, null);
createView(v, s);
llAchievement.addView(v);
}
rvOther.setLayoutManager(new LinearLayoutManager(getActivity()));
rvOther.setAdapter(new AdapterOtherInfo(getActivity(), achievement.getreferences()));
rvOther.setLayoutManager(new LinearLayoutManager(MainApplication.context));
rvOther.setAdapter(new AdapterOtherInfo(MainApplication.context, achievement.getreferences()));
}
}

Expand Down Expand Up @@ -130,23 +132,23 @@ private void populateAchievementList(JsonElement ob, View v) {
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, (llDesc.getVisibility() == View.GONE ? R.drawable.ic_down : R.drawable.ic_up), 0);
});
showResourceButtons(flexboxLayout, libraries);
}else{
} else {
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
createAchievementList();
rvOther.setLayoutManager(new LinearLayoutManager(getActivity()));
rvOther.setAdapter(new AdapterOtherInfo(getActivity(), achievement.getreferences()));
rvOther.setLayoutManager(new LinearLayoutManager(MainApplication.context));
rvOther.setAdapter(new AdapterOtherInfo(MainApplication.context, achievement.getreferences()));
}
mRealm.addChangeListener(realm -> {
if (llAchievement!=null)
llAchievement.removeAllViews();
if (llAchievement != null)
llAchievement.removeAllViews();
createAchievementList();
});
}


private void createAchievementList() {
for (String s : achievement.getAchievements()) {
View v = LayoutInflater.from(getActivity()).inflate(R.layout.row_achievement, null);
View v = LayoutInflater.from(MainApplication.context).inflate(R.layout.row_achievement, null);
TextView title = v.findViewById(R.id.tv_title);
TextView date = v.findViewById(R.id.tv_date);
TextView description = v.findViewById(R.id.tv_description);
Expand Down Expand Up @@ -175,7 +177,7 @@ private void createAchievementList() {
private void showResourceButtons(FlexboxLayout flexboxLayout, ArrayList<RealmMyLibrary> libraries) {
for (RealmMyLibrary lib : libraries
) {
Button b = (Button) LayoutInflater.from(getActivity()).inflate(R.layout.layout_button_primary, null);
Button b = (Button) LayoutInflater.from(MainApplication.context).inflate(R.layout.layout_button_primary, null);
b.setText(lib.getTitle());
b.setCompoundDrawablesWithIntrinsicBounds(0, 0, (lib.isResourceOffline() ? R.drawable.ic_eye : R.drawable.ic_download), 0);
b.setOnClickListener(view -> {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<string name="question">Question</string>
<string name="bug">Bug</string>
<string name="your_feedback">Your Feedback *</string>
<string name="app_version">0.3.44</string>
<string name="app_version">0.3.49</string>
<string name="button_update">Update</string>
<string name="level">Level</string>
<string name="male">Male</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<string name="question">Question</string>
<string name="bug">Bug</string>
<string name="your_feedback">Your Feedback *</string>
<string name="app_version">0.3.44</string>
<string name="app_version">0.3.49</string>
<string name="button_update">Update</string>
<string name="level">Level</string>
<string name="male">Male</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<string name="question">Question</string>
<string name="bug">Bug</string>
<string name="your_feedback">Your Feedback *</string>
<string name="app_version">0.3.44</string>
<string name="app_version">0.3.49</string>
<string name="button_update">Update</string>
<string name="level">Level</string>
<string name="male">Male</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ne/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<string name="question">Question</string>
<string name="bug">Bug</string>
<string name="your_feedback">Your Feedback *</string>
<string name="app_version">0.3.44</string>
<string name="app_version">0.3.49</string>
<string name="button_update">Update</string>
<string name="level">Level</string>
<string name="male">Male</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-so/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<string name="question">Question</string>
<string name="bug">Bug</string>
<string name="your_feedback">Your Feedback *</string>
<string name="app_version">0.3.44</string>
<string name="app_version">0.3.49</string>
<string name="button_update">Update</string>
<string name="level">Level</string>
<string name="male">Male</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<string name="question">Question</string>
<string name="bug">Bug</string>
<string name="your_feedback">Your Feedback *</string>
<string name="app_version">0.3.48</string>
<string name="app_version">0.3.49</string>
<string name="button_update">Update</string>
<string name="level">Level</string>
<string name="male">Male</string>
Expand Down

0 comments on commit f59b3bf

Please sign in to comment.