Skip to content

Commit b4c4bdd

Browse files
committed
Bug Fixes on Responsive and Removed Using Window Manager
1 parent 096aa04 commit b4c4bdd

File tree

5 files changed

+32
-26
lines changed

5 files changed

+32
-26
lines changed

app/src/main/java/com/fexcon/imgpopup/MainActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ protected void onCreate(Bundle savedInstanceState) {
2929
/** Set Image Height, Width & Background Color as you want **/
3030
final ImagePopup imagePopup = new ImagePopup(this);
3131
//imagePopup.setBackgroundColor(Color.BLACK);
32-
imagePopup.setWindowWidth(800);
33-
imagePopup.setWindowHeight(800);
3432
imagePopup.setHideCloseIcon(true);
3533
imagePopup.setImageOnClickClose(true);
3634

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.3'
8+
classpath 'com.android.tools.build:gradle:2.3.1'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Dec 28 10:00:20 PST 2015
1+
#Wed May 31 11:11:27 IST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

imageviewpopup/src/main/java/com/ceylonlabs/imageviewpopup/ImagePopup.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public void setHideCloseIcon(boolean hideCloseIcon) {
9191
}
9292

9393
public void initiatePopup(Drawable drawable){
94+
95+
9496
try{
9597
LayoutInflater inflater = (LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
9698

@@ -100,32 +102,30 @@ public void initiatePopup(Drawable drawable){
100102

101103
ImageView imageView = (ImageView)layout.findViewById(R.id.imageView);
102104
imageView.setImageDrawable(drawable);
105+
106+
107+
103108
Log.e("Image","Height--> "+imageView.getDrawable().getMinimumHeight());
104109
Log.e("Image","Width--> "+imageView.getDrawable().getMinimumWidth());
105110

106-
/** Height & Width Adjustments according to the Image size and Device Screen size **/
111+
112+
113+
114+
115+
// /** Height & Width Adjustments according to the Image size and Device Screen size **/
107116
DisplayMetrics metrics = new DisplayMetrics();
108117
((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics);
109118
Log.e("Phone Height","-->"+metrics.heightPixels);
110119
Log.e("Phone Width","-->"+metrics.widthPixels);
111120

112-
if(windowWidth == 0 || windowHeight == 0) {
113-
windowHeight = imageView.getDrawable().getMinimumHeight();
114-
windowWidth = imageView.getDrawable().getMinimumWidth();
115-
if (metrics.heightPixels < imageView.getDrawable().getMinimumHeight() && metrics.widthPixels < imageView.getDrawable().getMinimumWidth()) {
116-
/** Landscape Image **/
117-
if (windowHeight < windowWidth) {
118-
windowHeight = metrics.heightPixels - 1310;
119-
windowWidth = metrics.widthPixels - 250;
120-
} else {
121-
windowHeight = metrics.heightPixels - 460;
122-
windowWidth = metrics.widthPixels - 200;
123-
}
121+
int width = metrics.widthPixels;
122+
int height = metrics.heightPixels;
124123

125-
}
126-
}
124+
// ((Activity) getContext()).getWindow().setLayout((int)(width*.8),(int)(height*.6));
125+
//
126+
127+
popupWindow = new PopupWindow(layout, (int)(width*.8),(int)(height*.6), true);
127128

128-
popupWindow = new PopupWindow(layout, windowWidth, windowHeight, true);
129129
popupWindow.showAtLocation(layout, Gravity.CENTER, 0,0);
130130

131131
ImageView closeIcon = (ImageView)layout.findViewById(R.id.closeBtn);
@@ -152,11 +152,11 @@ public void onClick(View view) {
152152
}
153153

154154
/** Background dim part **/
155-
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
156-
WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) layout.getLayoutParams();
157-
layoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
158-
layoutParams.dimAmount = 0.3f;
159-
windowManager.updateViewLayout(layout, layoutParams);
155+
// WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
156+
// WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) layout.getLayoutParams();
157+
// layoutParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
158+
// layoutParams.dimAmount = 0.3f;
159+
// windowManager.updateViewLayout(layout, layoutParams);
160160

161161
}catch (Exception e){
162162
e.printStackTrace();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<style name="Theme.AppCompat.CustomTheme">
5+
<item name="android:windowIsTranslucent">true</item>
6+
<item name="android:windowCloseOnTouchOutside">true</item>
7+
</style>
8+
</resources>

0 commit comments

Comments
 (0)