joshuatee.wx.SPCFragment.java Source code

Java tutorial

Introduction

Here is the source code for joshuatee.wx.SPCFragment.java

Source

/*
    
Copyright 2013, 2014 joshua.tee@gmail.com
    
This file is part of wX.
    
wX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
wX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with wX.  If not, see <http://www.gnu.org/licenses/>.
    
 */

package joshuatee.wx;

import joshuatee.wx.R;
import android.os.Bundle;
import android.app.ActionBar.LayoutParams;
import android.content.Intent;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.support.v4.app.Fragment;

public class SPCFragment extends Fragment implements OnClickListener {

    // fragment used for SPC tab

    Intent intent;

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

        View view = inflater.inflate(R.layout.fragment_spc, container, false);

        DisplayMetrics dm = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);

        ImageView iv_1 = (ImageView) view.findViewById(R.id.iv_1);
        iv_1.setOnClickListener(this);
        ImageView iv_2 = (ImageView) view.findViewById(R.id.iv_2);
        iv_2.setOnClickListener(this);
        ImageView iv_3 = (ImageView) view.findViewById(R.id.iv_3);
        iv_3.setOnClickListener(this);
        ImageView iv_4 = (ImageView) view.findViewById(R.id.iv_4);
        iv_4.setOnClickListener(this);
        ImageView iv_5 = (ImageView) view.findViewById(R.id.iv_5);
        iv_5.setOnClickListener(this);
        ImageView iv_6 = (ImageView) view.findViewById(R.id.iv_6);
        iv_6.setOnClickListener(this);

        ImageView iv_7 = (ImageView) view.findViewById(R.id.iv_7);
        ImageView iv_8 = (ImageView) view.findViewById(R.id.iv_8);
        ImageView iv_9 = (ImageView) view.findViewById(R.id.iv_9);
        ImageView iv_10 = (ImageView) view.findViewById(R.id.iv_10);
        ImageView iv_11 = (ImageView) view.findViewById(R.id.iv_11);
        ImageView iv_12 = (ImageView) view.findViewById(R.id.iv_12);

        iv_7.setOnClickListener(this);
        iv_8.setOnClickListener(this);
        iv_9.setOnClickListener(this);
        iv_10.setOnClickListener(this);
        iv_11.setOnClickListener(this);
        iv_12.setOnClickListener(this);

        LayoutParams params_iv = null;
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.meso), iv_1, 3, params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.tstorm), iv_2, 3,
                params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.day1), iv_3, 3, params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.day2), iv_4, 3, params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.day3), iv_5, 3, params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.day48), iv_6, 3, params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.report_today), iv_7, 3,
                params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.report_yesterday), iv_8, 3,
                params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.mcd_tile), iv_9, 3,
                params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.wat), iv_10, 3, params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.spc_sum), iv_11, 3,
                params_iv);
        UtilityImg.ResizeViewSetImgTile(dm, UtilityImg.LoadBM(getActivity(), R.drawable.fire_outlook), iv_12, 3,
                params_iv);

        return view;
    }

    /*@Override
    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
        
    }*/

    @Override
    public void onClick(View v2) {

        switch (v2.getId()) {

        case R.id.iv_3:
            intent = new Intent(getActivity(), SPCSWOActivityv2.class);
            intent.putExtra(SPCSWOActivityv2.NO, "1");
            startActivity(intent);
            break;

        case R.id.iv_4:
            intent = new Intent(getActivity(), SPCSWOActivityv2.class);
            intent.putExtra(SPCSWOActivityv2.NO, "2");
            startActivity(intent);
            break;

        case R.id.iv_5:
            intent = new Intent(getActivity(), SPCSWOActivityv2.class);
            intent.putExtra(SPCSWOActivityv2.NO, "3");
            startActivity(intent);
            break;

        case R.id.iv_6:
            intent = new Intent(getActivity(), SPCSWOActivityv2.class);
            intent.putExtra(SPCSWOActivityv2.NO, "4-8");
            startActivity(intent);
            break;

        case R.id.iv_10:
            intent = new Intent(getActivity(), SPCMCDWShowSummaryActivity.class);
            intent.putExtra(SPCMCDWShowSummaryActivity.NO, "wat");
            startActivity(intent);
            break;

        case R.id.iv_11:
            intent = new Intent(getActivity(), SPCSWOSummaryActivity.class);
            startActivity(intent);
            break;

        case R.id.iv_12:
            intent = new Intent(getActivity(), SPCFireOutlookActivity.class);
            startActivity(intent);
            break;

        case R.id.iv_9:
            intent = new Intent(getActivity(), SPCMCDWShowSummaryActivity.class);
            intent.putExtra(SPCMCDWShowSummaryActivity.NO, "mcd");
            startActivity(intent);
            break;

        case R.id.iv_7:
            intent = new Intent(getActivity(), StormReportsActivity.class);
            intent.putExtra(StormReportsActivity.NO, "today");
            startActivity(intent);
            break;

        case R.id.iv_8:
            intent = new Intent(getActivity(), StormReportsActivity.class);
            intent.putExtra(StormReportsActivity.NO, "yesterday");
            startActivity(intent);
            break;

        case R.id.iv_2:
            intent = new Intent(getActivity(), SPCTstormOutlookActivity.class);
            startActivity(intent);
            break;

        case R.id.iv_1:
            intent = new Intent(getActivity(), SPCMesoActivity.class);
            startActivity(intent);
            break;

        }
    }

}