Search in sources :

Example 61 with AbsListView

use of android.widget.AbsListView in project iNaturalistAndroid by inaturalist.

the class ExploreActivity method refreshObservations.

private void refreshObservations() {
    if (mLoadingObservationsGrid == null) {
        // View hasn't loaded yet
        return;
    }
    refreshFilterBar(mObservationsGridFilterBar);
    refreshFilterBar(mObservationsMapFilterBar);
    mObservationsGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
            JSONObject item = (JSONObject) view.getTag();
            Intent intent = new Intent(ExploreActivity.this, ObservationViewerActivity.class);
            intent.putExtra("observation", item.toString());
            intent.putExtra("read_only", true);
            intent.putExtra("reload", true);
            startActivityForResult(intent, VIEW_OBSERVATION_REQUEST_CODE);
            try {
                JSONObject eventParams = new JSONObject();
                eventParams.put(AnalyticsClient.EVENT_PARAM_VIA, AnalyticsClient.EVENT_VALUE_EXPLORE_GRID);
                AnalyticsClient.getInstance().logEvent(AnalyticsClient.EVENT_NAME_NAVIGATE_OBS_DETAILS, eventParams);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
    if (mTotalResults[VIEW_TYPE_OBSERVATIONS] == NOT_LOADED) {
        if (mObservationsViewMode == OBSERVATIONS_VIEW_MODE_GRID) {
            mLoadingObservationsGrid.setVisibility(View.VISIBLE);
        } else {
            mLoadingObservationsGrid.setVisibility(View.GONE);
        }
        mObservationsGrid.setVisibility(View.GONE);
        mObservationsGridEmpty.setVisibility(View.GONE);
        mObservationsMapContainer.setVisibility(View.GONE);
    } else {
        mLoadingObservationsGrid.setVisibility(View.GONE);
        if (mResults[VIEW_TYPE_OBSERVATIONS].size() == 0) {
            mObservationsGridEmpty.setVisibility(View.VISIBLE);
        } else {
            mObservationsGridEmpty.setVisibility(View.GONE);
        }
        Runnable setObsInGrid = new Runnable() {

            @Override
            public void run() {
                if ((mGridAdapter != null) && (mCurrentResultsPage[VIEW_TYPE_OBSERVATIONS] > 1)) {
                    // New results appended - don't reload the entire adapter
                    mGridAdapter.notifyDataSetChanged();
                } else if (mObservationsGrid.getColumnWidth() > 0) {
                    mGridAdapter = new ObservationGridAdapter(ExploreActivity.this, mObservationsGrid.getColumnWidth(), mResults[VIEW_TYPE_OBSERVATIONS]);
                    mObservationsGrid.setAdapter(mGridAdapter);
                } else if (mObservationsGrid.getColumnWidth() == 0) {
                    mObservationsGrid.postDelayed(this, 100);
                }
            }
        };
        mObservationsGrid.post(setObsInGrid);
        mObservationsGrid.setVisibility(View.VISIBLE);
    }
    loadListViewOffset(mObservationsGrid, getIntent().getExtras(), "mList" + VIEW_TYPE_OBSERVATIONS);
    mObservationsGrid.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            if ((firstVisibleItem + visibleItemCount >= totalItemCount - 9) && (totalItemCount > 0)) {
                // The end has been reached - load more observations
                loadNextResultsPage(VIEW_TYPE_OBSERVATIONS, false);
            }
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
    if (mObservationsViewMode == OBSERVATIONS_VIEW_MODE_GRID) {
        mObservationsViewModeGrid.setSelected(true);
        mObservationsViewModeGrid.setColorFilter(Color.parseColor("#ffffff"));
        mObservationsViewModeMap.setSelected(false);
        mObservationsViewModeMap.setColorFilter(Color.parseColor("#676767"));
        mLoadingObservationsGrid.setVisibility(View.VISIBLE);
        mObservationsMapContainer.setVisibility(View.GONE);
    } else {
        mObservationsViewModeGrid.setSelected(false);
        mObservationsViewModeGrid.setColorFilter(Color.parseColor("#676767"));
        mObservationsViewModeMap.setSelected(true);
        mObservationsViewModeMap.setColorFilter(Color.parseColor("#ffffff"));
        mLoadingObservationsGrid.setVisibility(View.GONE);
        mObservationsMapContainer.setVisibility(View.VISIBLE);
        mMapHide.setVisibility(View.GONE);
        mObservationsGrid.setVisibility(View.GONE);
        mObservationsGridEmpty.setVisibility(View.GONE);
    }
    mObservationsViewModeGrid.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mObservationsViewMode = OBSERVATIONS_VIEW_MODE_GRID;
            refreshObservations();
        }
    });
    mObservationsViewModeMap.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mObservationsViewMode = OBSERVATIONS_VIEW_MODE_MAP;
            refreshObservations();
        }
    });
    mObservationsChangeMapLayers.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mObservationsMapType == GoogleMap.MAP_TYPE_SATELLITE) {
                mObservationsMapType = GoogleMap.MAP_TYPE_TERRAIN;
            } else {
                mObservationsMapType = GoogleMap.MAP_TYPE_SATELLITE;
            }
            refreshMapType();
        }
    });
    refreshMapType();
    mRedoObservationsSearch.setVisibility(mMapMoved ? View.VISIBLE : View.GONE);
    mPerformingSearch.setVisibility(mLoadingNextResults[VIEW_TYPE_OBSERVATIONS] ? View.VISIBLE : View.GONE);
    mRedoObservationSearchIcon.setVisibility(mLoadingNextResults[VIEW_TYPE_OBSERVATIONS] ? View.GONE : View.VISIBLE);
    mRedoObservationsSearchText.setTextColor(mLoadingNextResults[VIEW_TYPE_OBSERVATIONS] ? Color.parseColor("#8A000000") : Color.parseColor("#000000"));
    mRedoObservationsSearch.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // Re-search under the current map bounds
            VisibleRegion vr = mObservationsMap.getProjection().getVisibleRegion();
            LatLngBounds bounds = new LatLngBounds(new LatLng(vr.nearLeft.latitude, vr.farLeft.longitude), new LatLng(vr.farRight.latitude, vr.farRight.longitude));
            mSearchFilters.mapBounds = bounds;
            // Clear out the place (search by map bounds only)
            mSearchFilters.place = null;
            if ((mLastMapBounds != null) && (mInitialLocationBounds != null) && (mLastMapBounds.equals(mInitialLocationBounds) == true)) {
                mSearchFilters.isCurrentLocation = true;
            } else {
                mSearchFilters.isCurrentLocation = false;
            }
            resetResults(true);
            loadAllResults();
            mPerformingSearch.setVisibility(View.VISIBLE);
            mRedoObservationSearchIcon.setVisibility(View.GONE);
            mRedoObservationsSearchText.setTextColor(Color.parseColor("#8A000000"));
        }
    });
    if (mSearchFilters.place != null) {
        // Show the boundaries/border of the place on the map
        addPlaceLayerToMap(mSearchFilters.place);
    }
    // Set the tile overlay (for the taxon's observations map)
    TileProvider tileProvider = new UrlTileProvider(256, 256) {

        @Override
        public URL getTileUrl(int x, int y, int zoom) {
            String s = String.format(INaturalistService.API_HOST + "/%s/%d/%d/%d.png?%s", zoom <= 9 ? "colored_heatmap" : "points", zoom, x, y, mSearchFilters.toUrlQueryString());
            try {
                return new URL(s);
            } catch (MalformedURLException e) {
                throw new AssertionError(e);
            }
        }
    };
    if (mObservationsMap != null) {
        TileOverlay tileOverlay = mObservationsMap.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) UrlTileProvider(com.google.android.gms.maps.model.UrlTileProvider) TileProvider(com.google.android.gms.maps.model.TileProvider) URL(java.net.URL) VisibleRegion(com.google.android.gms.maps.model.VisibleRegion) UrlTileProvider(com.google.android.gms.maps.model.UrlTileProvider) LatLng(com.google.android.gms.maps.model.LatLng) TileOverlayOptions(com.google.android.gms.maps.model.TileOverlayOptions) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) JSONException(org.json.JSONException) AbsListView(android.widget.AbsListView) Intent(android.content.Intent) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) Point(android.graphics.Point) TileOverlay(com.google.android.gms.maps.model.TileOverlay) JSONObject(org.json.JSONObject) AdapterView(android.widget.AdapterView)

Example 62 with AbsListView

use of android.widget.AbsListView in project Osmand by osmandapp.

the class QuickSearchListFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ListView listView = getListView();
    if (listView != null) {
        listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            }

            public void onScrollStateChanged(AbsListView view, int scrollState) {
                scrolling = (scrollState != AbsListView.OnScrollListener.SCROLL_STATE_IDLE);
                if (scrolling) {
                    dialogFragment.hideKeyboard();
                }
            }
        });
    }
}
Also used : AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) FavouritePoint(net.osmand.data.FavouritePoint)

Example 63 with AbsListView

use of android.widget.AbsListView in project Zom-Android by zom.

the class ContactListFilterView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    // mFilterList = (AbsListView) findViewById(R.id.filteredList);
    mFilterList.setTextFilterEnabled(true);
    // mEmptyView = (TextView) findViewById(R.id.empty);
    mFilterList.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor c = (Cursor) mFilterList.getItemAtPosition(position);
            if (mListener != null)
                mListener.openChat(c);
        }
    });
    mFilterList.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
            String[] contactOptions = { // mContext.getString(R.string.menu_verify),
            mContext.getString(R.string.menu_contact_nickname), mContext.getString(R.string.menu_remove_contact) };
            // mContext.getString(R.string.menu_block_contact)};
            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setItems(contactOptions, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    if (which == 0)
                        setContactNickname(position);
                    else if (which == 1)
                        removeContactAtPosition(position);
                    else if (which == 2)
                        blockContactAtPosition(position);
                }
            });
            builder.create().show();
            return true;
        }
    });
/**
 *        mEtSearch = (EditText)findViewById(R.id.contactSearch);
 *
 *        mEtSearch.addTextChangedListener(new TextWatcher()
 *        {
 *
 *            @Override
 *            public void afterTextChanged(Editable s) {
 *
 *            }
 *
 *            @Override
 *            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
 *
 *            }
 *
 *            @Override
 *            public void onTextChanged(CharSequence s, int start, int before, int count) {
 *
 *                ContactListFilterView.this.doFilter(mEtSearch.getText().toString());
 *
 *            }
 *
 *        });
 *
 *        mEtSearch.setOnKeyListener(new OnKeyListener ()
 *        {
 *
 *            @Override
 *            public boolean onKey(View v, int keyCode, KeyEvent event) {
 *
 *                ContactListFilterView.this.doFilter(mEtSearch.getText().toString());
 *                return false;
 *            }
 *
 *        });
 */
/*
        mFilterList.setItemActionListener(new ListView.OnActionClickListener() {

            @Override
            public void onClick(View listView, View buttonview, int position) {

                Cursor c = (Cursor) mFilterList.getItemAtPosition(position);
                if (mListener != null)
                    if (buttonview.getId() == R.id.btnExListChat)
                        mListener.startChat(c);
                    else if (buttonview.getId() == R.id.btnExListProfile)
                        mListener.showProfile(c);

            }
    }, R.id.btnExListChat, R.id.btnExListProfile);
    */
// 
// if (!isInEditMode())
// mPresenceView = (UserPresenceView) findViewById(R.id.userPresence);
}
Also used : AlertDialog(android.app.AlertDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener)

Example 64 with AbsListView

use of android.widget.AbsListView in project Osmand by osmandapp.

the class AvailableGPXFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.available_gpx, container, false);
    listView = (ExpandableListView) v.findViewById(android.R.id.list);
    setHasOptionsMenu(true);
    if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
        currentGpxView = inflater.inflate(R.layout.current_gpx_item, null, false);
        createCurrentTrackView();
        currentGpxView.findViewById(R.id.current_track_info).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent newIntent = new Intent(getActivity(), getMyApplication().getAppCustomization().getTrackActivity());
                newIntent.putExtra(TrackActivity.CURRENT_RECORDING, true);
                newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(newIntent);
            }
        });
        listView.addHeaderView(currentGpxView);
    /*
			currentTrackView.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					openTrack(getActivity(), null);
				}
			});
			*/
    } else {
        View headerView = inflater.inflate(R.layout.list_shadow_header, null, false);
        listView.addHeaderView(headerView);
    }
    footerView = inflater.inflate(R.layout.list_shadow_footer, null, false);
    listView.addFooterView(footerView);
    emptyView = v.findViewById(android.R.id.empty);
    ImageView emptyImageView = (ImageView) emptyView.findViewById(R.id.empty_state_image_view);
    if (Build.VERSION.SDK_INT >= 18) {
        emptyImageView.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_empty_state_trip_day : R.drawable.ic_empty_state_trip_night);
    } else {
        emptyImageView.setVisibility(View.INVISIBLE);
    }
    Button importButton = (Button) emptyView.findViewById(R.id.import_button);
    importButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            addTrack();
        }
    });
    if (this.adapter != null) {
        listView.setAdapter(this.adapter);
    }
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
            View currentFocus = getActivity().getCurrentFocus();
            if (currentFocus != null) {
                InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int i, int i1, int i2) {
        }
    });
    return v;
}
Also used : ImageButton(android.widget.ImageButton) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) AbsListView(android.widget.AbsListView) Intent(android.content.Intent) InputMethodManager(android.view.inputmethod.InputMethodManager) ImageView(android.widget.ImageView) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AbsListView(android.widget.AbsListView) ExpandableListView(android.widget.ExpandableListView) OsmandMonitoringPlugin(net.osmand.plus.monitoring.OsmandMonitoringPlugin)

Example 65 with AbsListView

use of android.widget.AbsListView in project Osmand by osmandapp.

the class SplitSegmentDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    minMaxSpeedPaint = new Paint();
    minMaxSpeedPaint.setTextSize(getResources().getDimension(R.dimen.default_split_segments_data));
    minMaxSpeedPaint.setTypeface(FontCache.getFont(getContext(), "fonts/Roboto-Medium.ttf"));
    minMaxSpeedPaint.setStyle(Paint.Style.FILL);
    minMaxSpeedTextBounds = new Rect();
    final View view = getActivity().getLayoutInflater().inflate(R.layout.split_segments_layout, container, false);
    Toolbar toolbar = (Toolbar) view.findViewById(R.id.split_interval_toolbar);
    TextView titleTextView = (TextView) toolbar.findViewById(R.id.title);
    if (app.getSettings().isLightContent()) {
        titleTextView.setTextAppearance(getContext(), R.style.Widget_Styled_LightActionBarTitle);
    } else {
        titleTextView.setTextAppearance(getContext(), R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
    }
    ActionBar trackActivityActionBar = getTrackActivity().getSupportActionBar();
    if (trackActivityActionBar != null) {
        titleTextView.setText(trackActivityActionBar.getTitle());
    }
    toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    progressBar = view.findViewById(R.id.progress_bar);
    listView = (ListView) view.findViewById(R.id.list);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    adapter = new SplitSegmentsAdapter(new ArrayList<GpxDisplayItem>());
    headerView = view.findViewById(R.id.header_layout);
    ((ImageView) headerView.findViewById(R.id.header_split_image)).setImageDrawable(ic.getIcon(R.drawable.ic_action_split_interval, app.getSettings().isLightContent() ? R.color.icon_color : 0));
    listView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.gpx_split_segments_empty_header, null, false));
    listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
    listView.setOnScrollListener(new AbsListView.OnScrollListener() {

        int previousYPos = -1;

        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
            if (i == SCROLL_STATE_IDLE) {
                previousYPos = -1;
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int i, int i1, int i2) {
            View c = absListView.getChildAt(0);
            if (c != null) {
                int currentYPos = -c.getTop() + absListView.getFirstVisiblePosition() * c.getHeight();
                if (previousYPos == -1) {
                    previousYPos = currentYPos;
                }
                float yTranslationToSet = headerView.getTranslationY() + (previousYPos - currentYPos);
                if (yTranslationToSet < 0 && yTranslationToSet > -headerView.getHeight()) {
                    headerView.setTranslationY(yTranslationToSet);
                } else if (yTranslationToSet < -headerView.getHeight()) {
                    headerView.setTranslationY(-headerView.getHeight());
                } else if (yTranslationToSet > 0) {
                    headerView.setTranslationY(0);
                }
                previousYPos = currentYPos;
            }
        }
    });
    listView.setAdapter(adapter);
    return view;
}
Also used : Rect(android.graphics.Rect) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) AbsListView(android.widget.AbsListView) Paint(android.graphics.Paint) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) Paint(android.graphics.Paint) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

AbsListView (android.widget.AbsListView)223 View (android.view.View)126 ListView (android.widget.ListView)80 AdapterView (android.widget.AdapterView)54 TextView (android.widget.TextView)46 ViewGroup (android.view.ViewGroup)33 ImageView (android.widget.ImageView)29 ScrollView (android.widget.ScrollView)23 RecyclerView (android.support.v7.widget.RecyclerView)21 GridView (android.widget.GridView)21 SuppressLint (android.annotation.SuppressLint)20 OnScrollListener (android.widget.AbsListView.OnScrollListener)19 Intent (android.content.Intent)17 ArrayList (java.util.ArrayList)16 Context (android.content.Context)12 Point (android.graphics.Point)12 Handler (android.os.Handler)12 WebView (android.webkit.WebView)12 ExpandableListView (android.widget.ExpandableListView)12 ArrayListLoader (com.klinker.android.twitter.adapters.ArrayListLoader)10