See the License for the specific language governing permissions and
limitations under the License.
-->
-<GridView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/ingest_gridview"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:columnWidth="200px"
- android:numColumns="auto_fit"
- android:fastScrollEnabled="true"
- android:background="@android:color/background_dark"
- android:choiceMode="multipleChoiceModal"
- android:stretchMode="columnWidth" />
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+ <GridView
+ android:id="@+id/ingest_gridview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:columnWidth="200px"
+ android:numColumns="auto_fit"
+ android:fastScrollEnabled="true"
+ android:background="@android:color/background_dark"
+ android:choiceMode="multipleChoiceModal"
+ android:stretchMode="columnWidth" />
+
+ <LinearLayout
+ android:id="@+id/ingest_warning_overlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_margin="20dip"
+ android:gravity="center"
+ android:orientation="horizontal"
+ android:visibility="gone" >
+
+ <ImageView
+ android:id="@+id/ingest_warning_overlay_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:src="@android:drawable/ic_dialog_alert" />
+
+ <TextView
+ android:id="@+id/ingest_warning_overlay_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dip"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+ </LinearLayout>
+</merge>
+
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
+import android.widget.TextView;
import com.android.gallery3d.R;
import com.android.gallery3d.ingest.adapter.MtpAdapter;
private ProgressDialog mProgressDialog;
private ActionMode mActiveActionMode;
+ private View mWarningOverlay;
+ private TextView mWarningOverlayText;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DateTileView.refreshLocale();
mActive = true;
if (mHelperService != null) mHelperService.setClientActivity(this);
+ updateWarningOverlay();
super.onResume();
}
super.onPause();
}
- protected void notifyIndexChanged() {
+ private void showWarningOverlay(int textResId) {
+ if (mWarningOverlay == null) {
+ mWarningOverlay = findViewById(R.id.ingest_warning_overlay);
+ mWarningOverlayText =
+ (TextView)mWarningOverlay.findViewById(R.id.ingest_warning_overlay_text);
+ }
+ mWarningOverlayText.setText(textResId);
+ mWarningOverlay.setVisibility(View.VISIBLE);
+ mGridView.setVisibility(View.GONE);
+ }
+
+ private void hideWarningOverlay() {
+ if (mWarningOverlay != null) {
+ mWarningOverlay.setVisibility(View.GONE);
+ mGridView.setVisibility(View.VISIBLE);
+ }
+ }
+
+ private void updateWarningOverlay() {
+ if (!mAdapter.deviceConnected()) {
+ showWarningOverlay(R.string.ingest_no_device);
+ } else if (mAdapter.indexReady() && mAdapter.getCount() == 0) {
+ showWarningOverlay(R.string.ingest_empty_device);
+ } else {
+ hideWarningOverlay();
+ }
+ }
+
+ private void UiThreadNotifyIndexChanged() {
mAdapter.notifyDataSetChanged();
if (mActiveActionMode != null) {
mActiveActionMode.finish();
mActiveActionMode = null;
}
+ updateWarningOverlay();
+ }
+
+ protected void notifyIndexChanged() {
+ mHandler.sendEmptyMessage(ItemListHandler.MSG_NOTIFY_CHANGED);
}
private static class ProgressState {
public void onIndexFinish() {
// Not guaranteed to be called on the UI thread
mHandler.sendEmptyMessage(ItemListHandler.MSG_PROGRESS_HIDE);
- mHandler.sendEmptyMessage(ItemListHandler.MSG_ADAPTER_NOTIFY_CHANGED);
+ mHandler.sendEmptyMessage(ItemListHandler.MSG_NOTIFY_CHANGED);
}
@Override
private static class ItemListHandler extends Handler {
public static final int MSG_PROGRESS_UPDATE = 0;
public static final int MSG_PROGRESS_HIDE = 1;
- public static final int MSG_ADAPTER_NOTIFY_CHANGED = 2;
+ public static final int MSG_NOTIFY_CHANGED = 2;
WeakReference<IngestActivity> mParentReference;
case MSG_PROGRESS_UPDATE:
parent.updateProgressDialog();
break;
- case MSG_ADAPTER_NOTIFY_CHANGED:
- parent.notifyIndexChanged();
+ case MSG_NOTIFY_CHANGED:
+ parent.UiThreadNotifyIndexChanged();
break;
default:
break;