subscribe dialog: add a progressbar

This commit is contained in:
Andrew Dolgov 2015-06-03 13:43:28 +03:00
parent 3de302182c
commit 6b6107b276
2 changed files with 40 additions and 29 deletions

View File

@ -1,5 +1,26 @@
package org.fox.ttrss.share; package org.fox.ttrss.share;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Spinner;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.R;
import org.fox.ttrss.types.FeedCategory;
import org.fox.ttrss.types.FeedCategoryList;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -7,27 +28,6 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.R;
import org.fox.ttrss.types.FeedCategory;
import org.fox.ttrss.types.FeedCategoryList;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
public class SubscribeActivity extends CommonShareActivity { public class SubscribeActivity extends CommonShareActivity {
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
@ -35,6 +35,7 @@ public class SubscribeActivity extends CommonShareActivity {
private Button m_catButton; private Button m_catButton;
private CatListAdapter m_adapter; private CatListAdapter m_adapter;
private FeedCategoryList m_cats = new FeedCategoryList(); private FeedCategoryList m_cats = new FeedCategoryList();
private ProgressBar m_progressBar;
private static final int REQ_CATS = 1; private static final int REQ_CATS = 1;
private static final int REQ_POST = 2; private static final int REQ_POST = 2;
@ -88,6 +89,7 @@ public class SubscribeActivity extends CommonShareActivity {
setSmallScreen(false); setSmallScreen(false);
m_progressBar = (ProgressBar) findViewById(R.id.subscribe_progress);
Spinner catList = (Spinner) findViewById(R.id.category_spinner); Spinner catList = (Spinner) findViewById(R.id.category_spinner);
if (m_cats.size() == 0) m_cats.add(new FeedCategory(0, "Uncategorized", 0)); if (m_cats.size() == 0) m_cats.add(new FeedCategory(0, "Uncategorized", 0));
@ -138,7 +140,7 @@ public class SubscribeActivity extends CommonShareActivity {
ApiRequest req = new ApiRequest(getApplicationContext()) { ApiRequest req = new ApiRequest(getApplicationContext()) {
protected void onPostExecute(JsonElement result) { protected void onPostExecute(JsonElement result) {
setProgressBarIndeterminateVisibility(false); m_progressBar.setVisibility(View.INVISIBLE);
if (m_lastError != ApiError.NO_ERROR) { if (m_lastError != ApiError.NO_ERROR) {
toast(getErrorMessage()); toast(getErrorMessage());
@ -207,7 +209,7 @@ public class SubscribeActivity extends CommonShareActivity {
} }
}; };
setProgressBarIndeterminateVisibility(true); m_progressBar.setVisibility(View.VISIBLE);
req.execute(map); req.execute(map);
} }
@ -228,7 +230,7 @@ public class SubscribeActivity extends CommonShareActivity {
private void updateCats() { private void updateCats() {
ApiRequest req = new ApiRequest(getApplicationContext()) { ApiRequest req = new ApiRequest(getApplicationContext()) {
protected void onPostExecute(JsonElement result) { protected void onPostExecute(JsonElement result) {
setProgressBarIndeterminateVisibility(false); m_progressBar.setVisibility(View.INVISIBLE);
if (m_lastError != ApiError.NO_ERROR) { if (m_lastError != ApiError.NO_ERROR) {
toast(getErrorMessage()); toast(getErrorMessage());
@ -267,7 +269,7 @@ public class SubscribeActivity extends CommonShareActivity {
} }
}; };
setProgressBarIndeterminateVisibility(true); m_progressBar.setVisibility(View.VISIBLE);
req.execute(map); req.execute(map);
} }

11
org.fox.ttrss/src/main/res/layout/subscribe.xml Normal file → Executable file
View File

@ -26,13 +26,22 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_below="@+id/feed_url" /> android:layout_below="@+id/feed_url" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_below="@+id/category_spinner"
android:layout_width="match_parent"
android:visibility="invisible"
android:layout_height="wrap_content"
android:indeterminate="true"
android:id="@+id/subscribe_progress" />
<LinearLayout <LinearLayout
style="?android:attr/buttonBarStyle" style="?android:attr/buttonBarStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/category_spinner" android:layout_alignLeft="@+id/category_spinner"
android:layout_alignRight="@+id/category_spinner" android:layout_alignRight="@+id/category_spinner"
android:layout_below="@+id/category_spinner" > android:layout_below="@+id/subscribe_progress" >
<Button <Button
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"