Commit 5d5cfe6e authored by Varun Patil's avatar Varun Patil

Fix loading full resolution image without shared elem in body fragment (fix #257)

parent 2dc3ba09
...@@ -139,23 +139,24 @@ public final class Utils { ...@@ -139,23 +139,24 @@ public final class Utils {
.commit(); .commit();
} }
public static BodyFragment getBodyFragment(Body body) { public static BodyFragment getBodyFragment(Body body, boolean sharedElements) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(Constants.BODY_JSON, new Gson().toJson(body)); bundle.putString(Constants.BODY_JSON, new Gson().toJson(body));
bundle.putBoolean(Constants.NO_SHARED_ELEM, sharedElements);
BodyFragment bodyFragment = new BodyFragment(); BodyFragment bodyFragment = new BodyFragment();
bodyFragment.setArguments(bundle); bodyFragment.setArguments(bundle);
return bodyFragment; return bodyFragment;
} }
public static void openBodyFragment(Body body, FragmentActivity fragmentActivity) { public static void openBodyFragment(Body body, FragmentActivity fragmentActivity) {
updateFragment(getBodyFragment(body), fragmentActivity); updateFragment(getBodyFragment(body, true), fragmentActivity);
} }
public static void openBodyFragment(Body body, Fragment currentFragment, View sharedAvatar) { public static void openBodyFragment(Body body, Fragment currentFragment, View sharedAvatar) {
Map<View, String> sharedElements = new HashMap<>(); Map<View, String> sharedElements = new HashMap<>();
sharedElements.put(sharedAvatar, "sharedAvatar"); sharedElements.put(sharedAvatar, "sharedAvatar");
updateSharedElementFragment( updateSharedElementFragment(
getBodyFragment(body), currentFragment, sharedElements getBodyFragment(body, false), currentFragment, sharedElements
); );
} }
......
...@@ -328,10 +328,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -328,10 +328,10 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
switch (type) { switch (type) {
case DATA_TYPE_BODY: case DATA_TYPE_BODY:
openBodyFragment(id); Utils.openBodyFragment(new Body(id), this);
return; return;
case DATA_TYPE_USER: case DATA_TYPE_USER:
openUserFragment(id); Utils.openUserFragment(id, this);
return; return;
case DATA_TYPE_EVENT: case DATA_TYPE_EVENT:
openEventFragment(id); openEventFragment(id);
...@@ -363,21 +363,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -363,21 +363,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
/**
* Open user fragment from given id
*/
private void openUserFragment(String id) {
UserFragment userFragment = UserFragment.newInstance(id);
updateFragment(userFragment);
}
/**
* Open the body fragment from given id
*/
private void openBodyFragment(String id) {
Utils.openBodyFragment(new Body(id), this);
}
/** /**
* Open the event fragment from the provided id * Open the event fragment from the provided id
*/ */
...@@ -466,7 +451,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -466,7 +451,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
header.setOnClickListener(new View.OnClickListener() { header.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
openUserFragment(currentUser.getUserID()); Utils.openUserFragment(currentUser.getUserID(), MainActivity.this);
DrawerLayout drawer = findViewById(R.id.drawer_layout); DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START); drawer.closeDrawer(GravityCompat.START);
} }
......
...@@ -153,6 +153,11 @@ public class BodyFragment extends BackHandledFragment implements TransitionTarge ...@@ -153,6 +153,11 @@ public class BodyFragment extends BackHandledFragment implements TransitionTarge
Toolbar toolbar = getActivity().findViewById(R.id.toolbar); Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle(min_body.getBodyName()); toolbar.setTitle(min_body.getBodyName());
Bundle bundle = getArguments();
if (bundle != null && bundle.getBoolean(Constants.NO_SHARED_ELEM, true)) {
this.transitionEnd();
}
} }
private void updateBody() { private void updateBody() {
......
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