Android Open Source - wifi-auto-forget Auto Forget Wifis View






From Project

Back to project page wifi-auto-forget.

License

The source code is released under:

GNU General Public License

If you think the Android project wifi-auto-forget 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.cebesius.wifiautoforget.mvp;
//from  w ww.j  a  va2s .c  o  m
import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cebesius.wifiautoforget.R;
import com.cebesius.wifiautoforget.adapter.AutoForgetWifisAdapter;
import com.cebesius.wifiautoforget.dialog.ChangeAutoForgetBehaviorDialog;
import com.cebesius.wifiautoforget.domain.AutoForgetWifi;
import com.cebesius.wifiautoforget.util.BusPortal;
import com.squareup.otto.Subscribe;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

import static com.cebesius.wifiautoforget.mvp.AutoForgetWifisPresenter.RequestEditAutoForgetWifiEvent;

/**
 * View for the AutoForgetWifis management screen
 */
public class AutoForgetWifisView extends ActivityView {

    @InjectView(R.id.list)
    ListView autoForgetWifisList;
    @InjectView(R.id.message_wrapper)
    RelativeLayout messageWrapperView;
    @InjectView(R.id.message_subject)
    TextView messageSubjectView;
    @InjectView(R.id.message_body)
    TextView messageBodyView;

    private final ActivityViewProxy activityViewProxy = new ActivityViewProxy();
    private final BusPortal busPortal;

    private AutoForgetWifisAdapter autoForgetWifisAdapter;

    public AutoForgetWifisView(Activity activity, BusPortal busPortal) {
        super(activity);
        this.busPortal = busPortal;
    }

    public ActivityViewProxy getActivityViewProxy() {
        return activityViewProxy;
    }

    void showLoading() {
        getActivity().setProgressBarIndeterminate(true);
        getActivity().setProgressBarIndeterminateVisibility(true);
    }

    void hideLoading() {
        getActivity().setProgressBarIndeterminateVisibility(false);
    }

    void showAutoForgetWifis(List<AutoForgetWifi> autoForgetWifis) {
        setupAutoForgetWifisList(autoForgetWifis);
        setupMessage(null, null);
    }

    void showAutoForgetWifisListEmptyMessage() {
        setupAutoForgetWifisList(null);
        setupMessage(
                getActivity().getString(R.string.autoforget_wifis_message_list_empty_subject),
                getActivity().getString(R.string.autoforget_wifis_message_list_empty_body)
        );
    }

    void showAutoForgetWifiChangeBehaviorDialog(AutoForgetWifi autoForgetWifi) {
        ChangeAutoForgetBehaviorDialog dialog = ChangeAutoForgetBehaviorDialog.newInstance(autoForgetWifi);
        getActivity().getFragmentManager()
                .beginTransaction()
                .add(dialog, "change autoforgetwifi.behavior")
                .commit();
    }

    void onAutoForgetWifiBehaviorChanged(AutoForgetWifi autoForgetWifi) {
        autoForgetWifisAdapter.onAutoForgetWifiBehaviorChanged(autoForgetWifi);
    }

    @Subscribe
    public void onUserChangedAutoForgetEvent(ChangeAutoForgetBehaviorDialog.AutoForgetBehaviorChangedEvent event) {
        busPortal.post(new AutoForgetWifisPresenter.UserChangedAutoForgetBehaviorEvent(
                event.ssid,
                event.behavior
        ));
    }

    private void setupAutoForgetWifisList(List<AutoForgetWifi> autoForgetWifis) {
        if (autoForgetWifis != null) {
            if (autoForgetWifisAdapter == null) {
                autoForgetWifisAdapter = new AutoForgetWifisAdapter(autoForgetWifis);
                autoForgetWifisList.setAdapter(autoForgetWifisAdapter);
                autoForgetWifisList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                        AutoForgetWifi autoForgetWifi = (AutoForgetWifi) adapterView.getItemAtPosition(position);
                        busPortal.post(new RequestEditAutoForgetWifiEvent(autoForgetWifi));
                    }
                });
            }
            autoForgetWifisAdapter.setAutoForgetWifis(autoForgetWifis);
            autoForgetWifisList.setVisibility(View.VISIBLE);
        } else {
            autoForgetWifisList.setVisibility(View.GONE);
        }
    }

    private void setupMessage(String subject, String body) {
        if (!TextUtils.isEmpty(subject) && !TextUtils.isEmpty(body)) {
            messageSubjectView.setText(subject);
            messageBodyView.setText(body);
            messageWrapperView.setVisibility(View.VISIBLE);
        } else {
            messageWrapperView.setVisibility(View.GONE);
        }
    }

    public class ActivityViewProxy {

        private ActivityViewProxy() {
            // no-op
        }

        public void saveState(Bundle outState) {
            // TODO: save state
        }

        public void restoreState(Bundle savedInstanceState) {
            // TODO: restore state
        }

        public void onCreateView() {
            getActivity().setContentView(R.layout.activity_auto_forget_wifis);
            ButterKnife.inject(AutoForgetWifisView.this, getActivity());
        }

        public void onResume() {
            busPortal.register(AutoForgetWifisView.this);
        }

        public void onPause() {
            busPortal.unregister(AutoForgetWifisView.this);
        }
    }
}




Java Source Code List

antoche.HockeySender.java
com.cebesius.wifiautoforget.Secrets.java
com.cebesius.wifiautoforget.WifiAutoForgetApplication.java
com.cebesius.wifiautoforget.activity.AutoForgetWifisActivity.java
com.cebesius.wifiautoforget.adapter.AutoForgetWifisAdapter.java
com.cebesius.wifiautoforget.dialog.ChangeAutoForgetBehaviorDialog.java
com.cebesius.wifiautoforget.domain.AutoForgetWifi.java
com.cebesius.wifiautoforget.gateway.AddWifiNotificationUsageStorage.java
com.cebesius.wifiautoforget.gateway.AutoForgetWifiStorage.java
com.cebesius.wifiautoforget.gateway.NotificationIds.java
com.cebesius.wifiautoforget.gateway.SharedPreferenceKeys.java
com.cebesius.wifiautoforget.gateway.UserPreferenceStorage.java
com.cebesius.wifiautoforget.model.AutoForgetWifiModel.java
com.cebesius.wifiautoforget.mvp.ActivityView.java
com.cebesius.wifiautoforget.mvp.AddWifiModel.java
com.cebesius.wifiautoforget.mvp.AddWifiPresenter.java
com.cebesius.wifiautoforget.mvp.AddWifiView.java
com.cebesius.wifiautoforget.mvp.AppModel.java
com.cebesius.wifiautoforget.mvp.AppPresenter.java
com.cebesius.wifiautoforget.mvp.AppView.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisModel.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisPresenter.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisView.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangeModel.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangePresenter.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangeView.java
com.cebesius.wifiautoforget.receiver.ConnectivityChangeReceiver.java
com.cebesius.wifiautoforget.service.AddWifiService.java
com.cebesius.wifiautoforget.service.ConnectivityChangeService.java
com.cebesius.wifiautoforget.util.AutoForgetDelegate.java
com.cebesius.wifiautoforget.util.BusPortal.java
com.cebesius.wifiautoforget.widget.AutoForgetWifiItem.java