Пример #1
0
  public void setTextStatus(String msn, boolean hasError) {
    if (mActivity != null) {
      mSnackbar =
          Snackbar.with(mActivity)
              .type(SnackbarType.MULTI_LINE)
              .text(msn)
              .animation(false)
              .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE);

      if (hasError) {
        mSnackbar
            .actionLabel("Volver a Intenar")
            .actionListener(
                new ActionClickListener() {
                  @Override
                  public void onActionClicked(Snackbar snackbar) {
                    snackbar.dismiss();
                    searchDataInfo(callBack);
                  }
                })
            .color(Color.RED);
      }
      SnackbarManager.show(mSnackbar, mActivity);
    } else {
      Toast.makeText(mContext, msn, Toast.LENGTH_LONG).show();
    }
  }
Пример #2
0
  @OptionsItem(R.id.action_add_to_bookmarks)
  void onActionAddToBookmarks() {
    Log.d(TAG, "onActionAddToBookmarks");
    Bookmark bookmark;

    String title = getTitle().toString();
    if (title == null) {
      title = "";
    }

    CharSequence descriptionCharSequence = webView.getContentDescription();
    String description = "";
    if (descriptionCharSequence != null) {
      description = descriptionCharSequence.toString();
    }
    String url = webView.getUrl();
    if (url == null || url.isEmpty()) {
      return;
    }

    try {
      bookmark = databaseHelper.createBookmark(url, title, description);
    } catch (SQLException e) {
      activityHelper.showError(e);
      return;
    }
    Resources resources = getResources();
    String message =
        resources.getString(
            R.string.message_item_added_to,
            bookmark.getTitle(),
            resources.getString(R.string.title_activity_browser_bookmarks));
    SnackbarManager.show(createSnackbar().text(message), this);
  }
 private static void show(Activity activity, int msg, Style style, Integer tempo) {
   Snackbar snackbar = Snackbar.with(activity).text(activity.getResources().getText(msg));
   switch (style) {
     case INFO:
       snackbar.color(Color.BLUE);
       break;
     case ALERT:
       snackbar.color(Color.RED);
       break;
     case CONFIRM:
       snackbar.color(Color.GREEN);
       break;
   }
   if (tempo != null) {
     snackbar.duration(tempo);
   }
   snackbar.type(SnackbarType.MULTI_LINE);
   snackbar.actionLabel(activity.getResources().getString(R.string.close));
   snackbar.actionListener(
       new ActionClickListener() {
         @Override
         public void onActionClicked(Snackbar snackbar) {
           SnackbarManager.dismiss();
         }
       });
   SnackbarManager.show(snackbar);
 }
Пример #4
0
  @Override
  public void onResume() {
    if (activity != null) {

      Boolean a = s.getBoolean(IS_TIME_TABLE_CHANGED, true);
      timetable = s.getString(GET_TIME_TABLE, null);
      adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
      lvTest.setAdapter(adapter2);
      lvTest.setItemMargin(10);

      if (a || timetable == null) {
        if (Utils.isNetworkAvailable(activity)) new DownloadWebPageTask2().execute();
        else {
          if (activity != null)
            SnackbarManager.show(
                Snackbar.with(activity.getApplicationContext())
                    .text("Check Your Internet Connection")
                    .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
                activity);
        }
      } else {
        load();
      }
    }
    super.onResume();
  }
 public void backupDB(View view) {
   final String filename = DBUtils.backupDB(this);
   SnackbarManager.show(
       Snackbar.with(this)
           .type(SnackbarType.SINGLE_LINE)
           .text(String.format("Saved on: '%s'", filename))
           .swipeToDismiss(false)
           .animation(false)
           .color(Color.RED)
           .actionLabel("OPEN")
           .actionLabelTypeface(Typeface.DEFAULT_BOLD)
           .actionListener(
               new ActionClickListener() {
                 @Override
                 public void onActionClicked(Snackbar snackbar) {
                   try {
                     File fileToOpen = new File(filename);
                     Intent myIntent = new Intent();
                     myIntent.setAction(android.content.Intent.ACTION_VIEW);
                     myIntent.setDataAndType(Uri.fromFile(fileToOpen), "*/*");
                     startActivity(myIntent);
                   } catch (Exception e) {
                     Timber.e(e, "Exception during ActionsView enableWifiClickListener action");
                   }
                 }
               })
           .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE));
 }
 @Override
 protected void onResume() {
   super.onResume();
   final int entryCount = getSupportFragmentManager().getBackStackEntryCount();
   final ClipboardManager clipboardManager =
       (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   if (entryCount == 0
       && clipboardManager.hasPrimaryClip()
       && clipboardManager.getPrimaryClip().getItemCount() > 0) {
     final ClipData primaryClip = clipboardManager.getPrimaryClip();
     final ClipData.Item item = primaryClip.getItemAt(0);
     final String text = item.coerceToText(this).toString();
     if (text.trim().length() > 0) {
       final Snackbar snackbar =
           Snackbar.with(this)
               .text(getString(R.string.paste_from_clipboard_prompt))
               .actionLabel(getString(R.string.paste_clipboard_action))
               .actionColorResource(R.color.sharelock_orange)
               .actionListener(
                   new ActionClickListener() {
                     @Override
                     public void onActionClicked(Snackbar snackbar) {
                       bus.postSticky(new ClipboardSecretEvent(text));
                       clipboardManager.setPrimaryClip(ClipData.newPlainText("", ""));
                     }
                   })
               .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE);
       SnackbarManager.show(snackbar);
     }
   }
 }
Пример #7
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_calender, container, false);
    lvTest = (TwoWayView) rootView.findViewById(R.id.lvItems);
    if (activity == null) return rootView;

    s = PreferenceManager.getDefaultSharedPreferences(activity);
    e = s.edit();
    Boolean b = s.getBoolean(IS_CLASS_SET, false);
    if (!b) {
      Intent i = new Intent(activity, ChooseClass.class);
      startActivity(i);
    }

    Boolean a = s.getBoolean(IS_TIME_TABLE_CHANGED, true);
    timetable = s.getString(GET_TIME_TABLE, null);

    adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
    lvTest.setAdapter(adapter2);
    lvTest.setItemMargin(10);

    if (a == true || timetable == null) {
      if (Utils.isNetworkAvailable(activity)) new DownloadWebPageTask2().execute();
      else {
        SnackbarManager.show(
            Snackbar.with(activity.getApplicationContext())
                .text("Check Your Internet Connection")
                .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
            activity);
      }
    } else {
      load();
    }

    lvTest.setOnScrollListener(
        new TwoWayView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(TwoWayView view, int scrollState) {}

          @Override
          public void onScroll(
              TwoWayView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int lastInScreen = firstVisibleItem + visibleItemCount;
            if ((lastInScreen == totalItemCount) && !(loadingMore)) {
              load();
            }
            adapter2.notifyDataSetChanged();
          }
        });
    return rootView;
  }
Пример #8
0
    @Override
    protected void onPostExecute(String result) {
      timetable = result;
      if (activity == null) return;

      e.putBoolean(IS_TIME_TABLE_CHANGED, false);
      e.putString(GET_TIME_TABLE, result);
      e.commit();

      JSONObject ob;

      if (timetable == null) return;
      try {
        ob = new JSONObject(timetable);
        ob = ob.getJSONObject("metadata");
        String s2 = ob.optString("last_updated", "null");
        if (s2.equals("null")) {
          SnackbarManager.show(
              Snackbar.with(activity.getApplicationContext())
                  .text("Sorry, Time Table is not available now. It will be updated shortly.")
                  .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
              activity);
        }

      } catch (JSONException e) {
        e.printStackTrace();
      }

      adapter2 = new CustomList_calendar(activity, days, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
      load();
      lvTest.setAdapter(adapter2);
      lvTest.setItemMargin(10);
      lvTest.setOnScrollListener(
          new TwoWayView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(TwoWayView view, int scrollState) {}

            @Override
            public void onScroll(
                TwoWayView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
              int lastInScreen = firstVisibleItem + visibleItemCount;
              if ((lastInScreen == totalItemCount) && !(loadingMore)) {
                load();
              }
              adapter2.notifyDataSetChanged();
            }
          });

      progress.dismiss();
    }
Пример #9
0
  @Override
  public void onClickTranslatePanelAddToFlashcardButton(DicItemListView.Data data) {
    final Card card;
    try {
      final Card duplicate = databaseHelper.getCardByDisplay(data.Index.toString());
      if (duplicate != null) {
        activityHelper.onDuplicatedCardFound(
            duplicate, data.Trans.toString(), dictionaries.getDictionary(data.getDic()).getName());
        return;
      }
      card = databaseHelper.createCard(data);
    } catch (SQLException e) {
      activityHelper.showError(e);
      return;
    }
    Resources resources = getResources();
    String message =
        resources.getString(
            R.string.message_item_added_to,
            card.getShortDisplay(),
            resources.getString(R.string.title_activity_flashcard));

    SnackbarManager.show(
        createSnackbar()
            .text(message)
            .type(SnackbarType.MULTI_LINE)
            .actionLabel(R.string.action_undo)
            .actionListener(
                new ActionClickListener() {
                  @Override
                  public void onActionClicked(Snackbar snackbar) {
                    String message =
                        getResources()
                            .getString(R.string.message_item_removed, card.getShortDisplay());
                    try {
                      databaseHelper.deleteCard(card);
                    } catch (SQLException e) {
                      activityHelper.showError(e);
                      return;
                    }
                    SnackbarManager.show(
                        createSnackbar()
                            .text(message)
                            .type(SnackbarType.MULTI_LINE)
                            .duration(Snackbar.SnackbarDuration.LENGTH_SHORT),
                        BrowserActivity.this);
                  }
                }),
        this);
  }
Пример #10
0
  @UiThread
  protected void showError(String s) {
    if (navigator.isInForeground()) {
      Snackbar errorSnack;
      if (snackBarBackgroundColor != null) {
        errorSnack =
            Snackbar.with(context)
                .text(s)
                .duration(Snackbar.SnackbarDuration.LENGTH_SHORT)
                .color(snackBarBackgroundColor);
      } else {
        errorSnack =
            Snackbar.with(context).text(s).duration(Snackbar.SnackbarDuration.LENGTH_SHORT);
      }

      SnackbarManager.show(errorSnack, navigator.getCurrentActivityOnScreen());
    }
  }
Пример #11
0
 /**
  * The first time the app is ever opened, there will be no data present in the local db. So, we
  * HAVE to download from Parse This function checks if a download is completely necessary and if
  * it is, it starts the download and if it isn't it lets the app function with offline data
  */
 public void checkForDownload() {
   Cursor cursor =
       Login.db.rawQuery(
           "SELECT COUNT(name) FROM "
               + Login.USERNAME
               + "_projects WHERE username='******';",
           null);
   cursor.moveToFirst();
   int count = cursor.getInt(0);
   if (count == 0) {
     if (checkConnection()) {
       download();
     } else {
       // Toast.makeText(this, "Please check your Internet Connection!", Toast.LENGTH_LONG).show();
       // SnackbarManager.show(Snackbar.with(Login.this).text("Username and Password do not
       // match!"));
       SnackbarManager.show(
           Snackbar.with(getApplicationContext())
               .type(SnackbarType.MULTI_LINE)
               .duration(Snackbar.SnackbarDuration.LENGTH_LONG)
               .text("No Internet Connection!")
               .actionLabel("CLOSE")
               .actionListener(
                   new ActionClickListener() {
                     @Override
                     public void onActionClicked(Snackbar snackbar) {
                       SnackbarManager.dismiss();
                     }
                   }),
           MainActivity.this);
       (findViewById(R.id.viewVirtualTours)).setVisibility(View.GONE);
     }
   }
   cursor.close();
 }