Android Open Source - android.app.niuz.io Company Information Loading Activity






From Project

Back to project page android.app.niuz.io.

License

The source code is released under:

GNU General Public License

If you think the Android project android.app.niuz.io 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 io.niuz;
/*from  ww  w . j ava 2s  .  c  om*/
import io.niuz.model.APIRetrievalStatus;
import io.niuz.services.CompaniesService;
import io.niuz.services.PhoneService;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;

public class CompanyInformationLoadingActivity extends Activity {
  private ProgressBar cilaProgressBar;
  
  private Context context;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_company_information_loading);
    this.context = this;
    
    this.cilaProgressBar = (ProgressBar)findViewById(R.id.cilaProgressBar);
    this.cilaProgressBar.setVisibility(View.VISIBLE);
  }
  
  @Override
  protected void onResume() {
    super.onResume();
    // Getting relevant companies
    toast("Initializing relevant companies...");
    new GetRelevantCompaniesTask().execute();
  }

  private void continueWithCompanyData() {
    startActivity(new Intent(this, NewsCompaniesSelectionActivity.class));
  }
  
  private void toast(String message) {
    PhoneService.toast(message, this);
  }
  
  private class GetRelevantCompaniesTask extends AsyncTask<Object, Integer, APIRetrievalStatus> {
    @Override
    protected APIRetrievalStatus doInBackground(Object... params) {
      try {
        CompaniesService.initRelevantCompaniesForUsersIntro(context);
        return APIRetrievalStatus.SUCCESS;

      } catch (Exception e) {
        Log.w("Fatal", e);
        return APIRetrievalStatus.ERROR;
      }
    }
    
    @Override
    protected void onPostExecute(APIRetrievalStatus result) {
      switch (result) {
      case SUCCESS:
        continueWithCompanyData();
        break;

      case ERROR:
        toast("Failed to initialize companies...");
      }
    }
  }
  
  @Override
  public void onBackPressed() {
    startActivity(new Intent(context, PreMainActivity.class));
  }
}




Java Source Code List

io.niuz.CategoriesSelectionActivity.java
io.niuz.CompanyInformationLoadingActivity.java
io.niuz.MainActivity.java
io.niuz.NewsCompaniesSelectionActivity.java
io.niuz.NewsHeadersActivity.java
io.niuz.NewsReaderActivity.java
io.niuz.PreMainActivity.java
io.niuz.model.APIRetrievalStatus.java
io.niuz.model.CategoryInformation.java
io.niuz.model.CompanyInformation.java
io.niuz.model.InitUserStatus.java
io.niuz.model.News.java
io.niuz.services.BaseService.java
io.niuz.services.CategoriesSubcategoriesService.java
io.niuz.services.CompaniesService.java
io.niuz.services.NewsService.java
io.niuz.services.PhoneService.java
io.niuz.services.UserService.java