Android Open Source - Vispin Main Activity






From Project

Back to project page Vispin.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. ...

If you think the Android project Vispin 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.jpardogo.vispin.ui;
//  w w  w.j  a  va 2 s .  c o m
import android.app.Activity;
import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Rect;
import android.location.Address;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.jpardogo.vispin.models.PinInfo;
import com.jpardogo.vispin.ui.custom.DrawInsetsFrameLayout;
import com.jpardogo.vispin.R;
import com.jpardogo.vispin.ui.dialogs.PinsDialogFragment;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import timber.log.Timber;


public class MainActivity extends Activity implements PinsDialogFragment.OnPinsDialogListener,PinsMapFragment.OnMapPinsInteractionListener {

    private static final String DIALOG = "DIALOG";
    private PinsMapFragment mPinsMapFragment;
    @InjectView(R.id.insets_layout)
    DrawInsetsFrameLayout mDrawInsetsFrameLayout;
    @InjectView(R.id.sliding_layout)
    SlidingUpPanelLayout mSlidingUpPane;
    @InjectView(R.id.pane_countrytitle)
    TextView mCountryTitle;
    @InjectView(R.id.status)
    TextView mStatus;
    @InjectView(R.id.removeButton)
    ImageButton mButton;
    private Marker mSelectedMaker;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
        mPinsMapFragment = ((PinsMapFragment) getFragmentManager().findFragmentById(R.id.map));
        mDrawInsetsFrameLayout.setOnInsetsCallback(new DrawInsetsFrameLayout.OnInsetsCallback() {
            @Override
            public void onInsetsChanged(Rect insets) {
                // Update the map padding (inset the compass, zoom buttons, attribution, etc.)
                mPinsMapFragment.getMap().setPadding(insets.left, insets.top, insets.right, insets.bottom);
            }
        });

        mSlidingUpPane.setPanelSlideListener(mSlidingUpPanelLayoutListener);
        mSlidingUpPane.post(new Runnable() {
            @Override
            public void run() {
                mSlidingUpPane.hidePanel();
            }
        });
    }

    @Override
    public void pinCreated(MarkerOptions markerOptions) {
        FragmentManager fm = getFragmentManager();
        Fragment prev = fm.findFragmentByTag(DIALOG);
        if (prev != null) {
            fm.beginTransaction().remove(prev).commit();
        }
        mPinsMapFragment.drawMarker(markerOptions);
    }

    @Override
    public void startPinCreation(Address address) {
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        DialogFragment newFragment = PinsDialogFragment.newInstance(address);
        newFragment.show(ft, DIALOG);
    }

    @Override
    public void pinSelected(Marker marker) {
        mSlidingUpPane.showPanel();
        mSelectedMaker = marker;
        String[] pinInfo= marker.getSnippet().split(PinInfo.SEPARATOR);
        mCountryTitle.setText(pinInfo[PinInfo.TITLE_INDEX]);
        mStatus.setText(pinInfo[PinInfo.STATUS_INDEX]);
    }

    @Override
    public void mapSelected() {
        mSlidingUpPane.hidePanel();
    }

    private SlidingUpPanelLayout.PanelSlideListener mSlidingUpPanelLayoutListener = new SlidingUpPanelLayout.PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            Timber.i("onPanelSlide, offset " + slideOffset);
        }

        @Override
        public void onPanelExpanded(View panel) {
            Timber.i("onPanelExpanded");

        }

        @Override
        public void onPanelCollapsed(View panel) {
            Timber.i("onPanelCollapsed");

        }

        @Override
        public void onPanelAnchored(View panel) {
            Timber.i("onPanelAnchored");
        }

        @Override
        public void onPanelHidden(View panel) {
            Timber.i("onPanelHidden");
        }
    };

    @OnClick(R.id.removeButton)
    public void slidingRemoveButtonClicked(){
        if(mSelectedMaker!=null){
            mSelectedMaker.remove();
            mSlidingUpPane.hidePanel();
        }
    }
}




Java Source Code List

com.jpardogo.vispin.ApplicationTest.java
com.jpardogo.vispin.MainActivity.java
com.jpardogo.vispin.VispinApp.java
com.jpardogo.vispin.adapters.BaseAllAdapters.java
com.jpardogo.vispin.adapters.PinInfoWindowAdapter.java
com.jpardogo.vispin.adapters.PinsAdapter.java
com.jpardogo.vispin.adapters.delegates.BaseDelegateAdapter.java
com.jpardogo.vispin.adapters.delegates.DelegateAdapter.java
com.jpardogo.vispin.models.ListItem.java
com.jpardogo.vispin.models.PinInfo.java
com.jpardogo.vispin.ui.MainActivity.java
com.jpardogo.vispin.ui.PinsMapFragment.java
com.jpardogo.vispin.ui.custom.DrawInsetsFrameLayout.java
com.jpardogo.vispin.ui.dialogs.PinsDialogFragment.java
com.jpardogo.vispin.utils.Utils.java