-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added abstract adapter class and implemented a simple adapter using it.
- Loading branch information
Showing
22 changed files
with
327 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
library/src/main/java/com/psaravan/filebrowserview/lib/Utils/Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2014 Saravan Pantham | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.psaravan.filebrowserview.lib.Utils; | ||
|
||
import android.content.Context; | ||
import android.content.res.Resources; | ||
import android.util.DisplayMetrics; | ||
|
||
/** | ||
* Helper class with a set of commonly used helper methods. | ||
* | ||
* @author Saravan Pantham | ||
*/ | ||
public class Utils { | ||
|
||
/** | ||
* Converts the input dp unit to pixels, depending on device density. | ||
* | ||
* @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels | ||
* @param context Context to get resources and device specific display metrics | ||
* @return A floating point value to represent px equivalent to dp depending on device density. | ||
*/ | ||
public static float convertDpToPixels(float dp, Context context){ | ||
Resources resources = context.getResources(); | ||
DisplayMetrics metrics = resources.getDisplayMetrics(); | ||
float px = dp * (metrics.densityDpi / 160f); | ||
return px; | ||
} | ||
|
||
} |
108 changes: 108 additions & 0 deletions
108
library/src/main/java/com/psaravan/filebrowserview/lib/View/AbstractAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright (C) 2014 Saravan Pantham | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.psaravan.filebrowserview.lib.View; | ||
|
||
import android.content.Context; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
|
||
import com.psaravan.filebrowserview.lib.FileBrowserEngine.AdapterData; | ||
|
||
import java.util.ArrayList; | ||
|
||
/** | ||
* Extend this abstract class if you want to create your own adapter for the ListView/GridView. | ||
* | ||
* @author Saravan Pantham | ||
*/ | ||
public abstract class AbstractAdapter extends ArrayAdapter<String> { | ||
|
||
private Context mContext; | ||
private AdapterData mAdapterData; | ||
|
||
public AbstractAdapter(Context context, int layoutResourceId, AdapterData adapterData) { | ||
super(context, layoutResourceId); | ||
mContext = context; | ||
mAdapterData = adapterData; | ||
} | ||
|
||
/** | ||
* Get a View that displays the data at the specified position in the data set. You can either | ||
* create a View manually or inflate it from an XML layout file. When the View is inflated, the | ||
* parent View (GridView, ListView...) will apply default layout parameters unless you use | ||
* {@link android.view.LayoutInflater#inflate(int, android.view.ViewGroup, boolean)} | ||
* to specify a root view and to prevent attachment to the root. | ||
* | ||
* @param position The position of the item within the adapter's data set of the item whose view | ||
* we want. | ||
* @param convertView The old view to reuse, if possible. Note: You should check that this view | ||
* is non-null and of an appropriate type before using. If it is not possible to convert | ||
* this view to display the correct data, this method can create a new view. | ||
* Heterogeneous lists can specify their number of view types, so that this View is | ||
* always of the right type (see {@link #getViewTypeCount()} and | ||
* {@link #getItemViewType(int)}). | ||
* @param parent The parent that this view will eventually be attached to | ||
* @return A View corresponding to the data at the specified position. | ||
*/ | ||
@Override | ||
public abstract View getView(int position, View convertView, ViewGroup parent); | ||
|
||
/** | ||
* @return The list of file/subfolder names within the current directory. | ||
*/ | ||
public ArrayList<String> getNamesList() { | ||
if (mAdapterData!=null) | ||
return mAdapterData.getNamesList(); | ||
else | ||
return new ArrayList<String>(); | ||
|
||
} | ||
|
||
/** | ||
* @return The list of file/subfolder types within the current directory. | ||
*/ | ||
public ArrayList<Integer> getTypesList() { | ||
if (mAdapterData!=null) | ||
return mAdapterData.getTypesList(); | ||
else | ||
return new ArrayList<Integer>(); | ||
|
||
} | ||
|
||
/** | ||
* @return The list of file/subfolder paths within the current directory. | ||
*/ | ||
public ArrayList<String> getPathsList() { | ||
if (mAdapterData!=null) | ||
return mAdapterData.getPathsList(); | ||
else | ||
return new ArrayList<String>(); | ||
|
||
} | ||
|
||
/** | ||
* @return The list of file/subfolder sizes within the current directory. | ||
*/ | ||
public ArrayList<String> getSizesList() { | ||
if (mAdapterData!=null) | ||
return mAdapterData.getSizesList(); | ||
else | ||
return new ArrayList<String>(); | ||
|
||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+835 Bytes
library/src/main/res/drawable-mdpi/ic_action_overflow_universal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+801 Bytes
library/src/main/res/drawable-xhdpi/ic_action_overflow_universal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+575 Bytes
library/src/main/res/drawable-xxhdpi/ic_action_overflow_universal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" > | ||
<solid android:color="#11AAAAAA"/> | ||
</shape> |
12 changes: 12 additions & 0 deletions
12
library/src/main/res/drawable/empty_color_patch_circular.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval"> | ||
|
||
<solid | ||
android:color="#11AAAAAA"/> | ||
|
||
<size | ||
android:width="80dp" | ||
android:height="80dp"/> | ||
</shape> |
12 changes: 12 additions & 0 deletions
12
library/src/main/res/drawable/empty_color_patch_circular_light.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval"> | ||
|
||
<solid | ||
android:color="#33323232"/> | ||
|
||
<size | ||
android:width="80dp" | ||
android:height="80dp"/> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" > | ||
<solid android:color="#33323232"/> | ||
</shape> |
Oops, something went wrong.