This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<declare-styleable name="LocaleTextView"> | |
<attr name="stringResId" format="string"/> | |
</declare-styleable> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gunhansancar.android.sdk.helper; | |
import android.content.Context; | |
import android.content.SharedPreferences; | |
import android.content.res.Configuration; | |
import android.content.res.Resources; | |
import android.preference.PreferenceManager; | |
import java.util.Locale; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocaleTextView extends TextView { | |
OnLocaleChangeReceiver onLocaleChangeReceiver; | |
String stringResId; | |
public LocaleTextView(Context context) { | |
super(context); | |
} | |
public LocaleTextView(Context context, @Nullable AttributeSet attrs) { | |
super(context, attrs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocaleTextView extends TextView { | |
String stringResId; | |
public LocaleTextView(Context context) { | |
super(context); | |
} | |
public LocaleTextView(Context context, @Nullable AttributeSet attrs) { | |
super(context, attrs); | |
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.LocaleTextView, 0, 0); | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class OnLocaleChangeReceiver extends BroadcastReceiver{ | |
com.hypersoft.walletapp.ui.customviews.LocaleTextView v; | |
public void setTextView(com.hypersoft.walletapp.ui.customviews.LocaleTextView v){ | |
this.v = v; | |
} | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
//Utility.debugger("onReceive called "+v); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You will need to set MEDIA_URL and MEDIA_ROOT in your project’s settings.py. | |
MEDIA_URL = '/media/' | |
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | |
In the development server you may serve the user uploaded files (media) using django.contrib.staticfiles.views.serve() view. | |
from django.conf import settings | |
from django.conf.urls.static import static | |
urlpatterns = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.contenttypes.models import ContentType | |
from django.contrib.contenttypes.fields import GenericForeignKey | |
class FileAttachment(models.Model): | |
content_type = models.ForeignKey(ContentType, related_name="content_type_timelines") | |
object_id = models.PositiveIntegerField() | |
content_object = GenericForeignKey('content_type', 'object_id') | |
created = models.DateTimeField(_('created'), auto_now_add=True) | |
modified = models.DateTimeField(_('modified'), auto_now=True) | |
attachment_file = models.FileField(_('attachment'), upload_to=attachment_upload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def attachment_upload(instance, filename): | |
"""Stores the attachment in a "per module/appname/primary key" folder""" | |
return 'attachments/{app}_{model}/{pk}/{filename}'.format( | |
app=instance.content_object._meta.app_label, | |
model=instance.content_object._meta.object_name.lower(), | |
pk=instance.content_object.pk, | |
filename=filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
content_type = ContentType.objects.get_for_model(MODEL_NAME) | |
// primary key of the object in this case it was the project id | |
object_id = current_project.pk | |
FileAttachment.objects.create(content_type=content_type, | |
object_id=object_id, | |
file_type='project_image', | |
attachment_file=request.FILES.get('project_image')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from wgadmin.models import * | |
def get_file_attachment_url(object): | |
from django.contrib.contenttypes.models import ContentType | |
contenttype_obj = ContentType.objects.get_for_model(object) | |
return FileAttachment.objects.values('attachment_file','object_id').filter(object_id=object.id, | |
content_type=contenttype_obj) |
OlderNewer