Commit f98ae2cb authored by Varun Patil's avatar Varun Patil Committed by GitHub

Reduce technical debt (#271)

* Reduce technical debt (4)

* Remove test files

* Reduce technical debt (5)
parent 3449c40a
package app.insti;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("app.insti", appContext.getPackageName());
}
}
......@@ -199,7 +199,6 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService {
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xffa19774;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, radius, radius);
final Rect destRect = new Rect(
......
......@@ -11,9 +11,9 @@ import app.insti.api.model.User;
public class SessionManager {
public SharedPreferences pref;
Editor editor;
Context context;
int PRIVATE_MODE = 0;
private Editor editor;
private Context context;
private final int PRIVATE_MODE = 0;
public SessionManager(Context context) {
this.context = context;
......
......@@ -36,8 +36,8 @@ public class LoginActivity extends AppCompatActivity {
private final String guestUri = "https://guesturi";
public String authCode = null;
public String fcmId = null;
SessionManager session;
Context mContext = this;
private SessionManager session;
private Context mContext = this;
private boolean loggingIn = false;
private ProgressDialog progressDialog;
......@@ -169,22 +169,6 @@ public class LoginActivity extends AppCompatActivity {
});
}
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
.show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
private class WvClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
......
......@@ -93,8 +93,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private static final String TAG = "MainActivity";
SessionManager session;
FeedFragment feedFragment;
private SessionManager session;
private FeedFragment feedFragment;
private User currentUser;
private BackHandledFragment selectedFragment;
private Menu menu;
......
......@@ -18,8 +18,6 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
......@@ -30,7 +28,6 @@ import app.insti.api.model.User;
import app.insti.api.model.Venter;
import app.insti.fragment.ComplaintFragment;
import app.insti.utils.DateTimeUtil;
import de.hdodenhof.circleimageview.CircleImageView;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
......
......@@ -15,7 +15,6 @@ import app.insti.api.model.MessMenu;
public class MessMenuAdapter extends RecyclerView.Adapter<MessMenuAdapter.ViewHolder> {
private List<MessMenu> messMenus;
private Context context;
public MessMenuAdapter(List<MessMenu> messMenus) {
this.messMenus = messMenus;
......@@ -25,7 +24,7 @@ public class MessMenuAdapter extends RecyclerView.Adapter<MessMenuAdapter.ViewHo
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
final Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View postView = inflater.inflate(R.layout.mess_menu_card, parent, false);
......
......@@ -28,7 +28,6 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private final int VIEW_PROG = 0;
private List<TrainingBlogPost> posts;
private Context context;
private ItemClickListener itemClickListener;
public TrainingBlogAdapter(List<TrainingBlogPost> posts, ItemClickListener itemClickListener) {
......@@ -47,7 +46,7 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
context = parent.getContext();
final Context context = parent.getContext();
if (viewType == VIEW_ITEM) {
LayoutInflater inflater = LayoutInflater.from(context);
View postView = inflater.inflate(R.layout.blog_post_card, parent, false);
......@@ -63,7 +62,6 @@ public class TrainingBlogAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
} else {
LayoutInflater inflater = LayoutInflater.from(context);
View loadView = inflater.inflate(R.layout.blog_load_item, parent, false);
final TrainingBlogAdapter.ViewHolder postViewHolder = new TrainingBlogAdapter.ViewHolder(loadView);
return new TrainingBlogAdapter.ProgressViewHolder(loadView);
}
}
......
......@@ -56,23 +56,6 @@ public class Body implements CardInterface {
this.bodyID = bodyID;
}
public Body(String bodyID, String bodyStrID, String bodyName, String bodyShortDescription, String bodyDescription, String bodyImageURL, List<Body> bodyChildren, List<Body> bodyParents, List<Event> bodyEvents, int bodyFollowersCount, String bodyWebsiteURL, String bodyBlogURL, boolean bodyUserFollows, List<Role> bodyRoles) {
this.bodyID = bodyID;
this.bodyStrID = bodyStrID;
this.bodyName = bodyName;
this.bodyShortDescription = bodyShortDescription;
this.bodyDescription = bodyDescription;
this.bodyImageURL = bodyImageURL;
this.bodyChildren = bodyChildren;
this.bodyParents = bodyParents;
this.bodyEvents = bodyEvents;
this.bodyFollowersCount = bodyFollowersCount;
this.bodyWebsiteURL = bodyWebsiteURL;
this.bodyBlogURL = bodyBlogURL;
this.bodyUserFollows = bodyUserFollows;
this.bodyRoles = bodyRoles;
}
public String getBodyID() {
return bodyID;
}
......
......@@ -66,23 +66,8 @@ public class Event implements CardInterface {
private boolean eventBigImage = false;
public Event(String eventID, String eventStrID, String eventName, String eventDescription, String eventImageURL, Timestamp eventStartTime, Timestamp eventEndTime, boolean allDayEvent, List<Venue> eventVenues, List<Body> eventBodies, int eventInterestedCount, int eventGoingCount, List<User> eventInterested, List<User> eventGoing, String eventWebsiteURL, int eventUserUes) {
public Event(@NonNull String eventID) {
this.eventID = eventID;
this.eventStrID = eventStrID;
this.eventName = eventName;
this.eventDescription = eventDescription;
this.eventImageURL = eventImageURL;
this.eventStartTime = eventStartTime;
this.eventEndTime = eventEndTime;
this.allDayEvent = allDayEvent;
this.eventVenues = eventVenues;
this.eventBodies = eventBodies;
this.eventInterestedCount = eventInterestedCount;
this.eventGoingCount = eventGoingCount;
this.eventInterested = eventInterested;
this.eventGoing = eventGoing;
this.eventWebsiteURL = eventWebsiteURL;
this.eventUserUes = eventUserUes;
}
public String getEventID() {
......
......@@ -42,19 +42,8 @@ public class Venue {
@SerializedName("lng")
private double venueLongitude;
public Venue(String venueID, String venueName, String venueShortName, String venueDescripion, String venueParentId, String venueParentRelation, Integer venueGroupId, Integer venuePixelX, Integer venuePixelY, Boolean venueReusable, double venueLatitude, double venueLongitude) {
public Venue(@NonNull String venueID) {
this.venueID = venueID;
this.venueName = venueName;
this.venueShortName = venueShortName;
this.venueDescripion = venueDescripion;
this.venueParentId = venueParentId;
this.venueParentRelation = venueParentRelation;
this.venueGroupId = venueGroupId;
this.venuePixelX = venuePixelX;
this.venuePixelY = venuePixelY;
this.venueReusable = venueReusable;
this.venueLatitude = venueLatitude;
this.venueLongitude = venueLongitude;
}
public String getVenueID() {
......
......@@ -50,7 +50,7 @@ import retrofit2.Response;
* create an instance of this fragment.
*/
public class BodyFragment extends BackHandledFragment implements TransitionTargetFragment {
String TAG = "BodyFragment";
public final String TAG = "BodyFragment";
private Body min_body;
private SwipeRefreshLayout bodySwipeRefreshLayout;
......
......@@ -30,9 +30,6 @@ public class BodyRecyclerViewFragment extends Fragment implements TransitionTarg
public static final String TAG = "BodyRecyclerViewFragment";
public Fragment parentFragment = null;
private RecyclerView recyclerView;
private BodyAdapter bodyAdapter;
private List<Body> bodyList;
public BodyRecyclerViewFragment() {
......@@ -74,8 +71,8 @@ public class BodyRecyclerViewFragment extends Fragment implements TransitionTarg
public void onStart() {
super.onStart();
recyclerView = (RecyclerView) getActivity().findViewById(R.id.body_recycler_view);
bodyAdapter = new BodyAdapter(bodyList, this);
RecyclerView recyclerView = (RecyclerView) getActivity().findViewById(R.id.body_recycler_view);
BodyAdapter bodyAdapter = new BodyAdapter(bodyList, this);
bodyAdapter.uid = "BRVFrag";
recyclerView.setAdapter(bodyAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
......
......@@ -60,7 +60,7 @@ import static android.view.View.VISIBLE;
*/
public class CalendarFragment extends BaseFragment {
FloatingActionButton fab;
private FloatingActionButton fab;
private View view;
private FeedAdapter feedAdapter = null;
private List<Event> events = new ArrayList<>();
......
......@@ -352,7 +352,7 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
}
/** Setup button colors depending on status */
void setFollowButtons(int status) {
private void setFollowButtons(int status) {
// Set colors
Utils.setupFollowButton(getContext(), interestedButton, status == Constants.STATUS_INTERESTED);
Utils.setupFollowButton(getContext(), goingButton, status == Constants.STATUS_GOING);
......@@ -362,7 +362,7 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
goingButton.setText(getCountBadgeSpannable("GOING", event.getEventGoingCount()));
}
View.OnClickListener getUESOnClickListener(final int status) {
private View.OnClickListener getUESOnClickListener(final int status) {
return new View.OnClickListener() {
@Override
public void onClick(View view) {
......
......@@ -29,9 +29,6 @@ public class EventRecyclerViewFragment extends Fragment implements TransitionTar
private static final String TAG = "EventRecyclerViewFragment";
public Fragment parentFragment = null;
private RecyclerView recyclerView;
private FeedAdapter feedAdapter;
private List<Event> eventList;
public EventRecyclerViewFragment() {
......@@ -72,8 +69,8 @@ public class EventRecyclerViewFragment extends Fragment implements TransitionTar
public void onStart() {
super.onStart();
recyclerView = (RecyclerView) getActivity().findViewById(R.id.event_recycler_view);
feedAdapter = new FeedAdapter(eventList, this);
RecyclerView recyclerView = getActivity().findViewById(R.id.event_recycler_view);
FeedAdapter feedAdapter = new FeedAdapter(eventList, this);
recyclerView.setAdapter(feedAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
......
......@@ -282,7 +282,7 @@ public class MapFragment extends Fragment implements TextWatcher,
});
}
void setupWithData(List<Venue> venues) {
private void setupWithData(List<Venue> venues) {
if (getActivity() == null || getView() == null || getContext() == null) return;
// Setup fade animation for background
......@@ -502,7 +502,6 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
this.setCorrectIcons();
}
@Override
......@@ -536,7 +535,6 @@ public class MapFragment extends Fragment implements TextWatcher,
fragmentManager.popBackStack(firstStackTag,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
this.removeEditTextFocus(null);
this.setCorrectIcons();
this.displayMap();
}
......@@ -898,23 +896,6 @@ public class MapFragment extends Fragment implements TextWatcher,
}
}
private void setCorrectIcons() {
if (noFragments) {
if (this.handleRemoveIcon()) {
this.noIndexButton();
}
} else {
if (fragment instanceof ListFragment) {
if (this.handleRemoveIcon()) {
this.noIndexButton();
}
}
}
}
private void noIndexButton() {
}
private boolean handleRemoveIcon() {
String text = editText.getText().toString();
return !text.isEmpty();
......@@ -932,7 +913,6 @@ public class MapFragment extends Fragment implements TextWatcher,
} else {
fragmentContainer.setOnTouchListener(null);
}
this.setCorrectIcons();
}
private void hideKeyboard() {
......@@ -953,12 +933,10 @@ public class MapFragment extends Fragment implements TextWatcher,
}
public void playAnimSound(int sound_index) {
if (sound_index >= 0 && sound_index < soundPoolIds.length) {
if (!settingsManager.isMuted()) {
if ((sound_index >= 0 && sound_index < soundPoolIds.length) && !settingsManager.isMuted()) {
soundPool.play(soundPoolIds[sound_index], 1.0f, 1.0f, 1, 0, 1f);
}
}
}
public void playAnimSoundDelayed(int sound_index, long delay) {
Message msg = mHandler.obtainMessage(MSG_PLAY_SOUND, sound_index, 0);
......
......@@ -40,7 +40,6 @@ public class MessMenuFragment extends BaseFragment {
private MessMenuAdapter messMenuAdapter;
private RecyclerView messMenuRecyclerView;
private SwipeRefreshLayout messMenuSwipeRefreshLayout;
private Spinner hostelSpinner;
private String hostel;
public MessMenuFragment() {
......@@ -74,7 +73,7 @@ public class MessMenuFragment extends BaseFragment {
}
});
hostelSpinner = getActivity().findViewById(R.id.hostel_spinner);
Spinner hostelSpinner = getActivity().findViewById(R.id.hostel_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(), R.array.hostels_array, R.layout.hostel_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
hostelSpinner.setAdapter(adapter);
......
......@@ -24,7 +24,7 @@ import app.insti.api.model.Role;
* create an instance of this fragment.
*/
public class RoleRecyclerViewFragment extends Fragment implements TransitionTargetFragment, TransitionTargetChild {
private static final String TAG = "RoleRecyclerViewFragment";
public static final String TAG = "RoleRecyclerViewFragment";
public Fragment parentFragment = null;
private List<Role> roleList;
......
......@@ -24,8 +24,8 @@ import app.insti.fragment.MapFragment;
public class FuzzySearchAdapter extends BaseAdapter {
Context mContext;
LayoutInflater inflater;
private Context mContext;
private LayoutInflater inflater;
private List<Marker> resultlist = null;
private ArrayList<Marker> inputlist;
private List<ScoredMarker> map;
......
......@@ -7,29 +7,21 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import com.mrane.data.Marker;
import java.util.HashMap;
import app.insti.R;
import app.insti.fragment.MapFragment;
public class ListFragment extends Fragment {
MapFragment mainActivity;
View rootView;
ListView list;
public ListFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mainActivity = MapFragment.getMainActivity();
MapFragment mainActivity = MapFragment.getMainActivity();
final FuzzySearchAdapter adapter = mainActivity.getAdapter();
rootView = inflater.inflate(R.layout.map_list_fragment, container, false);
list = (ListView) rootView.findViewById(R.id.suggestion_list);
View rootView = inflater.inflate(R.layout.map_list_fragment, container, false);
ListView list = rootView.findViewById(R.id.suggestion_list);
list.setAdapter(adapter);
list.setOnItemClickListener(mainActivity);
list.setOnTouchListener(mainActivity);
......
package app.insti;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment