package com.uwflow.flow_android.activities;


import android.graphics.Bitmap;
import android.graphics.Point;
import android.os.Bundle;
import android.widget.ImageView;
import com.uwflow.flow_android.FlowActivity;
import com.uwflow.flow_android.R;
import com.uwflow.flow_android.custom_view.TouchImageView;
import com.uwflow.flow_android.db_object.ScheduleImage;
import com.uwflow.flow_android.network.FlowDatabaseLoader;

public class FullScreenImageActivity extends FlowActivity {
    private ImageView mImageView;

    private FlowDatabaseLoader mFlowDatabaseLoader;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mFlowDatabaseLoader = new FlowDatabaseLoader(getApplicationContext(), getHelper());
        getActionBar().hide();


        setContentView(R.layout.full_screen_image_layout);
        mImageView = (ImageView) findViewById(R.id.image_full_screen);

        String profileID = getIntent().getStringExtra("id");

        ScheduleImage scheduleImage = mFlowDatabaseLoader.queryUserScheduleImage(profileID);
        if (scheduleImage != null) {
            Bitmap bitmap = scheduleImage.getImage();
            if (bitmap != null) {
                // When entering fullscreen mode, ensure schedule is full height
                int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
                int statusBarHeight = resourceId > 0 ? getResources().getDimensionPixelSize(resourceId) : 50;
                Point displaySize = new Point();
                getWindowManager().getDefaultDisplay().getSize(displaySize);
                int screenWidth = displaySize.x;
                int screenHeight = displaySize.y - statusBarHeight;
                double scaledHeight = bitmap.getHeight() * ((double) screenWidth / bitmap.getWidth());
                double zoomFactor = (double) screenHeight / scaledHeight;
                ((TouchImageView) mImageView).setZoom((float) zoomFactor, 0, 0);

                // TODO(david): Figure out why some schedules get downscaled on Mack's phone
                mImageView.setImageBitmap(bitmap);
            }
        }
    }
}

@@ -355,16 +355,82 @@
 eImage;%0A
+import com.uwflow.flow_android.network.FlowDatabaseImageCallback;%0A
 import c
@@ -1072,93 +1072,203 @@
     
-ScheduleImage scheduleImage = mFlowDatabaseLoader.queryUserScheduleImage(profileID);%0A
+mFlowDatabaseLoader.queryUserScheduleImage(profileID, new FlowDatabaseImageCallback() %7B%0A            @Override%0A            public void onScheduleImageLoaded(ScheduleImage scheduleImage) %7B%0A        
     
@@ -1312,16 +1312,24 @@
         
+  
+      
 Bitmap b
@@ -1370,24 +1370,32 @@
             
+    
+    
 if (bitmap !
@@ -1396,32 +1396,40 @@
 tmap != null) %7B%0A
+        
                 
@@ -1493,16 +1493,24 @@
  height%0A
+        
         
@@ -1617,24 +1617,32 @@
             
+        
 int statusBa
@@ -1739,16 +1739,24 @@
         
+        
 Point di
@@ -1796,16 +1796,24 @@
         
+    
+    
 getWindo
@@ -1873,32 +1873,40 @@
                 
+        
 int screenWidth 
@@ -1922,16 +1922,24 @@
 Size.x;%0A
+        
         
@@ -2010,24 +2010,32 @@
             
+        
 double scale
@@ -2121,24 +2121,32 @@
             
+        
 double zoomF
@@ -2207,16 +2207,24 @@
         
+    
+    
 ((TouchI
@@ -2277,24 +2277,32 @@
 or, 0, 0);%0A%0A
+        
             
@@ -2382,16 +2382,24 @@
 s phone%0A
+        
         
@@ -2441,16 +2441,56 @@
 itmap);%0A
+                    %7D%0A                %7D%0A
         
@@ -2500,21 +2500,23 @@
  %7D%0A        %7D
+);
 %0A    %7D%0A%7D%0A

rebase fix