Commit 3449c40a authored by Varun Patil's avatar Varun Patil Committed by GitHub

Merge pull request #270 from wncc/codacy

Reduce technical debt, fix some issues
parents 3735fc4f c1756dfd
...@@ -2,7 +2,6 @@ package app.insti; ...@@ -2,7 +2,6 @@ package app.insti;
public class Constants { public class Constants {
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1; public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 1;
public static final int MY_PERMISSIONS_REQUEST_ACCESS_LOCATION = 2;
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 3; public static final int MY_PERMISSIONS_REQUEST_LOCATION = 3;
public static final int RESULT_LOAD_IMAGE = 11; public static final int RESULT_LOAD_IMAGE = 11;
public static final int REQUEST_CAMERA_INT_ID = 101; public static final int REQUEST_CAMERA_INT_ID = 101;
......
package app.insti;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
/**
* Created by mrunz on 6/7/17.
*/
public class PeopleSuggestionAdapter extends BaseAdapter implements Filterable {
List mData;
List mStringFilterList;
ValueFilter valueFilter;
private LayoutInflater inflater;
public PeopleSuggestionAdapter(List cancel_type) {
mData = cancel_type;
mStringFilterList = cancel_type;
}
@Override
public int getCount() {
return mData.size();
}
@Override
public Object getItem(int position) {
return mData.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, final ViewGroup parent) {
if (inflater == null) {
inflater = (LayoutInflater) parent.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
View view = inflater.inflate(R.layout.ppl_search_suggestion_item_view, parent, false);
TextView tv_suggestion = (TextView) view.findViewById(R.id.suggestion_item);
tv_suggestion.setText(mData.get(position).toString());
return view;
}
@Override
public Filter getFilter() {
if (valueFilter == null) {
valueFilter = new ValueFilter();
}
return valueFilter;
}
private class ValueFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
if (constraint != null && constraint.length() > 0) {
List filterList = new ArrayList();
for (int i = 0; i < mStringFilterList.size(); i++) {
if ((mStringFilterList.get(i).toString().toUpperCase()).contains(constraint.toString().toUpperCase())) {
filterList.add(mStringFilterList.get(i));
}
}
results.count = filterList.size();
results.values = filterList;
} else {
results.count = mStringFilterList.size();
results.values = mStringFilterList;
}
return results;
}
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
mData = (List) results.values;
notifyDataSetChanged();
}
}
}
\ No newline at end of file
...@@ -88,8 +88,8 @@ public final class Utils { ...@@ -88,8 +88,8 @@ public final class Utils {
public static final void updateFragment(Fragment fragment, FragmentActivity fragmentActivity) { public static final void updateFragment(Fragment fragment, FragmentActivity fragmentActivity) {
FragmentTransaction ft = fragmentActivity.getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = fragmentActivity.getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_up, R.anim.fade_out, R.anim.fade_in, R.anim.slide_out_down); ft.setCustomAnimations(R.anim.slide_in_up, R.anim.fade_out, R.anim.fade_in, R.anim.slide_out_down);
ft.replace(R.id.framelayout_for_fragment, fragment, fragment.getTag()); ft.replace(R.id.framelayout_for_fragment, fragment, getTag(fragment));
ft.addToBackStack(fragment.getTag()); ft.addToBackStack(getTag(fragment));
ft.commit(); ft.commit();
} }
...@@ -141,8 +141,8 @@ public final class Utils { ...@@ -141,8 +141,8 @@ public final class Utils {
} }
/* Update the fragment */ /* Update the fragment */
ft.replace(R.id.framelayout_for_fragment, fragment, fragment.getTag()) ft.replace(R.id.framelayout_for_fragment, fragment, getTag(fragment))
.addToBackStack(fragment.getTag()) .addToBackStack(getTag(fragment))
.commit(); .commit();
} }
...@@ -247,8 +247,8 @@ public final class Utils { ...@@ -247,8 +247,8 @@ public final class Utils {
FragmentManager fm = fragmentActivity.getSupportFragmentManager(); FragmentManager fm = fragmentActivity.getSupportFragmentManager();
fm.popBackStack(); fm.popBackStack();
FragmentTransaction ft = fm.beginTransaction(); FragmentTransaction ft = fm.beginTransaction();
ft.addToBackStack(newFragment.getTag()); ft.addToBackStack(getTag(fragment));
ft.replace(R.id.framelayout_for_fragment, newFragment, newFragment.getTag()).commit(); ft.replace(R.id.framelayout_for_fragment, newFragment, getTag(fragment)).commit();
} }
public static void setSelectedMenuItem(Activity activity, int id) { public static void setSelectedMenuItem(Activity activity, int id) {
...@@ -286,4 +286,12 @@ public final class Utils { ...@@ -286,4 +286,12 @@ public final class Utils {
CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().removeAllCookies(null);
CookieManager.getInstance().flush(); CookieManager.getInstance().flush();
} }
public static String getTag(Fragment fragment) {
String TAG = fragment.getTag();
try {
TAG = (String) fragment.getClass().getField("TAG").get(fragment);
} catch (NoSuchFieldException | IllegalAccessException ignored) {}
return TAG;
}
} }
...@@ -85,7 +85,6 @@ import static app.insti.Constants.DATA_TYPE_NEWS; ...@@ -85,7 +85,6 @@ import static app.insti.Constants.DATA_TYPE_NEWS;
import static app.insti.Constants.DATA_TYPE_PT; import static app.insti.Constants.DATA_TYPE_PT;
import static app.insti.Constants.DATA_TYPE_USER; import static app.insti.Constants.DATA_TYPE_USER;
import static app.insti.Constants.FCM_BUNDLE_NOTIFICATION_ID; import static app.insti.Constants.FCM_BUNDLE_NOTIFICATION_ID;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_ACCESS_LOCATION;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION; import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE; import static app.insti.Constants.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE;
import static app.insti.Constants.RESULT_LOAD_IMAGE; import static app.insti.Constants.RESULT_LOAD_IMAGE;
...@@ -616,7 +615,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -616,7 +615,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
* Change the active fragment to the supplied one * Change the active fragment to the supplied one
*/ */
public void updateFragment(Fragment fragment) { public void updateFragment(Fragment fragment) {
Log.d(TAG, "updateFragment: " + fragment.toString());
Bundle bundle = fragment.getArguments(); Bundle bundle = fragment.getArguments();
if (bundle == null) { if (bundle == null) {
bundle = new Bundle(); bundle = new Bundle();
...@@ -642,8 +640,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -642,8 +640,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
transaction.setCustomAnimations(R.anim.slide_in_up, R.anim.fade_out, R.anim.fade_in, R.anim.slide_out_down); transaction.setCustomAnimations(R.anim.slide_in_up, R.anim.fade_out, R.anim.fade_in, R.anim.slide_out_down);
} }
transaction.replace(R.id.framelayout_for_fragment, fragment, fragment.getTag()); transaction.replace(R.id.framelayout_for_fragment, fragment, Utils.getTag(fragment));
transaction.addToBackStack(fragment.getTag()).commit(); transaction.addToBackStack(Utils.getTag(fragment)).commit();
} }
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
...@@ -655,21 +653,20 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -655,21 +653,20 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
startActivityForResult(i, RESULT_LOAD_IMAGE); startActivityForResult(i, RESULT_LOAD_IMAGE);
} }
return; return;
case MY_PERMISSIONS_REQUEST_ACCESS_LOCATION:
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
MapFragment.getMainActivity().setupGPS();
} else {
Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT);
toast.show();
}
break;
case MY_PERMISSIONS_REQUEST_LOCATION: case MY_PERMISSIONS_REQUEST_LOCATION:
Log.i(TAG, "Permission request captured");
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Log.i(TAG, "Permission Granted"); // Map
FileComplaintFragment.getMainActivity().getMapReady(); MapFragment mapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MapFragment.TAG);
if (mapFragment != null && mapFragment.isVisible()) {
MapFragment.getMainActivity().setupGPS(true);
}
// File complaint
FileComplaintFragment fileComplaintFragment = (FileComplaintFragment) getSupportFragmentManager().findFragmentByTag(FileComplaintFragment.TAG);
if (fileComplaintFragment != null && fileComplaintFragment.isVisible()) {
FileComplaintFragment.getMainActivity().getMapReady();
}
} else { } else {
Log.i(TAG, "Permission Cancelled");
Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT); Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
......
...@@ -74,7 +74,7 @@ public class MessMenuAdapter extends RecyclerView.Adapter<MessMenuAdapter.ViewHo ...@@ -74,7 +74,7 @@ public class MessMenuAdapter extends RecyclerView.Adapter<MessMenuAdapter.ViewHo
case 7: case 7:
return "Sunday"; return "Sunday";
default: default:
throw new RuntimeException("DayIndexOutOfBounds: " + day); throw new IndexOutOfBoundsException("DayIndexOutOfBounds: " + day);
} }
} }
......
...@@ -29,7 +29,6 @@ public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i ...@@ -29,7 +29,6 @@ public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i
private final int VIEW_PROG = 0; private final int VIEW_PROG = 0;
private List<NewsArticle> newsArticles; private List<NewsArticle> newsArticles;
private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public NewsAdapter(List<NewsArticle> newsArticles, ItemClickListener itemClickListener) { public NewsAdapter(List<NewsArticle> newsArticles, ItemClickListener itemClickListener) {
...@@ -51,7 +50,7 @@ public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i ...@@ -51,7 +50,7 @@ public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> i
@NonNull @NonNull
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext(); final Context context = parent.getContext();
if (viewType == VIEW_ITEM) { if (viewType == VIEW_ITEM) {
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
View postView = inflater.inflate(R.layout.news_article_card, parent, false); View postView = inflater.inflate(R.layout.news_article_card, parent, false);
......
...@@ -27,7 +27,6 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View ...@@ -27,7 +27,6 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View
private final int VIEW_ITEM = 1; private final int VIEW_ITEM = 1;
private final int VIEW_PROG = 0; private final int VIEW_PROG = 0;
private List<PlacementBlogPost> posts; private List<PlacementBlogPost> posts;
private Context context;
private ItemClickListener itemClickListener; private ItemClickListener itemClickListener;
public PlacementBlogAdapter(List<PlacementBlogPost> posts, ItemClickListener itemClickListener) { public PlacementBlogAdapter(List<PlacementBlogPost> posts, ItemClickListener itemClickListener) {
this.posts = posts; this.posts = posts;
...@@ -45,7 +44,7 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View ...@@ -45,7 +44,7 @@ public class PlacementBlogAdapter extends RecyclerView.Adapter<RecyclerView.View
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
context = parent.getContext(); final Context context = parent.getContext();
if (viewType == VIEW_ITEM) { if (viewType == VIEW_ITEM) {
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
View postView = inflater.inflate(R.layout.blog_post_card, parent, false); View postView = inflater.inflate(R.layout.blog_post_card, parent, false);
......
...@@ -18,9 +18,10 @@ import retrofit2.Retrofit; ...@@ -18,9 +18,10 @@ import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
public class ServiceGenerator { public class ServiceGenerator {
public static final String HEADER_CACHE_CONTROL = "Cache-Control"; private static final String HEADER_CACHE_CONTROL = "Cache-Control";
public static final String HEADER_PRAGMA = "Pragma"; private static final String HEADER_PRAGMA = "Pragma";
private static final String BASE_URL = "https://api.insti.app/api/"; private static final String BASE_URL = "https://api.insti.app/api/";
public RetrofitInterface retrofitInterface;
private Context context; private Context context;
...@@ -99,10 +100,9 @@ public class ServiceGenerator { ...@@ -99,10 +100,9 @@ public class ServiceGenerator {
.baseUrl(BASE_URL) .baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create()); .addConverterFactory(GsonConverterFactory.create());
private Retrofit retrofit;
public RetrofitInterface retrofitInterface;
public ServiceGenerator(Context mContext) { public ServiceGenerator(Context mContext) {
context = mContext; context = mContext;
final Retrofit retrofit;
retrofit = retrofitBuilder.client( retrofit = retrofitBuilder.client(
clientBuilder clientBuilder
.addInterceptor(provideOfflineCacheInterceptor) .addInterceptor(provideOfflineCacheInterceptor)
......
package app.insti.api;
import android.content.Context;
import java.security.cert.CertificateException;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import okhttp3.Cache;
import okhttp3.OkHttpClient;
public class UnsafeOkHttpClient {
public static OkHttpClient getUnsafeOkHttpClient(Context context) {
try {
// Create a trust manager that does not validate certificate chains
final TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[]{};
}
}
};
// Install the all-trusting trust manager
final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
// Create an ssl socket factory with our all-trusting manager
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
OkHttpClient.Builder builder = new OkHttpClient.Builder();
Cache cache = new Cache(context.getCacheDir(), 200000000);
builder.cache(cache);
builder.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]);
builder.hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
OkHttpClient okHttpClient = builder.build();
return okHttpClient;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
...@@ -67,26 +67,8 @@ public class User implements CardInterface { ...@@ -67,26 +67,8 @@ public class User implements CardInterface {
private String currentRole; private String currentRole;
public User(@NonNull String userID, String userName, String userProfilePictureUrl, List<Event> userInterestedEvents, List<Event> userGoingEvents, String userEmail, String userRollNumber, String userContactNumber, Boolean showContactNumber, String userAbout, List<Body> userFollowedBodies, List<String> userFollowedBodiesID, List<Role> userRoles, List<Role> userInstituteRoles, List<Role> userFormerRoles, String userWebsiteURL, String userLDAPId, String hostel, String currentRole) { public User(@NonNull String userID) {
this.userID = userID; this.userID = userID;
this.userName = userName;
this.userProfilePictureUrl = userProfilePictureUrl;
this.userInterestedEvents = userInterestedEvents;
this.userGoingEvents = userGoingEvents;
this.userEmail = userEmail;
this.userRollNumber = userRollNumber;
this.userContactNumber = userContactNumber;
this.showContactNumber = showContactNumber;
this.userAbout = userAbout;
this.userFollowedBodies = userFollowedBodies;
this.userFollowedBodiesID = userFollowedBodiesID;
this.userRoles = userRoles;
this.userInstituteRoles = userInstituteRoles;
this.userFormerRoles = userFormerRoles;
this.userWebsiteURL = userWebsiteURL;
this.userLDAPId = userLDAPId;
this.hostel = hostel;
this.currentRole = currentRole;
} }
public static User fromString(String json) { public static User fromString(String json) {
......
...@@ -136,7 +136,7 @@ public class AddEventFragment extends BaseFragment { ...@@ -136,7 +136,7 @@ public class AddEventFragment extends BaseFragment {
return view; return view;
} }
void openEvent(Event event) { private void openEvent(Event event) {
String eventJson = new Gson().toJson(event); String eventJson = new Gson().toJson(event);
Bundle bundle = getArguments(); Bundle bundle = getArguments();
if (bundle == null) if (bundle == null)
...@@ -151,7 +151,7 @@ public class AddEventFragment extends BaseFragment { ...@@ -151,7 +151,7 @@ public class AddEventFragment extends BaseFragment {
transaction.addToBackStack(eventFragment.getTag()).commit(); transaction.addToBackStack(eventFragment.getTag()).commit();
} }
void openBody(Body body) { private void openBody(Body body) {
BodyFragment bodyFragment = BodyFragment.newInstance(body); BodyFragment bodyFragment = BodyFragment.newInstance(body);
FragmentManager manager = getActivity().getSupportFragmentManager(); FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction(); FragmentTransaction transaction = manager.beginTransaction();
......
...@@ -27,7 +27,7 @@ import app.insti.api.model.Body; ...@@ -27,7 +27,7 @@ import app.insti.api.model.Body;
* create an instance of this fragment. * create an instance of this fragment.
*/ */
public class BodyRecyclerViewFragment extends Fragment implements TransitionTargetFragment, TransitionTargetChild { public class BodyRecyclerViewFragment extends Fragment implements TransitionTargetFragment, TransitionTargetChild {
private static final String TAG = "BodyRecyclerViewFragment"; public static final String TAG = "BodyRecyclerViewFragment";
public Fragment parentFragment = null; public Fragment parentFragment = null;
private RecyclerView recyclerView; private RecyclerView recyclerView;
......
...@@ -230,6 +230,8 @@ public class CalendarFragment extends BaseFragment { ...@@ -230,6 +230,8 @@ public class CalendarFragment extends BaseFragment {
@Override @Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) { public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (getActivity() == null || getView() == null) return;
// Concatenate the response // Concatenate the response
NewsFeedResponse newsFeedResponse = response.body(); NewsFeedResponse newsFeedResponse = response.body();
List<Event> eventList = newsFeedResponse.getEvents(); List<Event> eventList = newsFeedResponse.getEvents();
......
...@@ -51,7 +51,7 @@ public class ComplaintsFragment extends BaseFragment { ...@@ -51,7 +51,7 @@ public class ComplaintsFragment extends BaseFragment {
FileComplaintFragment fileComplaintFragment = new FileComplaintFragment(); FileComplaintFragment fileComplaintFragment = new FileComplaintFragment();
fileComplaintFragment.setArguments(getArguments()); fileComplaintFragment.setArguments(getArguments());
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.framelayout_for_fragment, fileComplaintFragment, fileComplaintFragment.getTag()); fragmentTransaction.replace(R.id.framelayout_for_fragment, fileComplaintFragment, Utils.getTag(fileComplaintFragment));
fragmentTransaction.addToBackStack("Complaint Fragment").commit(); fragmentTransaction.addToBackStack("Complaint Fragment").commit();
} }
}); });
......
...@@ -65,14 +65,10 @@ import ru.noties.markwon.Markwon; ...@@ -65,14 +65,10 @@ import ru.noties.markwon.Markwon;
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
*/ */
public class EventFragment extends BackHandledFragment implements TransitionTargetFragment { public class EventFragment extends BackHandledFragment implements TransitionTargetFragment {
Event event; private Event event;
Button goingButton; private Button goingButton;
Button interestedButton; private Button interestedButton;
ImageButton navigateButton; public String TAG = "EventFragment";
ImageButton webEventButton;
ImageButton shareEventButton;
RecyclerView bodyRecyclerView;
String TAG = "EventFragment";
private int appBarOffset = 0; private int appBarOffset = 0;
private boolean creatingView = false; private boolean creatingView = false;
...@@ -198,14 +194,14 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg ...@@ -198,14 +194,14 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
private void inflateViews(final Event event) { private void inflateViews(final Event event) {
eventPicture = (ImageView) getActivity().findViewById(R.id.event_picture_2); eventPicture = (ImageView) getActivity().findViewById(R.id.event_picture_2);
TextView eventTitle = (TextView) getActivity().findViewById(R.id.event_page_title); final TextView eventTitle = (TextView) getActivity().findViewById(R.id.event_page_title);
TextView eventDate = (TextView) getActivity().findViewById(R.id.event_page_date); final TextView eventDate = (TextView) getActivity().findViewById(R.id.event_page_date);
TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_page_description); final TextView eventDescription = (TextView) getActivity().findViewById(R.id.event_page_description);
goingButton = getActivity().findViewById(R.id.going_button); goingButton = getActivity().findViewById(R.id.going_button);
interestedButton = getActivity().findViewById(R.id.interested_button); interestedButton = getActivity().findViewById(R.id.interested_button);
navigateButton = getActivity().findViewById(R.id.navigate_button); final ImageButton navigateButton = getActivity().findViewById(R.id.navigate_button);
webEventButton = getActivity().findViewById(R.id.web_event_button); final ImageButton webEventButton = getActivity().findViewById(R.id.web_event_button);
shareEventButton = getActivity().findViewById(R.id.share_event_button); final ImageButton shareEventButton = getActivity().findViewById(R.id.share_event_button);
if (event.isEventBigImage() || !creatingView) { if (event.isEventBigImage() || !creatingView) {
Picasso.get().load(event.getEventImageURL()).into(eventPicture); Picasso.get().load(event.getEventImageURL()).into(eventPicture);
...@@ -221,7 +217,7 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg ...@@ -221,7 +217,7 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm"); SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("HH:mm");
final List<Body> bodyList = event.getEventBodies(); final List<Body> bodyList = event.getEventBodies();
bodyRecyclerView = (RecyclerView) getActivity().findViewById(R.id.body_card_recycler_view); final RecyclerView bodyRecyclerView = getActivity().findViewById(R.id.body_card_recycler_view);
BodyAdapter bodyAdapter = new BodyAdapter(bodyList, this); BodyAdapter bodyAdapter = new BodyAdapter(bodyList, this);
bodyRecyclerView.setAdapter(bodyAdapter); bodyRecyclerView.setAdapter(bodyAdapter);
bodyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); bodyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
......
...@@ -41,7 +41,7 @@ import retrofit2.Response; ...@@ -41,7 +41,7 @@ import retrofit2.Response;
public class ExploreFragment extends Fragment { public class ExploreFragment extends Fragment {
private RecyclerView recyclerView; private RecyclerView recyclerView;
LinearLayoutManager mLayoutManager; private LinearLayoutManager mLayoutManager;
private static List<Body> allBodies = new ArrayList<>(); private static List<Body> allBodies = new ArrayList<>();
private static List<Body> bodies = new ArrayList<>(); private static List<Body> bodies = new ArrayList<>();
......
...@@ -35,7 +35,7 @@ public class FeedFragment extends BaseFragment { ...@@ -35,7 +35,7 @@ public class FeedFragment extends BaseFragment {
private RecyclerView feedRecyclerView; private RecyclerView feedRecyclerView;
private SwipeRefreshLayout feedSwipeRefreshLayout; private SwipeRefreshLayout feedSwipeRefreshLayout;
private FloatingActionButton fab; private FloatingActionButton fab;
LinearLayoutManager mLayoutManager; private LinearLayoutManager mLayoutManager;
private int index = -1, top = -1; private int index = -1, top = -1;
private FeedAdapter feedAdapter = null; private FeedAdapter feedAdapter = null;
......
...@@ -69,10 +69,10 @@ import java.io.ByteArrayOutputStream; ...@@ -69,10 +69,10 @@ import java.io.ByteArrayOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import app.insti.Constants;
import app.insti.ComplaintDescriptionAutoCompleteTextView; import app.insti.ComplaintDescriptionAutoCompleteTextView;
import app.insti.R;
import app.insti.ComplaintTag; import app.insti.ComplaintTag;
import app.insti.Constants;
import app.insti.R;
import app.insti.Utils; import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.adapter.ImageViewPagerAdapter; import app.insti.adapter.ImageViewPagerAdapter;
...@@ -95,7 +95,7 @@ import static app.insti.Constants.RESULT_LOAD_IMAGE; ...@@ -95,7 +95,7 @@ import static app.insti.Constants.RESULT_LOAD_IMAGE;
public class FileComplaintFragment extends Fragment { public class FileComplaintFragment extends Fragment {
private static final String TAG = FileComplaintFragment.class.getSimpleName(); public static final String TAG = FileComplaintFragment.class.getSimpleName();
private static FileComplaintFragment mainactivity; private static FileComplaintFragment mainactivity;
private Button buttonSubmit; private Button buttonSubmit;
private ComplaintDescriptionAutoCompleteTextView descriptionAutoCompleteTextview; private ComplaintDescriptionAutoCompleteTextView descriptionAutoCompleteTextview;
......
...@@ -27,9 +27,6 @@ public class RoleRecyclerViewFragment extends Fragment implements TransitionTarg ...@@ -27,9 +27,6 @@ public class RoleRecyclerViewFragment extends Fragment implements TransitionTarg
private static final String TAG = "RoleRecyclerViewFragment"; private static final String TAG = "RoleRecyclerViewFragment";
public Fragment parentFragment = null; public Fragment parentFragment = null;
private RecyclerView recyclerView;
private RoleAdapter roleAdapter;
private List<Role> roleList; private List<Role> roleList;
public RoleRecyclerViewFragment() { public RoleRecyclerViewFragment() {
...@@ -70,8 +67,8 @@ public class RoleRecyclerViewFragment extends Fragment implements TransitionTarg ...@@ -70,8 +67,8 @@ public class RoleRecyclerViewFragment extends Fragment implements TransitionTarg
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
recyclerView = (RecyclerView) getActivity().findViewById(R.id.role_recycler_view); RecyclerView recyclerView = (RecyclerView) getActivity().findViewById(R.id.role_recycler_view);
roleAdapter = new RoleAdapter(roleList, this); RoleAdapter roleAdapter = new RoleAdapter(roleList, this);
roleAdapter.uid = "RRVFrag"; roleAdapter.uid = "RRVFrag";
recyclerView.setAdapter(roleAdapter); recyclerView.setAdapter(roleAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
......
...@@ -24,21 +24,15 @@ import retrofit2.Callback; ...@@ -24,21 +24,15 @@ import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
public class SettingsFragment extends PreferenceFragmentCompat { public class SettingsFragment extends PreferenceFragmentCompat {
private SwitchPreferenceCompat showContactPref;
private SwitchPreferenceCompat darkThemePref;
private Preference profilePref;
private Preference feedbackPref;
private Preference aboutPref;
private Preference logoutPref;
private SharedPreferences sharedPref;
private SharedPreferences.Editor editor; private SharedPreferences.Editor editor;
private SwitchPreferenceCompat showContactPref;
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey); setPreferencesFromResource(R.xml.preferences, rootKey);
// Get preferences and editor // Get preferences and editor
sharedPref = getActivity().getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); SharedPreferences sharedPref = getActivity().getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
editor = sharedPref.edit(); editor = sharedPref.edit();
// Show contact number // Show contact number
...@@ -53,7 +47,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { ...@@ -53,7 +47,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
showContactPref.setEnabled(false); showContactPref.setEnabled(false);
// Dark Theme // Dark Theme
darkThemePref = (SwitchPreferenceCompat) findPreference("dark_theme"); SwitchPreferenceCompat darkThemePref = (SwitchPreferenceCompat) findPreference("dark_theme");
darkThemePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { darkThemePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object o) { public boolean onPreferenceChange(Preference preference, Object o) {
...@@ -64,7 +58,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { ...@@ -64,7 +58,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
darkThemePref.setChecked(sharedPref.getBoolean(Constants.DARK_THEME, false)); darkThemePref.setChecked(sharedPref.getBoolean(Constants.DARK_THEME, false));
// Update Profile // Update Profile
profilePref = findPreference("profile"); Preference profilePref = findPreference("profile");
profilePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { profilePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
...@@ -74,7 +68,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { ...@@ -74,7 +68,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}); });
// Feedback // Feedback
feedbackPref = findPreference("feedback"); Preference feedbackPref = findPreference("feedback");
feedbackPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { feedbackPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
...@@ -84,7 +78,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { ...@@ -84,7 +78,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}); });
// About // About
aboutPref = findPreference("about"); Preference aboutPref = findPreference("about");
aboutPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { aboutPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
...@@ -94,7 +88,7 @@ public class SettingsFragment extends PreferenceFragmentCompat { ...@@ -94,7 +88,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
}); });
// Logout // Logout
logoutPref = findPreference("logout"); Preference logoutPref = findPreference("logout");
logoutPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { logoutPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
......
...@@ -116,6 +116,7 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge ...@@ -116,6 +116,7 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge
@Override @Override
public void onResponse(Call<User> call, Response<User> response) { public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (getActivity() == null || getView() == null) return;
user = response.body(); user = response.body();
populateViews(); populateViews();
getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE); getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
...@@ -145,6 +146,8 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge ...@@ -145,6 +146,8 @@ public class UserFragment extends BackHandledFragment implements TransitionTarge
} }
private void populateViews() { private void populateViews() {
if (getActivity() == null || getView() == null) return;
userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile); userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile);
TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile); TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile);
TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile); TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile);
......
...@@ -17,8 +17,6 @@ import app.insti.fragment.MapFragment; ...@@ -17,8 +17,6 @@ import app.insti.fragment.MapFragment;
public class ListFragment extends Fragment { public class ListFragment extends Fragment {
MapFragment mainActivity; MapFragment mainActivity;
FuzzySearchAdapter adapter;
HashMap<String, Marker> data;
View rootView; View rootView;
ListView list; ListView list;
...@@ -29,7 +27,7 @@ public class ListFragment extends Fragment { ...@@ -29,7 +27,7 @@ public class ListFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
mainActivity = MapFragment.getMainActivity(); mainActivity = MapFragment.getMainActivity();
adapter = mainActivity.getAdapter(); final FuzzySearchAdapter adapter = mainActivity.getAdapter();
rootView = inflater.inflate(R.layout.map_list_fragment, container, false); rootView = inflater.inflate(R.layout.map_list_fragment, container, false);
list = (ListView) rootView.findViewById(R.id.suggestion_list); list = (ListView) rootView.findViewById(R.id.suggestion_list);
list.setAdapter(adapter); list.setAdapter(adapter);
......
...@@ -412,20 +412,17 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -412,20 +412,17 @@ public class CampusMapView extends SubsamplingScaleImageView {
for (Marker marker : markerList) { for (Marker marker : markerList) {
if (isInView(marker.getPoint())) { if (isInView(marker.getPoint())) {
if (isShowPinScale(marker) if (isShowPinScale(marker) &&
&& !(isResultMarker(marker) || addedMarkerList !(isResultMarker(marker) || addedMarkerList.contains(marker)) &&
.contains(marker))) { shouldShowUp(marker)) {
if (shouldShowUp(marker)) drawPionterAndText(canvas, marker);
drawPionterAndText(canvas, marker);
} }
} }
} }
for (Marker marker : addedMarkerList) { for (Marker marker : addedMarkerList) {
if (isInView(marker.getPoint())) { if (isInView(marker.getPoint()) && !isResultMarker(marker)) {
if (!isResultMarker(marker)) { drawMarkerBitmap(canvas, marker);
drawMarkerBitmap(canvas, marker); drawMarkerText(canvas, marker);
drawMarkerText(canvas, marker);
}
} }
} }
Marker marker = getResultMarker(); Marker marker = getResultMarker();
...@@ -689,8 +686,6 @@ public class CampusMapView extends SubsamplingScaleImageView { ...@@ -689,8 +686,6 @@ public class CampusMapView extends SubsamplingScaleImageView {
if (motionEvent.getX() < 20 * density) { if (motionEvent.getX() < 20 * density) {
getParent().requestDisallowInterceptTouchEvent(false); getParent().requestDisallowInterceptTouchEvent(false);
return true; return true;
} else {
// CampusMapView.this.setPanEnabled(true);
} }
} else if (action == MotionEvent.ACTION_UP) { } else if (action == MotionEvent.ACTION_UP) {
CampusMapView.this.setPanEnabled(true); CampusMapView.this.setPanEnabled(true);
......
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