Android Open Source - android_Findex Directory Manager






From Project

Back to project page android_Findex.

License

The source code is released under:

Apache License

If you think the Android project android_Findex listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lithidsw.findex.ef;
/*w  w w .  j  av  a  2s  . c  om*/
import android.app.ActionBar;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;

import com.lithidsw.findex.R;
import com.lithidsw.findex.info.DirPickerInfo;
import com.lithidsw.findex.utils.C;

import java.util.ArrayList;

public class DirectoryManager extends Activity {

    private SharedPreferences mPrefs;

    private GridView mGridView;
    private DirectoryAdapter mAdapter;
    private TextView mTextView;

    ArrayList<DirPickerInfo> mDirs = new ArrayList<DirPickerInfo>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPrefs = getSharedPreferences(C.PREF, MODE_PRIVATE);
        setTheme(getResources().getIdentifier(
                mPrefs.getString(C.PREF_THEME, C.DEFAULT_THEME),
                "style",
                C.THIS)
        );
        setContentView(R.layout.directory_manage);
        mTextView = (TextView) findViewById(R.id.no_content_list);
        mGridView = (GridView) findViewById(R.id.dir_list);
        if (mPrefs.getBoolean(C.PREF_TOGGLE_GRID, false)) {
            mGridView.setNumColumns(getResources().getInteger(R.integer.grid_items));
        } else {
            mGridView.setNumColumns(1);
        }
        mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                removeDir(mDirs.get(i).dir);
            }
        });
        mAdapter = new DirectoryAdapter(this, mDirs);
        mGridView.setAdapter(mAdapter);

        setupDirs();
        setupActionBar();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    private void setupActionBar() {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setHomeButtonEnabled(true);
        }
    }

    private void update() {
        mAdapter.notifyDataSetChanged();

        if (mDirs.size() > 0) {
            mGridView.setVisibility(View.VISIBLE);
            mTextView.setVisibility(View.GONE);
        } else {
            mGridView.setVisibility(View.GONE);
            mTextView.setVisibility(View.VISIBLE);
        }
    }

    private void setupDirs() {
        String[] folders = mPrefs.getString(C.PREF_EXCLUDE_FOLDERS, "").split("::");
        mDirs.clear();
        for (String string : folders) {
            if (string.length() > 0) {
                DirPickerInfo info = new DirPickerInfo();
                info.dir = string;
                info.name = string;
                mDirs.add(info);
            }
        }

        update();
    }

    private void removeDir(String dir) {
        String[] folders = mPrefs.getString(C.PREF_EXCLUDE_FOLDERS, "").split("::");
        String directories = "";
        for (String string : folders) {
            if (string.length() > 0) {
                if (!string.equals(dir)) {
                    directories = string + "::";
                }
            }
        }

        mPrefs.edit().putString(C.PREF_EXCLUDE_FOLDERS, directories).commit();
        setupDirs();
    }
}




Java Source Code List

com.lithidsw.findex.AddTagActivity.java
com.lithidsw.findex.FileInfoActivity.java
com.lithidsw.findex.IntroActivity.java
com.lithidsw.findex.IntroFragment.java
com.lithidsw.findex.MainActivity.java
com.lithidsw.findex.MainFragment.java
com.lithidsw.findex.SettingsActivity.java
com.lithidsw.findex.adapter.DrawerListAdapter.java
com.lithidsw.findex.adapter.FilePageAdapter.java
com.lithidsw.findex.adapter.InfoTagListAdapter.java
com.lithidsw.findex.adapter.StorageListAdapter.java
com.lithidsw.findex.adapter.WidgetListAdapter.java
com.lithidsw.findex.db.DBHelper.java
com.lithidsw.findex.db.DBUtils.java
com.lithidsw.findex.ef.DirectoryAdapter.java
com.lithidsw.findex.ef.DirectoryListActivity.java
com.lithidsw.findex.ef.DirectoryManager.java
com.lithidsw.findex.info.DirPickerInfo.java
com.lithidsw.findex.info.FileInfo.java
com.lithidsw.findex.loader.ImageLoader.java
com.lithidsw.findex.loader.MemoryCache.java
com.lithidsw.findex.receiver.ActionReceiver.java
com.lithidsw.findex.service.IndexService.java
com.lithidsw.findex.utils.C.java
com.lithidsw.findex.utils.DateBuilder.java
com.lithidsw.findex.utils.FileStartActivity.java
com.lithidsw.findex.utils.FileUtils.java
com.lithidsw.findex.utils.FileWalker.java
com.lithidsw.findex.utils.ItemCountLoader.java
com.lithidsw.findex.utils.MrToast.java
com.lithidsw.findex.utils.StorageOptions.java
com.lithidsw.findex.widget.WidgetConfigActivity.java
com.lithidsw.findex.widget.WidgetInfo.java
com.lithidsw.findex.widget.WidgetLoadStub.java
com.lithidsw.findex.widget.WidgetProvider.java
com.lithidsw.findex.widget.WidgetService.java
com.lithidsw.findex.widget.WidgetUtils.java
com.lithidsw.findex.widget.WidgetViews.java