Android Open Source - MatchHistory-League Main Activity






From Project

Back to project page MatchHistory-League.

License

The source code is released under:

MIT License

If you think the Android project MatchHistory-League 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.lando.matchhistory;
/*  w w  w  . ja va 2s . c om*/
import android.app.SearchManager;
import android.content.ComponentName;
import android.content.Context;
import android.os.Bundle;
import android.provider.SearchRecentSuggestions;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ProgressBar;

import com.lando.matchhistory.AsyncTask.BaseTask;
import com.lando.matchhistory.AsyncTask.MatchUpdateTask;
import com.lando.matchhistory.AsyncTask.SummonerUpdateTask;
import com.lando.matchhistory.AsyncTask.VersionUpdateTask;
import com.lando.matchhistory.Models.Match;
import com.lando.matchhistory.Provider.RecentSuggestionProvider;

import io.realm.Realm;


public class MainActivity extends ActionBarActivity implements BaseTask.UpdateResponse {

    public static final String DEBUG_INFO = "MatchHistory";
    private ProgressBar mProgressBar;
    private boolean mIsDownloadInProgress = false;
    private BaseTask mTask;

    private SearchView mSearchView;
    private Toolbar mToolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mToolbar = (Toolbar) findViewById(R.id.tool_bar);
        mProgressBar = (ProgressBar) findViewById(R.id.progressBar);

        setSupportActionBar(mToolbar);

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);

        SearchManager searchManager =
                (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        mSearchView =
                (SearchView) menu.findItem(R.id.search).getActionView();
        ComponentName cn = new ComponentName(this, SummonerActivity.class);
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(cn));
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        switch (id){
            case R.id.refresh_images:
                updateVersionData();
                return true;
            case R.id.refresh_matches:

                return true;
            case R.id.check_database:

                return true;

        }

        return super.onOptionsItemSelected(item);
    }

    private void updateVersionData(){
        if(mIsDownloadInProgress)
            return;

        mTask = new VersionUpdateTask(this,"na");
        executeTask();
    }


    private void executeTask(){
        mTask.setListener(this);
        mIsDownloadInProgress = true;
        mProgressBar.setVisibility(View.VISIBLE);
            ((VersionUpdateTask)mTask).execute((Void) null);
    }
    @Override
    public void processFinish() {
        mTask.setListener(null);
        mTask = null;
        mIsDownloadInProgress = false;
        mProgressBar.setVisibility(View.GONE);
        Log.v(DEBUG_INFO,"Complete");
    }
}




Java Source Code List

com.lando.matchhistory.ApplicationTest.java
com.lando.matchhistory.MainActivity.java
com.lando.matchhistory.SummonerActivity.java
com.lando.matchhistory.Adapter.DrawerAdapter.java
com.lando.matchhistory.Adapter.MatchAdapter.java
com.lando.matchhistory.ApiClient.ApiClient.java
com.lando.matchhistory.AsyncTask.BaseTask.java
com.lando.matchhistory.AsyncTask.MatchUpdateTask.java
com.lando.matchhistory.AsyncTask.SummonerUpdateTask.java
com.lando.matchhistory.AsyncTask.VersionUpdateTask.java
com.lando.matchhistory.ContentProvider.SummonerProvider.java
com.lando.matchhistory.Fragment.MasteriesFragment.java
com.lando.matchhistory.Fragment.MatchHistoryFragment.java
com.lando.matchhistory.Fragment.ProfileFragment.java
com.lando.matchhistory.Fragment.RuneFragment.java
com.lando.matchhistory.Models.Champion.java
com.lando.matchhistory.Models.CreepsPerMinDeltas.java
com.lando.matchhistory.Models.DamageTakenPerMinDeltas.java
com.lando.matchhistory.Models.GoldPerMinDeltas.java
com.lando.matchhistory.Models.Image.java
com.lando.matchhistory.Models.Item.java
com.lando.matchhistory.Models.Mastery.java
com.lando.matchhistory.Models.Match.java
com.lando.matchhistory.Models.ParticipantIdentity.java
com.lando.matchhistory.Models.Participant.java
com.lando.matchhistory.Models.Player.java
com.lando.matchhistory.Models.ProfileIcon.java
com.lando.matchhistory.Models.Rune.java
com.lando.matchhistory.Models.Stats.java
com.lando.matchhistory.Models.SummonerSpell.java
com.lando.matchhistory.Models.Summoner.java
com.lando.matchhistory.Models.Timeline.java
com.lando.matchhistory.Models.Version.java
com.lando.matchhistory.Models.XpPerMinDeltas.java
com.lando.matchhistory.Provider.RecentSuggestionProvider.java