Example #1
0
 public static ProgressFragment newInstance() {
   ProgressFragment frag = new ProgressFragment();
   frag.setRetainInstance(true);
   Bundle args = new Bundle();
   frag.setArguments(args);
   return frag;
 }
 @Override
 protected void onPostExecute(Boolean result) {
   if (result) {
     onAccountCreationSuccess(jid, password);
   } else {
     onAccountCreationFailed(exception);
   }
   ProgressFragment pf =
       (ProgressFragment) getFragmentManager().findFragmentByTag("progressFragment");
   if (pf != null) pf.dismiss();
 }
  @Override
  public void onDestroyView() {
    super.onDestroyView();

    mEmptyTextView = null;
    mRecyclerView = null;
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Start fetching data in order to populate views
    getVolleyManager()
        .initGsonRequest(getRequestUrl(), ActorList.class, null, this, this, TAG_VOLLEY_REQUEST);
  }
Example #5
0
 @Override
 protected void onCancelled(DBResult dbResult) {
   super.onCancelled(dbResult);
   if (progressFragment != null) {
     progressFragment.dismissAllowingStateLoss();
   }
   if (e != null) Toast.makeText(OAuthActivity.this, e.getError(), Toast.LENGTH_SHORT).show();
   webView.loadUrl(getWeiboOAuthUrl());
 }
  /*
   *  * ========== * ========== * ========== * ========== * ========== * ========== * ========== * ========== *
   *  * Android methods:
   *  * ========== * ========== * ========== * ========== * ========== * ========== * ========== * ========== *
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    progressFragment = new ProgressFragment();
    progressFragment.setActivity(this);

    setConnected(false);
    connectedOnceCalled = false;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // When creating retrieve the movie id from arguments
    mRottenTomatoesMovieId =
        (null != getArguments()) ? getArguments().getString(ARG_ROTTENTOMATOES_MOVIE_ID) : null;

    // TODO : Delete this line later, this line for debug only
    mRottenTomatoesMovieId = Integer.toString(770672122);
  }
Example #8
0
 @Override
 protected void onPostExecute(DBResult dbResult) {
   if (progressFragment.isVisible()) {
     progressFragment.dismissAllowingStateLoss();
   }
   switch (dbResult) {
     case add_successfuly:
       Toast.makeText(OAuthActivity.this, getString(R.string.login_success), Toast.LENGTH_SHORT)
           .show();
       break;
     case update_successfully:
       Toast.makeText(
               OAuthActivity.this,
               getString(R.string.update_account_success),
               Toast.LENGTH_SHORT)
           .show();
       break;
   }
   finish();
 }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final RobotoTypefaceUtils robotoTypefaceLoader = getRobotoTypefaceLoader();

    // EmptyTextView setup
    mEmptyTextView.setText("No cast to show");
    mEmptyTextView.setVisibility(View.GONE);
    mEmptyTextView.setTypeface(robotoTypefaceLoader.load(RobotoTypeface.LIGHT));

    // GridView setup
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(
        new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mAdapter = new ActorsAdapter();
    mRecyclerView.setAdapter(mAdapter);
  }
  public void execute(FragmentActivity activity, String title, String message) {
    // Create progress fragment
    progressFragment = new ProgressFragment();

    Bundle args = new Bundle();
    args.putString("title", title);
    args.putString("message", message);
    progressFragment.setArguments(args);
    activity
        .getSupportFragmentManager()
        .beginTransaction()
        .add(progressFragment, ProgressFragment.DEFAULT_TAG)
        .commit();

    // Start async task
    ProgressAsyncTask asyncTask = new ProgressAsyncTask();
    asyncTask.execute();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setCheckedItem(R.id.nav_new);

    // viewpager & tabs
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    final MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
    adapter.addFragment(SwitchesFragment.newInstance(0), "swiches");
    adapter.addFragment(ButtonFragment.newInstance(1), "botton");
    adapter.addFragment(ProgressFragment.newInstance(2), "progress");
    adapter.addFragment(TextfieldFragment.newInstance(3), "textfield");
    adapter.addFragment(SliderFragment.newInstance(4), "slider");
    adapter.addFragment(SpinnerFragment.newInstance(5), "spinner");
    adapter.addFragment(DialogsFragment.newInstance(6), "dialogs");
    pager.setAdapter(adapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(pager);
  }
Example #12
0
  class OAuthTask extends MyAsyncTask<String, UserBean, DBResult> {

    WeiboException e;

    ProgressFragment progressFragment = ProgressFragment.newInstance();

    @Override
    protected void onPreExecute() {
      progressFragment.setAsyncTask(this);
      progressFragment.show(getSupportFragmentManager(), "");
    }

    @Override
    protected DBResult doInBackground(String... params) {

      String token = params[0];
      long expiresInSeconds = Long.valueOf(params[1]);

      try {
        UserBean user = new OAuthDao(token).getOAuthUserInfo();
        AccountBean account = new AccountBean();
        account.setAccess_token(token);
        account.setExpires_time(System.currentTimeMillis() + expiresInSeconds * 1000);
        account.setInfo(user);
        AppLogger.e("token expires in " + Utility.calcTokenExpiresInDays(account) + " days");
        return AccountDBTask.addOrUpdateAccount(account, false);
      } catch (WeiboException e) {
        AppLogger.e(e.getError());
        this.e = e;
        cancel(true);
        return null;
      }
    }

    @Override
    protected void onCancelled(DBResult dbResult) {
      super.onCancelled(dbResult);
      if (progressFragment != null) {
        progressFragment.dismissAllowingStateLoss();
      }
      if (e != null) Toast.makeText(OAuthActivity.this, e.getError(), Toast.LENGTH_SHORT).show();
      webView.loadUrl(getWeiboOAuthUrl());
    }

    @Override
    protected void onPostExecute(DBResult dbResult) {
      if (progressFragment.isVisible()) {
        progressFragment.dismissAllowingStateLoss();
      }
      switch (dbResult) {
        case add_successfuly:
          Toast.makeText(OAuthActivity.this, getString(R.string.login_success), Toast.LENGTH_SHORT)
              .show();
          break;
        case update_successfully:
          Toast.makeText(
                  OAuthActivity.this,
                  getString(R.string.update_account_success),
                  Toast.LENGTH_SHORT)
              .show();
          break;
      }
      finish();
    }
  }
 protected void setProgressDetailMessage(String message) {
   if (progressFragment != null) {
     progressFragment.setProgressDetailMessage(message);
   }
 }
 protected void setProgressDetailMessage(int messageId) {
   if (progressFragment != null) {
     progressFragment.setProgressDetailMessage(messageId);
   }
 }
 @Override
 protected void onPreExecute() {
   progress = ProgressFragment.newInstance();
   progress.show(getFragmentManager(), "progressFragment");
 }
 protected void runOnActivity(ActivityTask task) {
   progressFragment.runWhenReady(task);
 }
Example #17
0
 @Override
 protected void onPreExecute() {
   progressFragment.setAsyncTask(this);
   progressFragment.show(getSupportFragmentManager(), "");
 }
 public boolean isCancelled() {
   if (progressFragment.isDestroyed() || progressFragment.isCancelled()) return true;
   return false;
 }
 public void updateProgress(int completed, int total) {
   progressFragment.updateProgress(completed, total);
 }