Browse Source

Drawer size fix (now depends on screen size)

pull/24/head
Ezerous 8 years ago
parent
commit
044d4ed736
  1. 2
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  2. 18
      app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java

2
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -198,7 +198,7 @@ public abstract class BaseActivity extends AppCompatActivity
drawer = new DrawerBuilder() drawer = new DrawerBuilder()
.withActivity(this) .withActivity(this)
.withToolbar(toolbar) .withToolbar(toolbar)
.withDrawerWidthDp(175) .withDrawerWidthDp((int)BaseApplication.getInstance().getDpWidth()/2)
.withSliderBackgroundColor(ContextCompat.getColor(this, R.color.primary_light)) .withSliderBackgroundColor(ContextCompat.getColor(this, R.color.primary_light))
.withAccountHeader(accountHeader) .withAccountHeader(accountHeader)
.addDrawerItems(homeItem,loginLogoutItem,aboutItem) .addDrawerItems(homeItem,loginLogoutItem,aboutItem)

18
app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java

@ -6,6 +6,7 @@ import android.content.SharedPreferences;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.DisplayMetrics;
import android.widget.ImageView; import android.widget.ImageView;
import com.franmontiel.persistentcookiejar.PersistentCookieJar; import com.franmontiel.persistentcookiejar.PersistentCookieJar;
@ -31,10 +32,13 @@ public class BaseApplication extends Application {
// Client & SessionManager // Client & SessionManager
private OkHttpClient client; private OkHttpClient client;
private static SessionManager sessionManager; private SessionManager sessionManager;
//Shared Preferences //Shared Preferences
private static final String SHARED_PREFS_NAME = "ThmmySharedPrefs"; private final String SHARED_PREFS_NAME = "ThmmySharedPrefs";
//Display Metrics
private static float dpHeight, dpWidth;
public static BaseApplication getInstance(){ public static BaseApplication getInstance(){
return baseApplication; return baseApplication;
@ -83,6 +87,10 @@ public class BaseApplication extends Application {
return super.placeholder(ctx, tag); return super.placeholder(ctx, tag);
} }
}); });
DisplayMetrics displayMetrics = getApplicationContext().getResources().getDisplayMetrics();
dpHeight = displayMetrics.heightPixels / displayMetrics.density;
dpWidth = displayMetrics.widthPixels / displayMetrics.density;
} }
public OkHttpClient getClient() { public OkHttpClient getClient() {
@ -93,5 +101,11 @@ public class BaseApplication extends Application {
return sessionManager; return sessionManager;
} }
public float getDpHeight() {
return dpHeight;
}
public float getDpWidth() {
return dpWidth;
}
} }

Loading…
Cancel
Save