Android Open Source - Multi-Mania-app About Fragment






From Project

Back to project page Multi-Mania-app.

License

The source code is released under:

MIT License

If you think the Android project Multi-Mania-app 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 be.ana.nmct.multimania.ui;
//from www. j  a  v a  2 s  . c  om
import android.app.Fragment;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bulletnoid.android.widget.StaggeredGridView.BulletStaggeredGridView;

import be.ana.nmct.multimania.R;
import be.ana.nmct.multimania.utils.Utility;

/*
* This fragment show details about the event
* info about location, sponsors, what it is
* */
public class AboutFragment extends Fragment {

    private AboutAdapter mAdapter;
    private static final Integer[] mSponsors = new Integer[]{
            R.drawable.adobe,
            R.drawable.chili_publish,
            R.drawable.adobe_user_group,
            R.drawable.richting_morgen,
            R.drawable.signpost,
            R.drawable.wacom,
            R.drawable.kortrijk_xpo,
            R.drawable.design_express,
            R.drawable.howest,
            R.drawable.wetenschap_maakt_knap,
            R.drawable.combell,
            R.drawable.microsoft,

    };
    private BulletStaggeredGridView mGrid;

    public AboutFragment() { }

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        mAdapter = new AboutAdapter();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_about, container, false);

        mGrid = (BulletStaggeredGridView)v.findViewById(R.id.about_grid);
        mGrid.setAdapter(mAdapter);
        mGrid.setItemMargin(Utility.dpToPx(getActivity(), 8));

        return v;
    }

    private class AboutAdapter extends BaseAdapter{

        private final LayoutInflater mInflater;

        public AboutAdapter(){
            mInflater = LayoutInflater.from(getActivity());
        }

        @Override
        public int getCount() {
            return 2+mSponsors.length;
        }

        @Override
        public Object getItem(int position) {
            return position;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public int getViewTypeCount() {
            return 3;
        }

        @Override
        public int getItemViewType(int position) {
            switch(position){
                case 0:
                    return 0;
                case 1:
                    return 1;
                default:
                    return 2;
            }
        }

        @Override
        public View getView(int position, View v, ViewGroup parent) {

            final int viewType = getItemViewType(position);
            if(v == null||v.getId()!=viewType) {
                v = createView( v,parent,viewType);
            }

            bindView(position, v);

            return v;
        }

        private void bindView(int position, View v) {


            switch(position){
                //TODO: case 0 can be removed
                case 0:
                    ViewHolder viewholder = (ViewHolder) v.getTag();
                    viewholder.txtTitleEvent.setText(R.string.about_title);
                    viewholder.txtInfoEvent.setText(R.string.about_info);
                    Drawable drawable = getResources().getDrawable(R.drawable.ic_multimania);
                    viewholder.imgAbout.setImageDrawable(drawable);
                    break;
                case 1:
                    viewholder = (ViewHolder) v.getTag();
                //TODO: everything except the clicklistener can be removed
                    viewholder.txtVenue.setText(R.string.name_venue);
                    viewholder.txtStreet.setText(R.string.street);
                    viewholder.txtCity.setText(R.string.city);
                    viewholder.txtCountry.setText(R.string.country);
                    viewholder.imgMaps.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            String longitude = "3.277815";
                            String lat = "50.807796";
                            String uri = "http://maps.google.com/maps?q=loc:" + lat + "," + longitude;
                            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                            startActivity(intent);
                        }
                    });
                    break;
                default:
                    int imgResource =getSponsorImage(position-2);
                    ImageView img =   ((SponsorViewHolder) v.getTag()).imgSponsor;
                    img.setImageResource(imgResource);
            }
        }

        private View createView(View v,ViewGroup parent,int viewType) {
            ViewHolder holder = new ViewHolder();
            switch(viewType){
                case 0:
                    v = mInflater.inflate(R.layout.row_about_intro, parent,false);
                    holder.txtTitleEvent = (TextView) v.findViewById(R.id.txtAboutTitle);
                    holder.txtInfoEvent = (TextView) v.findViewById(R.id.txtAboutInfo);
                    holder.imgAbout = (ImageView) v.findViewById(R.id.imgAbout);
                    v.setId(viewType);
                    break;
                case 1:
                    v = mInflater.inflate(R.layout.row_about_location, parent,false);
                    holder.txtVenue = (TextView) v.findViewById(R.id.txtNameVenue);
                    holder.txtStreet = (TextView) v.findViewById(R.id.txtStreet);
                    holder.txtCity = (TextView) v.findViewById(R.id.txtCity);
                    holder.txtCountry = (TextView) v.findViewById(R.id.txtCountry);
                    holder.imgMaps = (ImageView) v.findViewById(R.id.imgAboutMap);
                    v.setId(viewType);
                    break;
                case 2:
                    v = mInflater.inflate(R.layout.row_about_sponsor, parent,false);
                    v.setTag(new SponsorViewHolder(v));
                    v.setId(viewType);
                    return v;
            }

            v.setTag(holder);
            return v;
        }
    }

    private int getSponsorImage(int i) {
        return mSponsors[i];
    }

    private static class ViewHolder{
        public ImageView imgAbout;
        public TextView txtTitleEvent;
        public TextView txtInfoEvent;
        public TextView txtVenue;
        public TextView txtStreet;
        public TextView txtCity;
        public TextView txtCountry;
        public ImageView imgMaps;
    }

    private static class SponsorViewHolder {
        public final ImageView imgSponsor;

        public SponsorViewHolder(View v) {
            imgSponsor = (ImageView) v.findViewById(R.id.imgSponsor);
        }
    }
}




Java Source Code List

be.ana.nmct.multimania.ApiTest.java
be.ana.nmct.multimania.ApplicationTest.java
be.ana.nmct.multimania.CalendarTest.java
be.ana.nmct.multimania.DbTest.java
be.ana.nmct.multimania.Import.java
be.ana.nmct.multimania.NotificationImport.java
be.ana.nmct.multimania.ProviderTest.java
be.ana.nmct.multimania.SyncTest.java
be.ana.nmct.multimania.data.ApiActions.java
be.ana.nmct.multimania.data.DbHelper.java
be.ana.nmct.multimania.data.GsonLoader.java
be.ana.nmct.multimania.data.MultimaniaContract.java
be.ana.nmct.multimania.data.MultimaniaProvider.java
be.ana.nmct.multimania.data.NewsItemLoader.java
be.ana.nmct.multimania.data.RoomLoader.java
be.ana.nmct.multimania.data.TagLoader.java
be.ana.nmct.multimania.data.TalkLoader.java
be.ana.nmct.multimania.model.IData.java
be.ana.nmct.multimania.model.NewsItem.java
be.ana.nmct.multimania.model.Room.java
be.ana.nmct.multimania.model.Speaker.java
be.ana.nmct.multimania.model.Tag.java
be.ana.nmct.multimania.model.TalkSpeaker.java
be.ana.nmct.multimania.model.TalkTag.java
be.ana.nmct.multimania.model.Talk.java
be.ana.nmct.multimania.model.User.java
be.ana.nmct.multimania.service.AuthenticatorService.java
be.ana.nmct.multimania.service.Authenticator.java
be.ana.nmct.multimania.service.BootListener.java
be.ana.nmct.multimania.service.NotificationReceiver.java
be.ana.nmct.multimania.service.NotificationSender.java
be.ana.nmct.multimania.service.SyncAdapter.java
be.ana.nmct.multimania.service.SyncService.java
be.ana.nmct.multimania.ui.AboutFragment.java
be.ana.nmct.multimania.ui.LoadActivity.java
be.ana.nmct.multimania.ui.MainActivity.java
be.ana.nmct.multimania.ui.MapFragment.java
be.ana.nmct.multimania.ui.MyScheduleFragment.java
be.ana.nmct.multimania.ui.MySchedulesFragment.java
be.ana.nmct.multimania.ui.NavigationDrawerFragment.java
be.ana.nmct.multimania.ui.NewsFragment.java
be.ana.nmct.multimania.ui.NewsItemActivity.java
be.ana.nmct.multimania.ui.NewsItemFragment.java
be.ana.nmct.multimania.ui.ScheduleFragment.java
be.ana.nmct.multimania.ui.SchedulesFragment.java
be.ana.nmct.multimania.ui.SettingsFragment.java
be.ana.nmct.multimania.ui.SuggestionFragment.java
be.ana.nmct.multimania.ui.TalkActivity.java
be.ana.nmct.multimania.ui.TalkFragment.java
be.ana.nmct.multimania.utils.GoogleCalUtil.java
be.ana.nmct.multimania.utils.SettingsHelper.java
be.ana.nmct.multimania.utils.SettingsUtil.java
be.ana.nmct.multimania.utils.SyncUtils.java
be.ana.nmct.multimania.utils.Utility.java
be.ana.nmct.multimania.vm.NavigationItem.java
be.ana.nmct.multimania.vm.ScheduleTalkVm.java
be.ana.nmct.multimania.widget.StaggeredGridView.java
com.bulletnoid.android.widget.StaggeredGridView.BulletStaggeredGridView.java
com.bulletnoid.android.widget.StaggeredGridView.HeaderFooterListAdapter.java
com.bulletnoid.android.widget.StaggeredGridView.ScrollerCompatIcs.java
com.bulletnoid.android.widget.StaggeredGridView.ScrollerCompat.java