Android Open Source - interamap Category Screen






From Project

Back to project page interamap.

License

The source code is released under:

MIT License

If you think the Android project interamap 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.richso.interamap;
//w ww  . j a va2 s.  com
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.richso.interamap.adapter.CategoryAdapter;
import com.richso.interamap.item.ItemCategory;
import com.richso.interamap.utils.Constant;
import com.richso.interamap.utils.Device;
import com.richso.interamap.utils.L;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: nikolai
 * Date: 9/15/13
 * Time: 1:20 PM
 * To change this template use File | Settings | File Templates.
 */
public class CategoryScreen extends Activity {

    private GridView gridView;
    private CategoryAdapter categoryAdapter;
    private Device device;
    private String screenTitle = "";
    private TextView categoryTitle;

    {
        L.setTag(this.getClass().getName());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_category);
        Bundle bundle = getIntent().getExtras();
        screenTitle = bundle.getString(Constant.Extra.categoryTitle);
        init();
    }

    private void init() {
        device = new Device(this);
        categoryTitle = (TextView)findViewById(R.id.categoryTitle);
        categoryTitle.setText(screenTitle);
        gridView = (GridView)findViewById(R.id.categoryGridView);
        determineOrientation();
        categoryAdapter = new CategoryAdapter(this, R.layout.item_category_gridview, fillCategoryAdapter());
        gridView.setAdapter(categoryAdapter);
    }

    private ArrayList<ItemCategory> fillCategoryAdapter() {
        ArrayList<ItemCategory> arrayList = new ArrayList<ItemCategory>();
        Bitmap icon = BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher);
        arrayList.add(new ItemCategory(icon, "Nesvish castle", 30));
        arrayList.add(new ItemCategory(icon, "Nesvish castle", 30));
        arrayList.add(new ItemCategory(icon, "Nesvish castle", 30));
        arrayList.add(new ItemCategory(icon, "Nesvish castle", 30));
        arrayList.add(new ItemCategory(icon, "Nesvish castle", 30));
        arrayList.add(new ItemCategory(icon, "Nesvish castle", 30));
        return arrayList;
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
            orientationPortrait();
        } else if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
            orientationLandscape();
        }
    }

    private void orientationPortrait() {
        gridView.setNumColumns(1);
        gridView.setColumnWidth(RelativeLayout.LayoutParams.FILL_PARENT);
    }

    private void orientationLandscape() {
        gridView.setNumColumns(GridView.AUTO_FIT);
    }

    private void determineOrientation() {
        if(device.getCurrentOrientation() == Configuration.ORIENTATION_LANDSCAPE){
            orientationLandscape();
        } else if(device.getCurrentOrientation() == Configuration.ORIENTATION_PORTRAIT) {
            orientationPortrait();
        }
    }
}




Java Source Code List

com.richso.interamap.AuthorizationScreen.java
com.richso.interamap.BaseActivity.java
com.richso.interamap.CategoryScreen.java
com.richso.interamap.HomeScreen.java
com.richso.interamap.MapScreen.java
com.richso.interamap.MoreInfoScreen.java
com.richso.interamap.RegistrationScreen.java
com.richso.interamap.SplashScreen.java
com.richso.interamap.adapter.CategoryAdapter.java
com.richso.interamap.adapter.ImageAdapter.java
com.richso.interamap.adapter.MarkerInfoAdapter.java
com.richso.interamap.dialogue.WarningDialog.java
com.richso.interamap.item.Category.java
com.richso.interamap.item.ItemCategory.java
com.richso.interamap.utils.Constant.java
com.richso.interamap.utils.Device.java
com.richso.interamap.utils.L.java
com.richso.interamap.view.MapFragment.java