Android Open Source - texthem File Array Adapter






From Project

Back to project page texthem.

License

The source code is released under:

GNU General Public License

If you think the Android project texthem 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 filechooser;
//from   w w w  .ja  v  a  2 s  . com
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import a2.marketingsms.R;

public class FileArrayAdapter extends ArrayAdapter<Option> {

    private Context ctx;
    private List<Option> options;
    private int resId;

    public FileArrayAdapter(Context context, int textViewResourceId,
                            List<Option> objects) {
        super(context, textViewResourceId, objects);
        ctx = context;
        resId = textViewResourceId;
        options = objects;
    }

    public Option getOption(int i) {
        return options.get(i);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater) ctx
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(resId, null);
        }
        final Option o = options.get(position);
        if (o != null) {
            ImageView im = (ImageView) v.findViewById(R.id.img1);
            TextView t1 = (TextView) v.findViewById(R.id.TextView01);
            TextView t2 = (TextView) v.findViewById(R.id.TextView02);

            if (o.getData().equalsIgnoreCase(ctx.getString(R.string.folder))) {
                im.setImageResource(R.drawable.folder);
            } else if (position == 0 && o.getData().equalsIgnoreCase(ctx.getString(R.string.parentDirectory))) {
                im.setImageResource(R.drawable.back);
            } else {
                String name = o.getName().toLowerCase();
                if (name.endsWith(".xls") || name.endsWith(".xlsx"))
                    im.setImageResource(R.drawable.xls);
                else if (name.endsWith(".doc") || name.endsWith(".docx"))
                    im.setImageResource(R.drawable.doc);
                else if (name.endsWith(".ppt") || o.getName().endsWith(".pptx"))
                    im.setImageResource(R.drawable.ppt);
                else if (name.endsWith(".zip"))
                    im.setImageResource(R.drawable.zip);
                else if (name.endsWith(".pdf"))
                    im.setImageResource(R.drawable.pdf);
                else if (name.endsWith(".txt"))
                    im.setImageResource(R.drawable.txt);
                else if (name.endsWith(".jpg") || name.endsWith(".jpeg"))
                    im.setImageResource(R.drawable.jpg);
                else if (name.endsWith(".csv"))
                    im.setImageResource(R.drawable.csv);
                else if (name.endsWith(".png"))
                    im.setImageResource(R.drawable.png);
                else if (name.endsWith(".apk"))
                    im.setImageResource(R.drawable.apk);
                else if (name.endsWith(".rtf"))
                    im.setImageResource(R.drawable.rtf);
                else if (name.endsWith(".gif"))
                    im.setImageResource(R.drawable.gif);
                else
                    im.setImageResource(R.drawable.document);
            }

            if (t1 != null)
                t1.setText(o.getName());
            if (t2 != null)
                t2.setText(o.getData());

        }
        return v;
    }

}




Java Source Code List

a2.marketingsms.ApplicationTest.java
a2.marketingsms.SelectList.java
a2.marketingsms.Texthem.java
a2.marketingsms.components.ContactImporter.java
a2.marketingsms.components.DialogHandler.java
a2.marketingsms.components.MyProgressDialog.java
a2.marketingsms.components.SMSSender.java
a2.marketingsms.model.Contact.java
a2.marketingsms.model.TemplateText.java
au.com.bytecode.opencsv.CSVIterator.java
au.com.bytecode.opencsv.CSVParserBuilder.java
au.com.bytecode.opencsv.CSVParser.java
au.com.bytecode.opencsv.CSVReaderBuilder.java
au.com.bytecode.opencsv.CSVReader.java
au.com.bytecode.opencsv.CSVWriter.java
au.com.bytecode.opencsv.ResultSetHelperService.java
au.com.bytecode.opencsv.ResultSetHelper.java
com.danielme.blog.demo.listviewcheckbox.CustomArrayAdapter.java
com.danielme.blog.demo.listviewcheckbox.DontPressWhenPressParentCheckBox.java
com.danielme.blog.demo.listviewcheckbox.Row.java
filechooser.FileArrayAdapter.java
filechooser.FileChooser.java
filechooser.Option.java
org.mozilla.universalchardet.CharsetListener.java
org.mozilla.universalchardet.Constants.java
org.mozilla.universalchardet.UniversalDetector.java
org.mozilla.universalchardet.prober.Big5Prober.java
org.mozilla.universalchardet.prober.CharsetProber.java
org.mozilla.universalchardet.prober.EUCJPProber.java
org.mozilla.universalchardet.prober.EUCKRProber.java
org.mozilla.universalchardet.prober.EUCTWProber.java
org.mozilla.universalchardet.prober.EscCharsetProber.java
org.mozilla.universalchardet.prober.GB18030Prober.java
org.mozilla.universalchardet.prober.HebrewProber.java
org.mozilla.universalchardet.prober.Latin1Prober.java
org.mozilla.universalchardet.prober.MBCSGroupProber.java
org.mozilla.universalchardet.prober.SBCSGroupProber.java
org.mozilla.universalchardet.prober.SJISProber.java
org.mozilla.universalchardet.prober.SingleByteCharsetProber.java
org.mozilla.universalchardet.prober.UTF8Prober.java
org.mozilla.universalchardet.prober.contextanalysis.EUCJPContextAnalysis.java
org.mozilla.universalchardet.prober.contextanalysis.JapaneseContextAnalysis.java
org.mozilla.universalchardet.prober.contextanalysis.SJISContextAnalysis.java
org.mozilla.universalchardet.prober.distributionanalysis.Big5DistributionAnalysis.java
org.mozilla.universalchardet.prober.distributionanalysis.CharDistributionAnalysis.java
org.mozilla.universalchardet.prober.distributionanalysis.EUCJPDistributionAnalysis.java
org.mozilla.universalchardet.prober.distributionanalysis.EUCKRDistributionAnalysis.java
org.mozilla.universalchardet.prober.distributionanalysis.EUCTWDistributionAnalysis.java
org.mozilla.universalchardet.prober.distributionanalysis.GB2312DistributionAnalysis.java
org.mozilla.universalchardet.prober.distributionanalysis.JISDistributionAnalysis.java
org.mozilla.universalchardet.prober.distributionanalysis.SJISDistributionAnalysis.java
org.mozilla.universalchardet.prober.sequence.BulgarianModel.java
org.mozilla.universalchardet.prober.sequence.CyrillicModel.java
org.mozilla.universalchardet.prober.sequence.GreekModel.java
org.mozilla.universalchardet.prober.sequence.HebrewModel.java
org.mozilla.universalchardet.prober.sequence.Ibm855Model.java
org.mozilla.universalchardet.prober.sequence.Ibm866Model.java
org.mozilla.universalchardet.prober.sequence.Koi8rModel.java
org.mozilla.universalchardet.prober.sequence.Latin5BulgarianModel.java
org.mozilla.universalchardet.prober.sequence.Latin5Model.java
org.mozilla.universalchardet.prober.sequence.Latin7Model.java
org.mozilla.universalchardet.prober.sequence.MacCyrillicModel.java
org.mozilla.universalchardet.prober.sequence.SequenceModel.java
org.mozilla.universalchardet.prober.sequence.Win1251BulgarianModel.java
org.mozilla.universalchardet.prober.sequence.Win1251Model.java
org.mozilla.universalchardet.prober.sequence.Win1253Model.java
org.mozilla.universalchardet.prober.statemachine.Big5SMModel.java
org.mozilla.universalchardet.prober.statemachine.CodingStateMachine.java
org.mozilla.universalchardet.prober.statemachine.EUCJPSMModel.java
org.mozilla.universalchardet.prober.statemachine.EUCKRSMModel.java
org.mozilla.universalchardet.prober.statemachine.EUCTWSMModel.java
org.mozilla.universalchardet.prober.statemachine.GB18030SMModel.java
org.mozilla.universalchardet.prober.statemachine.HZSMModel.java
org.mozilla.universalchardet.prober.statemachine.ISO2022CNSMModel.java
org.mozilla.universalchardet.prober.statemachine.ISO2022JPSMModel.java
org.mozilla.universalchardet.prober.statemachine.ISO2022KRSMModel.java
org.mozilla.universalchardet.prober.statemachine.PkgInt.java
org.mozilla.universalchardet.prober.statemachine.SJISSMModel.java
org.mozilla.universalchardet.prober.statemachine.SMModel.java
org.mozilla.universalchardet.prober.statemachine.UCS2BESMModel.java
org.mozilla.universalchardet.prober.statemachine.UTF8SMModel.java