コード例 #1
1
ファイル: UpdateAdapter.java プロジェクト: kvite/Tasquid
  private void setupHistoryRow(View view, History history, User user) {
    final AsyncImageView pictureView = (AsyncImageView) view.findViewById(R.id.picture);
    {
      if (user.containsNonNullValue(USER_PICTURE)) {
        String pictureUrl = user.getPictureUrl(USER_PICTURE, RemoteModel.PICTURE_THUMB);
        pictureView.setUrl(pictureUrl);
      } else {
        pictureView.setUrl(null);
      }
      pictureView.setVisibility(View.VISIBLE);
    }

    final AsyncImageView commentPictureView =
        (AsyncImageView) view.findViewById(R.id.comment_picture);
    commentPictureView.setVisibility(View.GONE);

    final TextView nameView = (TextView) view.findViewById(R.id.title);
    {
      nameView.setText(
          getHistoryComment(
              (AstridActivity) fragment.getActivity(), history, user, linkColor, fromView));
      nameView.setTextColor(grayColor);
    }

    final TextView date = (TextView) view.findViewById(R.id.date);
    {
      CharSequence dateString =
          DateUtils.getRelativeTimeSpanString(
              history.getValue(History.CREATED_AT),
              DateUtilities.now(),
              DateUtils.MINUTE_IN_MILLIS,
              DateUtils.FORMAT_ABBREV_RELATIVE);
      date.setText(dateString);
    }
  }
コード例 #2
0
  public static void openBrowse(Uri uri, Fragment fragment) {
    Intent intent =
        new Intent(
            Intent
                .ACTION_GET_CONTENT); // TODO implement preference that allows to use
                                      // ACTION_OPEN_DOCUMENT
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    intent.setDataAndType(uri, "*/*");

    try {
      fragment.startActivityForResult(
          intent, ProtectedFragmentActivity.IMPORT_FILENAME_REQUESTCODE);
    } catch (ActivityNotFoundException e) {
      // No compatible file manager was found.
      Toast.makeText(fragment.getActivity(), R.string.no_filemanager_installed, Toast.LENGTH_SHORT)
          .show();
    } catch (SecurityException ex) {
      Toast.makeText(
              fragment.getActivity(),
              String.format(
                  "Sorry, this destination does not accept %s request. Please select a different one.",
                  intent.getAction()),
              Toast.LENGTH_SHORT)
          .show();
    }
  }
コード例 #3
0
  @SuppressLint("SetJavaScriptEnabled")
  protected void loginWebview(final OsmOAuth.AuthType type) {
    final WebView webview = new InputWebView(mFragment.getActivity());
    webview.getSettings().setJavaScriptEnabled(true);
    final AlertDialog dialog =
        new AlertDialog.Builder(mFragment.getActivity()).setView(webview).create();

    ThreadPool.getWorker()
        .execute(
            new Runnable() {
              @Override
              public void run() {
                final String[] auth =
                    (type == OsmOAuth.AuthType.FACEBOOK)
                        ? OsmOAuth.nativeGetFacebookAuthUrl()
                        : OsmOAuth.nativeGetGoogleAuthUrl();

                UiThread.run(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (mFragment.isAdded()) loadWebviewAuth(dialog, webview, auth, type);
                      }
                    });
              }
            });

    dialog.show();
  }
コード例 #4
0
  protected void onPostExecute(Bitmap bitmap) {
    final String finalMessage = errorMessage;

    if (fragment == null || fragment.getActivity() == null) {
      return;
    }

    if (isCancelled()) {
      bitmap = null;
    }
    final Bitmap finalBitmap = bitmap;

    // Set image and hide progress animation
    fragment
        .getActivity()
        .runOnUiThread(
            new Runnable() {
              public void run() {
                ProgressBar progress =
                    (ProgressBar) fragment.getActivity().findViewById(R.id.progressBar);
                progress.setVisibility(View.GONE);
                if (finalBitmap != null) {
                  image.setVisibility(View.VISIBLE);
                  image.setImageBitmap(finalBitmap);
                } else if (errorMessage != null) {
                  Toast.makeText(context, finalMessage, Toast.LENGTH_LONG).show();
                }
                // otherwise the ad doesn't contain any photo
              }
            });
  }
コード例 #5
0
ファイル: EditNoteActivity.java プロジェクト: 2bfree/astrid
  public EditNoteActivity(Fragment fragment, View parent, long t) {
    super(fragment.getActivity());
    DependencyInjectionService.getInstance().inject(this);

    imageCache = AsyncImageView.getImageCache();
    this.fragment = fragment;

    this.activity = (AstridActivity) fragment.getActivity();

    this.resources = fragment.getResources();
    TypedValue tv = new TypedValue();
    fragment.getActivity().getTheme().resolveAttribute(R.attr.asTextColor, tv, false);
    color = tv.data;

    fragment.getActivity().getTheme().resolveAttribute(R.attr.asDueDateColor, tv, false);
    grayColor = tv.data;

    linkColor = UpdateAdapter.getLinkColor(fragment);

    cameraButton = getDefaultCameraButton();

    setOrientation(VERTICAL);

    commentsBar = parent.findViewById(R.id.updatesFooter);

    loadViewForTaskID(t);
  }
コード例 #6
0
  protected void processAuth(@Size(2) String[] auth, OsmOAuth.AuthType type, String username) {
    if (auth == null) {
      if (mFragment.isAdded()) {
        new AlertDialog.Builder(mFragment.getActivity())
            .setTitle(R.string.editor_login_error_dialog)
            .setPositiveButton(android.R.string.ok, null)
            .show();

        Statistics.INSTANCE.trackEvent(
            Statistics.EventName.EDITOR_AUTH_REQUEST_RESULT,
            Statistics.params()
                .add(Statistics.EventParam.IS_SUCCESS, false)
                .add(Statistics.EventParam.TYPE, type.name));
      }
      return;
    }

    OsmOAuth.setAuthorization(auth[0], auth[1], username);
    if (mFragment.isAdded()) Utils.navigateToParent(mFragment.getActivity());
    Statistics.INSTANCE.trackEvent(
        Statistics.EventName.EDITOR_AUTH_REQUEST_RESULT,
        Statistics.params()
            .add(Statistics.EventParam.IS_SUCCESS, true)
            .add(Statistics.EventParam.TYPE, type.name));
  }
コード例 #7
0
 // simple convenience function for when a fragment wants to log a URL
 // don't need to worry about making sure it only happens once, because Fragments manage their own
 // state
 // in a way that activities do not.
 public static void track(Fragment fragment, String url) {
   if (fragment.isAdded()) {
     GoogleAnalyticsTracker tracker = start(fragment.getActivity());
     page(fragment.getActivity(), tracker, url);
     stop(tracker);
   }
 }
コード例 #8
0
 /**
  * @param fragment the fragment from where the keyboard will be removed
  * @brief methods for hiding the soft keyboard by forced
  */
 public static void hideSoftKeyboard(Fragment fragment) {
   if (fragment.getActivity().getCurrentFocus() != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager)
             fragment.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
     inputMethodManager.hideSoftInputFromWindow(
         fragment.getActivity().getCurrentFocus().getWindowToken(), 0);
   }
 }
コード例 #9
0
  @Override
  public void onAttach() {
    Intent intent = new Intent(fragment.getActivity(), PlayMusicService.class);

    fragment.getActivity().bindService(intent, mPlayMusicConnection, Service.BIND_AUTO_CREATE);

    registerMusicReceiver(); // ×¢²á·þÎñ

    // ÅжÏÊDz»ÊÇÒѾ­²¥·ÅÁË,²¥·ÅÁ˾ÍÄÃÐÅÏ¢³öÀ´
  }
コード例 #10
0
  protected void onPreExecute() {
    TextView title = (TextView) fragment.getActivity().findViewById(R.id.textTitle);
    TextView description = (TextView) fragment.getActivity().findViewById(R.id.textDescription);

    image = (ImageView) fragment.getActivity().findViewById(R.id.imageImage);
    image.setVisibility(View.INVISIBLE);
    title.setText(ad.getTitle());
    description.setText(ad.getBody());
    fragment.getActivity().setTitle(ad.getTitle());
  }
コード例 #11
0
 public static void startThisActivity(
     Fragment fragment, @NonNull String orderid, @NonNull String sellid, ShopCarInfo shopCarInfo) {
   if (CommonUtil.isLoginAndToLogin(fragment.getActivity(), false)) {
     Intent intent = new Intent(fragment.getActivity(), AddCommonActivity.class);
     intent.putExtra("oid", orderid);
     intent.putExtra("sid", sellid);
     Bundle bundle = new Bundle();
     bundle.putSerializable("goods", shopCarInfo);
     intent.putExtras(bundle);
     fragment.startActivityForResult(intent, 1);
   }
 }
コード例 #12
0
  /**
   * Constructor
   *
   * @param activity
   * @param resource layout resource to inflate
   * @param c database cursor
   * @param autoRequery whether cursor is automatically re-queried on changes
   * @param onCompletedTaskListener goal listener. can be null
   */
  public UpdateAdapter(
      Fragment fragment, int resource, Cursor c, boolean autoRequery, String fromView) {
    super(fragment.getActivity(), c, autoRequery);
    DependencyInjectionService.getInstance().inject(this);

    linkColor = getLinkColor(fragment);

    inflater =
        (LayoutInflater) fragment.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageCache = ImageDiskCache.getInstance();
    this.fromView = fromView;

    this.resource = resource;
    this.fragment = fragment;
  }
コード例 #13
0
  @Override
  public void onResume() {

    super.onResume();
    frag = getVisibleFragment();
    globalContext = frag.getActivity();
  }
コード例 #14
0
 public ShowAdTask(Fragment _fragment, Ad _ad) {
   api = NolotiroAPI.getInstance();
   context = _fragment.getActivity();
   fragment = _fragment;
   ad = _ad;
   Log.i(TAG, "ad=" + ad);
 }
コード例 #15
0
ファイル: UIHelper.java プロジェクト: yswheye/aima
 public static void showSimpleBackForResult(
     Fragment fragment, int requestCode, SimpleBackPage page, Bundle args) {
   Intent intent = new Intent(fragment.getActivity(), SimpleBackActivity.class);
   intent.putExtra(SimpleBackActivity.BUNDLE_KEY_PAGE, page.getValue());
   intent.putExtra(SimpleBackActivity.BUNDLE_KEY_ARGS, args);
   fragment.startActivityForResult(intent, requestCode);
 }
コード例 #16
0
 public static void openCameraFrom(Fragment fragment, @NonNull File imageFile) {
   Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
   if (takePictureIntent.resolveActivity(fragment.getActivity().getPackageManager()) != null) {
     takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
     fragment.startActivityForResult(takePictureIntent, CAMERA_REQUEST_CODE);
   }
 }
コード例 #17
0
 public DMConversationAdapter(Fragment fragment, List<DMBean> bean, ListView listView) {
   this.bean = bean;
   this.commander = TimeLineBitmapDownloader.getInstance();
   this.inflater = fragment.getActivity().getLayoutInflater();
   this.listView = listView;
   this.fragment = fragment;
 }
コード例 #18
0
  public ScoresAdapter(
      Context context,
      Cursor cursor,
      int flags,
      Fragment fragment,
      ScoresAdapterScrollHandler scrollHandler) {
    super(context, cursor, flags);
    mScrollHandler = scrollHandler;
    //        Log.v(LOG_TAG, "ScoresAdapter, " + "context = [" + context + "], cursor = [" + cursor
    // + "], flags = [" + flags + "]");

    // create requestBuilder for svg-glide-usage as described here:
    // https://github.com/bumptech/glide/tree/v3.6.0/samples/svg/src/main/java/com/bumptech/svgsample/app
    // uses androidsvg: http://mvnrepository.com/artifact/com.caverock/androidsvg/1.2.1
    requestBuilder =
        Glide.with(fragment)
            .using(
                Glide.buildStreamModelLoader(Uri.class, fragment.getActivity()), InputStream.class)
            .from(Uri.class)
            .as(SVG.class)
            .transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
            .sourceEncoder(new StreamEncoder())
            .cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder()))
            .decoder(new SvgDecoder())
            .placeholder(R.drawable.image_loading)
            .error(R.drawable.no_icon)
            .animate(android.R.anim.fade_in)
            .listener(new SvgSoftwareLayerSetter<Uri>());
  }
コード例 #19
0
  @Override
  public void onDetach() {

    unRegisterMusicReceiver();

    fragment.getActivity().unbindService(mPlayMusicConnection);
  }
コード例 #20
0
ファイル: EasyImage.java プロジェクト: rodcoimbra/EasyImage
 public static void openChooser(Fragment fragment) {
   try {
     Intent intent = createChooserIntent(fragment.getActivity());
     fragment.startActivityForResult(intent, REQ_SOURCE_CHOOSER);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #21
0
ファイル: a.java プロジェクト: pankajk87/CompSecurity
 public a(Fragment fragment, android.view.View.OnClickListener onclicklistener, int j) {
   b = fragment;
   c = fragment.getActivity();
   h = onclicklistener;
   f = j;
   g = c.getResources().getDisplayMetrics().widthPixels;
   e = g / j;
 }
コード例 #22
0
ファイル: adapterCapitulo.java プロジェクト: roycer/CITEC
 @Override
 public void onBindViewHolder(ViewHolder holder, int position) {
   if (paginas.get(position).getUrl() != null) {
     Picasso.with(fragment.getActivity())
         .load(paginas.get(position).getUrl())
         .into(holder.imgPagina);
   }
 }
コード例 #23
0
  protected void registerMusicReceiver() {
    // ¼àÌý²¥·Å½ø¶È

    progressReceiver = new SongProgressReceiver();
    fragment.getActivity().registerReceiver(progressReceiver, progressFilter);
    // ¼àÌý¸è´Ê
    lrcReceiver = new SongLrcReceiver();

    fragment.getActivity().registerReceiver(lrcReceiver, songFilter);
    // ¼àÌý×ܳ¤¶È
    durationReceiver = new SongDurationReceiver();
    fragment.getActivity().registerReceiver(durationReceiver, songDurationFilter);
    // ¼àÌýÍ£Ö¹
    songStopReceiver = new SongStopReceiver();
    fragment.getActivity().registerReceiver(songStopReceiver, songStopFilter);
    // ¼àÌýÔÝÍ£µÄ
    pauseReceiver = new SongPauseReceiver();
    fragment.getActivity().registerReceiver(pauseReceiver, songPauseFilter);
    // ²¥·ÅÍê³É

    completeReceiver = new SongCompleteReceiver();

    fragment.getActivity().registerReceiver(completeReceiver, songCompleteFilter);

    restartReceiver = new SongRestartReceiver();

    fragment.getActivity().registerReceiver(restartReceiver, songRestartFilter);
  }
コード例 #24
0
  public GetAddress_WebService(Fragment mFragment, Location myLoaction) {
    TAG = "LoginWebService";
    Log.d(MODULE, TAG);

    this.mFragment = mFragment;
    this.mActivity = mFragment.getActivity();
    this.myLoaction = myLoaction;
    mCallBack = (Address_Received_Listener) mFragment;
  }
コード例 #25
0
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {

    ArtistData artistData = artistDataList.get(position);
    holder.artistTitle.setText(artistData.getPost_title());
    Picasso.with(context.getActivity())
        .load(artistData.getFeatured_image())
        .into(holder.artistImage);
  }
コード例 #26
0
ファイル: UpdateAdapter.java プロジェクト: kvite/Tasquid
  private void setupUserActivityRow(View view, UserActivity activity, User user) {
    final AsyncImageView pictureView = (AsyncImageView) view.findViewById(R.id.picture);
    {
      if (user.containsNonNullValue(USER_PICTURE)) {
        String pictureUrl = user.getPictureUrl(USER_PICTURE, RemoteModel.PICTURE_THUMB);
        pictureView.setUrl(pictureUrl);
      } else {
        pictureView.setUrl(null);
      }
      pictureView.setVisibility(View.VISIBLE);
    }

    final AsyncImageView commentPictureView =
        (AsyncImageView) view.findViewById(R.id.comment_picture);
    {
      String pictureThumb =
          activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM);
      String pictureFull = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_LARGE);
      Bitmap updateBitmap = null;
      if (TextUtils.isEmpty(pictureThumb))
        updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE);
      setupImagePopupForCommentView(
          view,
          commentPictureView,
          pictureThumb,
          pictureFull,
          updateBitmap,
          activity.getValue(UserActivity.MESSAGE),
          fragment,
          imageCache);
    }

    // name
    final TextView nameView = (TextView) view.findViewById(R.id.title);
    {
      nameView.setText(
          getUpdateComment(
              (AstridActivity) fragment.getActivity(), activity, user, linkColor, fromView));
      nameView.setMovementMethod(new LinkMovementMethod());
      nameView.setTextColor(color);
    }

    // date
    final TextView date = (TextView) view.findViewById(R.id.date);
    {
      CharSequence dateString =
          DateUtils.getRelativeTimeSpanString(
              activity.getValue(UserActivity.CREATED_AT),
              DateUtilities.now(),
              DateUtils.MINUTE_IN_MILLIS,
              DateUtils.FORMAT_ABBREV_RELATIVE);
      date.setText(dateString);
    }
  }
コード例 #27
0
  public LoadingAndRetryManager(
      Object activityOrFragmentOrView, OnLoadingAndRetryListener listener) {
    if (listener == null) listener = DEFAULT_LISTENER;

    ViewGroup contentParent = null;
    Context context;
    if (activityOrFragmentOrView instanceof Activity) {
      Activity activity = (Activity) activityOrFragmentOrView;
      context = activity;
      contentParent = (ViewGroup) activity.findViewById(android.R.id.content);
    } else if (activityOrFragmentOrView instanceof Fragment) {
      Fragment fragment = (Fragment) activityOrFragmentOrView;
      context = fragment.getActivity();
      contentParent = (ViewGroup) (fragment.getView().getParent());
    } else if (activityOrFragmentOrView instanceof View) {
      View view = (View) activityOrFragmentOrView;
      contentParent = (ViewGroup) (view.getParent());
      context = view.getContext();
    } else {
      throw new IllegalArgumentException(
          "the argument's type must be Fragment or Activity: init(context)");
    }
    int childCount = contentParent.getChildCount();
    // get contentParent
    int index = 0;
    View oldContent;
    if (activityOrFragmentOrView instanceof View) {
      oldContent = (View) activityOrFragmentOrView;
      for (int i = 0; i < childCount; i++) {
        if (contentParent.getChildAt(i) == oldContent) {
          index = i;
          break;
        }
      }
    } else {
      oldContent = contentParent.getChildAt(0);
    }
    contentParent.removeView(oldContent);
    // setup content layout
    LoadingAndRetryLayout loadingAndRetryLayout = new LoadingAndRetryLayout(context);

    ViewGroup.LayoutParams lp = oldContent.getLayoutParams();
    contentParent.addView(loadingAndRetryLayout, index, lp);
    loadingAndRetryLayout.setContentView(oldContent);
    // setup loading,retry,empty layout
    setupLoadingLayout(listener, loadingAndRetryLayout);
    setupRetryLayout(listener, loadingAndRetryLayout);
    setupEmptyLayout(listener, loadingAndRetryLayout);
    // callback
    listener.setRetryEvent(loadingAndRetryLayout.getRetryView());
    listener.setLoadingEvent(loadingAndRetryLayout.getLoadingView());
    listener.setEmptyEvent(loadingAndRetryLayout.getEmptyView());
    mLoadingAndRetryLayout = loadingAndRetryLayout;
  }
コード例 #28
0
ファイル: PermissionUtils.java プロジェクト: Zankio/CCULife
  public static boolean checkPermission(Fragment fragment, String permission, int code) {
    if (ContextCompat.checkSelfPermission(fragment.getActivity(), permission)
        != PackageManager.PERMISSION_GRANTED) {

      if (fragment.shouldShowRequestPermissionRationale(permission)) {
        fragment.requestPermissions(new String[] {permission}, code);
      } else {
        fragment.requestPermissions(new String[] {permission}, code);
      }
      return false;
    }
    return true;
  }
コード例 #29
0
ファイル: UpdateAdapter.java プロジェクト: kvite/Tasquid
  /**
   * Constructor
   *
   * @param activity
   * @param resource layout resource to inflate
   * @param c database cursor
   * @param autoRequery whether cursor is automatically re-queried on changes
   * @param onCompletedTaskListener goal listener. can be null
   */
  public UpdateAdapter(
      Fragment fragment, int resource, Cursor c, boolean autoRequery, String fromView) {
    super(fragment.getActivity(), c, autoRequery);
    DependencyInjectionService.getInstance().inject(this);

    linkColor = getLinkColor(fragment);

    inflater =
        (LayoutInflater) fragment.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageCache = AsyncImageView.getImageCache();
    this.fromView = fromView;

    this.resource = resource;
    this.fragment = fragment;
    this.self = getSelfUser();

    TypedValue tv = new TypedValue();
    fragment.getActivity().getTheme().resolveAttribute(R.attr.asTextColor, tv, false);
    color = tv.data;

    fragment.getActivity().getTheme().resolveAttribute(R.attr.asDueDateColor, tv, false);
    grayColor = tv.data;
  }
コード例 #30
0
 public MobileBindings(
     Fragment fragment,
     String activityId,
     String activityToLoad,
     String sitesToLoad,
     ContentValues newSite,
     String themesToLoad) {
   this.ctx = fragment.getActivity();
   this.fragment = fragment;
   this.activityId = activityId;
   this.activityToLoad = activityToLoad;
   this.sitesToLoad = sitesToLoad;
   this.newSite = newSite;
   this.themesToLoad = themesToLoad;
 }