Replace refresh dialog with icon animation
Change-Id: I6d2cc649b9fa8883a7256d8ecb62cb56bbf5dd59
This commit is contained in:
@@ -61,7 +61,6 @@
|
|||||||
<string name="menu_show_changelog">Show changelog</string>
|
<string name="menu_show_changelog">Show changelog</string>
|
||||||
<string name="menu_changelog_url" translatable="false">https://download.lineageos.org/<xliff:g id="device_name">%1$s</xliff:g>/changes</string>
|
<string name="menu_changelog_url" translatable="false">https://download.lineageos.org/<xliff:g id="device_name">%1$s</xliff:g>/changes</string>
|
||||||
|
|
||||||
<string name="dialog_checking_for_updates">Checking for updates</string>
|
|
||||||
<string name="snack_updates_found">New updates found</string>
|
<string name="snack_updates_found">New updates found</string>
|
||||||
<string name="snack_no_updates_found">No new updates found</string>
|
<string name="snack_no_updates_found">No new updates found</string>
|
||||||
<string name="snack_updates_check_failed">The update check failed. Please check your internet connection and try again later.</string>
|
<string name="snack_updates_check_failed">The update check failed. Please check your internet connection and try again later.</string>
|
||||||
|
@@ -15,11 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.lineageos.updater;
|
package org.lineageos.updater;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
@@ -42,6 +40,9 @@ import android.util.Log;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.LinearInterpolator;
|
||||||
|
import android.view.animation.RotateAnimation;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -71,6 +72,9 @@ public class UpdatesActivity extends UpdatesListActivity {
|
|||||||
|
|
||||||
private UpdatesListAdapter mAdapter;
|
private UpdatesListAdapter mAdapter;
|
||||||
|
|
||||||
|
private View mRefreshIconView;
|
||||||
|
private RotateAnimation mRefreshAnimation;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -147,6 +151,11 @@ public class UpdatesActivity extends UpdatesListActivity {
|
|||||||
// This can't be collapsed without a touchscreen
|
// This can't be collapsed without a touchscreen
|
||||||
appBar.setExpanded(false);
|
appBar.setExpanded(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mRefreshAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
|
||||||
|
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||||
|
mRefreshAnimation.setInterpolator(new LinearInterpolator());
|
||||||
|
mRefreshAnimation.setDuration(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -353,12 +362,6 @@ public class UpdatesActivity extends UpdatesListActivity {
|
|||||||
String url = Utils.getServerURL(this);
|
String url = Utils.getServerURL(this);
|
||||||
Log.d(TAG, "Checking " + url);
|
Log.d(TAG, "Checking " + url);
|
||||||
|
|
||||||
final ProgressDialog progressDialog = new ProgressDialog(this);
|
|
||||||
progressDialog.setTitle(R.string.app_name);
|
|
||||||
progressDialog.setMessage(getString(R.string.dialog_checking_for_updates));
|
|
||||||
progressDialog.setIndeterminate(true);
|
|
||||||
progressDialog.setCancelable(true);
|
|
||||||
|
|
||||||
DownloadClient.DownloadCallback callback = new DownloadClient.DownloadCallback() {
|
DownloadClient.DownloadCallback callback = new DownloadClient.DownloadCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(final boolean cancelled) {
|
public void onFailure(final boolean cancelled) {
|
||||||
@@ -366,10 +369,10 @@ public class UpdatesActivity extends UpdatesListActivity {
|
|||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
progressDialog.dismiss();
|
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
showSnackbar(R.string.snack_updates_check_failed, Snackbar.LENGTH_LONG);
|
showSnackbar(R.string.snack_updates_check_failed, Snackbar.LENGTH_LONG);
|
||||||
}
|
}
|
||||||
|
refreshAnimationStop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -386,7 +389,7 @@ public class UpdatesActivity extends UpdatesListActivity {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Log.d(TAG, "List downloaded");
|
Log.d(TAG, "List downloaded");
|
||||||
processNewJson(jsonFile, jsonFileTmp, manualRefresh);
|
processNewJson(jsonFile, jsonFileTmp, manualRefresh);
|
||||||
progressDialog.dismiss();
|
refreshAnimationStop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -405,14 +408,7 @@ public class UpdatesActivity extends UpdatesListActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
refreshAnimationStart();
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
downloadClient.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
progressDialog.show();
|
|
||||||
downloadClient.start();
|
downloadClient.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,4 +442,22 @@ public class UpdatesActivity extends UpdatesListActivity {
|
|||||||
public void showSnackbar(int stringId, int duration) {
|
public void showSnackbar(int stringId, int duration) {
|
||||||
Snackbar.make(findViewById(R.id.main_container), stringId, duration).show();
|
Snackbar.make(findViewById(R.id.main_container), stringId, duration).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refreshAnimationStart() {
|
||||||
|
if (mRefreshIconView == null) {
|
||||||
|
mRefreshIconView = findViewById(R.id.menu_refresh);
|
||||||
|
}
|
||||||
|
if (mRefreshIconView != null) {
|
||||||
|
mRefreshAnimation.setRepeatCount(Animation.INFINITE);
|
||||||
|
mRefreshIconView.startAnimation(mRefreshAnimation);
|
||||||
|
mRefreshIconView.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshAnimationStop() {
|
||||||
|
if (mRefreshIconView != null) {
|
||||||
|
mRefreshAnimation.setRepeatCount(0);
|
||||||
|
mRefreshIconView.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user