Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
All resources with dd prefixes
Use provided invested of compile for external dependencies
  • Loading branch information
Mantas Palaima committed Dec 27, 2015
1 parent a2e91d8 commit a52ae96
Show file tree
Hide file tree
Showing 143 changed files with 648 additions and 857 deletions.
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ dependencies {
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'jp.wasabeef:takt:1.0.2'
compile 'com.jakewharton.timber:timber:4.1.0'
compile 'com.jakewharton.scalpel:scalpel:1.1.2'
compile 'com.google.android.gms:play-services-location:8.3.0'

/*debugCompile 'io.palaima.debugdrawer:debugdrawer:0.6.0'
Expand Down Expand Up @@ -75,13 +77,13 @@ dependencies {
debugCompile project(':debugdrawer-view')
compile project(':debugdrawer-base')
compile project(':debugdrawer-commons')
compile project(':debugdrawer-actions')
compile project(':debugdrawer-picasso')
compile project(':debugdrawer-okhttp')
compile project(':debugdrawer-scalpel')
compile project(':debugdrawer-location')
compile project(':debugdrawer-log')
compile project(':debugdrawer-timber')
compile project(':debugdrawer-fps')
compile project(':debugdrawer-actions')

debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.squareup.leakcanary.LeakCanary;

import io.palaima.debugdrawer.log.data.LumberYard;
import io.palaima.debugdrawer.timber.data.LumberYard;
import timber.log.Timber;


Expand All @@ -13,6 +13,7 @@
* @since 01/07/15
*/
public class DebugDrawerApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
Expand Down
42 changes: 21 additions & 21 deletions app/src/main/java/io/palaima/debugdrawer/app/DebugViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@
import io.palaima.debugdrawer.commons.SettingsModule;
import io.palaima.debugdrawer.fps.FpsModule;
import io.palaima.debugdrawer.location.LocationModule;
import io.palaima.debugdrawer.log.LogModule;
import io.palaima.debugdrawer.okhttp.OkHttpModule;
import io.palaima.debugdrawer.picasso.PicassoModule;
import io.palaima.debugdrawer.scalpel.ScalpelModule;
import io.palaima.debugdrawer.timber.TimberModule;
import io.palaima.debugdrawer.view.DebugView;
import jp.wasabeef.takt.Takt;
import timber.log.Timber;

public class DebugViewActivity extends AppCompatActivity {

private Toolbar mToolbar;
private Toolbar toolbar;

private DebugView mDebugView;
private DebugView debugView;

private Picasso mPicasso;
private Picasso picasso;

private OkHttpClient mOkHttpClient;
private OkHttpClient okHttpClient;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_debugview);
mOkHttpClient = createOkHttpClient(this.getApplication());
mPicasso = new Picasso.Builder(this)
.downloader(new OkHttpDownloader(mOkHttpClient))
okHttpClient = createOkHttpClient(this.getApplication());
picasso = new Picasso.Builder(this)
.downloader(new OkHttpDownloader(okHttpClient))
.listener(new Picasso.Listener() {
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception e) {
Expand Down Expand Up @@ -85,16 +85,16 @@ public void onClick() {
}
);

mDebugView = (DebugView) findViewById(R.id.debug_view);
debugView = (DebugView) findViewById(R.id.debug_view);

mDebugView.modules(
debugView.modules(
new ActionsModule(switchAction, buttonAction, spinnerAction),
new FpsModule(Takt.stock(getApplication())),
new LocationModule(this),
new ScalpelModule(this),
new LogModule(),
new OkHttpModule(mOkHttpClient),
new PicassoModule(mPicasso),
new TimberModule(),
new OkHttpModule(okHttpClient),
new PicassoModule(picasso),
new DeviceModule(this),
new BuildModule(this),
new NetworkModule(this),
Expand All @@ -115,32 +115,32 @@ private void showDummyLog() {

@Override protected void onResume() {
super.onResume();
mDebugView.onResume();
debugView.onResume();
}

@Override protected void onPause() {
super.onPause();
mDebugView.onPause();
debugView.onPause();
}

@Override
protected void onStart() {
super.onStart();
mDebugView.onStart();
debugView.onStart();
}

@Override
protected void onStop() {
super.onStop();
mDebugView.onStop();
debugView.onStop();
}

protected Toolbar setupToolBar() {
mToolbar = (Toolbar) findViewById(R.id.mainToolbar);
if (mToolbar != null) {
setSupportActionBar(mToolbar);
toolbar = (Toolbar) findViewById(R.id.mainToolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
}
return mToolbar;
return toolbar;
}

private static final int DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50 MB
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/io/palaima/debugdrawer/app/ImageAdapter.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package io.palaima.debugdrawer.app;

import com.squareup.picasso.Picasso;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

import java.util.List;

public class ImageAdapter extends ArrayAdapter<String> {

private final Picasso mPicasso;
private final Picasso picasso;

public ImageAdapter(Context context, List<String> images, Picasso picasso) {
super(context, 0, images);
mPicasso = picasso;
this.picasso = picasso;
}

@Override
Expand All @@ -26,7 +26,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.image_item, parent, false);
}
mPicasso.load(url).into((ImageView)convertView.findViewById(R.id.image));
picasso.load(url).into((ImageView)convertView.findViewById(R.id.image));
return convertView;
}
}
46 changes: 23 additions & 23 deletions app/src/main/java/io/palaima/debugdrawer/app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@
import io.palaima.debugdrawer.actions.SpinnerAction;
import io.palaima.debugdrawer.actions.SwitchAction;
import io.palaima.debugdrawer.commons.BuildModule;
import io.palaima.debugdrawer.fps.FpsModule;
import io.palaima.debugdrawer.location.LocationModule;
import io.palaima.debugdrawer.log.LogModule;
import io.palaima.debugdrawer.commons.DeviceModule;
import io.palaima.debugdrawer.commons.NetworkModule;
import io.palaima.debugdrawer.commons.SettingsModule;
import io.palaima.debugdrawer.fps.FpsModule;
import io.palaima.debugdrawer.location.LocationModule;
import io.palaima.debugdrawer.okhttp.OkHttpModule;
import io.palaima.debugdrawer.picasso.PicassoModule;
import io.palaima.debugdrawer.scalpel.ScalpelModule;
import io.palaima.debugdrawer.timber.TimberModule;
import jp.wasabeef.takt.Takt;
import timber.log.Timber;

public class MainActivity extends AppCompatActivity {

private Toolbar mToolbar;
private Toolbar toolbar;

private DebugDrawer mDebugDrawer;
private DebugDrawer debugDrawer;

private Picasso mPicasso;
private Picasso picasso;

private OkHttpClient mOkHttpClient;
private OkHttpClient okHttpClient;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mOkHttpClient = createOkHttpClient(this.getApplication());
mPicasso = new Picasso.Builder(this)
.downloader(new OkHttpDownloader(mOkHttpClient))
okHttpClient = createOkHttpClient(this.getApplication());
picasso = new Picasso.Builder(this)
.downloader(new OkHttpDownloader(okHttpClient))
.listener(new Picasso.Listener() {
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception e) {
Expand Down Expand Up @@ -97,14 +97,14 @@ public void onClick() {
}
);

mDebugDrawer = new DebugDrawer.Builder(this).modules(
debugDrawer = new DebugDrawer.Builder(this).modules(
new ActionsModule(switchAction, buttonAction, spinnerAction),
new FpsModule(Takt.stock(getApplication())),
new LocationModule(this),
new ScalpelModule(this),
new LogModule(),
new OkHttpModule(mOkHttpClient),
new PicassoModule(mPicasso),
new TimberModule(),
new OkHttpModule(okHttpClient),
new PicassoModule(picasso),
new DeviceModule(this),
new BuildModule(this),
new NetworkModule(this),
Expand All @@ -119,7 +119,7 @@ public void onClick() {
}

ListView listView = (ListView) findViewById(R.id.image_list);
listView.setAdapter(new ImageAdapter(this, images, mPicasso));
listView.setAdapter(new ImageAdapter(this, images, picasso));
}

private void showDummyLog() {
Expand All @@ -134,23 +134,23 @@ private void showDummyLog() {
@Override
protected void onStart() {
super.onStart();
mDebugDrawer.onStart();
debugDrawer.onStart();
}

@Override protected void onResume() {
super.onResume();
mDebugDrawer.onResume();
debugDrawer.onResume();
}

@Override protected void onPause() {
super.onPause();
mDebugDrawer.onPause();
debugDrawer.onPause();
}

@Override
protected void onStop() {
super.onStop();
mDebugDrawer.onStop();
debugDrawer.onStop();
}

@Override
Expand All @@ -177,11 +177,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

protected Toolbar setupToolBar() {
mToolbar = (Toolbar) findViewById(R.id.mainToolbar);
if (mToolbar != null) {
setSupportActionBar(mToolbar);
toolbar = (Toolbar) findViewById(R.id.mainToolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
}
return mToolbar;
return toolbar;
}

private static final int DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50 MB
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_debugview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
tools:context=".DebugViewActivity">

<include layout="@layout/toolbar"/>

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
1 change: 0 additions & 1 deletion debugdrawer-actions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ android {
}

dependencies {
compile 'com.android.support:support-v4:23.1.1'
compile project(':debugdrawer-base')
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.palaima.debugdrawer.actions;

import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -26,11 +25,11 @@ public ActionsModule(Action... actions) {

@NonNull @Override
public View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
LinearLayout view = (LinearLayout) inflater.inflate(R.layout.debug_drawer_module_actions, parent, false);
LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dd_debug_drawer_module_actions, parent, false);

if (actions.isEmpty()) {
TextView noActionsLabel = new TextView(parent.getContext());
noActionsLabel.setTextColor(ContextCompat.getColor(parent.getContext(), R.color.white));
noActionsLabel.setTextColor(parent.getResources().getColor(android.R.color.white));
noActionsLabel.setText("No actions added");
view.addView(noActionsLabel);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public View getView(LinearLayout linearLayout) {
Resources resources = context.getResources();

LinearLayout.LayoutParams buttonLayoutParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
buttonLayoutParams.topMargin = resources.getDimensionPixelOffset(R.dimen.padding_small);
buttonLayoutParams.topMargin = resources.getDimensionPixelOffset(R.dimen.dd_padding_small);

Button button = new Button(context);
button.setLayoutParams(buttonLayoutParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public View getView(LinearLayout view) {
Resources resources = context.getResources();

LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
layoutParams.topMargin = resources.getDimensionPixelOffset(R.dimen.padding_small);
layoutParams.topMargin = resources.getDimensionPixelOffset(R.dimen.dd_padding_small);

Spinner spinner = new Spinner(context);
spinner.setLayoutParams(layoutParams);
Expand All @@ -58,7 +58,7 @@ public View getView(LinearLayout view) {
}
});

ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.debug_drawer_module_actions_spinner_item, titles);
ArrayAdapter<String> adapter = new ArrayAdapter<>(context, R.layout.dd_debug_drawer_module_actions_spinner_item, titles);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

Expand Down
Loading

0 comments on commit a52ae96

Please sign in to comment.