Skip to content

Commit

Permalink
Demo: add no filter option too
Browse files Browse the repository at this point in the history
  • Loading branch information
codekidX committed Jul 27, 2017
1 parent 7c07550 commit 3ab7c60
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Spinner;
import android.widget.Toast;

import com.codekidlabs.storagechooser.Content;
Expand Down Expand Up @@ -120,6 +123,41 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
});


Spinner spinner = (Spinner) findViewById(R.id.filter_spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.filter_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
switch (i) {
case 0:
builder.filter(null);
break;
case 1:
builder.filter(StorageChooser.FileType.VIDEO);
break;
case 2:
builder.filter(StorageChooser.FileType.AUDIO);
break;
case 3:
builder.filter(StorageChooser.FileType.DOCS);
break;
case 4:
builder.filter(StorageChooser.FileType.IMAGES);
break;
}
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});


// ----------------- Localization -------------------
Content c = new Content();
c.setCreateLabel("Create");
Expand Down Expand Up @@ -154,9 +192,7 @@ public void onCancel() {
chooser.setOnMultipleSelectListener(new StorageChooser.OnMultipleSelectListener() {
@Override
public void onDone(ArrayList<String> selectedFilePaths) {
for(String s: selectedFilePaths) {
Log.e(TAG, s);
}

}
});

Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@
android:layout_marginTop="8dp"
android:text="setTheme" />

<Spinner
android:id="@+id/filter_spinner"
android:tooltipText="Filter Folders"
android:layout_gravity="start"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

</ScrollView>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
<string name="action_settings">Settings</string>
<string name="report_and_help"><![CDATA[REPORT & HELP]]></string>
<string name="text_freespace">%1$s free</string>

<string-array name="filter_array">
<item>None</item>
<item>Video</item>
<item>Audio</item>
<item>Documents</item>
<item>Images</item>
</string-array>
</resources>

0 comments on commit 3ab7c60

Please sign in to comment.