Search in sources :

Example 1 with ExplorerItem

use of im.actor.sdk.controllers.pickers.file.items.ExplorerItem in project actor-platform by actorapp.

the class ExplorerAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    //Timer.start();
    View itemView;
    ExploreItemViewHolder holder;
    if (convertView == null) {
        convertView = View.inflate(context, R.layout.picker_item_file, null);
        holder = new ExploreItemViewHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ExploreItemViewHolder) convertView.getTag();
    }
    itemView = convertView;
    ExplorerItem item = getItem(position);
    item.bindImage(holder);
    item.bindData(holder);
    if (getCount() == 1) {
        holder.disableDivider();
    }
    //Timer.stop("Item created");
    return itemView;
}
Also used : ExplorerItem(im.actor.sdk.controllers.pickers.file.items.ExplorerItem) View(android.view.View)

Example 2 with ExplorerItem

use of im.actor.sdk.controllers.pickers.file.items.ExplorerItem in project actor-platform by actorapp.

the class ExplorerFragment method loadHistory.

private ArrayList<ExplorerItem> loadHistory() {
    ArrayList<ExplorerItem> history = new ArrayList<ExplorerItem>();
    ArrayList<String> pathesFromDB = HistoryDatabase.getHistory(pickerActivity);
    if (!pathesFromDB.isEmpty()) {
        history.add(new HeaderItem(getString(R.string.picker_file_header_recent)));
        for (String pathFromDB : pathesFromDB) {
            File historyFile = new File(pathFromDB);
            if (historyFile.exists())
                history.add(getFileItem(historyFile));
        }
    }
    return history;
}
Also used : ExplorerItem(im.actor.sdk.controllers.pickers.file.items.ExplorerItem) ArrayList(java.util.ArrayList) HeaderItem(im.actor.sdk.controllers.pickers.file.items.HeaderItem) File(java.io.File)

Example 3 with ExplorerItem

use of im.actor.sdk.controllers.pickers.file.items.ExplorerItem in project actor-platform by actorapp.

the class FilePickerActivity method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View itemView, int position, long id) {
    ExplorerItem item = (ExplorerItem) parent.getItemAtPosition(position);
    if (item instanceof BackItem) {
        onBackPressed();
        return;
    }
    if (item.isDirectory()) {
        String path = item.getPath();
        Bundle bundle = new Bundle();
        bundle.putString("path", path);
        Fragment fragment = new ExplorerFragment();
        fragment.setArguments(bundle);
        getFragmentManager().beginTransaction().setCustomAnimations(R.animator.picker_fragment_explorer_enter, R.animator.picker_fragment_explorer_exit, R.animator.picker_fragment_explorer_return, R.animator.picker_fragment_explorer_out).replace(R.id.container, fragment).addToBackStack(path).commit();
    } else {
        selectItem(item, itemView);
        returnResult();
    }
}
Also used : ExplorerItem(im.actor.sdk.controllers.pickers.file.items.ExplorerItem) Bundle(android.os.Bundle) BackItem(im.actor.sdk.controllers.pickers.file.items.BackItem) Fragment(android.app.Fragment)

Example 4 with ExplorerItem

use of im.actor.sdk.controllers.pickers.file.items.ExplorerItem in project actor-platform by actorapp.

the class WelcomeExplorerAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View itemView;
    ExplorerItem item = getItem(position);
    if (item instanceof HeaderItem) {
        itemView = View.inflate(context, R.layout.picker_item_header, null);
        itemView.setTag("header");
        item.bindData(itemView);
        return itemView;
    } else {
        if (convertView != null && !convertView.getTag().equals("header"))
            return super.getView(position, convertView, parent);
        else
            return super.getView(position, null, parent);
    }
}
Also used : ExplorerItem(im.actor.sdk.controllers.pickers.file.items.ExplorerItem) HeaderItem(im.actor.sdk.controllers.pickers.file.items.HeaderItem) View(android.view.View)

Example 5 with ExplorerItem

use of im.actor.sdk.controllers.pickers.file.items.ExplorerItem in project actor-platform by actorapp.

the class SearchTask method doInBackground.

@Override
protected final ArrayList<ExplorerItem> doInBackground(Void... voids) {
    handler.post(new Runnable() {

        @Override
        public void run() {
        //onPreStart();
        }
    });
    handler.post(new Runnable() {

        @Override
        public void run() {
        //onSearchStarted();
        }
    });
    Log.i("Searching", "Search started. Root path: " + root);
    for (File file : index) {
        compare(file);
        if (isCancelled()) {
            Log.i("Searching", "Canceled");
            return null;
        }
    }
    resort();
    Log.i("Searching", "Search ended. " + foundItems.size() + " items found");
    ArrayList<ExplorerItem> items = new ArrayList<ExplorerItem>();
    for (File file : foundItems) {
        ExplorerItem item;
        if (file.isDirectory()) {
            item = Converter.getFolderItem(file);
        } else {
            item = Converter.getFileItem(file, false);
        }
        if (item != null)
            items.add(item);
    }
    // Collections.sort(items, new CancelableComparator(query));
    return items;
}
Also used : ExplorerItem(im.actor.sdk.controllers.pickers.file.items.ExplorerItem) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

ExplorerItem (im.actor.sdk.controllers.pickers.file.items.ExplorerItem)5 View (android.view.View)2 HeaderItem (im.actor.sdk.controllers.pickers.file.items.HeaderItem)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Fragment (android.app.Fragment)1 Bundle (android.os.Bundle)1 BackItem (im.actor.sdk.controllers.pickers.file.items.BackItem)1