Skip to content

Commit

Permalink
final refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
wasylews committed Feb 16, 2018
1 parent 828d2b0 commit 7397380
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static NotificationCompat.Builder provideNotification(Context context,
}

return new NotificationCompat.Builder(context, "default")
.setSmallIcon(R.drawable.ic_launcher_background);
.setSmallIcon(R.mipmap.ic_launcher);
}

@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import android.util.Log;

import com.genius.wasylews.converterlab.BuildConfig;
import com.genius.wasylews.converterlab.di.scope.PerActivity;
import com.genius.wasylews.converterlab.view.BaseHomeView;
import com.genius.wasylews.domain.model.Organization;
Expand Down Expand Up @@ -44,8 +45,10 @@ public void loadList() {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(mView::hideProgress)
.subscribe(mView::showOrganizations,
throwable -> Log.d(TAG, "Error on subscribe", throwable));
.subscribe(mView::showOrganizations, throwable -> {
if (BuildConfig.DEBUG)
Log.d(TAG, "Error on subscribe", throwable);
});
}

public void openOrganizationSite(Organization organization) {
Expand All @@ -68,7 +71,9 @@ public void findOrganizations(String filter) {
mFindOrganizations.execute(filter)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(mView::showOrganizations,
throwable -> Log.d(TAG, "Error on subscribe", throwable));
.subscribe(mView::showOrganizations, throwable -> {
if (BuildConfig.DEBUG)
Log.d(TAG, "Error on subscribe", throwable);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@PerActivity
public class MapPresenter {

private GetOrganizationLocation mGetOrganizationLocation;
private final GetOrganizationLocation mGetOrganizationLocation;
private BaseMapView mView;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class BitmapViewHolder {
@BindView(R.id.share_currency_list)
RecyclerView mRecyclerView;

private Context mContext;
private final Context mContext;

@Inject
public BitmapViewHolder(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public class HomeActivity extends DaggerAppCompatActivity implements BaseHomeVie
OrganizationsAdapter.CardToolbarItemClickedListener {

@Inject
HomePresenter presenter;
HomePresenter mPresenter;

@Inject
OrganizationsAdapter adapter;
OrganizationsAdapter mAdapter;

@Inject
NotificationUtil mNotificationManager;
Expand All @@ -58,14 +58,14 @@ protected void onCreate(Bundle savedInstanceState) {
ButterKnife.bind(this);

mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(adapter);
mRecyclerView.setAdapter(mAdapter);

adapter.setMenuItemClickedListener(this);
mAdapter.setMenuItemClickedListener(this);

mSwipeRefreshLayout.setOnRefreshListener(presenter::loadList);
mSwipeRefreshLayout.setOnRefreshListener(mPresenter::loadList);

presenter.setView(this);
presenter.loadList();
mPresenter.setView(this);
mPresenter.loadList();
}

@Override
Expand All @@ -80,7 +80,7 @@ public boolean onQueryTextSubmit(String s) {

@Override
public boolean onQueryTextChange(String s) {
presenter.findOrganizations(s);
mPresenter.findOrganizations(s);
return true;
}
});
Expand All @@ -89,7 +89,7 @@ public boolean onQueryTextChange(String s) {

@Override
public void showOrganizations(List<Organization> list) {
adapter.setOrganizations(list);
mAdapter.setOrganizations(list);
}

@Override
Expand All @@ -108,16 +108,16 @@ public void hideProgress() {
public boolean onItemClicked(@IdRes int buttonId, Organization organization) {
switch (buttonId) {
case R.id.card_toolbar_link:
presenter.openOrganizationSite(organization);
mPresenter.openOrganizationSite(organization);
break;
case R.id.card_toolbar_map:
presenter.showOnMap(organization);
mPresenter.showOnMap(organization);
break;
case R.id.card_toolbar_phone:
presenter.callOrganization(organization);
mPresenter.callOrganization(organization);
break;
case R.id.card_toolbar_details:
presenter.showDetails(organization);
mPresenter.showDetails(organization);
break;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class MapActivity extends DaggerAppCompatActivity implements OnMapReadyCallback, BaseMapView {

@Inject
MapPresenter presenter;
MapPresenter mPresenter;

private static final String EXTRA_ORGANIZATION = "ORGANIZATION_ID";

Expand All @@ -47,8 +47,8 @@ protected void onCreate(Bundle savedInstanceState) {
mapFragment.getMapAsync(this);

String organizationId = getIntent().getStringExtra(EXTRA_ORGANIZATION);
presenter.setView(this);
presenter.showOnMap(organizationId);
mPresenter.setView(this);
mPresenter.showOnMap(organizationId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.share_fragment_layout, container, false);
ButterKnife.bind(this, rootView);

Expand Down Expand Up @@ -96,7 +97,7 @@ public void share() {
shareIntent.setType("image/*");
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent,
getResources().getString(R.string.share_title)));
getString(R.string.share_title)));
}
}

Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_map.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
Expand Down
2 changes: 1 addition & 1 deletion device/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<service
android:name=".service.FetchService"
android:enabled="true"
android:exported="true"></service>
android:exported="true" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import javax.inject.Inject;

public class BitmapProviderUtil implements BitmapProvider {
private Context mContext;
private final Context mContext;

@Inject
public BitmapProviderUtil(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
@Singleton
public class LocationProvider implements LocationManager {

private GeoDataClient mGeoDataClient;
private NetworkManager mNetworkManager;
private final GeoDataClient mGeoDataClient;
private final NetworkManager mNetworkManager;

@Inject
public LocationProvider(GeoDataClient geoDataClient, NetworkManager networkManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class PreferencesManager {

private SharedPreferences mPreferences;
private final SharedPreferences mPreferences;

@Inject
public PreferencesManager(SharedPreferences preferences) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
@Singleton
public class GetOrganizationLocation {

private LocationManager mLocationManager;
private Repository mRepository;
private final LocationManager mLocationManager;
private final Repository mRepository;

@Inject
public GetOrganizationLocation(LocationManager manager, Repository repository) {
Expand Down

0 comments on commit 7397380

Please sign in to comment.