[Core sample] added progress bar
This commit is contained in:
parent
2fd33b2f50
commit
b5db90fa93
7 changed files with 56 additions and 14 deletions
BIN
OsmAndCore-sample/res/drawable-hdpi/ic_action_search_dark.png
Normal file
BIN
OsmAndCore-sample/res/drawable-hdpi/ic_action_search_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAndCore-sample/res/drawable-mdpi/ic_action_search_dark.png
Normal file
BIN
OsmAndCore-sample/res/drawable-mdpi/ic_action_search_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAndCore-sample/res/drawable-xhdpi/ic_action_search_dark.png
Normal file
BIN
OsmAndCore-sample/res/drawable-xhdpi/ic_action_search_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
OsmAndCore-sample/res/drawable-xxhdpi/ic_action_search_dark.png
Normal file
BIN
OsmAndCore-sample/res/drawable-xxhdpi/ic_action_search_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
|
@ -17,6 +17,39 @@
|
|||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/searchProgressBar"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/searchIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_action_search_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:background="@null"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/search_hint"
|
||||
android:lines="1"
|
||||
android:textColor="@color/titleTextColor"
|
||||
tools:text="Search request"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/clearButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
|
@ -25,24 +58,13 @@
|
|||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:background="@null"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/search_hint"
|
||||
android:lines="1"
|
||||
android:textColor="@color/titleTextColor"
|
||||
tools:text="Search request"/>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/searchDetailsText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="64dp"
|
||||
android:layout_marginLeft="56dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:gravity="center_vertical"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<resources>
|
||||
<color name="colorPrimary">#ff8f00</color>
|
||||
<color name="colorPrimaryDark">#e68200</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
<color name="colorAccent">#FFF</color>
|
||||
|
||||
<color name="dividerColor">#F0F0F0</color>
|
||||
<color name="windowBackgroundColor">#EAEAEA</color>
|
||||
|
|
|
@ -19,7 +19,9 @@ import android.view.View;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.core.android.AtlasMapRendererView;
|
||||
|
@ -85,13 +87,17 @@ public class MainActivity extends Activity {
|
|||
private MultiTouchSupport multiTouchSupport;
|
||||
|
||||
private SearchAPI searchAPI;
|
||||
|
||||
private EditText searchEditText;
|
||||
private TextView searchDetailsText;
|
||||
private ImageView searchIcon;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
private ListView searchListView;
|
||||
private SearchListAdapter adapter;
|
||||
private String queryText = "";
|
||||
private final static int MAX_SEARCH_RESULTS_CORE = 0;
|
||||
private final static int MAX_SEARCH_RESULTS_IU = 50;
|
||||
private final static int MAX_SEARCH_RESULTS_IU = 150;
|
||||
|
||||
// Germany
|
||||
private final static float INIT_LAT = 49.353953f;
|
||||
|
@ -143,6 +149,7 @@ public class MainActivity extends Activity {
|
|||
searchDetailsText.setText(sb.toString());
|
||||
searchDetailsText.setVisibility(View.VISIBLE);
|
||||
}
|
||||
hideProgressBar();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -262,6 +269,7 @@ public class MainActivity extends Activity {
|
|||
String newQueryText = s.toString();
|
||||
if (!queryText.equalsIgnoreCase(newQueryText)) {
|
||||
queryText = newQueryText;
|
||||
showProgressBar();
|
||||
runSearch(getScreenCenter31(), getScreenBounds31(), queryText);
|
||||
}
|
||||
}
|
||||
|
@ -279,6 +287,8 @@ public class MainActivity extends Activity {
|
|||
});
|
||||
|
||||
searchDetailsText = (TextView) findViewById(R.id.searchDetailsText);
|
||||
searchIcon = (ImageView) findViewById(R.id.searchIcon);
|
||||
progressBar = (ProgressBar) findViewById(R.id.searchProgressBar);
|
||||
|
||||
ImageButton clearButton = (ImageButton) findViewById(R.id.clearButton);
|
||||
clearButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -362,6 +372,16 @@ public class MainActivity extends Activity {
|
|||
return new AreaI(topLeftPoint, bottomRightPoint);
|
||||
}
|
||||
|
||||
private void showProgressBar() {
|
||||
searchIcon.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void hideProgressBar() {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
searchIcon.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private boolean isSearchListHidden() {
|
||||
return searchListView.getVisibility() != View.VISIBLE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue