Skip to content

Commit

Permalink
Migrate more classes to kotlin
Browse files Browse the repository at this point in the history
Signed-off-by: Unpublished <[email protected]>
  • Loading branch information
Unpublished committed Nov 1, 2023
1 parent c230bad commit 60e5d85
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 150 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.bumptech.glide.samples.svg

import com.bumptech.glide.load.Options
import com.bumptech.glide.load.ResourceDecoder
import com.bumptech.glide.load.engine.Resource
import com.bumptech.glide.load.resource.SimpleResource
import com.bumptech.glide.request.target.Target
import com.caverock.androidsvg.SVG
import com.caverock.androidsvg.SVGParseException
import java.io.IOException
import java.io.InputStream

/**
* Decodes an SVG internal representation from an [InputStream].
*/
class SvgDecoder : ResourceDecoder<InputStream, SVG> {
override fun handles(
source: InputStream,
options: Options,
): Boolean {
return true
}

@Throws(IOException::class)
override fun decode(
source: InputStream,
width: Int,
height: Int,
options: Options,
): Resource<SVG>? {
return try {
val svg = SVG.getFromInputStream(source)
if (width != Target.SIZE_ORIGINAL) {
svg.documentWidth = width.toFloat()
}
if (height != Target.SIZE_ORIGINAL) {
svg.documentHeight = height.toFloat()
}
SimpleResource(svg)
} catch (ex: SVGParseException) {
throw IOException("Cannot load SVG from stream", ex)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.bumptech.glide.samples.svg

import android.graphics.Picture
import android.graphics.drawable.PictureDrawable
import com.bumptech.glide.load.Options
import com.bumptech.glide.load.engine.Resource
import com.bumptech.glide.load.resource.SimpleResource
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder
import com.caverock.androidsvg.SVG

/**
* Convert the [SVG]'s internal representation to an Android-compatible one ([Picture]).
*/
class SvgDrawableTranscoder : ResourceTranscoder<SVG, PictureDrawable> {
override fun transcode(
toTranscode: Resource<SVG>,
options: Options,
): Resource<PictureDrawable> {
val svg = toTranscode.get()
val picture = svg.renderToPicture()
val drawable = PictureDrawable(picture)
return SimpleResource(drawable)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public View getView(final int position, View view, ViewGroup parent) {

Toast.makeText(getContext(), "Starting download.. Please wait", Toast.LENGTH_SHORT).show();

eventBus.post(new StartDownloadPodcast() {{ podcast = podcastItem; }});
eventBus.post(new StartDownloadPodcast(podcastItem));
});

holder.binding.flDeletePodcastWrapper.setOnClickListener(view13 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public View getView(final int position, View view, ViewGroup parent) {
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PodcastFeedClicked podcastFeedClicked = new PodcastFeedClicked();
podcastFeedClicked.position = position;
PodcastFeedClicked podcastFeedClicked = new PodcastFeedClicked(position);
eventBus.post(podcastFeedClicked);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ protected void tryOpeningPictureinPictureMode() {

@Subscribe
public void onEvent(StartDownloadPodcast podcast) {
PodcastDownloadService.startPodcastDownload(getActivity(), podcast.podcast);//, new DownloadReceiver(new Handler(), new WeakReference<ProgressBar>(holder.pbDownloadPodcast)));
PodcastDownloadService.startPodcastDownload(getActivity(), podcast.getPodcast());
}

@Subscribe
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package de.luhmer.owncloudnewsreader.events.podcast

class PodcastFeedClicked(val position: Int)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package de.luhmer.owncloudnewsreader.events.podcast

import de.luhmer.owncloudnewsreader.model.PodcastItem

class StartDownloadPodcast(val podcast: PodcastItem)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.luhmer.owncloudnewsreader.services

import android.app.Service
import android.content.Intent
import android.os.IBinder
import de.luhmer.owncloudnewsreader.authentication.OwnCloudAccountAuthenticator

class OwnCloudAuthenticatorService : Service() {
// Instance field that stores the authenticator object
private var mAuthenticator: OwnCloudAccountAuthenticator? = null

override fun onCreate() {
// Create a new authenticator object
mAuthenticator = OwnCloudAccountAuthenticator(this)
}

/*
* When the system binds to this Service to make the RPC call
* return the authenticator's IBinder.
*/
override fun onBind(intent: Intent): IBinder? {
return mAuthenticator?.iBinder
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.luhmer.owncloudnewsreader.view

import android.content.Context
import android.util.AttributeSet
import it.gmariotti.changelibs.library.view.ChangeLogListView

/**
* Thin wrapper around changeloglib to load local xml files by path
* after the view has already been instantiated.
*/
class ChangeLogFileListView
@JvmOverloads
constructor(
context: Context?,
attrs: AttributeSet? = null,
defStyle: Int = 0,
) : ChangeLogListView(context, attrs, defStyle) {
/**
* @param path local xml path staring with "file://"
*/
fun loadFile(path: String) {
mChangeLogFileResourceUrl = path
super.initAdapter()
}

override fun initAdapter() {
// do nothing yet - will be called in loadFile()
}
}

0 comments on commit 60e5d85

Please sign in to comment.