feat: Converted meta date helper to kotlin
This commit is contained in:
parent
b79c9072bd
commit
1c34556116
@ -14,42 +14,38 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package net.schueller.peertube.helper;
|
package net.schueller.peertube.helper
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context
|
||||||
|
import android.text.format.DateUtils
|
||||||
|
import net.schueller.peertube.R.string
|
||||||
|
import org.ocpsoft.prettytime.PrettyTime
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
import android.text.format.DateUtils;
|
object MetaDataHelper {
|
||||||
|
|
||||||
import net.schueller.peertube.R;
|
@JvmStatic
|
||||||
|
fun getMetaString(getCreatedAt: Date, viewCount: Int, context: Context): String {
|
||||||
import org.ocpsoft.prettytime.PrettyTime;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
|
|
||||||
public class MetaDataHelper {
|
|
||||||
|
|
||||||
|
|
||||||
public static String getMetaString(Date getCreatedAt, Integer viewCount, Context context) {
|
|
||||||
|
|
||||||
// Compatible with SDK 21+
|
// Compatible with SDK 21+
|
||||||
String currentLanguage = Locale.getDefault().getDisplayLanguage();
|
val currentLanguage = Locale.getDefault().displayLanguage
|
||||||
PrettyTime p = new PrettyTime(currentLanguage);
|
val p = PrettyTime(currentLanguage)
|
||||||
String relativeTime = p.format(new Date(getCreatedAt.getTime()));
|
val relativeTime = p.format(Date(getCreatedAt.time))
|
||||||
|
return relativeTime +
|
||||||
return (relativeTime +
|
context.resources.getString(string.meta_data_seperator) +
|
||||||
context.getResources().getString(R.string.meta_data_seperator) +
|
viewCount + context.resources.getString(string.meta_data_views)
|
||||||
viewCount + context.getResources().getString(R.string.meta_data_views));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getOwnerString(String accountName, String serverHost, Context context) {
|
@JvmStatic
|
||||||
|
fun getOwnerString(accountName: String, serverHost: String, context: Context): String {
|
||||||
return accountName +
|
return accountName +
|
||||||
context.getResources().getString(R.string.meta_data_owner_seperator) +
|
context.resources.getString(string.meta_data_owner_seperator) +
|
||||||
serverHost;
|
serverHost
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDuration(Long duration) {
|
@JvmStatic
|
||||||
return DateUtils.formatElapsedTime(duration);
|
fun getDuration(duration: Long?): String {
|
||||||
|
return DateUtils.formatElapsedTime(duration!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user